# HG changeset patch # User Matti Hamalainen # Date 1304640415 -10800 # Node ID 8a0f7446318e0b75f80d24d136281deea4a92e78 # Parent 214f0b524f9dc8ba65877b2e001833913a1dbc50 General cleanups. diff -r 214f0b524f9d -r 8a0f7446318e nnchat.c --- a/nnchat.c Thu Apr 28 16:32:00 2011 +0300 +++ b/nnchat.c Fri May 06 03:06:55 2011 +0300 @@ -64,7 +64,7 @@ *statusWin = NULL, *editWin = NULL; BOOL setPrvMode = FALSE; -BOOL setIgnoreMode = FALSE; +BOOL setIgnoreMode = FALSE; BOOL optDebug = FALSE; BOOL optLogEnable = FALSE; @@ -92,7 +92,7 @@ const int optListN = (sizeof(optList) / sizeof(optList[0])); -void argShowHelp() +void argShowHelp(void) { th_args_help(stdout, optList, optListN, th_prog_name, "[options] "); @@ -193,6 +193,7 @@ return str; } + char *decodeUsername(char *str) { unsigned char *c = (unsigned char *) str; @@ -202,6 +203,7 @@ return str; } + void updateStatus(BOOL insertMode) { char tmpStr[128]; @@ -477,8 +479,7 @@ * that it is not our OWN username! */ isMine = strcmp(userName, optUserName) == 0; - if (setIgnoreMode && !isMine) - isIgnored = checkIgnoreList(userName); + isIgnored = setIgnoreMode && !isMine && checkIgnoreList(userName); /* Is it a special control message? */ if (*s == '/') { @@ -658,12 +659,15 @@ buf[bufLen--] = 0; while (bufLen > 0 && (buf[bufLen] == '\n' || buf[bufLen] == '\r' || th_isspace(buf[bufLen]))) buf[bufLen--] = 0; + + /* Decode completed usernames */ decodeUsername(buf); /* Check for special user commands */ if (*buf == 0) { return 1; - } else if (!strncasecmp(buf, "/color ", 7)) { + } + else if (!strncasecmp(buf, "/color ", 7)) { /* Change color */ int tmpInt; if ((tmpInt = th_get_hex_triplet(trimLeft(buf + 7))) < 0) { @@ -674,7 +678,8 @@ printMsg("Setting color to #%06x\n", optUserColor); nn_conn_send_msg(conn, optUserNameEnc, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor); return 0; - } else if (!strncasecmp(buf, "/ignore", 7)) { + } + else if (!strncasecmp(buf, "/ignore", 7)) { char *name = trimLeft(buf + 7); if (strlen(name) > 0) { /* Add or remove someone to/from ignore */ @@ -702,7 +707,8 @@ printMsgC("\n"); } return 0; - } else if (!strncasecmp(buf, "/save", 5)) { + } + else if (!strncasecmp(buf, "/save", 5)) { /* Save configuration */ FILE *cfgfile = fopen(setConfigFile, "w"); if (cfgfile == NULL) { @@ -716,7 +722,8 @@ fclose(cfgfile); return 0; - } else if (!strncasecmp(buf, "/w ", 3)) { + } + else if (!strncasecmp(buf, "/w ", 3)) { /* Open given username's profile via firefox in a new tab */ char *name = trimLeft(buf + 3); @@ -759,7 +766,8 @@ } #endif return 0; - } else if (!strncasecmp(buf, "/to", 3)) { + } + else if (!strncasecmp(buf, "/to", 3)) { char *name = trimLeft(buf + 3); /* Set private messaging target */ th_free(setTarget); @@ -771,11 +779,13 @@ printMsg("Cleared prv target.\n"); } return 0; - } else if (!strncasecmp(buf, "/who", 4)) { + } + else if (!strncasecmp(buf, "/who", 4)) { /* Alias /who to /listallusers */ snprintf(tmpBuf, sizeof(tmpBuf), "/listallusers"); buf = tmpBuf; - } else if (setPrvMode) { + } + else if (setPrvMode) { /* Private chat mode, send as PRV */ if (setTarget != NULL) { snprintf(tmpBuf, sizeof(tmpBuf), "/prv -to %s -msg %s", setTarget, buf);