Mercurial > hg > nnchat
changeset 398:c345a8efb1d4
Rename another function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 24 May 2012 05:00:32 +0300 |
parents | 932829a556c7 |
children | 06a1c1db5bbb |
files | nnchat.c |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/nnchat.c Thu May 24 04:59:49 2012 +0300 +++ b/nnchat.c Thu May 24 05:00:32 2012 +0300 @@ -221,6 +221,17 @@ } +char * str_trim_left(char *buf) +{ + while (*buf != 0 && th_isspace(*buf)) buf++; + return buf; +} + +int compareUsername(const void *s1, const void *s2) +{ + return th_strcasecmp((char *) s1, (char *) s2); +} + nn_window_t *findWindow(const char *id) { int i; @@ -915,7 +926,7 @@ { /* Change color */ int tmpInt; - if ((tmpInt = th_get_hex_triplet(trimLeft(buf + 7))) < 0) + if ((tmpInt = th_get_hex_triplet(str_trim_left(buf + 7))) < 0) { printMsgQ(currWin, "Invalid color value '%s'\n", buf+7); return 1; @@ -927,7 +938,7 @@ } else if (!th_strncasecmp(buf, "/ignore", 7)) { - char *name = trimLeft(buf + 7); + char *name = str_trim_left(buf + 7); if (strlen(name) > 0) { /* Add or remove someone to/from ignore */ @@ -966,7 +977,7 @@ } else if (!th_strncasecmp(buf, "/query", 6)) { - char *name = trimLeft(buf + 6); + char *name = str_trim_left(buf + 6); if (strlen(name) > 0) { nn_user_t *user = nn_user_find(nnUsers, nn_username_encode(name)); @@ -990,7 +1001,7 @@ else if (!th_strncasecmp(buf, "/win", 4)) { /* Change color */ - char *tmp = trimLeft(buf + 4); + char *tmp = str_trim_left(buf + 4); if (strlen(tmp) > 0) { int val = atoi(tmp); @@ -1014,7 +1025,7 @@ } else if (!th_strncasecmp(buf, "/close", 6)) { - char *name = trimLeft(buf + 6); + char *name = str_trim_left(buf + 6); if (strlen(name) > 0) { nn_window_t *win = findWindow(name); @@ -1058,7 +1069,7 @@ else if (!th_strncasecmp(buf, "/w ", 3)) { /* Open given username's profile via firefox in a new tab */ - char *name = trimLeft(buf + 3); + char *name = str_trim_left(buf + 3); printMsg(currWin, "Opening profile for: '%s'\n", name); @@ -1383,7 +1394,7 @@ for (pos = strlen(tmpBuf) - 1; pos > 0 && (tmpBuf[pos] == '\n' || tmpBuf[pos] == '\r' || th_isspace(tmpBuf[pos])); pos--) tmpBuf[pos] = 0; - ptr = trimLeft(tmpBuf); + ptr = str_trim_left(tmpBuf); if (allowEmpty || strlen(ptr) > 0) return th_strdup(ptr);