xref: /openbmc/obmc-console/config.h (revision e3a083eb)
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 <stdint.h>
21 #include <termios.h>
22 
23 struct config;
24 
25 const char *config_get_section_value(struct config *config, const char *secname,
26 				     const char *name);
27 const char *config_get_value(struct config *config, const char *name);
28 struct config *config_init(const char *filename);
29 const char *config_resolve_console_id(struct config *config,
30 				      const char *id_arg);
31 void config_fini(struct config *config);
32 
33 int config_parse_baud(speed_t *speed, const char *baud_string);
34 uint32_t parse_baud_to_int(speed_t speed);
35 speed_t parse_int_to_baud(uint32_t baud);
36 int config_parse_bytesize(const char *size_str, size_t *size);
37 
38 int config_count_sections(struct config *config);
39 const char *config_get_section_name(struct config *config, int i);
40