ecsl_config: ecsl utilities library
Background
ecsl_config is a library that has the functions for parsing a config file and maintaining an associative array data structure. The library is used in Dusk and Dira projects. The idea behind the library is similar to that of GNU Common C++ which is a cross-platform C++ framework for writing C++ applications that need threads, XML parsing, config files, etc. ecsl_config is not that advanced yet.
Here is an example of config file:
# Dusk config file
target x86
connect netlink
sys-headers /usr/include
sys-headers /usr/src/linux
Use the following functions to parse it:
ec_tokens target, connect;
ec_tokens assembly_headers[100];
int num_files;
num_files=0;
ec_init();
ec_add_keyword("target", EC_ONE_VALUE, &target, NULL);
ec_add_keyword("connect", EC_ONE_VALUE, &connect, NULL);
ec_add_keyword("sys-headers", EC_MANY_VALUES, assembly_headers, &num_files);
ec_parse("config.txt");
ec_print();
ec_release();
ecsl_config implements an associative array data structure. This data structure implements a map from an object of one type to an object of another type. Using different types at the same time is allowed. The implementation takes advantage of the C functions overloading extension of GCC. The extension allows to declare functions with different argument types. Here is an example showing how to use the associative array data structure:
char *str;
ec_aa_init();
ec_aa_add(1, "abc");
ec_aa_add(2, 2);
str=ec_aa_get(1);
printf("%s\n", str);
ec_aa_cleanup();
Installation
Download ecsl_config from here. You will also need a modified GCC compiler. Take a copy of the extensibility framework called GEM from here. It will download GCC, patch it, and build an extensible compiler.
Alexey Smirnov
2006-03-05