Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Configuration language for C, inspired by nginx config syntax.
C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
include/config
src
.gitignore
Makefile
README.mdown

README.mdown

Overview

config.c is a simple language for expressing typed, hierarchical configuration data. It is has no reliance on any of the C standard library (although will use it if available) and hence should be compatible with a broad range of embedded processors, as well as conventional computers.

Syntax Example

# '#' is a comment and the rest of the line will be ignored.

an_integer      21;
a_float         -10.32;
a_boolean       yes;            # also: `true`, `on`.
other_boolean   no;             # also: `false`, `off`.
string          "foof bar baz";
ip_address      192.168.1.100;

# nesting
namespace {
    foo 1;
    bar 2;
    baz 3;
    nested {
        bleem: 10;
    }
}

# equivalent to:
namespace.foo 1;
namespace.bar 2;
namespace.baz 3;
namespace.nested.bleem 10;

Example usage

char            string_buffer[32];      /* longest decoded string value == 31 chars */
char            context_buffer[32];     /* longest context, including `.` separators == 31 chars */

void on_value(const char *key, config_type_t type, void *value_ptr) {

}

config_init(&config, context_buffer, 32, string_buffer, 32, on_value);

FILE *fd = fopen("test.cfg", "r");
while (!feof(fd)) config_put(&config, fgetc(fd));
int status = config_end();
Something went wrong with that request. Please try again.