diff --git a/libxtools/clcomp.c b/libxtools/clcomp.c index b0e3eeb..ce52637 100644 --- a/libxtools/clcomp.c +++ b/libxtools/clcomp.c @@ -12,6 +12,12 @@ #include #include +#ifdef DEBUG +#define DPRINTF(str, ...) printf(str, __VA_ARGS__) +#else +#define DPRINTF(str, ...) ((void)0) +#endif + static char* strcopy(char* src) { size_t srcsize = strlen(src) + 1; char* dst = malloc(srcsize); @@ -37,6 +43,8 @@ char* clcomp_geterr(clcomp_t * comp) { return comp->errstr; } +#define SPACE_TOKEN "space" + int clcomp_gettok(clcomp_t * comp, char* token) { if (comp->argn > comp->argc) { strcpy(token, "EOF"); @@ -48,7 +56,7 @@ int clcomp_gettok(clcomp_t * comp, char* token) { if (toktype == TOKEN_ENDF && comp->argn != comp->argc) { comp->argn++; cllexer_init(&(comp->lexer), comp->argv[comp->argn]); - strcpy(token, "space"); + strcpy(token, SPACE_TOKEN); return TOKEN_SPACE; } return toktype; @@ -65,12 +73,12 @@ int clcomp_parse(clcomp_t * comp) { while (toktype != TOKEN_ENDF) { toktype = clcomp_gettok(comp, token); i++; - printf("cllexer_parse res: %d: %d [%s]\n", i, toktype, token); + DPRINTF("cllexer_parse res: %d: %d [%s]\n", i, toktype, token); switch (comp->pos) { case 0:{ if (toktype == TOKEN_PREF) { comp->pos = 1; - printf("pos %d: TOKEN_PREF %s\n", comp->pos, token); + DPRINTF("pos %d: TOKEN_PREF %s\n", comp->pos, token); } continue; } @@ -78,7 +86,7 @@ int clcomp_parse(clcomp_t * comp) { if (toktype == TOKEN_WORD) { comp->pos = 2; key = strcopy(token); - printf("pos %d: TOKEN_WORD %s\n", comp->pos, token); + DPRINTF("pos %d: TOKEN_WORD %s\n", comp->pos, token); continue; } else { comp->errstr = "Unknown key token"; @@ -86,9 +94,9 @@ int clcomp_parse(clcomp_t * comp) { } } case 2:{ - if (toktype == TOKEN_DELIM || toktype == TOKEN_SPACE) { + if (toktype == TOKEN_DELIM) { comp->pos = 3; - printf("pos %d: TOKEN_DELIM %s\n", comp->pos, token); + DPRINTF("pos %d: TOKEN_DELIM %s\n", comp->pos, token); continue; } else { comp->errstr = "Unknown delimeter token"; @@ -100,7 +108,7 @@ int clcomp_parse(clcomp_t * comp) { comp->pos = 0; printf("pos %d: TOKEN_WORD %s\n", comp->pos, token); val = strcopy(token); - printf("keyval = [%s], [%s]\n", key, val); + DPRINTF("keyval = [%s], [%s]\n", key, val); vmapper_set(comp->vmapper, key, val); free(key); free(val); @@ -110,7 +118,6 @@ int clcomp_parse(clcomp_t * comp) { goto error; } } - } } return 0; diff --git a/libxtools/clconfig_test.c b/libxtools/clconfig_test.c index 8666ba4..450b748 100644 --- a/libxtools/clconfig_test.c +++ b/libxtools/clconfig_test.c @@ -27,11 +27,9 @@ int main(int argc, char** argv) { clconfig_bind(&clconfig, GCONF_STR, "strkey", &strkey); int res = clconfig_parse(&clconfig); - if (res < 0) { printf("error: %s\n", clconfig_geterr(&clconfig)); } - MASSERT(res == 0); clconfig_destroy(&clconfig); diff --git a/libxtools/cllexer.c b/libxtools/cllexer.c index bc55c34..0184054 100644 --- a/libxtools/cllexer.c +++ b/libxtools/cllexer.c @@ -21,6 +21,7 @@ #define LCONTEXT_ENDFL 5 #define LCONTEXT_UNDEF 7 + static int get_ltype(char newletter) { switch (newletter) { case '-': diff --git a/libxtools/cllexer_test.c b/libxtools/cllexer_test.c index b1f5c3d..c70681f 100644 --- a/libxtools/cllexer_test.c +++ b/libxtools/cllexer_test.c @@ -26,7 +26,7 @@ int main(int argc, char** argv) { while (toktype != TOKEN_ENDF) { toktype = cllexer_gettok(&lex, token); - printf("cllexer_gettok res: %d: %d [%s]\n", i, toktype, token); + printf("test cllexer_gettok res: %d: %d [%s]\n", i, toktype, token); i++; } diff --git a/server.c b/server.c index ca17319..30da6ac 100644 --- a/server.c +++ b/server.c @@ -9,30 +9,25 @@ int server_init(void) { - logger_dprintf("server init"); + logger_dprintf("server inited"); return 0; } #define SERVER_CONFIG_ERROR -1 int server_config(void) { - logger_dprintf("server config"); + logger_dprintf("server configi"); tconfig_t tconfig; - tconfig_init(&tconfig); char* logpath = NULL; - tconfig_bind(&tconfig, TCONF_STR, "logpath", &logpath); - ssize_t rsize = tconfig_read(&tconfig, "helmet.conf"); - if (rsize < 0) { return SERVER_CONFIG_ERROR; } int res = tconfig_parse(&tconfig); - if (res < 0) { return SERVER_CONFIG_ERROR; } @@ -40,11 +35,16 @@ int server_config(void) { tconfig_destroy(&tconfig); logger_dprintf("logpath = %s", logpath); + clconfig_t tconfig; + tconfig_init(&tconfig); + + + return 0; } int server_run(void) { - logger_dprintf("server start"); + logger_dprintf("server started"); return 0; }