# HG changeset patch # User Matti Hamalainen # Date 1288447409 -10800 # Node ID 10daf4660caeb3b037737f3621e25ebd39aad0aa # Parent 3896861974acb051c0bb8ca050dc1adce7243aee Use th_get_hex_triplet(). diff -r 3896861974ac -r 10daf4660cae nnchat.c --- a/nnchat.c Sat Oct 30 17:02:35 2010 +0300 +++ b/nnchat.c Sat Oct 30 17:03:29 2010 +0300 @@ -72,26 +72,6 @@ const int optListN = (sizeof(optList) / sizeof(optList[0])); -int getHexColorDef(char *str) -{ - char *p = str; - int len, val = 0; - - for (len = 0; *p && len < 6; p++, len++) { - if (*p >= '0' && *p <= '9') { - val *= 16; val += (*p - '0'); - } else if (*p >= 'A' && *p <= 'F') { - val *= 16; val += (*p - 'A') + 10; - } else if (*p >= 'a' && *p <= 'f') { - val *= 16; val += (*p - 'a') + 10; - } else - return -1; - } - - return (len == 6) ? val : -1; -} - - void argShowHelp() { th_args_help(stdout, optList, optListN, th_prog_name, @@ -120,7 +100,7 @@ break; case 4: - if ((optUserColor = getHexColorDef(optArg)) < 0) { + if ((optUserColor = th_get_hex_triplet(optArg)) < 0) { THERR("Invalid color argument '%s', should be a RGB hex triplet '000000'.\n", optArg); return FALSE; @@ -575,7 +555,7 @@ } else if (!strncasecmp(buf, "/color ", 7)) { /* Change color */ int tmpInt; - if ((tmpInt = getHexColorDef(trimLeft(buf + 7))) < 0) { + if ((tmpInt = th_get_hex_triplet(trimLeft(buf + 7))) < 0) { printMsg("Invalid color value '%s'\n", buf+7); return 1; }