Mercurial > hg > nnchat
diff nnchat.c @ 78:745f670068dc
Add functions to simplify code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 18 Dec 2008 14:34:44 +0200 |
parents | e8c9d7d13866 |
children | e36df57c5b0f |
line wrap: on
line diff
--- a/nnchat.c Sat Dec 13 11:19:19 2008 +0200 +++ b/nnchat.c Thu Dec 18 14:34:44 2008 +0200 @@ -425,7 +425,7 @@ if (!s) return 1; *s = 0; - p = decodeStr1(str); + p = doubleDecodeStr(str); if (!p) return -1; printMsg("! ˝3˝%s˝0˝ ˝2˝ADDED.˝0˝\n", p); @@ -443,7 +443,7 @@ if (!s) return 1; *s = 0; - p = decodeStr1(str); + p = doubleDecodeStr(str); if (!p) return -1; printMsg("! ˝3˝%s˝0˝ ˝1˝DELETED.˝0˝\n", p); @@ -494,7 +494,7 @@ int handleUserInput(const int sock, char *buf, size_t bufLen) { - char *tmpStr, *tmpStr2, tmpBuf[4096]; + char *tmpStr, tmpBuf[4096]; BOOL result; /* Trim right */ @@ -521,22 +521,16 @@ snprintf(tmpBuf, sizeof(tmpBuf), "/prv -to %s -msg . .", buf+7); - tmpStr = encodeStr2(tmpBuf); + tmpStr = doubleEncodeStr(tmpBuf); if (!tmpStr) return -2; - tmpStr2 = encodeStr1(tmpStr); - if (!tmpStr2) { - th_free(tmpStr); - return -3; - } result = TRUE; for (i = 0; i < 50 && result; i++) { - result = sendUserMsg(sock, optUserName2, "%s", tmpStr2); + result = sendUserMsg(sock, optUserName2, "%s", tmpStr); usleep(250); } th_free(tmpStr); - th_free(tmpStr2); return 0; } else if (!strncmp(buf, "/to ", 4)) { th_free(setTarget); @@ -559,17 +553,11 @@ /* Send double-encoded */ - tmpStr = encodeStr2(buf); + tmpStr = doubleEncodeStr(buf); if (!tmpStr) return -2; - tmpStr2 = encodeStr1(tmpStr); - if (!tmpStr2) { - th_free(tmpStr); - return -3; - } - result = sendUserMsg(sock, optUserName2, "%s", tmpStr2); + result = sendUserMsg(sock, optUserName2, "%s", tmpStr); th_free(tmpStr); - th_free(tmpStr2); if (result) return 0; else @@ -619,7 +607,7 @@ memset(histBuf, 0, sizeof(histBuf)); /* Initialize */ - th_init("NNChat", "Newbie Nudes chat client", "0.6.6", + th_init("NNChat", "Newbie Nudes chat client", "0.6.7", "Written and designed by Anonymous Finnish Guy (C) 2008", "This software is freeware, use and distribute as you wish."); th_verbosityLevel = 0; @@ -702,8 +690,8 @@ } THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite); - optUserName2 = encodeStr1(optUserName); - tmpStr = encodeStr1(optSite); + optUserName2 = doubleEncodeStr(optUserName); + tmpStr = doubleEncodeStr(optSite); sendUserMsg(tmpSocket, optUserName2, "%%2Flogin%%20%%2Dsite%%20%s%%20%%2Dpassword%%20%s", tmpStr, optPassword); th_free(tmpStr);