Changeset c36f73b for protocols/yahoo
- Timestamp:
- 2010-07-23T14:35:45Z (14 years ago)
- Branches:
- master
- Children:
- 9034ba0
- Parents:
- 938c305
- Location:
- protocols/yahoo
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
r938c305 rc36f73b 3 3 * 4 4 * Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net> 5 * YMSG16 code copyright (C) 2009, 6 * Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com> 5 7 * 6 8 * Yahoo Search copyright (C) 2003, Konstantin Klyagin <konst AT konst.org.ua> … … 27 29 * <hiro-y@kcn.ne.jp> 28 30 * 31 * YMSG16 authentication code based mostly on write-up at: 32 * http://www.carbonize.co.uk/ymsg16.html 29 33 * 30 34 * This program is free software; you can redistribute it and/or modify … … 92 96 93 97 #ifdef USE_STRUCT_CALLBACKS 94 struct yahoo_callbacks *yc =NULL;95 96 void yahoo_register_callbacks(struct yahoo_callbacks * 98 struct yahoo_callbacks *yc = NULL; 99 100 void yahoo_register_callbacks(struct yahoo_callbacks *tyc) 97 101 { 98 102 yc = tyc; … … 106 110 static int yahoo_send_data(int fd, void *data, int len); 107 111 108 int yahoo_log_message(char * 112 int yahoo_log_message(char *fmt, ...) 109 113 { 110 114 char out[1024]; … … 113 117 vsnprintf(out, sizeof(out), fmt, ap); 114 118 va_end(ap); 115 return YAHOO_CALLBACK(ext_yahoo_log) ("%s", out);116 } 117 118 int yahoo_connect(char * 119 { 120 return YAHOO_CALLBACK(ext_yahoo_connect) (host, port);119 return YAHOO_CALLBACK(ext_yahoo_log) ("%s", out); 120 } 121 122 int yahoo_connect(char *host, int port) 123 { 124 return YAHOO_CALLBACK(ext_yahoo_connect) (host, port); 121 125 } 122 126 … … 138 142 static char pager_host[] = "scs.msg.yahoo.com"; 139 143 static int pager_port = 5050; 140 static int fallback_ports[] ={23, 25, 80, 20, 119, 8001, 8002, 5050, 0};141 static char filetransfer_host[] ="filetransfer.msg.yahoo.com";142 static int filetransfer_port =80;143 static char webcam_host[] ="webcam.yahoo.com";144 static int webcam_port =5100;145 static char webcam_description[] ="";146 static char local_host[] ="";147 static int conn_type =Y_WCM_DSL;144 static int fallback_ports[] = { 23, 25, 80, 20, 119, 8001, 8002, 5050, 0 }; 145 static char filetransfer_host[] = "filetransfer.msg.yahoo.com"; 146 static int filetransfer_port = 80; 147 static char webcam_host[] = "webcam.yahoo.com"; 148 static int webcam_port = 5100; 149 static char webcam_description[] = ""; 150 static char local_host[] = ""; 151 static int conn_type = Y_WCM_DSL; 148 152 149 153 static char profile_url[] = "http://profiles.yahoo.com/"; … … 215 219 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 216 220 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, 217 YAHOO_SERVICE_Y6_VISIBILITY =0xc5,218 YAHOO_SERVICE_Y6_STATUS_UPDATE =0xc6,219 YAHOO_PHOTOSHARE_INIT =0xd2,220 YAHOO_SERVICE_CONTACT_YMSG13 =0xd6,221 YAHOO_PHOTOSHARE_PREV =0xd7,222 YAHOO_PHOTOSHARE_KEY =0xd8,223 YAHOO_PHOTOSHARE_TRANS =0xda,224 YAHOO_FILE_TRANSFER_INIT_YMSG13 =0xdc,225 YAHOO_FILE_TRANSFER_GET_YMSG13 =0xdd,226 YAHOO_FILE_TRANSFER_PUT_YMSG13 =0xde,227 YAHOO_SERVICE_YMSG15_STATUS =0xf0,228 YAHOO_SERVICE_YMSG15_BUDDY_LIST =0xf1,221 YAHOO_SERVICE_Y6_VISIBILITY = 0xc5, 222 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, 223 YAHOO_PHOTOSHARE_INIT = 0xd2, 224 YAHOO_SERVICE_CONTACT_YMSG13 = 0xd6, 225 YAHOO_PHOTOSHARE_PREV = 0xd7, 226 YAHOO_PHOTOSHARE_KEY = 0xd8, 227 YAHOO_PHOTOSHARE_TRANS = 0xda, 228 YAHOO_FILE_TRANSFER_INIT_YMSG13 = 0xdc, 229 YAHOO_FILE_TRANSFER_GET_YMSG13 = 0xdd, 230 YAHOO_FILE_TRANSFER_PUT_YMSG13 = 0xde, 231 YAHOO_SERVICE_YMSG15_STATUS = 0xf0, 232 YAHOO_SERVICE_YMSG15_BUDDY_LIST = 0xf1, 229 233 }; 230 234 … … 242 246 243 247 struct yahoo_search_state { 244 int 245 char 246 int 247 int 248 int 249 int 250 int 251 int 252 int 248 int lsearch_type; 249 char *lsearch_text; 250 int lsearch_gender; 251 int lsearch_agerange; 252 int lsearch_photo; 253 int lsearch_yahoo_only; 254 int lsearch_nstart; 255 int lsearch_nfound; 256 int lsearch_ntotal; 253 257 }; 254 258 … … 264 268 struct yahoo_search_state *ys; 265 269 266 int 270 int fd; 267 271 enum yahoo_connection_type type; 268 272 269 unsigned char 270 int 271 int 273 unsigned char *rxqueue; 274 int rxlen; 275 int read_tag; 272 276 273 277 YList *txqueues; 274 int 278 int write_tag; 275 279 }; 276 280 277 281 struct yahoo_server_settings { 278 282 char *pager_host; 279 int 283 int pager_port; 280 284 char *filetransfer_host; 281 int 285 int filetransfer_port; 282 286 char *webcam_host; 283 int 287 int webcam_port; 284 288 char *webcam_description; 285 289 char *local_host; 286 int 290 int conn_type; 287 291 }; 288 292 289 static void * 293 static void *_yahoo_default_server_settings() 290 294 { 291 295 struct yahoo_server_settings *yss = y_new0(struct yahoo_server_settings, 1); … … 304 308 } 305 309 306 static void * 310 static void *_yahoo_assign_server_settings(va_list ap) 307 311 { 308 312 struct yahoo_server_settings *yss = _yahoo_default_server_settings(); 309 313 char *key; 310 314 char *svalue; 311 int 312 313 while (1) {315 int nvalue; 316 317 while (1) { 314 318 key = va_arg(ap, char *); 315 if (key == NULL)316 break; 317 318 if (!strcmp(key, "pager_host")) {319 if (key == NULL) 320 break; 321 322 if (!strcmp(key, "pager_host")) { 319 323 svalue = va_arg(ap, char *); 320 324 free(yss->pager_host); 321 325 yss->pager_host = strdup(svalue); 322 } else if (!strcmp(key, "pager_port")) {326 } else if (!strcmp(key, "pager_port")) { 323 327 nvalue = va_arg(ap, int); 324 328 yss->pager_port = nvalue; 325 } else if (!strcmp(key, "filetransfer_host")) {329 } else if (!strcmp(key, "filetransfer_host")) { 326 330 svalue = va_arg(ap, char *); 327 331 free(yss->filetransfer_host); 328 332 yss->filetransfer_host = strdup(svalue); 329 } else if (!strcmp(key, "filetransfer_port")) {333 } else if (!strcmp(key, "filetransfer_port")) { 330 334 nvalue = va_arg(ap, int); 331 335 yss->filetransfer_port = nvalue; 332 } else if (!strcmp(key, "webcam_host")) {336 } else if (!strcmp(key, "webcam_host")) { 333 337 svalue = va_arg(ap, char *); 334 338 free(yss->webcam_host); 335 339 yss->webcam_host = strdup(svalue); 336 } else if (!strcmp(key, "webcam_port")) {340 } else if (!strcmp(key, "webcam_port")) { 337 341 nvalue = va_arg(ap, int); 338 342 yss->webcam_port = nvalue; 339 } else if (!strcmp(key, "webcam_description")) {343 } else if (!strcmp(key, "webcam_description")) { 340 344 svalue = va_arg(ap, char *); 341 345 free(yss->webcam_description); 342 346 yss->webcam_description = strdup(svalue); 343 } else if (!strcmp(key, "local_host")) {347 } else if (!strcmp(key, "local_host")) { 344 348 svalue = va_arg(ap, char *); 345 349 free(yss->local_host); 346 350 yss->local_host = strdup(svalue); 347 } else if (!strcmp(key, "conn_type")) {351 } else if (!strcmp(key, "conn_type")) { 348 352 nvalue = va_arg(ap, int); 349 353 yss->conn_type = nvalue; 350 354 } else { 351 355 WARNING(("Unknown key passed to yahoo_init, " 352 "perhaps you didn't terminate the list "353 "with NULL"));356 "perhaps you didn't terminate the list " 357 "with NULL")); 354 358 } 355 359 } … … 360 364 static void yahoo_free_server_settings(struct yahoo_server_settings *yss) 361 365 { 362 if (!yss)366 if (!yss) 363 367 return; 364 368 … … 372 376 } 373 377 374 static YList *conns =NULL;375 static YList *inputs =NULL;376 static int last_id =0;378 static YList *conns = NULL; 379 static YList *inputs = NULL; 380 static int last_id = 0; 377 381 378 382 static void add_to_list(struct yahoo_data *yd) … … 380 384 conns = y_list_prepend(conns, yd); 381 385 } 382 static struct yahoo_data * 386 static struct yahoo_data *find_conn_by_id(int id) 383 387 { 384 388 YList *l; 385 for (l = conns; l; l = y_list_next(l)) {389 for (l = conns; l; l = y_list_next(l)) { 386 390 struct yahoo_data *yd = l->data; 387 if (yd->client_id == id)391 if (yd->client_id == id) 388 392 return yd; 389 393 } … … 396 400 397 401 /* call repeatedly to get the next one */ 398 static struct yahoo_input_data * 402 static struct yahoo_input_data *find_input_by_id(int id) 399 403 { 400 404 YList *l; … … 407 411 } 408 412 409 static struct yahoo_input_data * find_input_by_id_and_webcam_user(int id, const char *who)413 static struct yahoo_input_data *find_input_by_id_and_webcam_user(int id, const char *who) 410 414 { 411 415 YList *l; 412 416 LOG(("find_input_by_id_and_webcam_user")); 413 for (l = inputs; l; l = y_list_next(l)) {417 for (l = inputs; l; l = y_list_next(l)) { 414 418 struct yahoo_input_data *yid = l->data; 415 if (yid->type == YAHOO_CONNECTION_WEBCAM && yid->yd->client_id == id419 if (yid->type == YAHOO_CONNECTION_WEBCAM && yid->yd->client_id == id 416 420 && yid->wcm && 417 421 ((who && yid->wcm->user && !strcmp(who, yid->wcm->user)) || … … 422 426 } 423 427 424 static struct yahoo_input_data * 428 static struct yahoo_input_data *find_input_by_id_and_type(int id, enum yahoo_connection_type type) 425 429 { 426 430 YList *l; 427 431 LOG(("find_input_by_id_and_type")); 428 for (l = inputs; l; l = y_list_next(l)) {432 for (l = inputs; l; l = y_list_next(l)) { 429 433 struct yahoo_input_data *yid = l->data; 430 if (yid->type == type && yid->yd->client_id == id)434 if (yid->type == type && yid->yd->client_id == id) 431 435 return yid; 432 436 } … … 434 438 } 435 439 436 static struct yahoo_input_data * 440 static struct yahoo_input_data *find_input_by_id_and_fd(int id, int fd) 437 441 { 438 442 YList *l; 439 443 LOG(("find_input_by_id_and_fd")); 440 for (l = inputs; l; l = y_list_next(l)) {444 for (l = inputs; l; l = y_list_next(l)) { 441 445 struct yahoo_input_data *yid = l->data; 442 if (yid->fd == fd && yid->yd->client_id == id)446 if (yid->fd == fd && yid->yd->client_id == id) 443 447 return yid; 444 448 } … … 448 452 static int count_inputs_with_id(int id) 449 453 { 450 int c =0;454 int c = 0; 451 455 YList *l; 452 456 LOG(("counting %d", id)); 453 for (l = inputs; l; l = y_list_next(l)) {457 for (l = inputs; l; l = y_list_next(l)) { 454 458 struct yahoo_input_data *yid = l->data; 455 if (yid->yd->client_id == id)459 if (yid->yd->client_id == id) 456 460 c++; 457 461 } … … 464 468 465 469 /* Free a buddy list */ 466 static void yahoo_free_buddies(YList * 470 static void yahoo_free_buddies(YList *list) 467 471 { 468 472 YList *l; 469 473 470 for(l = list; l; l = l->next) 471 { 474 for (l = list; l; l = l->next) { 472 475 struct yahoo_buddy *bud = l->data; 473 if (!bud)476 if (!bud) 474 477 continue; 475 478 … … 477 480 FREE(bud->id); 478 481 FREE(bud->real_name); 479 if (bud->yab_entry) {482 if (bud->yab_entry) { 480 483 FREE(bud->yab_entry->fname); 481 484 FREE(bud->yab_entry->lname); … … 496 499 497 500 /* Free an identities list */ 498 static void yahoo_free_identities(YList * 501 static void yahoo_free_identities(YList *list) 499 502 { 500 503 while (list) { … … 690 693 } 691 694 692 693 695 static void yahoo_packet_dump(unsigned char *data, int len) 694 696 { 695 if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) {697 if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { 696 698 int i; 697 699 for (i = 0; i < len; i++) { 698 700 if ((i % 8 == 0) && i) 699 YAHOO_CALLBACK(ext_yahoo_log) (" ");701 YAHOO_CALLBACK(ext_yahoo_log) (" "); 700 702 if ((i % 16 == 0) && i) 701 YAHOO_CALLBACK(ext_yahoo_log) ("\n");702 YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]);703 } 704 YAHOO_CALLBACK(ext_yahoo_log) ("\n");703 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 704 YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]); 705 } 706 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 705 707 for (i = 0; i < len; i++) { 706 708 if ((i % 8 == 0) && i) 707 YAHOO_CALLBACK(ext_yahoo_log) (" ");709 YAHOO_CALLBACK(ext_yahoo_log) (" "); 708 710 if ((i % 16 == 0) && i) 709 YAHOO_CALLBACK(ext_yahoo_log) ("\n");711 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 710 712 if (isprint(data[i])) 711 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]);713 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]); 712 714 else 713 YAHOO_CALLBACK(ext_yahoo_log) (" . ");714 } 715 YAHOO_CALLBACK(ext_yahoo_log) ("\n");715 YAHOO_CALLBACK(ext_yahoo_log) (" . "); 716 } 717 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 716 718 } 717 719 } … … 723 725 } 724 726 725 static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, int length) 727 static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, 728 int length) 726 729 { 727 730 struct data_queue *tx = y_new0(struct data_queue, 1); … … 732 735 yid->txqueues = y_list_append(yid->txqueues, tx); 733 736 734 if(!yid->write_tag) 735 yid->write_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_WRITE, yid); 736 } 737 738 static void yahoo_send_packet(struct yahoo_input_data *yid, struct yahoo_packet *pkt, int extra_pad) 737 if (!yid->write_tag) 738 yid->write_tag = 739 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd-> 740 client_id, yid->fd, YAHOO_INPUT_WRITE, yid); 741 } 742 743 static void yahoo_send_packet(struct yahoo_input_data *yid, 744 struct yahoo_packet *pkt, int extra_pad) 739 745 { 740 746 int pktlen = yahoo_packet_length(pkt); 741 747 int len = YAHOO_PACKET_HDRLEN + pktlen; 742 743 748 unsigned char *data; 744 749 int pos = 0; … … 749 754 data = y_new0(unsigned char, len + 1); 750 755 751 memcpy(data + pos, "YMSG", 4); pos += 4; 752 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); 753 pos += yahoo_put16(data + pos, 0x0000); 754 pos += yahoo_put16(data + pos, pktlen + extra_pad); 755 pos += yahoo_put16(data + pos, pkt->service); 756 pos += yahoo_put32(data + pos, pkt->status); 757 pos += yahoo_put32(data + pos, pkt->id); 756 memcpy(data + pos, "YMSG", 4); 757 pos += 4; 758 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); /* version [latest 12 0x000c] */ 759 pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */ 760 pos += yahoo_put16(data + pos, pktlen + extra_pad); /* LOWORD pkt length? */ 761 pos += yahoo_put16(data + pos, pkt->service); /* service */ 762 pos += yahoo_put32(data + pos, pkt->status); /* status [4bytes] */ 763 pos += yahoo_put32(data + pos, pkt->id); /* session [4bytes] */ 758 764 759 765 yahoo_packet_write(pkt, data + pos); 760 766 761 767 yahoo_packet_dump(data, len); 762 763 if ( yid->type == YAHOO_CONNECTION_FT)768 769 if (yid->type == YAHOO_CONNECTION_FT) 764 770 yahoo_send_data(yid->fd, data, len); 765 771 else … … 794 800 do { 795 801 ret = write(fd, data, len); 796 } while (ret == -1 && errno==EINTR);797 e =errno;798 799 if (ret == -1) 802 } while (ret == -1 && errno == EINTR); 803 e = errno; 804 805 if (ret == -1) { 800 806 LOG(("wrote data: ERR %s", strerror(errno))); 801 807 } else { … … 803 809 } 804 810 805 errno =e;811 errno = e; 806 812 return ret; 807 813 } 808 814 809 void yahoo_close(int id) 815 void yahoo_close(int id) 810 816 { 811 817 struct yahoo_data *yd = find_conn_by_id(id); 812 813 if(!yd) 818 if (!yd) 814 819 return; 815 820 … … 817 822 818 823 yahoo_free_data(yd); 819 if (id == last_id)824 if (id == last_id) 820 825 last_id--; 821 826 } 822 827 823 static void yahoo_input_close(struct yahoo_input_data *yid) 828 static void yahoo_input_close(struct yahoo_input_data *yid) 824 829 { 825 830 inputs = y_list_remove(inputs, yid); 826 831 827 LOG(("yahoo_input_close(read)")); 828 YAHOO_CALLBACK(ext_yahoo_remove_handler)(yid->yd->client_id, yid->read_tag); 829 LOG(("yahoo_input_close(write)")); 830 YAHOO_CALLBACK(ext_yahoo_remove_handler)(yid->yd->client_id, yid->write_tag); 832 LOG(("yahoo_input_close(read)")); 833 YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id, 834 yid->read_tag); 835 LOG(("yahoo_input_close(write)")); 836 YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id, 837 yid->write_tag); 831 838 yid->read_tag = yid->write_tag = 0; 832 if (yid->fd)839 if (yid->fd) 833 840 close(yid->fd); 834 841 yid->fd = 0; 835 842 FREE(yid->rxqueue); 836 if (count_inputs_with_id(yid->yd->client_id) == 0) {843 if (count_inputs_with_id(yid->yd->client_id) == 0) { 837 844 LOG(("closing %d", yid->yd->client_id)); 838 845 yahoo_close(yid->yd->client_id); 839 846 } 840 847 yahoo_free_webcam(yid->wcm); 841 if (yid->wcd)848 if (yid->wcd) 842 849 FREE(yid->wcd); 843 if (yid->ys) {850 if (yid->ys) { 844 851 FREE(yid->ys->lsearch_text); 845 852 FREE(yid->ys); … … 848 855 } 849 856 850 static int is_same_bud(const void * a, const void * b) { 857 static int is_same_bud(const void *a, const void *b) 858 { 851 859 const struct yahoo_buddy *subject = a; 852 860 const struct yahoo_buddy *object = b; … … 855 863 } 856 864 857 static char * 858 { 859 char * cookie=NULL;860 char * tmpcookie;861 char * 862 863 if (strlen(rawcookie) < 2) 865 static char *getcookie(char *rawcookie) 866 { 867 char *cookie = NULL; 868 char *tmpcookie; 869 char *cookieend; 870 871 if (strlen(rawcookie) < 2) 864 872 return NULL; 865 873 866 tmpcookie = strdup(rawcookie +2);874 tmpcookie = strdup(rawcookie + 2); 867 875 cookieend = strchr(tmpcookie, ';'); 868 876 869 if (cookieend)877 if (cookieend) 870 878 *cookieend = '\0'; 871 879 … … 877 885 } 878 886 879 static char * 887 static char *getlcookie(char *cookie) 880 888 { 881 889 char *tmp; … … 884 892 885 893 tmpend = strstr(cookie, "n="); 886 if (tmpend) {887 tmp = strdup(tmpend +2);894 if (tmpend) { 895 tmp = strdup(tmpend + 2); 888 896 tmpend = strchr(tmp, '&'); 889 if (tmpend)890 *tmpend ='\0';897 if (tmpend) 898 *tmpend = '\0'; 891 899 login_cookie = strdup(tmp); 892 900 FREE(tmp); … … 896 904 } 897 905 898 static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 906 static void yahoo_process_notify(struct yahoo_input_data *yid, 907 struct yahoo_packet *pkt) 899 908 { 900 909 struct yahoo_data *yd = yid->yd; … … 927 936 if (!msg) 928 937 return; 929 930 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 931 YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat); 932 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 933 YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat); 934 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) 935 { 938 939 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 940 YAHOO_CALLBACK(ext_yahoo_typing_notify) (yd->client_id, to, 941 from, stat); 942 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 943 YAHOO_CALLBACK(ext_yahoo_game_notify) (yd->client_id, to, from, 944 stat); 945 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) { 936 946 if (!strcmp(ind, " ")) { 937 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from); 947 YAHOO_CALLBACK(ext_yahoo_webcam_invite) (yd->client_id, 948 to, from); 938 949 } else { 939 950 accept = atoi(ind); … … 941 952 if (accept < 0) 942 953 accept = 0; 943 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd->client_id, to, from, accept);944 }945 }946 else954 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd-> 955 client_id, to, from, accept); 956 } 957 } else 947 958 LOG(("Got unknown notification: %s", msg)); 948 959 } … … 951 962 { 952 963 struct yahoo_data *yd = yid->yd; 953 char *from =NULL;954 char *to =NULL;955 char *msg =NULL;956 char *url =NULL;957 long expires =0;958 959 char *service =NULL;960 961 char *filename =NULL;962 unsigned long filesize =0L;964 char *from = NULL; 965 char *to = NULL; 966 char *msg = NULL; 967 char *url = NULL; 968 long expires = 0; 969 970 char *service = NULL; 971 972 char *filename = NULL; 973 unsigned long filesize = 0L; 963 974 964 975 YList *l; … … 985 996 } 986 997 987 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) {988 if (strcmp("FILEXFER", service) != 0) {998 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) { 999 if (strcmp("FILEXFER", service) != 0) { 989 1000 WARNING(("unhandled service 0x%02x", pkt->service)); 990 1001 yahoo_dump_unhandled(pkt); … … 993 1004 } 994 1005 995 if (msg) {1006 if (msg) { 996 1007 char *tmp; 997 1008 tmp = strchr(msg, '\006'); 998 if (tmp)1009 if (tmp) 999 1010 *tmp = '\0'; 1000 1011 } 1001 if (url && from)1002 YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, to, from, url, expires, msg, filename, filesize);1012 if (url && from) 1013 YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, to, from, url, expires, msg, filename, filesize); 1003 1014 1004 1015 } … … 1012 1023 char *room = NULL; 1013 1024 char *id = NULL; 1014 int 1025 int utf8 = 0; 1015 1026 YList *members = NULL; 1016 1027 YList *l; 1017 1028 1018 1029 for (l = pkt->hash; l; l = l->next) { 1019 1030 struct yahoo_pair *pair = l->data; 1020 1031 if (pair->key == 50) 1021 1032 host = pair->value; 1022 1023 if (pair->key == 52) { 1033 1034 if (pair->key == 52) { /* invite */ 1024 1035 members = y_list_append(members, strdup(pair->value)); 1025 1036 } 1026 if (pair->key == 53) 1037 if (pair->key == 53) /* logon */ 1027 1038 who = pair->value; 1028 if (pair->key == 54) 1039 if (pair->key == 54) /* decline */ 1029 1040 who = pair->value; 1030 if (pair->key == 55) 1041 if (pair->key == 55) /* unavailable (status == 2) */ 1031 1042 who = pair->value; 1032 if (pair->key == 56) 1043 if (pair->key == 56) /* logoff */ 1033 1044 who = pair->value; 1034 1045 … … 1036 1047 room = pair->value; 1037 1048 1038 if (pair->key == 58) 1049 if (pair->key == 58) /* join message */ 1039 1050 msg = pair->value; 1040 if (pair->key == 14) 1051 if (pair->key == 14) /* decline/conf message */ 1041 1052 msg = pair->value; 1042 1053 1043 if (pair->key == 13) 1044 ; 1045 if (pair->key == 16) /* error */ 1054 if (pair->key == 13) ; 1055 if (pair->key == 16) /* error */ 1046 1056 msg = pair->value; 1047 1057 1048 if (pair->key == 1) 1058 if (pair->key == 1) /* my id */ 1049 1059 id = pair->value; 1050 if (pair->key == 3) 1060 if (pair->key == 3) /* message sender */ 1051 1061 who = pair->value; 1052 1062 … … 1055 1065 } 1056 1066 1057 if (!room)1058 return; 1059 1060 if (host) {1061 for (l = members; l; l = l->next) {1062 char * 1063 if (!strcmp(w, host))1067 if (!room) 1068 return; 1069 1070 if (host) { 1071 for (l = members; l; l = l->next) { 1072 char *w = l->data; 1073 if (!strcmp(w, host)) 1064 1074 break; 1065 1075 } 1066 if (!l)1076 if (!l) 1067 1077 members = y_list_append(members, strdup(host)); 1068 1078 } 1069 1079 /* invite, decline, join, left, message -> status == 1 */ 1070 1080 1071 switch (pkt->service) {1081 switch (pkt->service) { 1072 1082 case YAHOO_SERVICE_CONFINVITE: 1073 if(pkt->status == 2) 1074 ; 1075 else if(members) 1076 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1077 else if(msg) 1078 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL); 1083 if (pkt->status == 2) ; 1084 else if (members) 1085 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd-> 1086 client_id, id, host, room, msg, members); 1087 else if (msg) 1088 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, msg, 0, 1089 E_CONFNOTAVAIL); 1079 1090 break; 1080 1091 case YAHOO_SERVICE_CONFADDINVITE: 1081 if (pkt->status == 2)1092 if (pkt->status == 2) 1082 1093 ; 1083 1094 else 1084 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->client_id, id, host, room, msg, members);1095 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->client_id, id, host, room, msg, members); 1085 1096 break; 1086 1097 case YAHOO_SERVICE_CONFDECLINE: 1087 if(who) 1088 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg); 1098 if (who) 1099 YAHOO_CALLBACK(ext_yahoo_conf_userdecline) (yd-> 1100 client_id, id, who, room, msg); 1089 1101 break; 1090 1102 case YAHOO_SERVICE_CONFLOGON: 1091 if(who) 1092 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room); 1103 if (who) 1104 YAHOO_CALLBACK(ext_yahoo_conf_userjoin) (yd->client_id, 1105 id, who, room); 1093 1106 break; 1094 1107 case YAHOO_SERVICE_CONFLOGOFF: 1095 if(who) 1096 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room); 1108 if (who) 1109 YAHOO_CALLBACK(ext_yahoo_conf_userleave) (yd->client_id, 1110 id, who, room); 1097 1111 break; 1098 1112 case YAHOO_SERVICE_CONFMSG: 1099 if(who) 1100 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8); 1113 if (who) 1114 YAHOO_CALLBACK(ext_yahoo_conf_message) (yd->client_id, 1115 id, who, room, msg, utf8); 1101 1116 break; 1102 1117 } 1103 1118 } 1104 1119 1105 static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1120 static void yahoo_process_chat(struct yahoo_input_data *yid, 1121 struct yahoo_packet *pkt) 1106 1122 { 1107 1123 char *msg = NULL; … … 1112 1128 YList *members = NULL; 1113 1129 struct yahoo_chat_member *currentmember = NULL; 1114 int 1115 int 1116 int 1117 int 1118 int chaterr=0;1130 int msgtype = 1; 1131 int utf8 = 0; 1132 int firstjoin = 0; 1133 int membercount = 0; 1134 int chaterr = 0; 1119 1135 YList *l; 1120 1136 … … 1148 1164 1149 1165 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1150 currentmember = y_new0(struct yahoo_chat_member, 1); 1166 currentmember = 1167 y_new0(struct yahoo_chat_member, 1); 1151 1168 currentmember->id = strdup(pair->value); 1152 1169 members = y_list_append(members, currentmember); … … 1178 1195 } 1179 1196 1180 1181 1197 if (pair->key == 130) { 1182 1198 /* first join */ … … 1196 1212 /* message error not sure what all the pair values mean */ 1197 1213 /* but -1 means no session in room */ 1198 chaterr= atoi(pair->value); 1199 } 1200 } 1201 1202 if(!room) { 1203 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1204 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id); 1205 return ; 1206 } 1207 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1208 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id); 1214 chaterr = atoi(pair->value); 1215 } 1216 } 1217 1218 if (!room) { 1219 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1220 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout) (yid->yd-> 1221 client_id, id); 1209 1222 return; 1210 1223 } 1224 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1225 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror) (yid->yd-> 1226 client_id, id); 1227 return; 1228 } 1211 1229 1212 1230 WARNING(("We didn't get a room name, ignoring packet")); … … 1214 1232 } 1215 1233 1216 switch (pkt->service) {1234 switch (pkt->service) { 1217 1235 case YAHOO_SERVICE_CHATJOIN: 1218 if (y_list_length(members) != membercount) {1236 if (y_list_length(members) != membercount) { 1219 1237 WARNING(("Count of members doesn't match No. of members we got")); 1220 1238 } 1221 if(firstjoin && members) { 1222 YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd); 1223 } else if(who) { 1224 if(y_list_length(members) != 1) { 1239 if (firstjoin && members) { 1240 YAHOO_CALLBACK(ext_yahoo_chat_join) (yid->yd->client_id, 1241 id, room, topic, members, yid->fd); 1242 } else if (who) { 1243 if (y_list_length(members) != 1) { 1225 1244 WARNING(("Got more than 1 member on a normal join")); 1226 1245 } 1227 1246 /* this should only ever have one, but just in case */ 1228 while (members) {1247 while (members) { 1229 1248 YList *n = members->next; 1230 1249 currentmember = members->data; 1231 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember); 1250 YAHOO_CALLBACK(ext_yahoo_chat_userjoin) (yid-> 1251 yd->client_id, id, room, currentmember); 1232 1252 y_list_free_1(members); 1233 members =n;1253 members = n; 1234 1254 } 1235 1255 } 1236 1256 break; 1237 1257 case YAHOO_SERVICE_CHATEXIT: 1238 if(who) { 1239 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who); 1258 if (who) { 1259 YAHOO_CALLBACK(ext_yahoo_chat_userleave) (yid->yd-> 1260 client_id, id, room, who); 1240 1261 } 1241 1262 break; 1242 1263 case YAHOO_SERVICE_COMMENT: 1243 if(who) { 1244 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8); 1264 if (who) { 1265 YAHOO_CALLBACK(ext_yahoo_chat_message) (yid->yd-> 1266 client_id, id, who, room, msg, msgtype, utf8); 1245 1267 } 1246 1268 break; … … 1248 1270 } 1249 1271 1250 static void yahoo_process_message(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1272 static void yahoo_process_message(struct yahoo_input_data *yid, 1273 struct yahoo_packet *pkt) 1251 1274 { 1252 1275 struct yahoo_data *yd = yid->yd; 1253 1276 YList *l; 1254 YList * 1277 YList *messages = NULL; 1255 1278 1256 1279 struct m { 1257 int 1258 int 1280 int i_31; 1281 int i_32; 1259 1282 char *to; 1260 1283 char *from; 1261 1284 long tm; 1262 1285 char *msg; 1263 int 1286 int utf8; 1264 1287 } *message = y_new0(struct m, 1); 1265 1288 1266 1289 for (l = pkt->hash; l; l = l->next) { 1267 1290 struct yahoo_pair *pair = l->data; 1268 if (pair->key == 1 || pair->key == 4) 1269 { 1270 if(!message->from) 1291 if (pair->key == 1 || pair->key == 4) { 1292 if (!message->from) 1271 1293 message->from = pair->value; 1272 } 1273 else if (pair->key == 5) 1294 } else if (pair->key == 5) 1274 1295 message->to = pair->value; 1275 1296 else if (pair->key == 15) … … 1281 1302 message->msg = pair->value; 1282 1303 else if (pair->key == 31) { 1283 if (message->i_31) {1304 if (message->i_31) { 1284 1305 messages = y_list_append(messages, message); 1285 1306 message = y_new0(struct m, 1); 1286 1307 } 1287 1308 message->i_31 = atoi(pair->value); 1288 } 1289 else if (pair->key == 32) 1309 } else if (pair->key == 32) 1290 1310 message->i_32 = atoi(pair->value); 1291 1311 else 1292 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", 1293 pkt->status, pair->key, pair->value)); 1312 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key, pair->value)); 1294 1313 } 1295 1314 1296 1315 messages = y_list_append(messages, message); 1297 1316 1298 for (l = messages; l; l =l->next) {1317 for (l = messages; l; l = l->next) { 1299 1318 message = l->data; 1300 1319 if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) { 1301 YAHOO_CALLBACK(ext_yahoo_system_message) (yd->client_id, message->msg);1320 YAHOO_CALLBACK(ext_yahoo_system_message) (yd->client_id, message->msg); 1302 1321 } else if (pkt->status <= 2 || pkt->status == 5) { 1303 YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8);1322 YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8); 1304 1323 } else if (pkt->status == 0xffffffff) { 1305 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, message->msg, 0, E_SYSTEM);1324 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, message->msg, 0, E_SYSTEM); 1306 1325 } 1307 1326 free(message); … … 1327 1346 } 1328 1347 1329 /* Status updates may be spread accross multiple packets and not 1330 even on buddy boundaries, so keeping some state is important. 1331 So, continue where we left off, and only add a user entry to 1332 the list once it's complete (301-315 End buddy). */ 1348 /* 1349 * Status updates may be spread accross multiple packets and not 1350 * even on buddy boundaries, so keeping some state is important. 1351 * So, continue where we left off, and only add a user entry to 1352 * the list once it's complete (301-315 End buddy). 1353 */ 1333 1354 u = yd->half_user; 1334 1355 … … 1594 1615 } 1595 1616 1596 static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1617 static void yahoo_process_verify(struct yahoo_input_data *yid, 1618 struct yahoo_packet *pkt) 1597 1619 { 1598 1620 struct yahoo_data *yd = yid->yd; 1599 1621 1600 if (pkt->status != 0x01) {1622 if (pkt->status != 0x01) { 1601 1623 DEBUG_MSG(("expected status: 0x01, got: %d", pkt->status)); 1602 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_LOCK, ""); 1603 return; 1604 } 1605 1606 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 1624 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1625 YAHOO_LOGIN_LOCK, ""); 1626 return; 1627 } 1628 1629 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT, 1630 yd->session_id); 1607 1631 1608 1632 yahoo_packet_hash(pkt, 1, yd->user); … … 1613 1637 } 1614 1638 1615 static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1639 static void yahoo_process_picture_checksum(struct yahoo_input_data *yid, 1640 struct yahoo_packet *pkt) 1616 1641 { 1617 1642 struct yahoo_data *yd = yid->yd; … … 1621 1646 YList *l; 1622 1647 1623 for(l = pkt->hash; l; l = l->next) 1624 { 1648 for (l = pkt->hash; l; l = l->next) { 1625 1649 struct yahoo_pair *pair = l->data; 1626 1650 1627 switch(pair->key) 1628 { 1629 case 1: 1630 case 4: 1631 from = pair->value; 1632 case 5: 1633 to = pair->value; 1634 break; 1635 case 212: 1636 break; 1637 case 192: 1638 checksum = atoi( pair->value ); 1639 break; 1640 } 1641 } 1642 1643 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum); 1644 } 1645 1646 static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1651 switch (pair->key) { 1652 case 1: 1653 case 4: 1654 from = pair->value; 1655 case 5: 1656 to = pair->value; 1657 break; 1658 case 212: 1659 break; 1660 case 192: 1661 checksum = atoi(pair->value); 1662 break; 1663 } 1664 } 1665 1666 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum) (yd->client_id, to, 1667 from, checksum); 1668 } 1669 1670 static void yahoo_process_picture(struct yahoo_input_data *yid, 1671 struct yahoo_packet *pkt) 1647 1672 { 1648 1673 struct yahoo_data *yd = yid->yd; … … 1653 1678 int checksum = 0; 1654 1679 YList *l; 1655 1656 for(l = pkt->hash; l; l = l->next) 1657 { 1680 1681 for (l = pkt->hash; l; l = l->next) { 1658 1682 struct yahoo_pair *pair = l->data; 1659 1683 1660 switch(pair->key) 1661 { 1684 switch (pair->key) { 1662 1685 case 1: 1663 case 4: 1686 case 4: /* sender */ 1664 1687 from = pair->value; 1665 1688 break; 1666 case 5: 1689 case 5: /* we */ 1667 1690 to = pair->value; 1668 1691 break; 1669 case 13: 1670 status = atoi( pair->value);1671 break; 1672 case 20: 1692 case 13: /* request / sending */ 1693 status = atoi(pair->value); 1694 break; 1695 case 20: /* url */ 1673 1696 url = pair->value; 1674 1697 break; 1675 1698 case 192: /*checksum */ 1676 checksum = atoi( pair->value ); 1677 break; 1678 } 1679 } 1680 1681 switch( status ) 1682 { 1683 case 1: /* this is a request, ignore for now */ 1684 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from); 1685 break; 1686 case 2: /* this is cool - we get a picture :) */ 1687 YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum); 1688 break; 1689 } 1690 } 1691 1692 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1699 checksum = atoi(pair->value); 1700 break; 1701 } 1702 } 1703 1704 switch (status) { 1705 case 1: /* this is a request, ignore for now */ 1706 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request) (yd->client_id, 1707 to, from); 1708 break; 1709 case 2: /* this is cool - we get a picture :) */ 1710 YAHOO_CALLBACK(ext_yahoo_got_buddyicon) (yd->client_id, to, 1711 from, url, checksum); 1712 break; 1713 } 1714 } 1715 1716 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, 1717 struct yahoo_packet *pkt) 1693 1718 { 1694 1719 struct yahoo_data *yd = yid->yd; … … 1699 1724 return; /* something went wrong */ 1700 1725 1701 for (l = pkt->hash; l; l = l->next)1726 for (l = pkt->hash; l; l = l->next) 1702 1727 { 1703 1728 struct yahoo_pair *pair = l->data; … … 1717 1742 } 1718 1743 1719 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded) (yd->client_id, url);1744 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded) (yd->client_id, url); 1720 1745 } 1721 1746 … … 1873 1898 const unsigned char *magic_ptr; 1874 1899 1875 unsigned int 1876 unsigned int magic_work=0;1900 unsigned int magic[64]; 1901 unsigned int magic_work = 0; 1877 1902 1878 1903 char comparison_src[20]; … … 1991 2016 1992 2017 do { 1993 unsigned int 1994 unsigned int 2018 unsigned int bl = 0; 2019 unsigned int cl = magic[magic_cnt++]; 1995 2020 1996 2021 if (magic_cnt >= magic_len) … … 2018 2043 2019 2044 2020 for (x = 0; x < 4; x++)2045 for (x = 0; x < 4; x++) 2021 2046 magic_key_char[x] = comparison_src[x]; 2022 2047 … … 2024 2049 memcpy( chal, magic_key_char, 4 ); 2025 2050 x = 1; 2026 for ( i = 0; i < 0xFFFF && x; i++ )2051 for ( i = 0; i < 0xFFFF && x; i++ ) 2027 2052 { 2028 for ( j = 0; j < 5 && x; j++ )2053 for ( j = 0; j < 5 && x; j++ ) 2029 2054 { 2030 2055 chal[4] = i; … … 2034 2059 md5_append( &ctx, chal, 7 ); 2035 2060 md5_finish( &ctx, result ); 2036 if ( memcmp( comparison_src + 4, result, 16 ) == 0 )2061 if ( memcmp( comparison_src + 4, result, 16 ) == 0 ) 2037 2062 { 2038 2063 depth = i; … … 2110 2135 2111 2136 for (x = 0; x < 20; x += 2) { 2112 unsigned int 2113 unsigned int 2114 char 2137 unsigned int val = 0; 2138 unsigned int lookup = 0; 2139 char byte[6]; 2115 2140 2116 2141 memset(&byte, 0, 6); … … 2353 2378 2354 2379 if (req->status_code != 200) { 2355 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);2380 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 2356 2381 goto fail; 2357 2382 } 2358 2383 2359 2384 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2360 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);2385 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 2361 2386 goto fail; 2362 2387 } 2363 2388 2364 2389 if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) { 2365 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL);2390 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL); 2366 2391 goto fail; 2367 2392 } … … 2409 2434 2410 2435 if (req->status_code != 200) { 2411 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);2436 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 2412 2437 goto fail; 2413 2438 } 2414 2439 2415 2440 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2416 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);2441 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 2417 2442 goto fail; 2418 2443 } … … 2421 2446 (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL || 2422 2447 (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) { 2423 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL);2448 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL); 2424 2449 goto fail; 2425 2450 } … … 2498 2523 char *login_id; 2499 2524 char *handle; 2500 char *url =NULL;2501 int login_status=0;2525 char *url = NULL; 2526 int login_status = 0; 2502 2527 2503 2528 YList *l; … … 2515 2540 } 2516 2541 2517 if (pkt->status == 0xffffffff) {2518 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, login_status, url);2542 if (pkt->status == 0xffffffff) { 2543 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, login_status, url); 2519 2544 /* yahoo_logoff(yd->client_id);*/ 2520 2545 } 2521 2546 } 2522 2547 2523 static void yahoo_process_mail(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2548 static void yahoo_process_mail(struct yahoo_input_data *yid, 2549 struct yahoo_packet *pkt) 2524 2550 { 2525 2551 struct yahoo_data *yd = yid->yd; … … 2547 2573 char from[1024]; 2548 2574 snprintf(from, sizeof(from), "%s (%s)", who, email); 2549 YAHOO_CALLBACK(ext_yahoo_mail_notify)(yd->client_id, from, subj, count); 2550 } else if(count > 0) 2551 YAHOO_CALLBACK(ext_yahoo_mail_notify)(yd->client_id, NULL, NULL, count); 2552 } 2553 2554 static void yahoo_process_contact(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2575 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, from, 2576 subj, count); 2577 } else if (count > 0) 2578 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, NULL, 2579 NULL, count); 2580 } 2581 2582 static void yahoo_process_contact(struct yahoo_input_data *yid, 2583 struct yahoo_packet *pkt) 2555 2584 { 2556 2585 struct yahoo_data *yd = yid->yd; … … 2561 2590 long tm = 0L; 2562 2591 int state = YAHOO_STATUS_AVAILABLE; 2563 int online = FALSE;2592 int online = 0; 2564 2593 int away = 0; 2565 2594 int idle = 0; … … 2590 2619 else if (pair->key == 60) 2591 2620 mobile = strtol(pair->value, NULL, 10); 2592 2621 2593 2622 } 2594 2623 2595 2624 if (id) 2596 YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg); 2625 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, id, who, 2626 msg); 2597 2627 else if (name) 2598 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile); 2599 else if(pkt->status == 0x07) 2600 YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg); 2601 } 2602 2603 static void yahoo_process_buddyadd(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2628 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, name, 2629 state, msg, away, idle, mobile); 2630 else if (pkt->status == 0x07) 2631 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg); 2632 } 2633 2634 static void yahoo_process_buddyadd(struct yahoo_input_data *yid, 2635 struct yahoo_packet *pkt) 2604 2636 { 2605 2637 struct yahoo_data *yd = yid->yd; … … 2609 2641 char *me = NULL; 2610 2642 2611 struct yahoo_buddy *bud =NULL;2643 struct yahoo_buddy *bud = NULL; 2612 2644 2613 2645 YList *l; … … 2624 2656 } 2625 2657 2626 yahoo_dump_unhandled(pkt); 2627 2628 if(!who) 2629 return; 2630 if(!where) 2658 if (!who) 2659 return; 2660 if (!where) 2631 2661 where = "Unknown"; 2632 2662 2633 2663 /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */ 2634 if ( status == 0 ) {2664 if ( status == 0 ) { 2635 2665 bud = y_new0(struct yahoo_buddy, 1); 2636 2666 bud->id = strdup(who); … … 2642 2672 /* Possibly called already, but at least the call above doesn't 2643 2673 seem to happen every time (not anytime I tried). */ 2644 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who, NULL);2645 } 2646 2647 /* YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */2674 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who, NULL); 2675 } 2676 2677 /* YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ 2648 2678 } 2649 2679 2650 2680 static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2651 2681 { 2652 char* who =NULL;2653 char* me =NULL;2654 char* msg =NULL;2682 char* who = NULL; 2683 char* me = NULL; 2684 char* msg = NULL; 2655 2685 YList *l; 2656 2686 for (l = pkt->hash; l; l = l->next) { … … 2664 2694 } 2665 2695 2666 if(pkt->status==3) 2667 YAHOO_CALLBACK(ext_yahoo_contact_auth_request)(yid->yd->client_id, me, who, msg); 2668 } 2669 2670 static void yahoo_process_buddydel(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2696 if (pkt->status==3) 2697 YAHOO_CALLBACK(ext_yahoo_contact_auth_request) (yid->yd->client_id, me, who, msg); 2698 } 2699 2700 static void yahoo_process_buddydel(struct yahoo_input_data *yid, 2701 struct yahoo_packet *pkt) 2671 2702 { 2672 2703 struct yahoo_data *yd = yid->yd; … … 2691 2722 unk_66 = strtol(pair->value, NULL, 10); 2692 2723 else 2693 DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value)); 2694 } 2695 2696 if(!who || !where) 2697 return; 2698 2724 DEBUG_MSG(("unknown key: %d = %s", pair->key, 2725 pair->value)); 2726 } 2727 2728 if (!who || !where) 2729 return; 2730 2699 2731 bud = y_new0(struct yahoo_buddy, 1); 2700 2732 bud->id = strdup(who); … … 2707 2739 FREE(bud); 2708 2740 2709 if (buddy) {2741 if (buddy) { 2710 2742 bud = buddy->data; 2711 2743 yd->buddies = y_list_remove_link(yd->buddies, buddy); … … 2717 2749 FREE(bud); 2718 2750 2719 bud=NULL; 2720 } 2721 } 2722 2723 static void yahoo_process_ignore(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2751 bud = NULL; 2752 } 2753 } 2754 2755 static void yahoo_process_ignore(struct yahoo_input_data *yid, 2756 struct yahoo_packet *pkt) 2724 2757 { 2725 2758 char *who = NULL; 2726 int 2759 int status = 0; 2727 2760 char *me = NULL; 2728 int 2761 int un_ignore = 0; 2729 2762 2730 2763 YList *l; … … 2735 2768 if (pair->key == 1) 2736 2769 me = pair->value; 2737 if (pair->key == 13) /* 1 == ignore, 2 == unignore */2770 if (pair->key == 13) /* 1 == ignore, 2 == unignore */ 2738 2771 un_ignore = strtol(pair->value, NULL, 10); 2739 if (pair->key == 66) 2772 if (pair->key == 66) 2740 2773 status = strtol(pair->value, NULL, 10); 2741 2774 } 2742 2743 2775 2744 2776 /* 2745 2777 * status 2746 * 2747 * 2748 * 2749 * 2778 * 0 - ok 2779 * 2 - already in ignore list, could not add 2780 * 3 - not in ignore list, could not delete 2781 * 12 - is a buddy, could not add 2750 2782 */ 2751 2783 2752 2784 /* if(status) 2753 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status); 2754 */ 2755 } 2756 2757 static void yahoo_process_voicechat(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2785 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, who, 0, status); 2786 */ 2787 } 2788 2789 static void yahoo_process_voicechat(struct yahoo_input_data *yid, 2790 struct yahoo_packet *pkt) 2758 2791 { 2759 2792 char *who = NULL; … … 2770 2803 me = pair->value; 2771 2804 if (pair->key == 13) 2772 voice_room=pair->value; 2773 if (pair->key == 57) 2774 room=pair->value; 2775 } 2776 2777 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me)); 2805 voice_room = pair->value; 2806 if (pair->key == 57) 2807 room = pair->value; 2808 } 2809 2810 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, 2811 me)); 2778 2812 /* 2779 2813 * send: s:0 1:me 5:who 57:room 13:1 … … 2787 2821 } 2788 2822 2789 static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2823 static void yahoo_process_ping(struct yahoo_input_data *yid, 2824 struct yahoo_packet *pkt) 2790 2825 { 2791 2826 char *errormsg = NULL; 2792 2827 2793 2828 YList *l; 2794 2829 for (l = pkt->hash; l; l = l->next) { … … 2797 2832 errormsg = pair->value; 2798 2833 } 2799 2834 2800 2835 NOTICE(("got ping packet")); 2801 YAHOO_CALLBACK(ext_yahoo_got_ping) (yid->yd->client_id, errormsg);2836 YAHOO_CALLBACK(ext_yahoo_got_ping) (yid->yd->client_id, errormsg); 2802 2837 } 2803 2838 … … 2808 2843 char *data = NULL; 2809 2844 char *packet = NULL; 2810 unsigned char magic_nr[] = { 0, 1, 0};2845 unsigned char magic_nr[] = { 0, 1, 0 }; 2811 2846 unsigned char header_len = 8; 2812 2847 unsigned int len = 0; 2813 2848 unsigned int pos = 0; 2814 2849 2815 if (error || fd <= 0) {2850 if (error || fd <= 0) { 2816 2851 FREE(who); 2817 2852 FREE(yid); … … 2821 2856 yid->fd = fd; 2822 2857 inputs = y_list_prepend(inputs, yid); 2823 2858 2824 2859 /* send initial packet */ 2825 2860 if (who) … … 2831 2866 2832 2867 /* send data */ 2833 if (who) 2834 { 2868 if (who) { 2835 2869 data = strdup("g="); 2836 2870 data = y_string_append(data, who); … … 2851 2885 FREE(data); 2852 2886 2853 yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, fd, YAHOO_INPUT_READ, yid); 2854 } 2855 2856 static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, char *key) 2887 yid->read_tag = 2888 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, 2889 YAHOO_INPUT_READ, yid); 2890 } 2891 2892 static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, 2893 char *key) 2857 2894 { 2858 2895 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); … … 2862 2899 yid->yd = y->yd; 2863 2900 yid->wcm = y_new0(struct yahoo_webcam, 1); 2864 yid->wcm->user = who ?strdup(who):NULL;2865 yid->wcm->direction = who ?YAHOO_WEBCAM_DOWNLOAD:YAHOO_WEBCAM_UPLOAD;2901 yid->wcm->user = who ? strdup(who) : NULL; 2902 yid->wcm->direction = who ? YAHOO_WEBCAM_DOWNLOAD : YAHOO_WEBCAM_UPLOAD; 2866 2903 yid->wcm->key = strdup(key); 2867 2904 2868 YAHOO_CALLBACK(ext_yahoo_connect_async)(yid->yd->client_id, yss->webcam_host, yss->webcam_port, 2869 _yahoo_webcam_get_server_connected, yid); 2870 2871 } 2872 2873 static YList *webcam_queue=NULL; 2874 static void yahoo_process_webcam_key(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2905 YAHOO_CALLBACK(ext_yahoo_connect_async) (yid->yd->client_id, 2906 yss->webcam_host, yss->webcam_port, 2907 _yahoo_webcam_get_server_connected, yid); 2908 2909 } 2910 2911 static YList *webcam_queue = NULL; 2912 static void yahoo_process_webcam_key(struct yahoo_input_data *yid, 2913 struct yahoo_packet *pkt) 2875 2914 { 2876 2915 char *me = NULL; … … 2879 2918 2880 2919 YList *l; 2881 //yahoo_dump_unhandled(pkt);2920 yahoo_dump_unhandled(pkt); 2882 2921 for (l = pkt->hash; l; l = l->next) { 2883 2922 struct yahoo_pair *pair = l->data; 2884 2923 if (pair->key == 5) 2885 2924 me = pair->value; 2886 if (pair->key == 61) 2887 key =pair->value;2925 if (pair->key == 61) 2926 key = pair->value; 2888 2927 } 2889 2928 2890 2929 l = webcam_queue; 2891 if (!l)2930 if (!l) 2892 2931 return; 2893 2932 who = l->data; … … 2898 2937 } 2899 2938 2900 static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2939 static void yahoo_packet_process(struct yahoo_input_data *yid, 2940 struct yahoo_packet *pkt) 2901 2941 { 2902 2942 DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service)); 2903 yahoo_dump_unhandled(pkt); 2904 switch (pkt->service) 2905 { 2943 switch (pkt->service) { 2906 2944 case YAHOO_SERVICE_USERSTAT: 2907 2945 case YAHOO_SERVICE_LOGON: … … 3022 3060 } 3023 3061 3024 static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data *yid)3062 static struct yahoo_packet *yahoo_getdata(struct yahoo_input_data *yid) 3025 3063 { 3026 3064 struct yahoo_packet *pkt; … … 3029 3067 int pktlen; 3030 3068 3031 if (!yd)3069 if (!yd) 3032 3070 return NULL; 3033 3071 … … 3038 3076 } 3039 3077 3040 pos += 4; 3078 pos += 4; /* YMSG */ 3041 3079 pos += 2; 3042 3080 pos += 2; 3043 3081 3044 pktlen = yahoo_get16(yid->rxqueue + pos); pos += 2;3045 DEBUG_MSG(("%d bytes to read, rxlen is %d",3046 3082 pktlen = yahoo_get16(yid->rxqueue + pos); 3083 pos += 2; 3084 DEBUG_MSG(("%d bytes to read, rxlen is %d", pktlen, yid->rxlen)); 3047 3085 3048 3086 if (yid->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) { … … 3056 3094 pkt = yahoo_packet_new(0, 0, 0); 3057 3095 3058 pkt->service = yahoo_get16(yid->rxqueue + pos); pos += 2; 3059 pkt->status = yahoo_get32(yid->rxqueue + pos); pos += 4; 3096 pkt->service = yahoo_get16(yid->rxqueue + pos); 3097 pos += 2; 3098 pkt->status = yahoo_get32(yid->rxqueue + pos); 3099 pos += 4; 3060 3100 DEBUG_MSG(("Yahoo Service: 0x%02x Status: %d", pkt->service, 3061 pkt->status)); 3062 pkt->id = yahoo_get32(yid->rxqueue + pos); pos += 4; 3101 pkt->status)); 3102 pkt->id = yahoo_get32(yid->rxqueue + pos); 3103 pos += 4; 3063 3104 3064 3105 yd->session_id = pkt->id; … … 3068 3109 yid->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; 3069 3110 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 3070 if (yid->rxlen >0) {3071 unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN 3072 3111 if (yid->rxlen > 0) { 3112 unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN 3113 + pktlen, yid->rxlen); 3073 3114 FREE(yid->rxqueue); 3074 3115 yid->rxqueue = tmp; 3075 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 3116 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 3117 yid->rxqueue)); 3076 3118 } else { 3077 3119 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3082 3124 } 3083 3125 3084 static void yahoo_yab_read(struct yab *yab,unsigned char *d, int len)3126 static struct yab *yahoo_yab_read(unsigned char *d, int len) 3085 3127 { 3086 3128 char *st, *en; 3087 3129 char *data = (char *)d; 3088 data[len]='\0'; 3130 struct yab *yab = NULL; 3131 3132 data[len] = '\0'; 3089 3133 3090 3134 DEBUG_MSG(("Got yab: %s", data)); 3091 st = en = strstr(data, "userid=\""); 3092 if(st) { 3093 st += strlen("userid=\""); 3094 en = strchr(st, '"'); *en++ = '\0'; 3135 st = en = strstr(data, "e0=\""); 3136 if (st) { 3137 yab = y_new0(struct yab, 1); 3138 3139 st += strlen("e0=\""); 3140 en = strchr(st, '"'); 3141 *en++ = '\0'; 3142 yab->email = yahoo_xmldecode(st); 3143 } 3144 3145 if (!en) 3146 return NULL; 3147 3148 st = strstr(en, "id=\""); 3149 if (st) { 3150 st += strlen("id=\""); 3151 en = strchr(st, '"'); 3152 *en++ = '\0'; 3153 yab->yid = atoi(yahoo_xmldecode(st)); 3154 } 3155 3156 st = strstr(en, "fn=\""); 3157 if (st) { 3158 st += strlen("fn=\""); 3159 en = strchr(st, '"'); 3160 *en++ = '\0'; 3161 yab->fname = yahoo_xmldecode(st); 3162 } 3163 3164 st = strstr(en, "ln=\""); 3165 if (st) { 3166 st += strlen("ln=\""); 3167 en = strchr(st, '"'); 3168 *en++ = '\0'; 3169 yab->lname = yahoo_xmldecode(st); 3170 } 3171 3172 st = strstr(en, "nn=\""); 3173 if (st) { 3174 st += strlen("nn=\""); 3175 en = strchr(st, '"'); 3176 *en++ = '\0'; 3177 yab->nname = yahoo_xmldecode(st); 3178 } 3179 3180 st = strstr(en, "yi=\""); 3181 if (st) { 3182 st += strlen("yi=\""); 3183 en = strchr(st, '"'); 3184 *en++ = '\0'; 3095 3185 yab->id = yahoo_xmldecode(st); 3096 3186 } 3097 3187 3098 st = strstr(en, "fname=\"");3099 if(st) {3100 st += strlen("fname=\"");3101 en = strchr(st, '"'); *en++ = '\0';3102 yab->fname = yahoo_xmldecode(st);3103 }3104 3105 st = strstr(en, "lname=\"");3106 if(st) {3107 st += strlen("lname=\"");3108 en = strchr(st, '"'); *en++ = '\0';3109 yab->lname = yahoo_xmldecode(st);3110 }3111 3112 st = strstr(en, "nname=\"");3113 if(st) {3114 st += strlen("nname=\"");3115 en = strchr(st, '"'); *en++ = '\0';3116 yab->nname = yahoo_xmldecode(st);3117 }3118 3119 st = strstr(en, "email=\"");3120 if(st) {3121 st += strlen("email=\"");3122 en = strchr(st, '"'); *en++ = '\0';3123 yab->email = yahoo_xmldecode(st);3124 }3125 3126 3188 st = strstr(en, "hphone=\""); 3127 if (st) {3189 if (st) { 3128 3190 st += strlen("hphone=\""); 3129 en = strchr(st, '"'); *en++ = '\0'; 3191 en = strchr(st, '"'); 3192 *en++ = '\0'; 3130 3193 yab->hphone = yahoo_xmldecode(st); 3131 3194 } 3132 3195 3133 3196 st = strstr(en, "wphone=\""); 3134 if (st) {3197 if (st) { 3135 3198 st += strlen("wphone=\""); 3136 en = strchr(st, '"'); *en++ = '\0'; 3199 en = strchr(st, '"'); 3200 *en++ = '\0'; 3137 3201 yab->wphone = yahoo_xmldecode(st); 3138 3202 } 3139 3203 3140 3204 st = strstr(en, "mphone=\""); 3141 if (st) {3205 if (st) { 3142 3206 st += strlen("mphone=\""); 3143 en = strchr(st, '"'); *en++ = '\0'; 3207 en = strchr(st, '"'); 3208 *en++ = '\0'; 3144 3209 yab->mphone = yahoo_xmldecode(st); 3145 3210 } 3146 3211 3147 3212 st = strstr(en, "dbid=\""); 3148 if (st) {3213 if (st) { 3149 3214 st += strlen("dbid=\""); 3150 en = strchr(st, '"'); *en++ = '\0'; 3215 en = strchr(st, '"'); 3216 *en++ = '\0'; 3151 3217 yab->dbid = atoi(st); 3152 3218 } 3153 } 3154 3155 static struct yab * yahoo_getyab(struct yahoo_input_data *yid) 3219 3220 return yab; 3221 } 3222 3223 static struct yab *yahoo_getyab(struct yahoo_input_data *yid) 3156 3224 { 3157 3225 struct yab *yab = NULL; 3158 int pos = 0, end =0;3226 int pos = 0, end = 0; 3159 3227 struct yahoo_data *yd = yid->yd; 3160 3228 3161 if (!yd)3229 if (!yd) 3162 3230 return NULL; 3163 3231 3232 do { 3233 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 3234 3235 if (yid->rxlen <= strlen("<ct")) 3236 return NULL; 3237 3238 /* start with <ct */ 3239 while (pos < yid->rxlen - strlen("<ct") + 1 3240 && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct"))) 3241 pos++; 3242 3243 if (pos >= yid->rxlen - 1) 3244 return NULL; 3245 3246 end = pos + 2; 3247 /* end with > */ 3248 while (end < yid->rxlen - strlen(">") 3249 && memcmp(yid->rxqueue + end, ">", strlen(">"))) 3250 end++; 3251 3252 if (end >= yid->rxlen - 1) 3253 return NULL; 3254 3255 yab = yahoo_yab_read(yid->rxqueue + pos, end + 2 - pos); 3256 3257 yid->rxlen -= end + 1; 3258 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, 3259 yid->rxqueue)); 3260 if (yid->rxlen > 0) { 3261 unsigned char *tmp = 3262 y_memdup(yid->rxqueue + end + 1, yid->rxlen); 3263 FREE(yid->rxqueue); 3264 yid->rxqueue = tmp; 3265 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 3266 yid->rxqueue)); 3267 } else { 3268 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); 3269 FREE(yid->rxqueue); 3270 } 3271 3272 } while (!yab && end < yid->rxlen - 1); 3273 3274 return yab; 3275 } 3276 3277 static char *yahoo_getwebcam_master(struct yahoo_input_data *yid) 3278 { 3279 unsigned int pos = 0; 3280 unsigned int len = 0; 3281 unsigned int status = 0; 3282 char *server = NULL; 3283 struct yahoo_data *yd = yid->yd; 3284 3285 if (!yid || !yd) 3286 return NULL; 3287 3164 3288 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 3165 3289 3166 if(yid->rxlen <= strlen("<record")) 3290 len = yid->rxqueue[pos++]; 3291 if (yid->rxlen < len) 3167 3292 return NULL; 3168 3293 3169 /* start with <record */ 3170 while(pos < yid->rxlen-strlen("<record")+1 3171 && memcmp(yid->rxqueue + pos, "<record", strlen("<record"))) 3172 pos++; 3173 3174 if(pos >= yid->rxlen-1) 3175 return NULL; 3176 3177 end = pos+2; 3178 /* end with /> */ 3179 while(end < yid->rxlen-strlen("/>")+1 && memcmp(yid->rxqueue + end, "/>", strlen("/>"))) 3180 end++; 3181 3182 if(end >= yid->rxlen-1) 3183 return NULL; 3184 3185 yab = y_new0(struct yab, 1); 3186 yahoo_yab_read(yab, yid->rxqueue + pos, end+2-pos); 3187 3188 3189 yid->rxlen -= end+1; 3294 /* extract status (0 = ok, 6 = webcam not online) */ 3295 status = yid->rxqueue[pos++]; 3296 3297 if (status == 0) { 3298 pos += 2; /* skip next 2 bytes */ 3299 server = y_memdup(yid->rxqueue + pos, 16); 3300 pos += 16; 3301 } else if (status == 6) { 3302 YAHOO_CALLBACK(ext_yahoo_webcam_closed) 3303 (yd->client_id, yid->wcm->user, 4); 3304 } 3305 3306 /* skip rest of the data */ 3307 3308 yid->rxlen -= len; 3190 3309 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 3191 if (yid->rxlen >0) {3192 unsigned char *tmp = y_memdup(yid->rxqueue + end + 1, yid->rxlen);3310 if (yid->rxlen > 0) { 3311 unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen); 3193 3312 FREE(yid->rxqueue); 3194 3313 yid->rxqueue = tmp; 3195 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 3314 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 3315 yid->rxqueue)); 3196 3316 } else { 3197 3317 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3199 3319 } 3200 3320 3201 3202 return yab; 3203 } 3204 3205 static char * yahoo_getwebcam_master(struct yahoo_input_data *yid) 3206 { 3207 unsigned int pos=0; 3208 unsigned int len=0; 3209 unsigned int status=0; 3210 char *server=NULL; 3321 return server; 3322 } 3323 3324 static int yahoo_get_webcam_data(struct yahoo_input_data *yid) 3325 { 3326 unsigned char reason = 0; 3327 unsigned int pos = 0; 3328 unsigned int begin = 0; 3329 unsigned int end = 0; 3330 unsigned int closed = 0; 3331 unsigned char header_len = 0; 3332 char *who; 3333 int connect = 0; 3211 3334 struct yahoo_data *yd = yid->yd; 3212 3335 3213 if(!yid || !yd) 3214 return NULL; 3336 if (!yd) 3337 return -1; 3338 3339 if (!yid->wcm || !yid->wcd || !yid->rxlen) 3340 return -1; 3215 3341 3216 3342 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 3217 3343 3218 len = yid->rxqueue[pos++];3219 if (yid->rxlen < len)3220 return NULL;3221 3222 /* extract status (0 = ok, 6 = webcam not online) */3223 status = yid->rxqueue[pos++];3224 3225 if (status == 0)3226 {3227 pos += 2; /* skip next 2 bytes */3228 server = y_memdup(yid->rxqueue+pos, 16);3229 pos += 16;3230 }3231 else if (status == 6)3232 {3233 YAHOO_CALLBACK(ext_yahoo_webcam_closed)3234 (yd->client_id, yid->wcm->user, 4);3235 }3236 3237 /* skip rest of the data */3238 3239 yid->rxlen -= len;3240 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));3241 if (yid->rxlen>0) {3242 unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen);3243 FREE(yid->rxqueue);3244 yid->rxqueue = tmp;3245 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue));3246 } else {3247 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));3248 FREE(yid->rxqueue);3249 }3250 3251 return server;3252 }3253 3254 static int yahoo_get_webcam_data(struct yahoo_input_data *yid)3255 {3256 unsigned char reason=0;3257 unsigned int pos=0;3258 unsigned int begin=0;3259 unsigned int end=0;3260 unsigned int closed=0;3261 unsigned char header_len=0;3262 char *who;3263 int connect=0;3264 struct yahoo_data *yd = yid->yd;3265 3266 if(!yd)3267 return -1;3268 3269 if(!yid->wcm || !yid->wcd || !yid->rxlen)3270 return -1;3271 3272 DEBUG_MSG(("rxlen is %d", yid->rxlen));3273 3274 3344 /* if we are not reading part of image then read header */ 3275 if (!yid->wcd->to_read) 3276 { 3277 header_len=yid->rxqueue[pos++]; 3278 yid->wcd->packet_type=0; 3345 if (!yid->wcd->to_read) { 3346 header_len = yid->rxqueue[pos++]; 3347 yid->wcd->packet_type = 0; 3279 3348 3280 3349 if (yid->rxlen < header_len) 3281 3350 return 0; 3282 3351 3283 if (header_len >= 8) 3284 { 3352 if (header_len >= 8) { 3285 3353 reason = yid->rxqueue[pos++]; 3286 3354 /* next 2 bytes should always be 05 00 */ … … 3290 3358 yid->wcd->to_read = yid->wcd->data_size; 3291 3359 } 3292 if (header_len >= 13) 3293 { 3360 if (header_len >= 13) { 3294 3361 yid->wcd->packet_type = yid->rxqueue[pos++]; 3295 3362 yid->wcd->timestamp = yahoo_get32(yid->rxqueue + pos); … … 3303 3370 begin = pos; 3304 3371 pos += yid->wcd->to_read; 3305 if (pos > yid->rxlen) pos = yid->rxlen; 3372 if (pos > yid->rxlen) 3373 pos = yid->rxlen; 3306 3374 3307 3375 /* if it is not an image then make sure we have the whole packet */ … … 3316 3384 3317 3385 DEBUG_MSG(("packet type %.2X, data length %d", yid->wcd->packet_type, 3318 yid->wcd->data_size));3386 yid->wcd->data_size)); 3319 3387 3320 3388 /* find out what kind of packet we got */ … … 3332 3400 who = y_memdup(yid->rxqueue + begin, end - begin); 3333 3401 who[end - begin - 1] = 0; 3334 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, who + 2, 2);3402 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, who + 2, 2); 3335 3403 FREE(who); 3336 3404 } … … 3342 3410 /* 1 = accepted viewing permission */ 3343 3411 if (yid->wcd->timestamp == 0) { 3344 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id, yid->wcm->user, 3);3412 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id, yid->wcm->user, 3); 3345 3413 } 3346 3414 } … … 3351 3419 break; 3352 3420 case 0x02: /* image data */ 3353 YAHOO_CALLBACK(ext_yahoo_got_webcam_image) (yd->client_id,3421 YAHOO_CALLBACK(ext_yahoo_got_webcam_image) (yd->client_id, 3354 3422 yid->wcm->user, yid->rxqueue + begin, 3355 3423 yid->wcd->data_size, pos - begin, … … 3358 3426 case 0x05: /* response packets when uploading */ 3359 3427 if (!yid->wcd->data_size) { 3360 YAHOO_CALLBACK(ext_yahoo_webcam_data_request) (yd->client_id, yid->wcd->timestamp);3428 YAHOO_CALLBACK(ext_yahoo_webcam_data_request) (yd->client_id, yid->wcd->timestamp); 3361 3429 } 3362 3430 break; … … 3371 3439 break; 3372 3440 } 3373 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id, yid->wcm->user, closed);3441 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id, yid->wcm->user, closed); 3374 3442 break; 3375 3443 case 0x0C: /* user connected */ … … 3379 3447 who[pos - begin] = 0; 3380 3448 if (yid->wcd->packet_type == 0x0C) 3381 connect =1;3449 connect = 1; 3382 3450 else 3383 connect =0;3384 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, who, connect);3451 connect = 0; 3452 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, who, connect); 3385 3453 FREE(who); 3386 3454 } 3387 3455 break; 3388 3456 case 0x13: /* user data */ 3389 /* i =user_ip (ip of the user we are viewing) */3390 /* j =user_ext_ip (external ip of the user we */3457 /* i = user_ip (ip of the user we are viewing) */ 3458 /* j = user_ext_ip (external ip of the user we */ 3391 3459 /* are viewing) */ 3392 3460 break; … … 3422 3490 3423 3491 LOG(("write callback: id=%d fd=%d data=%p", id, fd, data)); 3424 if (!yid || !yid->txqueues || !find_conn_by_id(id))3492 if (!yid || !yid->txqueues || !find_conn_by_id(id)) 3425 3493 return -2; 3426 3494 … … 3429 3497 len = yahoo_send_data(fd, tx->queue, MIN(1024, tx->len)); 3430 3498 3431 if (len == -1 && errno == EAGAIN)3499 if (len == -1 && errno == EAGAIN) 3432 3500 return 1; 3433 3501 3434 if (len <= 0) {3502 if (len <= 0) { 3435 3503 int e = errno; 3436 3504 DEBUG_MSG(("len == %d (<= 0)", len)); 3437 while (yid->txqueues) {3438 YList *l =yid->txqueues;3505 while (yid->txqueues) { 3506 YList *l = yid->txqueues; 3439 3507 tx = l->data; 3440 3508 free(tx->queue); … … 3444 3512 } 3445 3513 LOG(("yahoo_write_ready(%d, %d) len < 0", id, fd)); 3446 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag);3514 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag); 3447 3515 yid->write_tag = 0; 3448 errno =e;3516 errno = e; 3449 3517 return 0; 3450 3518 } … … 3452 3520 3453 3521 tx->len -= len; 3454 if (tx->len > 0) {3522 if (tx->len > 0) { 3455 3523 unsigned char *tmp = y_memdup(tx->queue + len, tx->len); 3456 3524 FREE(tx->queue); 3457 3525 tx->queue = tmp; 3458 3526 } else { 3459 YList *l =yid->txqueues;3527 YList *l = yid->txqueues; 3460 3528 free(tx->queue); 3461 3529 free(tx); … … 3463 3531 y_list_free_1(l); 3464 3532 /* 3465 if (!yid->txqueues)3533 if (!yid->txqueues) 3466 3534 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3467 3535 */ 3468 if (!yid->txqueues) {3536 if (!yid->txqueues) { 3469 3537 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3470 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag);3538 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag); 3471 3539 yid->write_tag = 0; 3472 3540 } … … 3482 3550 int id = yd->client_id; 3483 3551 3484 if (over)3552 if (over) 3485 3553 return; 3486 3554 … … 3500 3568 static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, int over) 3501 3569 { 3502 if (over)3570 if (over) 3503 3571 return; 3504 3572 3505 3573 if (strstr((char*)yid->rxqueue+(yid->rxlen-20), "</content>")) { 3506 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, (char*)yid->rxqueue);3574 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, (char*)yid->rxqueue); 3507 3575 } 3508 3576 } … … 3513 3581 struct yab *yab; 3514 3582 YList *buds; 3515 int changed =0;3583 int changed = 0; 3516 3584 int id = yd->client_id; 3517 3585 3518 if (over)3519 return; 3520 3521 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB)3586 if (over) 3587 return; 3588 3589 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB) 3522 3590 && (yab = yahoo_getyab(yid)) != NULL) { 3523 if (!yab->id)3591 if (!yab->id) 3524 3592 continue; 3525 changed =1;3526 for (buds = yd->buddies; buds; buds=buds->next) {3527 struct yahoo_buddy * 3528 if (!strcmp(bud->id, yab->id)) {3593 changed = 1; 3594 for (buds = yd->buddies; buds; buds = buds->next) { 3595 struct yahoo_buddy *bud = buds->data; 3596 if (!strcmp(bud->id, yab->id)) { 3529 3597 bud->yab_entry = yab; 3530 if (yab->nname) {3598 if (yab->nname) { 3531 3599 bud->real_name = strdup(yab->nname); 3532 } else if (yab->fname && yab->lname) {3600 } else if (yab->fname && yab->lname) { 3533 3601 bud->real_name = y_new0(char, 3534 3602 strlen(yab->fname)+ … … 3537 3605 sprintf(bud->real_name, "%s %s", 3538 3606 yab->fname, yab->lname); 3539 } else if (yab->fname) {3607 } else if (yab->fname) { 3540 3608 bud->real_name = strdup(yab->fname); 3541 3609 } … … 3545 3613 } 3546 3614 3547 if (changed)3548 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies);3615 if (changed) 3616 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies); 3549 3617 } 3550 3618 3551 3619 static void yahoo_process_search_connection(struct yahoo_input_data *yid, int over) 3552 3620 { 3553 struct yahoo_found_contact *yct =NULL;3621 struct yahoo_found_contact *yct = NULL; 3554 3622 char *p = (char *)yid->rxqueue, *np, *cp; 3555 3623 int k, n; 3556 int start =0, found=0, total=0;3557 YList *contacts =NULL;3624 int start = 0, found=0, total=0; 3625 YList *contacts = NULL; 3558 3626 struct yahoo_input_data *pyid = find_input_by_id_and_type(yid->yd->client_id, YAHOO_CONNECTION_PAGER); 3559 3627 3560 if (!over || !pyid)3561 return; 3562 3563 if (p && (p=strstr(p, "\r\n\r\n"))) {3628 if (!over || !pyid) 3629 return; 3630 3631 if (p && (p = strstr(p, "\r\n\r\n"))) { 3564 3632 p += 4; 3565 3633 3566 for (k = 0; (p = strchr(p, 4)) && (k < 4); k++) {3634 for (k = 0; (p = strchr(p, 4)) && (k < 4); k++) { 3567 3635 p++; 3568 3636 n = atoi(p); … … 3574 3642 } 3575 3643 3576 if (p)3644 if (p) 3577 3645 p++; 3578 3646 3579 k =0;3580 while (p && *p) {3647 k = 0; 3648 while (p && *p) { 3581 3649 cp = p; 3582 3650 np = strchr(p, 4); 3583 3651 3584 if (!np)3652 if (!np) 3585 3653 break; 3586 3654 *np = 0; … … 3589 3657 switch(k++) { 3590 3658 case 1: 3591 if (strlen(cp) > 2 && y_list_length(contacts) < total) {3659 if (strlen(cp) > 2 && y_list_length(contacts) < total) { 3592 3660 yct = y_new0(struct yahoo_found_contact, 1); 3593 3661 contacts = y_list_append(contacts, yct); … … 3607 3675 break; 3608 3676 case 5: 3609 if (strcmp(cp, "5") != 0)3677 if (strcmp(cp, "5") != 0) 3610 3678 yct->location = cp; 3611 3679 k = 0; … … 3615 3683 } 3616 3684 3617 YAHOO_CALLBACK(ext_yahoo_got_search_result) (yid->yd->client_id, found, start, total, contacts);3618 3619 while (contacts) {3685 YAHOO_CALLBACK(ext_yahoo_got_search_result) (yid->yd->client_id, found, start, total, contacts); 3686 3687 while (contacts) { 3620 3688 YList *node = contacts; 3621 3689 contacts = y_list_remove_link(contacts, node); … … 3631 3699 struct yahoo_data *yd = yid->yd; 3632 3700 char conn_type[100]; 3633 char *data =NULL;3634 char *packet =NULL;3701 char *data = NULL; 3702 char *packet = NULL; 3635 3703 unsigned char magic_nr[] = {1, 0, 0, 0, 1}; 3636 unsigned header_len =0;3637 unsigned int len =0;3638 unsigned int pos =0;3639 3640 if (error || fd <= 0) {3704 unsigned header_len = 0; 3705 unsigned int len = 0; 3706 unsigned int pos = 0; 3707 3708 if (error || fd <= 0) { 3641 3709 FREE(yid); 3642 3710 return; … … 3724 3792 FREE(data); 3725 3793 3726 yid->read_tag =YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid);3794 yid->read_tag = YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid); 3727 3795 } 3728 3796 … … 3749 3817 3750 3818 LOG(("Connecting to: %s:%d", wcm->server, wcm->port)); 3751 YAHOO_CALLBACK(ext_yahoo_connect_async) (y->yd->client_id, wcm->server, wcm->port,3819 YAHOO_CALLBACK(ext_yahoo_connect_async) (y->yd->client_id, wcm->server, wcm->port, 3752 3820 _yahoo_webcam_connected, yid); 3753 3821 … … 3759 3827 struct yahoo_server_settings *yss; 3760 3828 3761 if (over)3829 if (over) 3762 3830 return; 3763 3831 … … 3783 3851 int fd = yid->fd; 3784 3852 3785 if (over)3853 if (over) 3786 3854 return; 3787 3855 … … 3808 3876 3809 3877 LOG(("read callback: id=%d fd=%d data=%p", id, fd, data)); 3810 if (!yid)3878 if (!yid) 3811 3879 return -2; 3812 3880 … … 3814 3882 do { 3815 3883 len = read(fd, buf, sizeof(buf)); 3816 } while (len == -1 && errno == EINTR);3817 3818 if (len == -1 && (errno == EAGAIN||errno == EINTR)) /* we'll try again later */3884 } while (len == -1 && errno == EINTR); 3885 3886 if (len == -1 && (errno == EAGAIN||errno == EINTR)) /* we'll try again later */ 3819 3887 return 1; 3820 3888 … … 3823 3891 DEBUG_MSG(("len == %d (<= 0)", len)); 3824 3892 3825 if (yid->type == YAHOO_CONNECTION_PAGER) {3826 YAHOO_CALLBACK(ext_yahoo_error) (yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION);3893 if (yid->type == YAHOO_CONNECTION_PAGER) { 3894 YAHOO_CALLBACK(ext_yahoo_error) (yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION); 3827 3895 } 3828 3896 … … 3831 3899 3832 3900 /* no need to return an error, because we've already fixed it */ 3833 if (len == 0)3901 if (len == 0) 3834 3902 return 1; 3835 3903 3836 errno =e;3904 errno = e; 3837 3905 LOG(("read error: %s", strerror(errno))); 3838 3906 return -1; … … 3855 3923 yd = y_new0(struct yahoo_data, 1); 3856 3924 3857 if (!yd)3925 if (!yd) 3858 3926 return 0; 3859 3927 … … 3894 3962 struct yahoo_server_settings *yss = yd->server_settings; 3895 3963 3896 if (error) {3897 if (fallback_ports[ccd->i]) {3964 if (error) { 3965 if (fallback_ports[ccd->i]) { 3898 3966 int tag; 3899 3967 yss->pager_port = fallback_ports[ccd->i++]; 3900 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, yss->pager_host,3968 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, yss->pager_host, 3901 3969 yss->pager_port, yahoo_connected, ccd); 3902 3970 3903 if (tag > 0)3904 ccd->tag =tag;3971 if (tag > 0) 3972 ccd->tag = tag; 3905 3973 } else { 3906 3974 FREE(ccd); 3907 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, YAHOO_LOGIN_SOCK, NULL);3975 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, YAHOO_LOGIN_SOCK, NULL); 3908 3976 } 3909 3977 return; … … 3913 3981 3914 3982 /* fd < 0 && error == 0 means connect was cancelled */ 3915 if (fd < 0)3983 if (fd < 0) 3916 3984 return; 3917 3985 … … 3930 3998 yahoo_packet_free(pkt); 3931 3999 3932 yid->read_tag =YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid);4000 yid->read_tag = YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid); 3933 4001 } 3934 4002 … … 3940 4008 int tag; 3941 4009 3942 if (!yd)4010 if (!yd) 3943 4011 return; 3944 4012 … … 3949 4017 ccd = y_new0(struct connect_callback_data, 1); 3950 4018 ccd->yd = yd; 3951 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, yss->pager_host, yss->pager_port,4019 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, yss->pager_host, yss->pager_port, 3952 4020 yahoo_connected, ccd); 3953 4021 … … 3956 4024 * so ccd will have been freed 3957 4025 */ 3958 if (tag > 0)4026 if (tag > 0) 3959 4027 ccd->tag = tag; 3960 else if (tag < 0)3961 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, YAHOO_LOGIN_SOCK, NULL);4028 else if (tag < 0) 4029 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, YAHOO_LOGIN_SOCK, NULL); 3962 4030 } 3963 4031 … … 3966 4034 { 3967 4035 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3968 if (!yid)4036 if (!yid) 3969 4037 return 0; 3970 4038 else … … 3979 4047 char pic_str[10]; 3980 4048 3981 if (!yid)4049 if (!yid) 3982 4050 return; 3983 4051 … … 3988 4056 snprintf(pic_str, sizeof(pic_str), "%d", picture); 3989 4057 3990 if (from && strcmp(from, yd->user))4058 if (from && strcmp(from, yd->user)) 3991 4059 yahoo_packet_hash(pkt, 0, yd->user); 3992 4060 yahoo_packet_hash(pkt, 1, from?from:yd->user); … … 3994 4062 yahoo_packet_hash(pkt, 14, what); 3995 4063 3996 if (utf8)4064 if (utf8) 3997 4065 yahoo_packet_hash(pkt, 97, "1"); 3998 4066 … … 4012 4080 struct yahoo_data *yd; 4013 4081 struct yahoo_packet *pkt = NULL; 4014 if (!yid)4082 if (!yid) 4015 4083 return; 4016 4084 … … 4037 4105 char s[4]; 4038 4106 4039 if (!yid)4107 if (!yid) 4040 4108 return; 4041 4109 … … 4062 4130 yahoo_packet_free(pkt); 4063 4131 4064 if (old_status == YAHOO_STATUS_INVISIBLE) {4132 if (old_status == YAHOO_STATUS_INVISIBLE) { 4065 4133 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 4066 4134 yahoo_packet_hash(pkt, 13, "1"); … … 4076 4144 struct yahoo_packet *pkt = NULL; 4077 4145 4078 if (!yid)4146 if (!yid) 4079 4147 return; 4080 4148 yd = yid->yd; … … 4082 4150 LOG(("yahoo_logoff: current status: %d", yd->current_status)); 4083 4151 4084 if (yd->current_status != -1 && 0) {4152 if (yd->current_status != -1 && 0) { 4085 4153 /* Meh. Don't send this. The event handlers are not going to 4086 4154 get to do this so it'll just leak memory. And the TCP … … 4097 4165 do { 4098 4166 yahoo_input_close(yid); 4099 } while ((yid = find_input_by_id(id)));4167 } while ((yid = find_input_by_id(id))); 4100 4168 } 4101 4169 … … 4106 4174 struct yahoo_packet *pkt = NULL; 4107 4175 4108 if (!yid)4176 if (!yid) 4109 4177 return; 4110 4178 yd = yid->yd; … … 4121 4189 { 4122 4190 struct yahoo_input_data *yid = data; 4123 if (fd <= 0) {4191 if (fd <= 0) { 4124 4192 inputs = y_list_remove(inputs, yid); 4125 4193 FREE(yid); … … 4128 4196 4129 4197 yid->fd = fd; 4130 yid->read_tag =YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, fd, YAHOO_INPUT_READ, yid);4198 yid->read_tag = YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, YAHOO_INPUT_READ, yid); 4131 4199 } 4132 4200 … … 4138 4206 char buff[1024]; 4139 4207 4140 if (!yd)4208 if (!yd) 4141 4209 return; 4142 4210 … … 4156 4224 } 4157 4225 4158 void yahoo_set_yab(int id, struct yab * 4226 void yahoo_set_yab(int id, struct yab *yab) 4159 4227 { 4160 4228 struct yahoo_data *yd = find_conn_by_id(id); … … 4165 4233 int size = sizeof(url)-1; 4166 4234 4167 if (!yd)4235 if (!yd) 4168 4236 return; 4169 4237 … … 4174 4242 strncpy(url, "http://insider.msg.yahoo.com/ycontent/?addab2=0", size); 4175 4243 4176 if (yab->dbid) {4244 if (yab->dbid) { 4177 4245 /* change existing yab */ 4178 4246 char tmp[32]; … … 4182 4250 } 4183 4251 4184 if (yab->fname) {4252 if (yab->fname) { 4185 4253 strncat(url, "&fn=", size - strlen(url)); 4186 4254 temp = yahoo_urlencode(yab->fname); … … 4188 4256 free(temp); 4189 4257 } 4190 if (yab->lname) {4258 if (yab->lname) { 4191 4259 strncat(url, "&ln=", size - strlen(url)); 4192 4260 temp = yahoo_urlencode(yab->lname); … … 4198 4266 strncat(url, temp, size - strlen(url)); 4199 4267 free(temp); 4200 if (yab->nname) {4268 if (yab->nname) { 4201 4269 strncat(url, "&nn=", size - strlen(url)); 4202 4270 temp = yahoo_urlencode(yab->nname); … … 4204 4272 free(temp); 4205 4273 } 4206 if (yab->email) {4274 if (yab->email) { 4207 4275 strncat(url, "&e=", size - strlen(url)); 4208 4276 temp = yahoo_urlencode(yab->email); … … 4210 4278 free(temp); 4211 4279 } 4212 if (yab->hphone) {4280 if (yab->hphone) { 4213 4281 strncat(url, "&hp=", size - strlen(url)); 4214 4282 temp = yahoo_urlencode(yab->hphone); … … 4216 4284 free(temp); 4217 4285 } 4218 if (yab->wphone) {4286 if (yab->wphone) { 4219 4287 strncat(url, "&wp=", size - strlen(url)); 4220 4288 temp = yahoo_urlencode(yab->wphone); … … 4222 4290 free(temp); 4223 4291 } 4224 if (yab->mphone) {4292 if (yab->mphone) { 4225 4293 strncat(url, "&mp=", size - strlen(url)); 4226 4294 temp = yahoo_urlencode(yab->mphone); … … 4239 4307 } 4240 4308 4241 void yahoo_set_identity_status(int id, const char * 4309 void yahoo_set_identity_status(int id, const char *identity, int active) 4242 4310 { 4243 4311 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4245 4313 struct yahoo_packet *pkt = NULL; 4246 4314 4247 if (!yid)4315 if (!yid) 4248 4316 return; 4249 4317 yd = yid->yd; … … 4264 4332 struct yahoo_packet *pkt = NULL; 4265 4333 4266 if (!yid)4334 if (!yid) 4267 4335 return; 4268 4336 yd = yid->yd; … … 4279 4347 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4280 4348 struct yahoo_data *yd; 4281 struct yahoo_packet *pkt =NULL;4282 if (!yid)4349 struct yahoo_packet *pkt = NULL; 4350 if (!yid) 4283 4351 return; 4284 4352 yd = yid->yd; … … 4311 4379 struct yahoo_packet *pkt; 4312 4380 4313 if (!yid)4381 if (!yid) 4314 4382 return; 4315 4383 yd = yid->yd; … … 4346 4414 struct yahoo_packet *pkt = NULL; 4347 4415 4348 if (!yid)4416 if (!yid) 4349 4417 return; 4350 4418 yd = yid->yd; … … 4363 4431 struct yahoo_data *yd; 4364 4432 4365 if (!yid)4433 if (!yid) 4366 4434 return; 4367 4435 yd = yid->yd; 4368 4436 4369 struct yahoo_packet* pkt =NULL;4437 struct yahoo_packet* pkt = NULL; 4370 4438 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4371 4439 … … 4382 4450 struct yahoo_data *yd; 4383 4451 4384 if (!yid)4452 if (!yid) 4385 4453 return; 4386 4454 yd = yid->yd; 4387 4455 4388 struct yahoo_packet* pkt =NULL;4456 struct yahoo_packet* pkt = NULL; 4389 4457 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4390 4458 … … 4408 4476 struct yahoo_packet *pkt; 4409 4477 4410 if (!yid)4478 if (!yid) 4411 4479 return; 4412 4480 yd = yid->yd; … … 4429 4497 struct yahoo_packet *pkt; 4430 4498 4431 if (!yid)4499 if (!yid) 4432 4500 return; 4433 4501 yd = yid->yd; … … 4450 4518 struct yahoo_packet *pkt; 4451 4519 4452 if (!yid)4520 if (!yid) 4453 4521 return; 4454 4522 yd = yid->yd; … … 4472 4540 struct yahoo_packet *pkt = NULL; 4473 4541 4474 if (!yid)4542 if (!yid) 4475 4543 return; 4476 4544 yd = yid->yd; … … 4499 4567 struct yahoo_packet *pkt = NULL; 4500 4568 4501 if (!yid)4569 if (!yid) 4502 4570 return; 4503 4571 yd = yid->yd; … … 4512 4580 } 4513 4581 4514 void yahoo_conference_addinvite(int id, const char * from, const char *who, const char *room, const YList *members, const char *msg)4582 void yahoo_conference_addinvite(int id, const char *from, const char *who, const char *room, const YList *members, const char *msg) 4515 4583 { 4516 4584 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4518 4586 struct yahoo_packet *pkt; 4519 4587 4520 if (!yid)4588 if (!yid) 4521 4589 return; 4522 4590 yd = yid->yd; … … 4529 4597 yahoo_packet_hash(pkt, 58, msg); 4530 4598 yahoo_packet_hash(pkt, 13, "0"); 4531 for (; members; members = members->next) {4599 for (; members; members = members->next) { 4532 4600 yahoo_packet_hash(pkt, 52, (char *)members->data); 4533 4601 yahoo_packet_hash(pkt, 53, (char *)members->data); … … 4540 4608 } 4541 4609 4542 void yahoo_conference_invite(int id, const char * 4610 void yahoo_conference_invite(int id, const char *from, YList *who, const char *room, const char *msg) 4543 4611 { 4544 4612 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4546 4614 struct yahoo_packet *pkt; 4547 4615 4548 if (!yid)4616 if (!yid) 4549 4617 return; 4550 4618 yd = yid->yd; … … 4554 4622 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4555 4623 yahoo_packet_hash(pkt, 50, yd->user); 4556 for (; who; who = who->next) {4624 for (; who; who = who->next) { 4557 4625 yahoo_packet_hash(pkt, 52, (char *)who->data); 4558 4626 } … … 4572 4640 struct yahoo_packet *pkt; 4573 4641 4574 if (!yid)4642 if (!yid) 4575 4643 return; 4576 4644 yd = yid->yd; … … 4579 4647 4580 4648 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4581 for (; who; who = who->next) {4649 for (; who; who = who->next) { 4582 4650 yahoo_packet_hash(pkt, 3, (char *)who->data); 4583 4651 } … … 4589 4657 } 4590 4658 4591 void yahoo_conference_decline(int id, const char * 4659 void yahoo_conference_decline(int id, const char *from, YList *who, const char *room, const char *msg) 4592 4660 { 4593 4661 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4595 4663 struct yahoo_packet *pkt; 4596 4664 4597 if (!yid)4665 if (!yid) 4598 4666 return; 4599 4667 yd = yid->yd; … … 4602 4670 4603 4671 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4604 for (; who; who = who->next) {4672 for (; who; who = who->next) { 4605 4673 yahoo_packet_hash(pkt, 3, (char *)who->data); 4606 4674 } … … 4613 4681 } 4614 4682 4615 void yahoo_conference_logoff(int id, const char * 4683 void yahoo_conference_logoff(int id, const char *from, YList *who, const char *room) 4616 4684 { 4617 4685 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4619 4687 struct yahoo_packet *pkt; 4620 4688 4621 if (!yid)4689 if (!yid) 4622 4690 return; 4623 4691 yd = yid->yd; … … 4626 4694 4627 4695 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4628 for (; who; who = who->next) {4696 for (; who; who = who->next) { 4629 4697 yahoo_packet_hash(pkt, 3, (char *)who->data); 4630 4698 } … … 4636 4704 } 4637 4705 4638 void yahoo_conference_message(int id, const char * 4706 void yahoo_conference_message(int id, const char *from, YList *who, const char *room, const char *msg, int utf8) 4639 4707 { 4640 4708 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 4642 4710 struct yahoo_packet *pkt; 4643 4711 4644 if (!yid)4712 if (!yid) 4645 4713 return; 4646 4714 yd = yid->yd; … … 4649 4717 4650 4718 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4651 for (; who; who = who->next) {4719 for (; who; who = who->next) { 4652 4720 yahoo_packet_hash(pkt, 53, (char *)who->data); 4653 4721 } … … 4655 4723 yahoo_packet_hash(pkt, 14, msg); 4656 4724 4657 if (utf8)4725 if (utf8) 4658 4726 yahoo_packet_hash(pkt, 97, "1"); 4659 4727 … … 4670 4738 char buff[1024]; 4671 4739 4672 if (!yd)4740 if (!yd) 4673 4741 return; 4674 4742 … … 4696 4764 struct yahoo_packet *pkt; 4697 4765 4698 if (!yid)4766 if (!yid) 4699 4767 return; 4700 4768 … … 4731 4799 char buf[2]; 4732 4800 4733 if (!yid)4801 if (!yid) 4734 4802 return; 4735 4803 … … 4745 4813 yahoo_packet_hash(pkt, 124, buf); 4746 4814 4747 if (utf8)4815 if (utf8) 4748 4816 yahoo_packet_hash(pkt, 97, "1"); 4749 4817 … … 4760 4828 struct yahoo_packet *pkt; 4761 4829 4762 if (!yid)4830 if (!yid) 4763 4831 return; 4764 4832 … … 4780 4848 struct yahoo_packet *pkt; 4781 4849 4782 if ( !yid )4850 if ( !yid ) 4783 4851 return; 4784 4852 … … 4801 4869 char checksum_str[10]; 4802 4870 4803 if ( !yid )4871 if ( !yid ) 4804 4872 return; 4805 4873 … … 4827 4895 char type_str[10]; 4828 4896 4829 if ( !yid )4897 if ( !yid ) 4830 4898 return; 4831 4899 … … 4850 4918 char checksum_str[10]; 4851 4919 4852 if ( !yid )4920 if ( !yid ) 4853 4921 return; 4854 4922 … … 4859 4927 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); 4860 4928 yahoo_packet_hash(pkt, 1, yd->user); 4861 if ( who != 0 )4929 if ( who != 0 ) 4862 4930 yahoo_packet_hash(pkt, 5, who); 4863 4931 yahoo_packet_hash(pkt, 192, checksum_str); … … 4872 4940 struct yahoo_input_data *yid = find_input_by_id_and_webcam_user(id, who); 4873 4941 4874 if (yid)4942 if (yid) 4875 4943 yahoo_input_close(yid); 4876 4944 } … … 4882 4950 struct yahoo_packet *pkt; 4883 4951 4884 if (!yid)4952 if (!yid) 4885 4953 return; 4886 4954 … … 4968 5036 struct yahoo_packet *pkt; 4969 5037 4970 if (!yid)5038 if (!yid) 4971 5039 return; 4972 5040 … … 4991 5059 char *ctext, *p; 4992 5060 4993 if (!yd)5061 if (!yd) 4994 5062 return; 4995 5063 … … 5006 5074 5007 5075 ctext = strdup(text); 5008 while ((p = strchr(ctext, ' ')))5076 while ((p = strchr(ctext, ' '))) 5009 5077 *p = '+'; 5010 5078 … … 5027 5095 struct yahoo_search_state *yss; 5028 5096 5029 if (!yid)5030 return; 5031 5032 if (!yid->ys)5097 if (!yid) 5098 return; 5099 5100 if (!yid->ys) 5033 5101 yid->ys = y_new0(struct yahoo_search_state, 1); 5034 5102 … … 5051 5119 struct yahoo_search_state *yss; 5052 5120 5053 if (!yid || !yid->ys)5121 if (!yid || !yid->ys) 5054 5122 return; 5055 5123 5056 5124 yss = yid->ys; 5057 5125 5058 if (start == -1)5126 if (start == -1) 5059 5127 start = yss->lsearch_nstart + yss->lsearch_nfound; 5060 5128 … … 5078 5146 unsigned char buff[1024]; 5079 5147 5080 if (fd <= 0) {5148 if (fd <= 0) { 5081 5149 sfd->callback(id, fd, error, sfd->user_data); 5082 5150 FREE(sfd); … … 5097 5165 write(yid->fd, buff, 4); 5098 5166 5099 /* YAHOO_CALLBACK(ext_yahoo_add_handler) (nyd->fd, YAHOO_INPUT_READ); */5167 /* YAHOO_CALLBACK(ext_yahoo_add_handler) (nyd->fd, YAHOO_INPUT_READ); */ 5100 5168 5101 5169 sfd->callback(id, fd, error, sfd->user_data); … … 5103 5171 inputs = y_list_remove(inputs, yid); 5104 5172 /* 5105 while (yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) {5106 if (!strcmp(buff, ""))5173 while (yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 5174 if (!strcmp(buff, "")) 5107 5175 break; 5108 5176 } … … 5121 5189 char size_str[10]; 5122 5190 char expire_str[10]; 5123 long content_length =0;5191 long content_length = 0; 5124 5192 unsigned char buff[1024]; 5125 5193 char url[255]; 5126 5194 struct send_file_data *sfd; 5127 5195 5128 if (!yd)5196 if (!yd) 5129 5197 return; 5130 5198 … … 5171 5239 unsigned char buff[1024]; 5172 5240 5173 if (fd <= 0) {5241 if (fd <= 0) { 5174 5242 sfd->callback(id, fd, error, sfd->user_data); 5175 5243 FREE(sfd); … … 5190 5258 write(yid->fd, buff, 4); 5191 5259 5192 /* YAHOO_CALLBACK(ext_yahoo_add_handler) (nyd->fd, YAHOO_INPUT_READ); */5260 /* YAHOO_CALLBACK(ext_yahoo_add_handler) (nyd->fd, YAHOO_INPUT_READ); */ 5193 5261 5194 5262 sfd->callback(id, fd, error, sfd->user_data); … … 5196 5264 inputs = y_list_remove(inputs, yid); 5197 5265 /* 5198 while (yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) {5199 if (!strcmp(buff, ""))5266 while (yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 5267 if (!strcmp(buff, "")) 5200 5268 break; 5201 5269 } … … 5214 5282 struct yahoo_packet *pkt = NULL; 5215 5283 char size_str[10]; 5216 long content_length =0;5284 long content_length = 0; 5217 5285 unsigned char buff[1024]; 5218 5286 char url[255]; 5219 5287 struct send_file_data *sfd; 5220 5288 5221 if (!yd)5289 if (!yd) 5222 5290 return; 5223 5291 … … 5258 5326 { 5259 5327 struct yahoo_data *yd = find_conn_by_id(id); 5260 if (!yd)5328 if (!yd) 5261 5329 return YAHOO_STATUS_OFFLINE; 5262 5330 return yd->current_status; 5263 5331 } 5264 5332 5265 const YList * 5333 const YList *yahoo_get_buddylist(int id) 5266 5334 { 5267 5335 struct yahoo_data *yd = find_conn_by_id(id); 5268 if (!yd)5336 if (!yd) 5269 5337 return NULL; 5270 5338 return yd->buddies; 5271 5339 } 5272 5340 5273 const YList * 5341 const YList *yahoo_get_ignorelist(int id) 5274 5342 { 5275 5343 struct yahoo_data *yd = find_conn_by_id(id); 5276 if (!yd)5344 if (!yd) 5277 5345 return NULL; 5278 5346 return yd->ignore; 5279 5347 } 5280 5348 5281 const YList * 5349 const YList *yahoo_get_identities(int id) 5282 5350 { 5283 5351 struct yahoo_data *yd = find_conn_by_id(id); 5284 if (!yd)5352 if (!yd) 5285 5353 return NULL; 5286 5354 return yd->identities; 5287 5355 } 5288 5356 5289 const char * 5357 const char *yahoo_get_cookie(int id, const char *which) 5290 5358 { 5291 5359 struct yahoo_data *yd = find_conn_by_id(id); 5292 if (!yd)5360 if (!yd) 5293 5361 return NULL; 5294 if (!strncasecmp(which, "y", 1))5362 if (!strncasecmp(which, "y", 1)) 5295 5363 return yd->cookie_y; 5296 if (!strncasecmp(which, "t", 1))5364 if (!strncasecmp(which, "t", 1)) 5297 5365 return yd->cookie_t; 5298 if (!strncasecmp(which, "c", 1))5366 if (!strncasecmp(which, "c", 1)) 5299 5367 return yd->cookie_c; 5300 if (!strncasecmp(which, "login", 5))5368 if (!strncasecmp(which, "login", 5)) 5301 5369 return yd->login_cookie; 5302 5370 return NULL; … … 5307 5375 { 5308 5376 struct yahoo_data *yd = find_conn_by_id(id); 5309 if (!yd)5377 if (!yd) 5310 5378 return; 5311 5379 … … 5313 5381 } 5314 5382 5315 const char * 5383 const char *yahoo_get_profile_url( void ) 5316 5384 { 5317 5385 return profile_url; -
protocols/yahoo/yahoo2.h
r938c305 rc36f73b 62 62 /* who always means the buddy you're acting on */ 63 63 /* id is the successful value returned by yahoo_init */ 64 65 64 66 65 /* init returns a connection id used to identify the connection hereon */ … … 88 87 * You should set at least local_host if you intend to use webcams 89 88 */ 90 int yahoo_init_with_attributes(const char *username, const char *password, ...); 89 int yahoo_init_with_attributes(const char *username, 90 const char *password, ...); 91 91 92 92 /* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults 93 93 * for all attributes */ 94 int yahoo_init(const char *username, const char *password); 95 96 94 int yahoo_init(const char *username, const char *password); 97 95 98 96 /* release all resources held by this session */ 99 97 /* you need to call yahoo_close for a session only if 100 98 * yahoo_logoff is never called for it (ie, it was never logged in) */ 101 void yahoo_close(int id);99 void yahoo_close(int id); 102 100 /* login logs in to the server */ 103 101 /* initial is of type enum yahoo_status. see yahoo2_types.h */ 104 void yahoo_login(int id, int initial);105 void yahoo_logoff(int id);102 void yahoo_login(int id, int initial); 103 void yahoo_logoff(int id); 106 104 /* reloads status of all buddies */ 107 void yahoo_refresh(int id);105 void yahoo_refresh(int id); 108 106 /* activates/deactivates an identity */ 109 void yahoo_set_identity_status(int id, const char * identity, int active); 107 void yahoo_set_identity_status(int id, const char *identity, 108 int active); 110 109 /* regets the entire buddy list from the server */ 111 void yahoo_get_list(int id);110 void yahoo_get_list(int id); 112 111 /* download buddy contact information from your yahoo addressbook */ 113 void yahoo_get_yab(int id);112 void yahoo_get_yab(int id); 114 113 /* add/modify an address book entry. if yab->dbid is set, it will */ 115 114 /* modify that entry else it creates a new entry */ 116 void yahoo_set_yab(int id, struct yab *yab);117 void yahoo_keepalive(int id);118 void yahoo_chat_keepalive(int id);115 void yahoo_set_yab(int id, struct yab *yab); 116 void yahoo_keepalive(int id); 117 void yahoo_chat_keepalive(int id); 119 118 120 119 /* from is the identity you're sending from. if NULL, the default is used */ 121 120 /* utf8 is whether msg is a utf8 string or not. */ 122 void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8, int picture); 121 void yahoo_send_im(int id, const char *from, const char *who, 122 const char *msg, int utf8, int picture); 123 void yahoo_send_buzz(int id, const char *from, const char *who); 123 124 /* if type is true, send typing notice, else send stopped typing notice */ 124 void yahoo_send_typing(int id, const char *from, const char *who, int typ); 125 void yahoo_send_typing(int id, const char *from, const char *who, 126 int typ); 125 127 126 128 /* used to set away/back status. */ 127 129 /* away says whether the custom message is an away message or a sig */ 128 void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away); 129 130 void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg); 131 void yahoo_remove_buddy(int id, const char *who, const char *group); 132 void yahoo_reject_buddy(int id, const char *who, const char *msg); 133 void yahoo_stealth_buddy(int id, const char *who, int unstealth); 130 void yahoo_set_away(int id, enum yahoo_status state, const char *msg, 131 int away); 132 133 void yahoo_add_buddy(int id, const char *who, const char *group, 134 const char *msg); 135 void yahoo_remove_buddy(int id, const char *who, const char *group); 136 void yahoo_confirm_buddy(int id, const char *who, int reject, 137 const char *msg); 138 void yahoo_stealth_buddy(int id, const char *who, int unstealth); 134 139 /* if unignore is true, unignore, else ignore */ 135 void yahoo_ignore_buddy(int id, const char *who, int unignore); 136 void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group); 137 void yahoo_group_rename(int id, const char *old_group, const char *new_group); 138 139 void yahoo_conference_invite(int id, const char * from, YList *who, const char *room, const char *msg); 140 void yahoo_conference_addinvite(int id, const char * from, const char *who, const char *room, const YList * members, const char *msg); 141 void yahoo_conference_decline(int id, const char * from, YList *who, const char *room, const char *msg); 142 void yahoo_conference_message(int id, const char * from, YList *who, const char *room, const char *msg, int utf8); 143 void yahoo_conference_logon(int id, const char * from, YList *who, const char *room); 144 void yahoo_conference_logoff(int id, const char * from, YList *who, const char *room); 140 void yahoo_ignore_buddy(int id, const char *who, int unignore); 141 void yahoo_change_buddy_group(int id, const char *who, 142 const char *old_group, const char *new_group); 143 void yahoo_group_rename(int id, const char *old_group, 144 const char *new_group); 145 146 void yahoo_conference_invite(int id, const char *from, YList *who, 147 const char *room, const char *msg); 148 void yahoo_conference_addinvite(int id, const char *from, 149 const char *who, const char *room, const YList *members, 150 const char *msg); 151 void yahoo_conference_decline(int id, const char *from, YList *who, 152 const char *room, const char *msg); 153 void yahoo_conference_message(int id, const char *from, YList *who, 154 const char *room, const char *msg, int utf8); 155 void yahoo_conference_logon(int id, const char *from, YList *who, 156 const char *room); 157 void yahoo_conference_logoff(int id, const char *from, YList *who, 158 const char *room); 145 159 146 160 /* Get a list of chatrooms */ 147 void yahoo_get_chatrooms(int id,int chatroomid);161 void yahoo_get_chatrooms(int id, int chatroomid); 148 162 /* join room with specified roomname and roomid */ 149 void yahoo_chat_logon(int id, const char *from, const char *room, const char *roomid); 163 void yahoo_chat_logon(int id, const char *from, const char *room, 164 const char *roomid); 150 165 /* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */ 151 void yahoo_chat_message(int id, const char *from, const char *room, const char *msg, const int msgtype, const int utf8); 166 void yahoo_chat_message(int id, const char *from, const char *room, 167 const char *msg, const int msgtype, const int utf8); 152 168 /* Log off chat */ 153 void yahoo_chat_logoff(int id, const char *from);169 void yahoo_chat_logoff(int id, const char *from); 154 170 155 171 /* requests a webcam feed */ 156 172 /* who is the person who's webcam you would like to view */ 157 173 /* if who is null, then you're the broadcaster */ 158 void yahoo_webcam_get_feed(int id, const char *who);159 void yahoo_webcam_close_feed(int id, const char *who);174 void yahoo_webcam_get_feed(int id, const char *who); 175 void yahoo_webcam_close_feed(int id, const char *who); 160 176 161 177 /* sends an image when uploading */ … … 163 179 /* in bytes. The timestamp is the time in milliseconds since we started the */ 164 180 /* webcam. */ 165 void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, unsigned int timestamp); 181 void yahoo_webcam_send_image(int id, unsigned char *image, 182 unsigned int length, unsigned int timestamp); 166 183 167 184 /* this function should be called if we want to allow a user to watch the */ 168 185 /* webcam. Who is the user we want to accept. */ 169 186 /* Accept user (accept = 1), decline user (accept = 0) */ 170 void yahoo_webcam_accept_viewer(int id, const char*who, int accept);187 void yahoo_webcam_accept_viewer(int id, const char *who, int accept); 171 188 172 189 /* send an invitation to a user to view your webcam */ 173 void yahoo_webcam_invite(int id, const char *who);190 void yahoo_webcam_invite(int id, const char *who); 174 191 175 192 /* will set up a connection and initiate file transfer. … … 177 194 * the file data to 178 195 */ 179 void yahoo_send_file(int id, const char *who, const char *msg, const char *name, unsigned long size, 196 void yahoo_send_file(int id, const char *who, const char *msg, 197 const char *name, unsigned long size, 180 198 yahoo_get_fd_callback callback, void *data); 181 199 200 /* 201 * Respond to a file transfer request. Be sure to provide the callback data 202 * since that is your only chance to recognize future callbacks 203 */ 204 void yahoo_send_file_transfer_response(int client_id, int response, 205 char *id, void *data); 206 207 182 208 /* send a search request 183 209 */ 184 void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar, 210 void yahoo_search(int id, enum yahoo_search_type t, const char *text, 211 enum yahoo_search_gender g, enum yahoo_search_agerange ar, 185 212 int photo, int yahoo_only); 186 213 … … 190 217 * where the above three are passed to ext_yahoo_got_search_result 191 218 */ 192 void yahoo_search_again(int id, int start); 193 194 /* returns a socket fd to a url for downloading a file. */ 195 void yahoo_get_url_handle(int id, const char *url, 196 yahoo_get_url_handle_callback callback, void *data); 219 void yahoo_search_again(int id, int start); 197 220 198 221 /* these should be called when input is available on a fd */ … … 203 226 204 227 /* utility functions. these do not hit the server */ 205 enum yahoo_status yahoo_current_status(int id);206 const YList *yahoo_get_buddylist(int id);207 const YList *yahoo_get_ignorelist(int id);208 const YList *yahoo_get_identities(int id);228 enum yahoo_status yahoo_current_status(int id); 229 const YList *yahoo_get_buddylist(int id); 230 const YList *yahoo_get_ignorelist(int id); 231 const YList *yahoo_get_identities(int id); 209 232 /* 'which' could be y, t, c or login. This may change in later versions. */ 210 const char *yahoo_get_cookie(int id, const char *which);233 const char *yahoo_get_cookie(int id, const char *which); 211 234 212 235 /* returns the url used to get user profiles - you must append the user id */ 213 236 /* as of now this is http://profiles.yahoo.com/ */ 214 237 /* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */ 215 const char * yahoo_get_profile_url( void);216 217 void yahoo_buddyicon_request(int id, const char *who);218 219 void yahoo_accept_buddy_ymsg13(int,const char*,const char*);220 void yahoo_reject_buddy_ymsg13(int,const char*,const char*,const char*);238 const char *yahoo_get_profile_url(void); 239 240 void yahoo_buddyicon_request(int id, const char *who); 241 242 void yahoo_accept_buddy_ymsg13(int,const char*, const char*); 243 void yahoo_reject_buddy_ymsg13(int,const char*, const char*, const char*); 221 244 222 245 #include "yahoo_httplib.h" … … 225 248 } 226 249 #endif 227 228 250 #endif -
protocols/yahoo/yahoo2_callbacks.h
r938c305 rc36f73b 30 30 */ 31 31 32 33 32 #ifndef YAHOO2_CALLBACKS_H 34 33 #define YAHOO2_CALLBACKS_H … … 46 45 */ 47 46 48 typedef enum {49 YAHOO_INPUT_READ = 1 << 0,50 YAHOO_INPUT_WRITE = 1 << 1,51 YAHOO_INPUT_EXCEPTION = 1 << 252 } yahoo_input_condition;47 typedef enum { 48 YAHOO_INPUT_READ = 1 << 0, 49 YAHOO_INPUT_WRITE = 1 << 1, 50 YAHOO_INPUT_EXCEPTION = 1 << 2 51 } yahoo_input_condition; 53 52 54 53 /* … … 94 93 * url - url to reactivate account if locked 95 94 */ 96 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url); 97 95 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ, 96 const char *url); 98 97 99 98 /* … … 104 103 * buds - the buddy list 105 104 */ 106 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds); 107 105 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds); 108 106 109 107 /* … … 114 112 * igns - the ignore list 115 113 */ 116 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns); 117 114 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns); 118 115 119 116 /* … … 124 121 * ids - the identity list 125 122 */ 126 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids); 127 123 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids); 128 124 129 125 /* … … 133 129 * id - the id that identifies the server connection 134 130 */ 135 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id); 136 131 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id); 137 132 138 133 /* … … 143 138 * errormsg - optional error message 144 139 */ 145 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg); 146 140 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id, 141 const char *errormsg); 147 142 148 143 /* … … 159 154 * TODO: add support for pager, chat, and game states 160 155 */ 161 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile); 162 156 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id, 157 const char *who, int stat, const char *msg, int away, int idle, 158 int mobile); 159 160 /* 161 * Name: ext_yahoo_got_buzz 162 * Called when remote user sends you a buzz. 163 * Params: 164 * id - the id that identifies the server connection 165 * me - the identity the message was sent to 166 * who - the handle of the remote user 167 * tm - timestamp of message if offline 168 */ 169 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me, 170 const char *who, long tm); 163 171 164 172 /* … … 177 185 * utf8 - whether the message is encoded as utf8 or not 178 186 */ 179 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8); 180 187 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me, 188 const char *who, const char *msg, long tm, int stat, int utf8); 181 189 182 190 /* … … 191 199 * members - the initial members of the conference (null terminated list) 192 200 */ 193 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, const char *who, const char *room, const char *msg, YList *members); 194 201 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id, 202 const char *me, const char *who, const char *room, 203 const char *msg, YList *members); 195 204 196 205 /* … … 204 213 * msg - the declining message 205 214 */ 206 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg); 207 215 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id, 216 const char *me, const char *who, const char *room, 217 const char *msg); 208 218 209 219 /* … … 216 226 * room - the room joined 217 227 */ 218 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room); 219 228 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id, 229 const char *me, const char *who, const char *room); 220 230 221 231 /* … … 228 238 * room - the room left 229 239 */ 230 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room); 231 240 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id, 241 const char *me, const char *who, const char *room); 232 242 233 243 /* … … 238 248 * xml - ? 239 249 */ 240 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml); 241 250 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id, 251 const char *xml); 242 252 243 253 /* … … 254 264 * fd - the socket where the connection is coming from (for tracking) 255 265 */ 256 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char *room, const char *topic, YList *members, int fd); 257 266 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me, 267 const char *room, const char *topic, YList *members, int fd); 258 268 259 269 /* … … 266 276 * who - the user who has joined, Must be freed by the client 267 277 */ 268 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who); 269 278 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id, 279 const char *me, const char *room, 280 struct yahoo_chat_member *who); 270 281 271 282 /* … … 278 289 * who - the user who has left (Just the User ID) 279 290 */ 280 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who); 281 291 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id, 292 const char *me, const char *room, const char *who); 282 293 283 294 /* … … 294 305 * utf8 - whether the message is utf8 encoded or not 295 306 */ 296 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8); 297 307 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id, 308 const char *me, const char *who, const char *room, 309 const char *msg, int msgtype, int utf8); 298 310 299 311 /* … … 310 322 * nothing. 311 323 */ 312 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me); 313 324 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id, 325 const char *me); 314 326 315 327 /* … … 327 339 * nothing. 328 340 */ 329 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me); 330 341 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id, 342 const char *me); 331 343 332 344 /* … … 341 353 * utf8 - whether the message is utf8 encoded or not 342 354 */ 343 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const char *who, const char *room, const char *msg, int utf8); 344 355 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id, 356 const char *me, const char *who, const char *room, 357 const char *msg, int utf8); 345 358 346 359 /* … … 381 394 * msg - any message sent 382 395 */ 383 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg); 384 396 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id, 397 const char *myid, const char *who, const char *msg); 385 398 386 399 /* … … 392 405 * msg - any message sent 393 406 */ 394 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg); 395 407 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who, 408 const char *msg); 396 409 397 410 /* … … 404 417 * stat - 1 if typing, 0 if stopped typing 405 418 */ 406 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat); 407 419 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id, 420 const char *me, const char *who, int stat); 408 421 409 422 /* … … 428 441 * cnt - mail count - 0 if new mail notification 429 442 */ 430 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt); 431 443 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id, 444 const char *from, const char *subj, int cnt); 432 445 433 446 /* … … 450 463 * checksum - the checksum of the icon content 451 464 */ 452 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const char *who, const char *url, int checksum); 465 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id, 466 const char *me, const char *who, const char *url, int checksum); 453 467 454 468 /* … … 461 475 * checksum - the checksum of the icon content 462 476 */ 463 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *me,const char *who, int checksum); 477 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id, 478 const char *me, const char *who, int checksum); 464 479 465 480 /* … … 471 486 * who - the yahoo id of the buddy that requested the buddy icon 472 487 */ 473 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me, const char *who); 488 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id, 489 const char *me, const char *who); 474 490 475 491 /* … … 480 496 * url - remote url, the uploaded buddy icon can be fetched from 481 497 */ 482 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url); 498 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id, 499 const char *url); 483 500 484 501 /* … … 505 522 * a timestamp to stay in sync 506 523 */ 507 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image)(int id, const char * who, 508 const unsigned char *image, unsigned int image_size, unsigned int real_size, 524 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id, 525 const char *who, const unsigned char *image, 526 unsigned int image_size, unsigned int real_size, 509 527 unsigned int timestamp); 510 511 528 512 529 /* … … 518 535 * from - who the invitation is from 519 536 */ 520 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from); 521 537 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id, 538 const char *me, const char *from); 522 539 523 540 /* … … 530 547 * accept - 0 (decline), 1 (accept) 531 548 */ 532 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept); 533 549 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id, 550 const char *me, const char *from, int accept); 534 551 535 552 /* … … 545 562 * 4 = user does not have webcam online 546 563 */ 547 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason); 548 564 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id, 565 const char *who, int reason); 549 566 550 567 /* … … 560 577 * if you need to use the information, make a copy 561 578 */ 562 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int start, int total, YList *contacts); 563 579 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id, 580 int found, int start, int total, YList *contacts); 564 581 565 582 /* … … 572 589 * num - Which error is this 573 590 */ 574 void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num); 575 591 void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err, 592 int fatal, int num); 576 593 577 594 /* … … 583 600 * connect - 0=disconnect 1=connect 2=request 584 601 */ 585 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect); 586 602 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id, 603 const char *who, int connect); 587 604 588 605 /* … … 593 610 * send - whether to send images or not 594 611 */ 595 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send); 596 612 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id, 613 int send); 597 614 598 615 /* … … 604 621 * 0 605 622 */ 606 int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...); 607 623 int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...); 608 624 609 625 /* … … 620 636 * Returns: a tag to be used when removing the handler 621 637 */ 622 int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condition cond, void *data); 623 638 int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, int fd, 639 yahoo_input_condition cond, void *data); 624 640 625 641 /* … … 630 646 * tag - the handler tag to remove 631 647 */ 632 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag); 633 648 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag); 634 649 635 650 /* … … 642 657 * a unix file descriptor to the socket 643 658 */ 644 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port); 645 659 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port); 646 660 647 661 /* 648 662 * Name: ext_yahoo_connect_async 649 * Connect to a host:port asynchronously. 663 * Connect to a host:port asynchronously. This function should return 650 664 * immediately returing a tag used to identify the connection handler, 651 665 * or a pre-connect error (eg: host name lookup failure). … … 663 677 * a unix file descriptor to the socket 664 678 */ 665 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port, 666 yahoo_connect_callback callback, void *callback_data); 679 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id, 680 const char *host, int port, yahoo_connect_callback callback, 681 void *callback_data); 667 682 668 683 #ifdef USE_STRUCT_CALLBACKS … … 673 688 * before doing anything else 674 689 */ 675 void yahoo_register_callbacks(struct yahoo_callbacks * 690 void yahoo_register_callbacks(struct yahoo_callbacks *tyc); 676 691 677 692 #undef YAHOO_CALLBACK_TYPE -
protocols/yahoo/yahoo2_types.h
r938c305 rc36f73b 201 201 202 202 struct yab { 203 int yid; 203 204 char *id; 204 205 char *fname; -
protocols/yahoo/yahoo_fn.h
r938c305 rc36f73b 19 19 */ 20 20 21 #define IDENT 1 22 #define XOR 2 23 #define MULADD 3 24 #define LOOKUP 4 25 #define BITFLD 5 21 #define IDENT 1 /* identify function */ 22 #define XOR 2 /* xor with arg1 */ 23 #define MULADD 3 /* multipy by arg1 then add arg2 */ 24 #define LOOKUP 4 /* lookup each byte in the table pointed to by arg1 */ 25 #define BITFLD 5 /* reorder bits according to table pointed to by arg1 */ 26 26 27 struct yahoo_fn 28 { 29 int type; 27 struct yahoo_fn { 28 int type; 30 29 long arg1, arg2; 31 30 }; 32 31 33 int yahoo_xfrm( int table, int depth, int seed);32 int yahoo_xfrm(int table, int depth, int seed); -
protocols/yahoo/yahoo_util.c
r938c305 rc36f73b 36 36 #include "yahoo_util.h" 37 37 38 char * y_string_append(char * string, char *append)38 char *y_string_append(char *string, char *append) 39 39 { 40 40 int size = strlen(string) + strlen(append) + 1; 41 char * 41 char *new_string = y_renew(char, string, size); 42 42 43 if (new_string == NULL) {43 if (new_string == NULL) { 44 44 new_string = y_new(char, size); 45 45 strcpy(new_string, string); -
protocols/yahoo/yahoo_util.h
r938c305 rc36f73b 61 61 # define y_renew(type, mem, n) (type *)realloc(mem, n) 62 62 63 void * y_memdup(const void *addr, int n);64 char ** y_strsplit(char * str, char *sep, int nelem);65 void y_strfreev(char ** 63 void *y_memdup(const void *addr, int n); 64 char **y_strsplit(char *str, char *sep, int nelem); 65 void y_strfreev(char **vector); 66 66 67 int strncasecmp(const char * s1, const char * s2, size_t n); 68 int strcasecmp(const char * s1, const char * s2); 67 #ifndef _WIN32 68 int strncasecmp(const char *s1, const char *s2, size_t n); 69 int strcasecmp(const char *s1, const char *s2); 69 70 70 char * 71 char *strdup(const char *s); 71 72 72 73 int snprintf(char *str, size_t size, const char *format, ...); 73 74 int vsnprintf(char *str, size_t size, const char *format, va_list ap); 75 #endif 74 76 75 77 #endif … … 95 97 * You must free it yourself 96 98 */ 97 char * y_string_append(char * str, char *append);98 char * y_str_to_utf8(const char *in);99 char * y_utf8_to_str(const char *in);99 char *y_string_append(char *str, char *append); 100 char *y_str_to_utf8(const char *in); 101 char *y_utf8_to_str(const char *in); 100 102 101 103 #endif
Note: See TracChangeset
for help on using the changeset viewer.