62 static void getToken(FILE *file,
char *token,
int *newline) {
76 }
else if (c ==
'\n') {
95 if (feof(file) || c <
' ') {
130 file = fopen(filename,
"r");
132 fprintf(stderr,
"file '%s' not found\n", filename);
136 while (!feof(file)) {
138 if (newline || *key == 0x00) {
142 fprintf(stderr,
"missing key in '%s'\n", filename);
147 if (strcmp(value,
"=")) {
148 fprintf(stderr,
"missing '=' in '%s'\n", filename);
155 printf(
"%s = %s\n", key, value);
157 if (cb(key, value, info)) {
158 printf(
"Invalid entry in '%s': %s = %s\n",
159 filename, key, value);
167 if (0 == strcmp(value,
"")) {
static void getToken(FILE *file, char *token, int *newline)
Gets token.
#define CONF_VALUE_MAX_LEN
int parseConfigurationFile(char *filename, conf_cb cb, void *info)
Parses configuration file. If cb is NULL the key value pairs are output to the console. Returns 0 if successful.
static void skipComment(FILE *file)
Skips comment.
int(* conf_cb)(const char *key, const char *value, void *info)
Analyze configuration file.