# HG changeset patch # User Matti Hamalainen # Date 1288875387 -7200 # Node ID e59cec39781119720a85a7e786e7d5911d023969 # Parent 6dd282b5f43138ba3c72718818ef2e71f4a125f7 Add a debug mode option (commandline) and enable certain features when we are in debug mode. diff -r 6dd282b5f431 -r e59cec397811 nnchat.c --- a/nnchat.c Thu Nov 04 14:56:06 2010 +0200 +++ b/nnchat.c Thu Nov 04 14:56:27 2010 +0200 @@ -52,6 +52,7 @@ *editWin = NULL; BOOL setPrvMode = FALSE; BOOL setIgnoreMode = FALSE; +BOOL optDebug = FALSE; qlist_t *nnIgnoreList = NULL; @@ -72,6 +73,7 @@ { 5, 'l', "logfile", "Log filename", OPT_ARGREQ }, { 6, 'D', "daemon", "A pseudo-daemon mode for logging", OPT_NONE }, { 7, 'S', "site", "Site (default: NN)", OPT_ARGREQ }, + { 8, 'd', "debug", "Enable various debug features", OPT_NONE }, }; const int optListN = (sizeof(optList) / sizeof(optList[0])); @@ -126,6 +128,11 @@ THMSG(1, "Running in pseudo-daemon mode.\n"); break; + case 8: + optDebug = TRUE; + THMSG(1, "Debug mode enabled.\n"); + break; + default: THERR("Unknown option '%s'.\n", currArg); return FALSE; @@ -381,7 +388,7 @@ if (*s == '/') { /* Ignore room join/leave messages */ - if (strstr(s, "left the room") || strstr(s, "joined the room from")) + if (!optDebug && (strstr(s, "left the room") || strstr(s, "joined the room from"))) goto error; t = nn_strip_tags(s + 1); @@ -530,8 +537,12 @@ if (cmdLen < bufLen && !strncmp(buf, protoCmds[i].cmd, cmdLen)) return protoCmds[i].handler(sock, buf + cmdLen); } - - return 1; + + if (optDebug) { + printMsg("Unknown protocmd: \"%s\"\n", buf); + return 0; + } else + return 1; } char * trimLeft(char *buf) @@ -755,7 +766,8 @@ mode = 2; } -// printMsg("%d, %d <-> %d : '%s' (%d, %d)\n", startPos, endPos, buf->len, pattern, mode, again); + if (optDebug) + printMsg("%d, %d <-> %d : '%s' (%d, %d)\n", startPos, endPos, buf->len, pattern, mode, again); if (pattern) { nn_user_t *user = nn_user_match(nnUsers, pattern, previous, again); @@ -763,7 +775,8 @@ if (user) { int i; char *c = user->name; -// printMsg("match '%s' / prev '%s'\n", user->name, previous); + if (optDebug) + printMsg("match '%s' / prev '%s'\n", user->name, previous); for (i = startPos; i <= endPos; i++) nn_editbuf_delete(buf, startPos);