comparison main.c @ 657:8b8ef14d7177 dev-1_5_2

Update to match th-libs API changes.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Feb 2015 23:04:24 +0200
parents 9c2ae1b96674
children eb3692d85ac2
comparison
equal deleted inserted replaced
656:10c05931dfe5 657:8b8ef14d7177
93 optDebug = FALSE, 93 optDebug = FALSE,
94 optLogEnable = FALSE, 94 optLogEnable = FALSE,
95 optLogDaily = FALSE, 95 optLogDaily = FALSE,
96 optOnlyFriendPrv = FALSE; 96 optOnlyFriendPrv = FALSE;
97 97
98 qlist_t *setIgnoreList = NULL, 98 th_llist_t *setIgnoreList = NULL,
99 *setFriendList = NULL, 99 *setFriendList = NULL,
100 *setIdleMessages = NULL; 100 *setIdleMessages = NULL;
101 nn_userhash_t *nnUsers = NULL; 101 nn_userhash_t *nnUsers = NULL;
102 char *setConfigFile = NULL, 102 char *setConfigFile = NULL,
103 *setBrowser = NULL; 103 *setBrowser = NULL;
624 (void) ctx; 624 (void) ctx;
625 printMsgConst(NULL, LOG_STAMP | LOG_WINDOW | LOG_FILE, msg); 625 printMsgConst(NULL, LOG_STAMP | LOG_WINDOW | LOG_FILE, msg);
626 } 626 }
627 627
628 628
629 BOOL nn_check_name_list(qlist_t *list, const char *name) 629 BOOL nn_check_name_list(th_llist_t *list, const char *name)
630 { 630 {
631 qlist_t *node; 631 th_llist_t *node;
632 632
633 for (node = list; node != NULL; node = node->next) 633 for (node = list; node != NULL; node = node->next)
634 { 634 {
635 if (th_strcasecmp(name, (char *) node->data) == 0) 635 if (th_strcasecmp(name, (char *) node->data) == 0)
636 return TRUE; 636 return TRUE;
1015 th_free(enc_name); 1015 th_free(enc_name);
1016 return 0; 1016 return 0;
1017 } 1017 }
1018 1018
1019 1019
1020 int nncmd_change_list(th_conn_t *conn, const char *listname, qlist_t **list, const char *name) 1020 int nncmd_change_list(th_conn_t *conn, const char *listname, th_llist_t **list, const char *name)
1021 { 1021 {
1022 (void) conn; 1022 (void) conn;
1023 1023
1024 if (name[0]) 1024 if (name[0])
1025 { 1025 {
1026 // Add or remove someone to/from ignore 1026 // Add or remove someone to/from ignore
1027 qlist_t *user = th_llist_find_func(*list, name, str_compare); 1027 th_llist_t *user = th_llist_find_func(*list, name, str_compare);
1028 if (user != NULL) 1028 if (user != NULL)
1029 { 1029 {
1030 printMsgQ(currWin, "Removed user '%s' from %s list.\n", name, listname); 1030 printMsgQ(currWin, "Removed user '%s' from %s list.\n", name, listname);
1031 th_llist_delete_node(list, user); 1031 th_llist_delete_node(list, user);
1032 } 1032 }
1037 } 1037 }
1038 } 1038 }
1039 else 1039 else
1040 { 1040 {
1041 // Just list whomever is in ignore now 1041 // Just list whomever is in ignore now
1042 qlist_t *user = *list; 1042 th_llist_t *user = *list;
1043 size_t nuser = th_llist_length(*list); 1043 size_t nuser = th_llist_length(*list);
1044 char *result = th_strdup_printf("Users on %s list (%d): ", listname, nuser); 1044 char *result = th_strdup_printf("Users on %s list (%d): ", listname, nuser);
1045 while (user != NULL) 1045 while (user != NULL)
1046 { 1046 {
1047 if (user->data != NULL) 1047 if (user->data != NULL)
1354 { "/raw", CMDARG_STRING, 0, nncmd_send_raw }, 1354 { "/raw", CMDARG_STRING, 0, nncmd_send_raw },
1355 1355
1356 { "/quit", CMDARG_NONE, 0, nncmd_quit }, 1356 { "/quit", CMDARG_NONE, 0, nncmd_quit },
1357 }; 1357 };
1358 1358
1359 static qlist_t *userCmds = NULL; 1359 static th_llist_t *userCmds = NULL;
1360 1360
1361 1361
1362 void nn_usercmd_init() 1362 void nn_usercmd_init()
1363 { 1363 {
1364 size_t i; 1364 size_t i;
1370 } 1370 }
1371 1371
1372 1372
1373 int nn_handle_command(th_conn_t *conn, char *buf) 1373 int nn_handle_command(th_conn_t *conn, char *buf)
1374 { 1374 {
1375 qlist_t *curr; 1375 th_llist_t *curr;
1376 1376
1377 for (curr = userCmds; curr != NULL; curr = curr->next) 1377 for (curr = userCmds; curr != NULL; curr = curr->next)
1378 { 1378 {
1379 nn_usercmd_t *cmd = curr->data; 1379 nn_usercmd_t *cmd = curr->data;
1380 1380
1431 printMsgQ(currWin, "Unknown command: %s\n", buf); 1431 printMsgQ(currWin, "Unknown command: %s\n", buf);
1432 return 1; 1432 return 1;
1433 } 1433 }
1434 1434
1435 1435
1436 static nn_usercmd_t *nn_usercmd_match_do(qlist_t *list, const char *pattern, size_t len) 1436 static nn_usercmd_t *nn_usercmd_match_do(th_llist_t *list, const char *pattern, size_t len)
1437 { 1437 {
1438 qlist_t *node; 1438 th_llist_t *node;
1439 for (node = list; node != NULL; node = node->next) 1439 for (node = list; node != NULL; node = node->next)
1440 { 1440 {
1441 nn_usercmd_t *cmd = node->data; 1441 nn_usercmd_t *cmd = node->data;
1442 if (len <= strlen(cmd->name) && th_strncasecmp(cmd->name, pattern, len) == 0) 1442 if (len <= strlen(cmd->name) && th_strncasecmp(cmd->name, pattern, len) == 0)
1443 return cmd; 1443 return cmd;
1444 } 1444 }
1445 return NULL; 1445 return NULL;
1446 } 1446 }
1447 1447
1448 1448
1449 nn_usercmd_t *nn_usercmd_match(qlist_t *list, const char *pattern, const char *current, BOOL again) 1449 nn_usercmd_t *nn_usercmd_match(th_llist_t *list, const char *pattern, const char *current, BOOL again)
1450 { 1450 {
1451 nn_usercmd_t *curr; 1451 nn_usercmd_t *curr;
1452 size_t len; 1452 size_t len;
1453 1453
1454 if (list == NULL || pattern == NULL) return NULL; 1454 if (list == NULL || pattern == NULL) return NULL;
1455 1455
1456 len = strlen(pattern); 1456 len = strlen(pattern);
1457 1457
1458 if (current != NULL) 1458 if (current != NULL)
1459 { 1459 {
1460 qlist_t *node; 1460 th_llist_t *node;
1461 for (node = list; node != NULL; node = node->next) 1461 for (node = list; node != NULL; node = node->next)
1462 { 1462 {
1463 curr = node->data; 1463 curr = node->data;
1464 if (th_strcasecmp(curr->name, current) == 0) 1464 if (th_strcasecmp(curr->name, current) == 0)
1465 { 1465 {
2390 { 2390 {
2391 time_t tmpTime = time(NULL); 2391 time_t tmpTime = time(NULL);
2392 if (tmpTime - editState.prevKeepAlive > SET_KEEPALIVE) 2392 if (tmpTime - editState.prevKeepAlive > SET_KEEPALIVE)
2393 { 2393 {
2394 size_t n = ((size_t) rand()) % th_llist_length(setIdleMessages); 2394 size_t n = ((size_t) rand()) % th_llist_length(setIdleMessages);
2395 qlist_t *node = th_llist_get_nth(setIdleMessages, n); 2395 th_llist_t *node = th_llist_get_nth(setIdleMessages, n);
2396 nn_conn_send_msg(conn, optUserNameEnc, node->data); 2396 nn_conn_send_msg(conn, optUserNameEnc, node->data);
2397 editState.prevKeepAlive = tmpTime; 2397 editState.prevKeepAlive = tmpTime;
2398 } 2398 }
2399 2399
2400 if (!colorSet) 2400 if (!colorSet)