comparison nnchat.c @ 240:e85d453e82eb

Merged.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 20 Apr 2011 15:46:42 +0300
parents b7e7ed741a18 52a2f06fd41c
children cb86d7543be2
comparison
equal deleted inserted replaced
239:b7e7ed741a18 240:e85d453e82eb
1 /* 1 /*
2 * NNChat - Custom chat client for NewbieNudes.com chatrooms 2 * NNChat - Custom chat client for NewbieNudes.com chatrooms
3 * Written by Matti 'ccr' Hämäläinen 3 * Written by Matti 'ccr' Hämäläinen
4 * (C) Copyright 2008-2010 Tecnic Software productions (TNSP) 4 * (C) Copyright 2008-2011 Tecnic Software productions (TNSP)
5 */ 5 */
6 #include "libnnchat.h" 6 #include "libnnchat.h"
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include "th_args.h" 8 #include "th_args.h"
9 #include "th_config.h" 9 #include "th_config.h"
389 } 389 }
390 390
391 391
392 char *errorMessages = NULL; 392 char *errorMessages = NULL;
393 393
394 void errorMsg(const char *fmt, ...) 394 void errorMsgV(const char *fmt, va_list ap)
395 { 395 {
396 char *tmp; 396 char *tmp;
397 va_list ap1, ap2; 397 va_list ap2;
398 398
399 va_start(ap1, fmt); 399 va_copy(ap2, ap);
400 va_copy(ap2, ap1); 400 printMsgV(TRUE, FALSE, fmt, ap);
401 printMsgV(TRUE, FALSE, fmt, ap1);
402 va_end(ap1);
403 401
404 tmp = th_strdup_vprintf(fmt, ap2); 402 tmp = th_strdup_vprintf(fmt, ap2);
405 va_end(ap2);
406 403
407 if (errorMessages != NULL) { 404 if (errorMessages != NULL) {
408 char *tmp2 = th_strdup_printf("%s%s", errorMessages, tmp); 405 char *tmp2 = th_strdup_printf("%s%s", errorMessages, tmp);
409 th_free(errorMessages); 406 th_free(errorMessages);
410 th_free(tmp); 407 th_free(tmp);
411 errorMessages = tmp2; 408 errorMessages = tmp2;
412 } else 409 } else
413 errorMessages = tmp; 410 errorMessages = tmp;
411 }
412
413 void errorMsg(const char *fmt, ...)
414 {
415 va_list ap;
416
417 va_start(ap, fmt);
418 errorMsgV(fmt, ap);
419 va_end(ap);
420 }
421
422 void errorFunc(struct _nn_conn_t *conn, const char *fmt, va_list ap)
423 {
424 errorMsgV(fmt, ap);
425 }
426
427 void messageFunc(struct _nn_conn_t *conn, const char *fmt, va_list ap)
428 {
429 printMsgV(TRUE, FALSE, fmt, ap);
414 } 430 }
415 431
416 432
417 BOOL checkIgnoreList(const char *name) 433 BOOL checkIgnoreList(const char *name)
418 { 434 {
1028 memset(histBuf, 0, sizeof(histBuf)); 1044 memset(histBuf, 0, sizeof(histBuf));
1029 backBuf = nn_ringbuf_new(SET_BACKBUF_LEN); 1045 backBuf = nn_ringbuf_new(SET_BACKBUF_LEN);
1030 1046
1031 /* Initialize */ 1047 /* Initialize */
1032 th_init("NNChat", "Newbie Nudes chat client", NN_VERSION, 1048 th_init("NNChat", "Newbie Nudes chat client", NN_VERSION,
1033 "Written and designed by Anonymous Finnish Guy (C) 2008-2010", 1049 "Written and designed by Anonymous Finnish Guy (C) 2008-2011",
1034 "This software is freeware, use and distribute as you wish."); 1050 "This software is freeware, use and distribute as you wish.");
1035 th_verbosityLevel = 0; 1051 th_verbosityLevel = 0;
1036 1052
1037 /* Read config */ 1053 /* Read config */
1038 tmpcfg = NULL; 1054 tmpcfg = NULL;
1170 if (!nn_conn_check(conn)) { 1186 if (!nn_conn_check(conn)) {
1171 THERR("Main connection setup failed!\n"); 1187 THERR("Main connection setup failed!\n");
1172 goto err_exit; 1188 goto err_exit;
1173 } 1189 }
1174 1190
1191 conn->errfunc = errorFunc;
1192 conn->msgfunc = messageFunc;
1193
1175 THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite); 1194 THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite);
1176 optUserNameEnc = nn_dblencode_str(optUserName); 1195 optUserNameEnc = nn_dblencode_str(optUserName);
1177 tmpStr = nn_dblencode_str(optSite); 1196 tmpStr = nn_dblencode_str(optSite);
1178 nn_conn_send_msg(conn, optUserNameEnc, "%%2Flogin%%20%%2Dsite%%20%s%%20%%2Dpassword%%20%s", tmpStr, optPassword); 1197 nn_conn_send_msg(conn, optUserNameEnc, "%%2Flogin%%20%%2Dsite%%20%s%%20%%2Dpassword%%20%s", tmpStr, optPassword);
1179 th_free(tmpStr); 1198 th_free(tmpStr);