diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 5c648c3..2b79cff 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -1,4 +1,5 @@ +# experimental config file input_device s /def/ttyACM0 diff --git a/core/parseconf.c b/core/parseconf.c index 70ef497..56af341 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -1,5 +1,5 @@ /* - * parseconf + * core/parseconf.c */ #include @@ -10,12 +10,14 @@ extern int verbosity; extern Configuration config; +#define CMP(a) (!strcmp(cptr, a)) + /* ---------------------------------------------------------------- */ int parse_config(char *fname, int flags) { FILE *fp; -char line[SZ_STRINGS+1]; - +char line[SZ_STRINGS+1], *cptr; +int numligne; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' $%x )\n", fname, flags); @@ -28,19 +30,39 @@ if (NULL==(fp=fopen(fname, "r"))) { return -2; } +numligne = 0; + while (fgets(line, SZ_STRINGS, fp)) { + numligne++; + if ('\0'==line[0]) { + fprintf(stderr, "%s : short read line %d\n", + fname, numligne); + fclose(fp); + return -1; + } + /* massage the end of line */ + line[strlen(line)-1] = '\0'; /* kill EOL */ + if (verbosity) { + fprintf(stderr, "%3d :\t%s\n", numligne, line); + } + + /* seek for the first token in this line */ + if (NULL==(cptr = strtok(line, " \t"))) { + /* Got an empty line */ + continue; + } /* skip comments */ + if ('#'==*cptr) continue; + + if(verbosity) fprintf(stderr, "[%s]\n", cptr); - /* seek for keyword */ } - - fclose(fp); return -1; diff --git a/core/t.c b/core/t.c index aaf2f3c..835fa58 100644 --- a/core/t.c +++ b/core/t.c @@ -33,7 +33,6 @@ while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { case 'v': verbosity++; break; - default: fprintf(stderr, "%s : uh ?", argv[0]); exit(1); @@ -47,9 +46,10 @@ foo = parse_config(conffile, 1); fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); show_config("foo"); +/* foo = load_lut1024f("foo.lut1024f", NULL, 1); - fprintf(stderr, "chargement de la lut --> %d\n\n", foo); +*/ return 0; } diff --git a/core/utils.c b/core/utils.c index f0a2646..17cf615 100644 --- a/core/utils.c +++ b/core/utils.c @@ -21,7 +21,6 @@ v1 = getpid(); v2 = time(NULL); return v1 ^ v2; } /* --------------------------------------------------------------- */ - int random1000(int type) { int value; @@ -55,5 +54,4 @@ if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__); return (double)tv.tv_sec + (double)tv.tv_usec / 1e6; } - /* --------------------------------------------------------------- */ diff --git a/core/utils.h b/core/utils.h index e69de29..b71651c 100644 --- a/core/utils.h +++ b/core/utils.h @@ -0,0 +1,8 @@ +/* + * core/utils.h + */ + +int seed_my_rand(int foo); +int random1000(int type); + +double dtime(void);