changeset 258:8a0f7446318e

General cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 May 2011 03:06:55 +0300
parents 214f0b524f9d
children f870001f658c
files nnchat.c
diffstat 1 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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] <username> <password>");
@@ -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);