#include <stdio.h>
int
main(int argc, char *argv[])
{
char *default_filename = SOURCE_DIR "/examplerc";
char *filename_ptr = default_filename;
if (argc == 2)
filename_ptr = argv[1];
if (argc > 2)
{
fputs("This example program only accepts a single argument:\n\n", stderr);
fprintf(stderr, "%s <config-file>\n\n", argv[0]);
return -1;
}
if (!config)
return -1;
int i = 0;
while (config != NULL)
{
printf(
"Key: %s, Value: %s\n", config->
key,
config->
value != NULL ? config->value :
"NULL");
char *attr = NULL;
while (attr)
{
printf("Attribute: %s\n", attr);
}
putchar('\n');
i++;
}
if (i != 6)
return -1;
return 0;
}
Header file for the Canfigger configuration parser.
void canfigger_free_current_key_node_advance(struct Canfigger **list)
Frees the current key node and advances to the next node in the list.
struct Canfigger * canfigger_parse_file(const char *file, const int delimiter)
Parses a configuration file and creates a linked list of key-value pairs.
void canfigger_free_current_attr_str_advance(struct attributes *attributes, char **attr)
Frees the current attribute string and advances to the next attribute.
Structure to represent a key-value pair with attributes in the configuration.