# HG changeset patch # User Matti Hamalainen # Date 1303303602 -10800 # Node ID e85d453e82ebbe81ff6398eb05d82990fcc4dd4c # Parent b7e7ed741a1836748fb0f67f168b87756de1d9d4# Parent 578730eebe076a72d6ecdb1bf922a9cbbc25c72f Merged. diff -r 578730eebe07 -r e85d453e82eb nnchat.c --- a/nnchat.c Wed Apr 20 15:06:40 2011 +0300 +++ b/nnchat.c Wed Apr 20 15:46:42 2011 +0300 @@ -941,6 +941,66 @@ return FALSE; } +char *logParseFilename(const char *fmt, int id) +{ + size_t tmpLen = strlen(fmt) + 32; + char *res = NULL, tmpBuf[32]; + const char *s = fmt; + + if ((res = th_malloc(len)) == NULL) + return NULL; + + while (*s) { + if (*s == '%') { + s++; + switch (*s) { + case 'i': + + { + snprintf(tmpBuf, sizeof(tmpBuf), "%05d", id); + len -= strlen(tmpBuf) + 1; + if (len <= 0) { + res = th_realloc(res, + } + VPUTS(tmpBuf); + } + break; + + case '%': + VPUTCH(res, '%'); + break; + + default: + VPUTCH(res, '%'); + VPUTCH(res, *s); + break; + } + } + } +} + + +BOOL logFileOpen(void) +{ + char *filename; + + if (optLogFilename == NULL) + return FALSE; + + + + if ((optLogFile = fopen(filename, "a")) == NULL) { + errMsg("Could not open logfile '%s' for appending!\n", filename); + th_free(filename); + return FALSE; + } + return TRUE; +} + +BOOL logFileClose(void) +{ +} + char *promptRequester(const char *info, BOOL allowEmpty) { char tmpBuf[512], *ptr; @@ -1011,6 +1071,13 @@ th_cfg_add_int(&tmpcfg, "port", &optPort, optPort); th_cfg_add_section(&cfg, "server", tmpcfg); + tmpcfg = NULL; + th_cfg_add_comment(&tmpcfg, "Enable logging"); + th_cfg_add_string(&tmpcfg, "host", &optServer, optServer); + th_cfg_add_comment(&tmpcfg, "Default port to connect to (8002 = public room, 8003 = passion pit, 8005 = members only)"); + th_cfg_add_int(&tmpcfg, "port", &optPort, optPort); + th_cfg_add_section(&cfg, "server", tmpcfg); + #ifdef __WIN32 { char tmpPath[MAX_PATH];