Mercurial > hg > nnchat
changeset 21:29098addfa65
Added a "daemon" mode.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 12 Jun 2008 23:55:41 +0300 |
parents | 323c98360d8b |
children | ccf302dae898 |
files | nnchat.c th_args.c th_args.h th_string.c th_string.h th_types.h th_util.c th_util.h |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/nnchat.c Wed Mar 26 04:38:05 2008 +0000 +++ b/nnchat.c Thu Jun 12 23:55:41 2008 +0300 @@ -31,7 +31,7 @@ *optUserName2 = NULL, *optPassword = NULL, *optLogFilename = NULL; - +BOOL optDaemon = FALSE; FILE *optLogFile = NULL; @@ -44,6 +44,7 @@ { 3, 's', "server", "Server to connect to", OPT_ARGREQ }, { 4, 'C', "color", "Initial color in RGB hex 000000", OPT_ARGREQ }, { 5, 'l', "logfile", "Log filename", OPT_ARGREQ }, + { 6, 'D', "daemon", "A pseudo-daemon mode for logging", OPT_NONE }, }; const int optListN = (sizeof(optList) / sizeof(optarg_t)); @@ -100,6 +101,11 @@ optLogFilename = optArg; break; + case 6: + optDaemon = TRUE; + THMSG(1, "Running in pseudo-daemon mode.\n"); + break; + default: THERR("Unknown option '%s'.\n", currArg); return FALSE; @@ -200,11 +206,13 @@ fflush(optLogFile); } - fputs(tmpStr, stdout); - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - fflush(stdout); + if (!optDaemon) { + fputs(tmpStr, stdout); + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + fflush(stdout); + } } @@ -679,7 +687,7 @@ char *tmpStr; /* Initialize */ - th_init("NNChat", "Newbie Nudes chat client", "0.3", + th_init("NNChat", "Newbie Nudes chat client", "0.4", "Written and designed by Anonymous Finnish Guy (C) 2008", "This software is freeware, use and distribute as you wish."); th_verbosityLevel = 0; @@ -798,6 +806,7 @@ } /* Check for user input */ + if (!optDaemon) { tv.tv_sec = 0; tv.tv_usec = SET_SELECT_USEC; tmpfds = inputfds; @@ -820,6 +829,7 @@ } } } + } /* !optDaemon */ if (!colorSet) { colorSet = TRUE;