Mercurial > hg > nnchat
changeset 132:10daf4660cae
Use th_get_hex_triplet().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 30 Oct 2010 17:03:29 +0300 |
parents | 3896861974ac |
children | ffe8bbd429fa |
files | nnchat.c |
diffstat | 1 files changed, 2 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- 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; }