canfigger v0.3.1
Lightweight config file parser library
Loading...
Searching...
No Matches
canfigger.h
Go to the documentation of this file.
1
35/* This file is part of canfigger<https://github.com/andy5995/canfigger>
36
37MIT License
38
39Copyright (c) 2024 Andy Alt(arch_stanton5995@proton.me)
40
41Permission is hereby granted, free of charge, to any person obtaining a copy
42of this software and associated documentation files (the "Software"), to deal
43in the Software without restriction, including without limitation the rights
44to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45copies of the Software, and to permit persons to whom the Software is
46furnished to do so, subject to the following conditions:
47
48The above copyright notice and this permission notice shall be included in all
49copies or substantial portions of the Software.
50
51THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
57SOFTWARE.
58*/
59
60#pragma once
61
62#include "canfigger_version.h"
63
80#define CANFIGGER_CHECK_VERSION(maj, min) \
81 (CANFIGGER_VERSION_MAJOR > (maj) || \
82 (CANFIGGER_VERSION_MAJOR == (maj) && CANFIGGER_VERSION_MINOR >= (min)))
83
84#ifdef __cplusplus
85extern "C" {
86#endif
87
104{
105 char *str;
106 char *current;
107 char *iter_ptr;
108};
109
126{
127 char *key;
128 char *value;
129 struct attributes *attributes;
130 struct Canfigger *next;
131};
132
153struct Canfigger *canfigger_parse_file(const char *file, const int delimiter);
154
171
196
207void canfigger_free_list(struct Canfigger **node);
208
221char *canfigger_config_dir(const char *appname);
222
237char *canfigger_data_dir(const char *appname);
238
252char *canfigger_path_join(const char *dir, const char *file);
253
254#ifdef __cplusplus
255}
256#endif
struct Canfigger * canfigger_parse_file(const char *file, const int delimiter)
Parse a configuration file into a linked list of key-value nodes.
Definition canfigger.c:351
char * canfigger_data_dir(const char *appname)
Return the platform data directory for an application.
Definition canfigger.c:564
void canfigger_free_list(struct Canfigger **node)
Free all remaining nodes in the list.
Definition canfigger.c:166
void canfigger_free_current_attr_str_advance(struct attributes *attributes, char **attr)
Free the current attribute string and advance to the next attribute.
Definition canfigger.c:86
char * canfigger_config_dir(const char *appname)
Return the platform config directory for an application.
Definition canfigger.c:553
char * canfigger_path_join(const char *dir, const char *file)
Join a directory path and a filename with the platform separator.
Definition canfigger.c:575
void canfigger_free_current_key_node_advance(struct Canfigger **node)
Free the current node and advance the list pointer to the next node.
Definition canfigger.c:125
A single node in the parsed configuration linked list.
Definition canfigger.h:126
Internal iteration state for a node's attribute list.
Definition canfigger.h:104