Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
dlight/read-config.c
Henrik Hautakoski b2df740514 Initial commit
2011-09-21 17:13:28 +02:00

50 lines
827 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cconf.h"
#include "env.h"
static char *usage = "dlight-read-config [ <file> | -h ]\n";
int main(int argc, char **argv) {
int i;
struct cconf *c;
char file[4096];
if (argc > 1) {
if (!strcmp(argv[1], "-h")) {
fprintf(stderr, usage);
return 1;
}
strncpy(file, argv[1], sizeof(file));
} else {
snprintf(file, sizeof(file), "%s/config", env_get_dir());
}
c = cconf_read(file);
if (!c) {
perror(file);
return 1;
}
printf("--- Config file: %s ---\n", file);
for(i=0; i < c->nr; i++) {
int j;
struct target *t = c->target + i;
printf("src: %s\n", t->src);
printf("dest: %s\n", t->dest);
for(j=0; j < t->nr; j++)
printf("filter: %s\n", t->filter[j]);
printf("---\n");
}
cconf_free(c);
free(c);
return 0;
}