xref: /openbmc/obmc-console/config.h (revision 7a765956ab33769880a42aafe1b7287ddf2dd126)
1 /**
2  * Copyright © 2016 IBM
3  * Copyright © 2024 9elements
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <termios.h>
23 
24 struct config;
25 
26 const char *config_get_section_value(struct config *config, const char *secname,
27 				     const char *name);
28 const char *config_get_value(struct config *config, const char *name);
29 struct config *config_init(const char *filename);
30 const char *config_resolve_console_id(struct config *config,
31 				      const char *id_arg);
32 void config_fini(struct config *config);
33 
34 int config_parse_baud(speed_t *speed, const char *baud_string);
35 uint32_t parse_baud_to_int(speed_t speed);
36 speed_t parse_int_to_baud(uint32_t baud);
37 int config_parse_bytesize(const char *size_str, size_t *size);
38 
39 int config_count_sections(struct config *config);
40 const char *config_get_section_name(struct config *config, int i);
41