nmsg 1.3.0
config_file.h
1/*
2 * Copyright (c) 2024 DomainTools LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NMSG_CONFIG_FILE_H
18#define NMSG_CONFIG_FILE_H
19
20#include <stdbool.h>
21
22/*
23 * Provides support for "INI" style configuration file:
24 * # This is a configuration file example
25 * [Section1]
26 * Key1 = Value1
27 * Key2 = Value2
28 */
29
30#define CONFIG_FILE_DEFAULT_SECTION "default"
31
32struct config_file;
33struct config_file_item;
34
35struct config_file *config_file_init(void);
36
37bool config_file_fill_from_str(struct config_file *, const char *);
38bool config_file_load(struct config_file *, const char *);
39
40const struct config_file_item *config_file_find_section(struct config_file *, const char *);
41const struct config_file_item *config_file_next_item(const struct config_file_item *);
42
43const char *config_file_item_key(const struct config_file_item *);
44const char *config_file_item_value(const struct config_file_item *);
45
46void config_file_destroy(struct config_file **);
47
48#endif /* NMSG_CONFIG_FILE_H */