Changes in / [938c305:c8791f2]
- Location:
- protocols/yahoo
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/Makefile
r938c305 rc8791f2 15 15 objects = yahoo.o crypt.o libyahoo2.o yahoo_fn.o yahoo_httplib.o yahoo_util.o 16 16 17 CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAVE_GLIB 17 CFLAGS += -Wall -DSTDC_HEADERS -DHAVE_STRING_H -DHAVE_STRCHR -DHAVE_MEMCPY -DHAVE_GLIB -Wno-pointer-to-int-cast 18 18 LFLAGS += -r 19 19 -
protocols/yahoo/libyahoo2.c
r938c305 rc8791f2 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; … … 104 108 #endif 105 109 106 static int yahoo_send_data(int fd, void *data, int len); 107 108 int yahoo_log_message(char * fmt, ...) 110 static int yahoo_send_data(void *fd, void *data, int len); 111 static void _yahoo_http_connected(int id, void *fd, int error, void *data); 112 static void yahoo_connected(void *fd, int error, void *data); 113 114 int yahoo_log_message(char *fmt, ...) 109 115 { 110 116 char out[1024]; … … 113 119 vsnprintf(out, sizeof(out), fmt, ap); 114 120 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);121 return YAHOO_CALLBACK(ext_yahoo_log) ("%s", out); 122 } 123 124 int yahoo_connect(char *host, int port) 125 { 126 return YAHOO_CALLBACK(ext_yahoo_connect) (host, port); 121 127 } 122 128 … … 136 142 137 143 /* default values for servers */ 138 static char pager_host[] = "scs.msg.yahoo.com"; 144 static char *default_pager_hosts[] = { "scs.msg.yahoo.com", 145 "scsa.msg.yahoo.com", 146 "scsb.msg.yahoo.com", 147 "scsc.msg.yahoo.com", 148 NULL}; 149 139 150 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; 151 static int fallback_ports[] = { 23, 25, 80, 20, 119, 8001, 8002, 5050, 0 }; 152 153 static char filetransfer_host[] = "filetransfer.msg.yahoo.com"; 154 static int filetransfer_port = 80; 155 static char webcam_host[] = "webcam.yahoo.com"; 156 static int webcam_port = 5100; 157 static char webcam_description[] = ""; 158 static char local_host[] = ""; 159 static int conn_type = Y_WCM_DSL; 148 160 149 161 static char profile_url[] = "http://profiles.yahoo.com/"; 150 162 151 enum yahoo_service { /* these are easier to see in hex */ 152 YAHOO_SERVICE_LOGON = 1, 153 YAHOO_SERVICE_LOGOFF, 154 YAHOO_SERVICE_ISAWAY, 155 YAHOO_SERVICE_ISBACK, 156 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ 157 YAHOO_SERVICE_MESSAGE, 158 YAHOO_SERVICE_IDACT, 159 YAHOO_SERVICE_IDDEACT, 160 YAHOO_SERVICE_MAILSTAT, 161 YAHOO_SERVICE_USERSTAT, /* 0xa */ 162 YAHOO_SERVICE_NEWMAIL, 163 YAHOO_SERVICE_CHATINVITE, 164 YAHOO_SERVICE_CALENDAR, 165 YAHOO_SERVICE_NEWPERSONALMAIL, 166 YAHOO_SERVICE_NEWCONTACT, 167 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ 168 YAHOO_SERVICE_ADDIGNORE, 169 YAHOO_SERVICE_PING, 170 YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */ 171 YAHOO_SERVICE_SYSMESSAGE = 0x14, 172 YAHOO_SERVICE_SKINNAME = 0x15, 173 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, 174 YAHOO_SERVICE_CONFINVITE = 0x18, 175 YAHOO_SERVICE_CONFLOGON, 176 YAHOO_SERVICE_CONFDECLINE, 177 YAHOO_SERVICE_CONFLOGOFF, 178 YAHOO_SERVICE_CONFADDINVITE, 179 YAHOO_SERVICE_CONFMSG, 180 YAHOO_SERVICE_CHATLOGON, 181 YAHOO_SERVICE_CHATLOGOFF, 182 YAHOO_SERVICE_CHATMSG = 0x20, 183 YAHOO_SERVICE_GAMELOGON = 0x28, 184 YAHOO_SERVICE_GAMELOGOFF, 185 YAHOO_SERVICE_GAMEMSG = 0x2a, 186 YAHOO_SERVICE_FILETRANSFER = 0x46, 187 YAHOO_SERVICE_VOICECHAT = 0x4A, 188 YAHOO_SERVICE_NOTIFY, 189 YAHOO_SERVICE_VERIFY, 190 YAHOO_SERVICE_P2PFILEXFER, 191 YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */ 192 YAHOO_SERVICE_WEBCAM, 193 YAHOO_SERVICE_AUTHRESP = 0x54, 194 YAHOO_SERVICE_LIST, 195 YAHOO_SERVICE_AUTH = 0x57, 196 YAHOO_SERVICE_AUTHBUDDY = 0x6d, 197 YAHOO_SERVICE_ADDBUDDY = 0x83, 198 YAHOO_SERVICE_REMBUDDY, 199 YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0*/ 200 YAHOO_SERVICE_REJECTCONTACT, 201 YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ 202 YAHOO_SERVICE_Y7_PING = 0x8A, /* 0 - id and that's it?? */ 203 YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/ 204 YAHOO_SERVICE_CHATGOTO, 205 YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */ 206 YAHOO_SERVICE_CHATLEAVE, 207 YAHOO_SERVICE_CHATEXIT = 0x9b, 208 YAHOO_SERVICE_CHATADDINVITE = 0x9d, 209 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 210 YAHOO_SERVICE_CHATPING, 211 YAHOO_SERVICE_COMMENT = 0xa8, 212 YAHOO_SERVICE_STEALTH = 0xb9, 213 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 214 YAHOO_SERVICE_PICTURE = 0xbe, 215 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 216 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, 163 struct connect_callback_data { 164 struct yahoo_data *yd; 165 int tag; 166 int i; 167 int server_i; 229 168 }; 230 169 … … 242 181 243 182 struct yahoo_search_state { 244 int 245 char 246 int 247 int 248 int 249 int 250 int 251 int 252 int 183 int lsearch_type; 184 char *lsearch_text; 185 int lsearch_gender; 186 int lsearch_agerange; 187 int lsearch_photo; 188 int lsearch_yahoo_only; 189 int lsearch_nstart; 190 int lsearch_nfound; 191 int lsearch_ntotal; 253 192 }; 254 193 … … 264 203 struct yahoo_search_state *ys; 265 204 266 intfd;205 void *fd; 267 206 enum yahoo_connection_type type; 268 269 unsigned char 270 int 271 int 207 208 unsigned char *rxqueue; 209 int rxlen; 210 int read_tag; 272 211 273 212 YList *txqueues; 274 int 213 int write_tag; 275 214 }; 276 215 277 216 struct yahoo_server_settings { 278 217 char *pager_host; 279 int 218 int pager_port; 280 219 char *filetransfer_host; 281 int 220 int filetransfer_port; 282 221 char *webcam_host; 283 int 222 int webcam_port; 284 223 char *webcam_description; 285 224 char *local_host; 286 int conn_type; 225 int conn_type; 226 char **pager_host_list; 287 227 }; 288 228 289 static void * _yahoo_default_server_settings() 290 { 291 struct yahoo_server_settings *yss = y_new0(struct yahoo_server_settings, 1); 292 293 yss->pager_host = strdup(pager_host); 229 static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over); 230 231 static void yahoo_process_filetransfer(struct yahoo_input_data *yid, 232 struct yahoo_packet *pkt); 233 static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid, 234 struct yahoo_packet *pkt); 235 static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid, 236 struct yahoo_packet *pkt); 237 238 static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn); 239 240 static void *_yahoo_default_server_settings() 241 { 242 struct yahoo_server_settings *yss = 243 y_new0(struct yahoo_server_settings, 1); 244 245 /* Give preference to the default host list 246 * Make sure that only one of the two is set at any time 247 */ 248 yss->pager_host = NULL; 249 yss->pager_host_list = default_pager_hosts; 250 294 251 yss->pager_port = pager_port; 295 252 yss->filetransfer_host = strdup(filetransfer_host); … … 304 261 } 305 262 306 static void * 263 static void *_yahoo_assign_server_settings(va_list ap) 307 264 { 308 265 struct yahoo_server_settings *yss = _yahoo_default_server_settings(); 309 266 char *key; 310 267 char *svalue; 311 int nvalue; 312 313 while(1) { 268 int nvalue; 269 char **pvalue; 270 271 while (1) { 314 272 key = va_arg(ap, char *); 315 if (key == NULL)316 break; 317 318 if (!strcmp(key, "pager_host")) {273 if (key == NULL) 274 break; 275 276 if (!strcmp(key, "pager_host")) { 319 277 svalue = va_arg(ap, char *); 320 278 free(yss->pager_host); 321 279 yss->pager_host = strdup(svalue); 322 } else if(!strcmp(key, "pager_port")) { 280 yss->pager_host_list = NULL; 281 } else if (!strcmp(key, "pager_host_list")) { 282 pvalue = va_arg(ap, char **); 283 yss->pager_host_list = pvalue; 284 free(yss->pager_host); 285 yss->pager_host = NULL; 286 } else if (!strcmp(key, "pager_port")) { 323 287 nvalue = va_arg(ap, int); 324 288 yss->pager_port = nvalue; 325 } else if (!strcmp(key, "filetransfer_host")) {289 } else if (!strcmp(key, "filetransfer_host")) { 326 290 svalue = va_arg(ap, char *); 327 291 free(yss->filetransfer_host); 328 292 yss->filetransfer_host = strdup(svalue); 329 } else if (!strcmp(key, "filetransfer_port")) {293 } else if (!strcmp(key, "filetransfer_port")) { 330 294 nvalue = va_arg(ap, int); 331 295 yss->filetransfer_port = nvalue; 332 } else if (!strcmp(key, "webcam_host")) {296 } else if (!strcmp(key, "webcam_host")) { 333 297 svalue = va_arg(ap, char *); 334 298 free(yss->webcam_host); 335 299 yss->webcam_host = strdup(svalue); 336 } else if (!strcmp(key, "webcam_port")) {300 } else if (!strcmp(key, "webcam_port")) { 337 301 nvalue = va_arg(ap, int); 338 302 yss->webcam_port = nvalue; 339 } else if (!strcmp(key, "webcam_description")) {303 } else if (!strcmp(key, "webcam_description")) { 340 304 svalue = va_arg(ap, char *); 341 305 free(yss->webcam_description); 342 306 yss->webcam_description = strdup(svalue); 343 } else if (!strcmp(key, "local_host")) {307 } else if (!strcmp(key, "local_host")) { 344 308 svalue = va_arg(ap, char *); 345 309 free(yss->local_host); 346 310 yss->local_host = strdup(svalue); 347 } else if (!strcmp(key, "conn_type")) {311 } else if (!strcmp(key, "conn_type")) { 348 312 nvalue = va_arg(ap, int); 349 313 yss->conn_type = nvalue; 350 314 } else { 351 315 WARNING(("Unknown key passed to yahoo_init, " 352 "perhaps you didn't terminate the list "353 "with NULL"));316 "perhaps you didn't terminate the list " 317 "with NULL")); 354 318 } 355 319 } … … 360 324 static void yahoo_free_server_settings(struct yahoo_server_settings *yss) 361 325 { 362 if (!yss)326 if (!yss) 363 327 return; 364 328 … … 372 336 } 373 337 374 static YList *conns =NULL;375 static YList *inputs =NULL;376 static int last_id =0;338 static YList *conns = NULL; 339 static YList *inputs = NULL; 340 static int last_id = 0; 377 341 378 342 static void add_to_list(struct yahoo_data *yd) … … 380 344 conns = y_list_prepend(conns, yd); 381 345 } 382 static struct yahoo_data * find_conn_by_id(int id) 346 347 static struct yahoo_data *find_conn_by_id(int id) 383 348 { 384 349 YList *l; 385 for (l = conns; l; l = y_list_next(l)) {350 for (l = conns; l; l = y_list_next(l)) { 386 351 struct yahoo_data *yd = l->data; 387 if (yd->client_id == id)352 if (yd->client_id == id) 388 353 return yd; 389 354 } 390 355 return NULL; 391 356 } 357 392 358 static void del_from_list(struct yahoo_data *yd) 393 359 { … … 396 362 397 363 /* call repeatedly to get the next one */ 364 /* 398 365 static struct yahoo_input_data * find_input_by_id(int id) 399 366 { … … 406 373 return NULL; 407 374 } 408 409 static struct yahoo_input_data * find_input_by_id_and_webcam_user(int id, const char * who) 375 */ 376 377 static struct yahoo_input_data *find_input_by_id_and_webcam_user(int id, 378 const char *who) 410 379 { 411 380 YList *l; 412 381 LOG(("find_input_by_id_and_webcam_user")); 413 for (l = inputs; l; l = y_list_next(l)) {382 for (l = inputs; l; l = y_list_next(l)) { 414 383 struct yahoo_input_data *yid = l->data; 415 if(yid->type == YAHOO_CONNECTION_WEBCAM && yid->yd->client_id == id 416 && yid->wcm && 417 ((who && yid->wcm->user && !strcmp(who, yid->wcm->user)) || 418 !(yid->wcm->user && !who))) 384 if (yid->type == YAHOO_CONNECTION_WEBCAM 385 && yid->yd->client_id == id && yid->wcm && ((who 386 && yid->wcm->user 387 && !strcmp(who, yid->wcm->user)) 388 || !(yid->wcm->user && !who))) 419 389 return yid; 420 390 } … … 422 392 } 423 393 424 static struct yahoo_input_data * find_input_by_id_and_type(int id, enum yahoo_connection_type type) 394 static struct yahoo_input_data *find_input_by_id_and_type(int id, 395 enum yahoo_connection_type type) 425 396 { 426 397 YList *l; 427 398 LOG(("find_input_by_id_and_type")); 428 for (l = inputs; l; l = y_list_next(l)) {399 for (l = inputs; l; l = y_list_next(l)) { 429 400 struct yahoo_input_data *yid = l->data; 430 if (yid->type == type && yid->yd->client_id == id)401 if (yid->type == type && yid->yd->client_id == id) 431 402 return yid; 432 403 } … … 434 405 } 435 406 436 static struct yahoo_input_data * find_input_by_id_and_fd(int id, intfd)407 static struct yahoo_input_data *find_input_by_id_and_fd(int id, void *fd) 437 408 { 438 409 YList *l; 439 410 LOG(("find_input_by_id_and_fd")); 440 for (l = inputs; l; l = y_list_next(l)) {411 for (l = inputs; l; l = y_list_next(l)) { 441 412 struct yahoo_input_data *yid = l->data; 442 if (yid->fd == fd && yid->yd->client_id == id)413 if (yid->fd == fd && yid->yd->client_id == id) 443 414 return yid; 444 415 } … … 448 419 static int count_inputs_with_id(int id) 449 420 { 450 int c =0;421 int c = 0; 451 422 YList *l; 452 423 LOG(("counting %d", id)); 453 for (l = inputs; l; l = y_list_next(l)) {424 for (l = inputs; l; l = y_list_next(l)) { 454 425 struct yahoo_input_data *yid = l->data; 455 if (yid->yd->client_id == id)426 if (yid->yd->client_id == id) 456 427 c++; 457 428 } … … 460 431 } 461 432 462 463 433 extern char *yahoo_crypt(char *, char *); 464 434 465 435 /* Free a buddy list */ 466 static void yahoo_free_buddies(YList * 436 static void yahoo_free_buddies(YList *list) 467 437 { 468 438 YList *l; 469 439 470 for(l = list; l; l = l->next) 471 { 440 for (l = list; l; l = l->next) { 472 441 struct yahoo_buddy *bud = l->data; 473 if (!bud)442 if (!bud) 474 443 continue; 475 444 … … 477 446 FREE(bud->id); 478 447 FREE(bud->real_name); 479 if (bud->yab_entry) {448 if (bud->yab_entry) { 480 449 FREE(bud->yab_entry->fname); 481 450 FREE(bud->yab_entry->lname); … … 496 465 497 466 /* Free an identities list */ 498 static void yahoo_free_identities(YList * 467 static void yahoo_free_identities(YList *list) 499 468 { 500 469 while (list) { … … 525 494 FREE(yd->cookie_y); 526 495 FREE(yd->cookie_t); 496 FREE(yd->cookie_b); 527 497 FREE(yd->cookie_c); 528 498 FREE(yd->login_cookie); … … 540 510 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) 541 511 542 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, 543 enum yahoo_status status, int id)512 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, 513 enum ypacket_status status, int id) 544 514 { 545 515 struct yahoo_packet *pkt = y_new0(struct yahoo_packet, 1); … … 552 522 } 553 523 554 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value) 524 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, 525 const char *value) 555 526 { 556 527 struct yahoo_pair *pair = y_new0(struct yahoo_pair, 1); … … 597 568 (((*((buf)+3))&0xff))) 598 569 599 static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data, int len) 570 static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data, 571 int len) 600 572 { 601 573 int pos = 0; … … 650 622 FREE(value); 651 623 pkt->hash = y_list_append(pkt->hash, pair); 652 DEBUG_MSG(("Key: %d \tValue: %s", pair->key, pair->value)); 624 DEBUG_MSG(("Key: %d \tValue: %s", pair->key, 625 pair->value)); 653 626 } else { 654 627 FREE(pair); … … 690 663 } 691 664 692 693 665 static void yahoo_packet_dump(unsigned char *data, int len) 694 666 { 695 if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) {667 if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { 696 668 int i; 697 669 for (i = 0; i < len; i++) { 698 670 if ((i % 8 == 0) && i) 699 YAHOO_CALLBACK(ext_yahoo_log) (" ");671 YAHOO_CALLBACK(ext_yahoo_log) (" "); 700 672 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");673 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 674 YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]); 675 } 676 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 705 677 for (i = 0; i < len; i++) { 706 678 if ((i % 8 == 0) && i) 707 YAHOO_CALLBACK(ext_yahoo_log) (" ");679 YAHOO_CALLBACK(ext_yahoo_log) (" "); 708 680 if ((i % 16 == 0) && i) 709 YAHOO_CALLBACK(ext_yahoo_log) ("\n");681 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 710 682 if (isprint(data[i])) 711 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]);683 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]); 712 684 else 713 YAHOO_CALLBACK(ext_yahoo_log) (" . ");714 } 715 YAHOO_CALLBACK(ext_yahoo_log) ("\n");685 YAHOO_CALLBACK(ext_yahoo_log) (" . "); 686 } 687 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 716 688 } 717 689 } … … 723 695 } 724 696 725 static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, int length) 697 static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, 698 int length) 726 699 { 727 700 struct data_queue *tx = y_new0(struct data_queue, 1); … … 732 705 yid->txqueues = y_list_append(yid->txqueues, tx); 733 706 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) 707 if (!yid->write_tag) 708 yid->write_tag = 709 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd-> 710 client_id, yid->fd, YAHOO_INPUT_WRITE, yid); 711 } 712 713 static void yahoo_send_packet(struct yahoo_input_data *yid, 714 struct yahoo_packet *pkt, int extra_pad) 739 715 { 740 716 int pktlen = yahoo_packet_length(pkt); 741 717 int len = YAHOO_PACKET_HDRLEN + pktlen; 742 743 718 unsigned char *data; 744 719 int pos = 0; … … 749 724 data = y_new0(unsigned char, len + 1); 750 725 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); 726 memcpy(data + pos, "YMSG", 4); 727 pos += 4; 728 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); /* version [latest 12 0x000c] */ 729 pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */ 730 pos += yahoo_put16(data + pos, pktlen + extra_pad); /* LOWORD pkt length? */ 731 pos += yahoo_put16(data + pos, pkt->service); /* service */ 732 pos += yahoo_put32(data + pos, pkt->status); /* status [4bytes] */ 733 pos += yahoo_put32(data + pos, pkt->id); /* session [4bytes] */ 758 734 759 735 yahoo_packet_write(pkt, data + pos); 760 736 761 737 yahoo_packet_dump(data, len); 762 763 if ( yid->type == YAHOO_CONNECTION_FT)738 739 if (yid->type == YAHOO_CONNECTION_FT) 764 740 yahoo_send_data(yid->fd, data, len); 765 741 else … … 782 758 } 783 759 784 static int yahoo_send_data( intfd, void *data, int len)760 static int yahoo_send_data(void *fd, void *data, int len) 785 761 { 786 762 int ret; 787 763 int e; 788 764 789 if (fd < 0)765 if (fd == NULL) 790 766 return -1; 791 767 … … 793 769 794 770 do { 795 ret = write(fd, data, len);796 } while (ret == -1 && errno==EINTR);797 e =errno;798 799 if (ret == -1) 771 ret = YAHOO_CALLBACK(ext_yahoo_write) (fd, data, len); 772 } while (ret == -1 && errno == EINTR); 773 e = errno; 774 775 if (ret == -1) { 800 776 LOG(("wrote data: ERR %s", strerror(errno))); 801 777 } else { … … 803 779 } 804 780 805 errno =e;781 errno = e; 806 782 return ret; 807 783 } 808 784 809 void yahoo_close(int id) 785 void yahoo_close(int id) 810 786 { 811 787 struct yahoo_data *yd = find_conn_by_id(id); 812 813 if(!yd) 788 if (!yd) 814 789 return; 815 790 … … 817 792 818 793 yahoo_free_data(yd); 819 if (id == last_id)794 if (id == last_id) 820 795 last_id--; 821 796 } 822 797 823 static void yahoo_input_close(struct yahoo_input_data *yid) 798 static void yahoo_input_close(struct yahoo_input_data *yid) 824 799 { 825 800 inputs = y_list_remove(inputs, yid); 826 801 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); 802 LOG(("yahoo_input_close(read)")); 803 YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id, 804 yid->read_tag); 805 LOG(("yahoo_input_close(write)")); 806 YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id, 807 yid->write_tag); 831 808 yid->read_tag = yid->write_tag = 0; 832 if (yid->fd)833 close(yid->fd);809 if (yid->fd) 810 YAHOO_CALLBACK(ext_yahoo_close) (yid->fd); 834 811 yid->fd = 0; 835 812 FREE(yid->rxqueue); 836 if (count_inputs_with_id(yid->yd->client_id) == 0) {813 if (count_inputs_with_id(yid->yd->client_id) == 0) { 837 814 LOG(("closing %d", yid->yd->client_id)); 838 815 yahoo_close(yid->yd->client_id); 839 816 } 840 817 yahoo_free_webcam(yid->wcm); 841 if (yid->wcd)818 if (yid->wcd) 842 819 FREE(yid->wcd); 843 if (yid->ys) {820 if (yid->ys) { 844 821 FREE(yid->ys->lsearch_text); 845 822 FREE(yid->ys); … … 848 825 } 849 826 850 static int is_same_bud(const void * a, const void * b) { 827 static int is_same_bud(const void *a, const void *b) 828 { 851 829 const struct yahoo_buddy *subject = a; 852 830 const struct yahoo_buddy *object = b; … … 855 833 } 856 834 857 static char * 858 { 859 char * cookie=NULL;860 char * tmpcookie;861 char * 862 863 if (strlen(rawcookie) < 2) 835 static char *getcookie(char *rawcookie) 836 { 837 char *cookie = NULL; 838 char *tmpcookie; 839 char *cookieend; 840 841 if (strlen(rawcookie) < 2) 864 842 return NULL; 865 843 866 tmpcookie = strdup(rawcookie +2);844 tmpcookie = strdup(rawcookie + 2); 867 845 cookieend = strchr(tmpcookie, ';'); 868 846 869 if (cookieend)847 if (cookieend) 870 848 *cookieend = '\0'; 871 849 … … 877 855 } 878 856 879 static char * 857 static char *getlcookie(char *cookie) 880 858 { 881 859 char *tmp; … … 884 862 885 863 tmpend = strstr(cookie, "n="); 886 if (tmpend) {887 tmp = strdup(tmpend +2);864 if (tmpend) { 865 tmp = strdup(tmpend + 2); 888 866 tmpend = strchr(tmp, '&'); 889 if (tmpend)890 *tmpend ='\0';867 if (tmpend) 868 *tmpend = '\0'; 891 869 login_cookie = strdup(tmp); 892 870 FREE(tmp); … … 896 874 } 897 875 898 static void yahoo_process_notify(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 876 static void yahoo_process_notify(struct yahoo_input_data *yid, 877 struct yahoo_packet *pkt) 899 878 { 900 879 struct yahoo_data *yd = yid->yd; … … 927 906 if (!msg) 928 907 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 { 908 909 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 910 YAHOO_CALLBACK(ext_yahoo_typing_notify) (yd->client_id, to, 911 from, stat); 912 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 913 YAHOO_CALLBACK(ext_yahoo_game_notify) (yd->client_id, to, from, 914 stat, ind); 915 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) { 936 916 if (!strcmp(ind, " ")) { 937 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from); 917 YAHOO_CALLBACK(ext_yahoo_webcam_invite) (yd->client_id, 918 to, from); 938 919 } else { 939 920 accept = atoi(ind); … … 941 922 if (accept < 0) 942 923 accept = 0; 943 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd->client_id, to, from, accept);944 }945 }946 else924 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd-> 925 client_id, to, from, accept); 926 } 927 } else 947 928 LOG(("Got unknown notification: %s", msg)); 948 929 } 949 930 950 static void yahoo_process_filetransfer(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 951 { 952 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; 963 964 YList *l; 965 for (l = pkt->hash; l; l = l->next) { 966 struct yahoo_pair *pair = l->data; 967 if (pair->key == 4) 968 from = pair->value; 969 if (pair->key == 5) 970 to = pair->value; 971 if (pair->key == 14) 972 msg = pair->value; 973 if (pair->key == 20) 974 url = pair->value; 975 if (pair->key == 38) 976 expires = atol(pair->value); 977 978 if (pair->key == 27) 979 filename = pair->value; 980 if (pair->key == 28) 981 filesize = atol(pair->value); 982 983 if (pair->key == 49) 984 service = pair->value; 985 } 986 987 if(pkt->service == YAHOO_SERVICE_P2PFILEXFER) { 988 if(strcmp("FILEXFER", service) != 0) { 989 WARNING(("unhandled service 0x%02x", pkt->service)); 990 yahoo_dump_unhandled(pkt); 991 return; 992 } 993 } 994 995 if(msg) { 996 char *tmp; 997 tmp = strchr(msg, '\006'); 998 if(tmp) 999 *tmp = '\0'; 1000 } 1001 if(url && from) 1002 YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize); 1003 1004 } 1005 1006 static void yahoo_process_conference(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 931 static void yahoo_process_conference(struct yahoo_input_data *yid, 932 struct yahoo_packet *pkt) 1007 933 { 1008 934 struct yahoo_data *yd = yid->yd; … … 1012 938 char *room = NULL; 1013 939 char *id = NULL; 1014 int 940 int utf8 = 0; 1015 941 YList *members = NULL; 1016 942 YList *l; 1017 943 1018 944 for (l = pkt->hash; l; l = l->next) { 1019 945 struct yahoo_pair *pair = l->data; 1020 946 if (pair->key == 50) 1021 947 host = pair->value; 1022 1023 if (pair->key == 52) { 948 949 if (pair->key == 52) { /* invite */ 1024 950 members = y_list_append(members, strdup(pair->value)); 1025 951 } 1026 if (pair->key == 53) 952 if (pair->key == 53) /* logon */ 1027 953 who = pair->value; 1028 if (pair->key == 54) 954 if (pair->key == 54) /* decline */ 1029 955 who = pair->value; 1030 if (pair->key == 55) 956 if (pair->key == 55) /* unavailable (status == 2) */ 1031 957 who = pair->value; 1032 if (pair->key == 56) 958 if (pair->key == 56) /* logoff */ 1033 959 who = pair->value; 1034 960 … … 1036 962 room = pair->value; 1037 963 1038 if (pair->key == 58) 964 if (pair->key == 58) /* join message */ 1039 965 msg = pair->value; 1040 if (pair->key == 14) 966 if (pair->key == 14) /* decline/conf message */ 1041 967 msg = pair->value; 1042 968 1043 if (pair->key == 13) 1044 ; 1045 if (pair->key == 16) /* error */ 969 if (pair->key == 13) ; 970 if (pair->key == 16) /* error */ 1046 971 msg = pair->value; 1047 972 1048 if (pair->key == 1) 973 if (pair->key == 1) /* my id */ 1049 974 id = pair->value; 1050 if (pair->key == 3) 975 if (pair->key == 3) /* message sender */ 1051 976 who = pair->value; 1052 977 … … 1055 980 } 1056 981 1057 if (!room)1058 return; 1059 1060 if (host) {1061 for (l = members; l; l = l->next) {1062 char * 1063 if (!strcmp(w, host))982 if (!room) 983 return; 984 985 if (host) { 986 for (l = members; l; l = l->next) { 987 char *w = l->data; 988 if (!strcmp(w, host)) 1064 989 break; 1065 990 } 1066 if (!l)991 if (!l) 1067 992 members = y_list_append(members, strdup(host)); 1068 993 } 1069 994 /* invite, decline, join, left, message -> status == 1 */ 1070 995 1071 switch (pkt->service) {996 switch (pkt->service) { 1072 997 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); 998 if (pkt->status == 2) ; 999 else if (members) 1000 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd-> 1001 client_id, id, host, room, msg, members); 1002 else if (msg) 1003 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, msg, 0, 1004 E_CONFNOTAVAIL); 1079 1005 break; 1080 1006 case YAHOO_SERVICE_CONFADDINVITE: 1081 if(pkt->status == 2) 1082 ; 1083 else 1084 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1007 if (pkt->status == 1) 1008 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd-> 1009 client_id, id, host, room, msg, members); 1085 1010 break; 1086 1011 case YAHOO_SERVICE_CONFDECLINE: 1087 if(who) 1088 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg); 1012 if (who) 1013 YAHOO_CALLBACK(ext_yahoo_conf_userdecline) (yd-> 1014 client_id, id, who, room, msg); 1089 1015 break; 1090 1016 case YAHOO_SERVICE_CONFLOGON: 1091 if(who) 1092 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room); 1017 if (who) 1018 YAHOO_CALLBACK(ext_yahoo_conf_userjoin) (yd->client_id, 1019 id, who, room); 1093 1020 break; 1094 1021 case YAHOO_SERVICE_CONFLOGOFF: 1095 if(who) 1096 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room); 1022 if (who) 1023 YAHOO_CALLBACK(ext_yahoo_conf_userleave) (yd->client_id, 1024 id, who, room); 1097 1025 break; 1098 1026 case YAHOO_SERVICE_CONFMSG: 1099 if(who) 1100 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8); 1027 if (who) 1028 YAHOO_CALLBACK(ext_yahoo_conf_message) (yd->client_id, 1029 id, who, room, msg, utf8); 1101 1030 break; 1102 1031 } 1103 1032 } 1104 1033 1105 static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1034 static void yahoo_process_chat(struct yahoo_input_data *yid, 1035 struct yahoo_packet *pkt) 1106 1036 { 1107 1037 char *msg = NULL; … … 1112 1042 YList *members = NULL; 1113 1043 struct yahoo_chat_member *currentmember = NULL; 1114 int 1115 int 1116 int 1117 int 1118 int chaterr=0;1044 int msgtype = 1; 1045 int utf8 = 0; 1046 int firstjoin = 0; 1047 int membercount = 0; 1048 int chaterr = 0; 1119 1049 YList *l; 1120 1050 1121 1051 yahoo_dump_unhandled(pkt); 1122 1052 for (l = pkt->hash; l; l = l->next) { … … 1148 1078 1149 1079 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1150 currentmember = y_new0(struct yahoo_chat_member, 1); 1080 currentmember = 1081 y_new0(struct yahoo_chat_member, 1); 1151 1082 currentmember->id = strdup(pair->value); 1152 1083 members = y_list_append(members, currentmember); … … 1178 1109 } 1179 1110 1180 1181 1111 if (pair->key == 130) { 1182 1112 /* first join */ … … 1196 1126 /* message error not sure what all the pair values mean */ 1197 1127 /* 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); 1128 chaterr = atoi(pair->value); 1129 } 1130 } 1131 1132 if (!room) { 1133 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1134 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout) (yid->yd-> 1135 client_id, id); 1209 1136 return; 1210 1137 } 1138 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1139 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror) (yid->yd-> 1140 client_id, id); 1141 return; 1142 } 1211 1143 1212 1144 WARNING(("We didn't get a room name, ignoring packet")); … … 1214 1146 } 1215 1147 1216 switch (pkt->service) {1148 switch (pkt->service) { 1217 1149 case YAHOO_SERVICE_CHATJOIN: 1218 if (y_list_length(members) != membercount) {1150 if (y_list_length(members) != membercount) { 1219 1151 WARNING(("Count of members doesn't match No. of members we got")); 1220 1152 } 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) { 1153 if (firstjoin && members) { 1154 YAHOO_CALLBACK(ext_yahoo_chat_join) (yid->yd->client_id, 1155 id, room, topic, members, yid->fd); 1156 } else if (who) { 1157 if (y_list_length(members) != 1) { 1225 1158 WARNING(("Got more than 1 member on a normal join")); 1226 1159 } 1227 1160 /* this should only ever have one, but just in case */ 1228 while (members) {1161 while (members) { 1229 1162 YList *n = members->next; 1230 1163 currentmember = members->data; 1231 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember); 1164 YAHOO_CALLBACK(ext_yahoo_chat_userjoin) (yid-> 1165 yd->client_id, id, room, currentmember); 1232 1166 y_list_free_1(members); 1233 members =n;1167 members = n; 1234 1168 } 1235 1169 } 1236 1170 break; 1237 1171 case YAHOO_SERVICE_CHATEXIT: 1238 if(who) { 1239 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who); 1172 if (who) { 1173 YAHOO_CALLBACK(ext_yahoo_chat_userleave) (yid->yd-> 1174 client_id, id, room, who); 1240 1175 } 1241 1176 break; 1242 1177 case YAHOO_SERVICE_COMMENT: 1243 if(who) { 1244 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8); 1178 if (who) { 1179 YAHOO_CALLBACK(ext_yahoo_chat_message) (yid->yd-> 1180 client_id, id, who, room, msg, msgtype, utf8); 1245 1181 } 1246 1182 break; … … 1248 1184 } 1249 1185 1250 static void yahoo_process_message(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1186 static void yahoo_process_message(struct yahoo_input_data *yid, 1187 struct yahoo_packet *pkt) 1251 1188 { 1252 1189 struct yahoo_data *yd = yid->yd; 1253 1190 YList *l; 1254 YList * 1191 YList *messages = NULL; 1255 1192 1256 1193 struct m { 1257 int 1258 int 1194 int i_31; 1195 int i_32; 1259 1196 char *to; 1260 1197 char *from; 1261 1198 long tm; 1262 1199 char *msg; 1263 int utf8; 1200 int utf8; 1201 char *gunk; 1264 1202 } *message = y_new0(struct m, 1); 1265 1203 1266 1204 for (l = pkt->hash; l; l = l->next) { 1267 1205 struct yahoo_pair *pair = l->data; 1268 if (pair->key == 1 || pair->key == 4) 1269 { 1270 if(!message->from) 1206 if (pair->key == 1 || pair->key == 4) { 1207 if (!message->from) 1271 1208 message->from = pair->value; 1272 } 1273 else if (pair->key == 5) 1209 } else if (pair->key == 5) 1274 1210 message->to = pair->value; 1275 1211 else if (pair->key == 15) … … 1277 1213 else if (pair->key == 97) 1278 1214 message->utf8 = atoi(pair->value); 1279 /* user message */ /* sys message */ 1215 /* This comes when the official client sends us a message */ 1216 else if (pair->key == 429) 1217 message->gunk = pair->value; 1218 /* user message *//* sys message */ 1280 1219 else if (pair->key == 14 || pair->key == 16) 1281 1220 message->msg = pair->value; 1282 1221 else if (pair->key == 31) { 1283 if (message->i_31) {1222 if (message->i_31) { 1284 1223 messages = y_list_append(messages, message); 1285 1224 message = y_new0(struct m, 1); 1286 1225 } 1287 1226 message->i_31 = atoi(pair->value); 1288 } 1289 else if (pair->key == 32) 1227 } else if (pair->key == 32) 1290 1228 message->i_32 = atoi(pair->value); 1291 1229 else 1292 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", 1293 pkt->status, pair->key, pair->value)); 1230 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key, pair->value)); 1294 1231 } 1295 1232 1296 1233 messages = y_list_append(messages, message); 1297 1234 1298 for (l = messages; l; l =l->next) {1235 for (l = messages; l; l = l->next) { 1299 1236 message = l->data; 1300 1237 if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) { 1301 YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg); 1238 YAHOO_CALLBACK(ext_yahoo_system_message) (yd->client_id, 1239 message->to, message->from, message->msg); 1302 1240 } 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); 1241 /* Confirm message receipt if we got the gunk */ 1242 if(message->gunk) { 1243 struct yahoo_packet *outpkt; 1244 1245 outpkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_CONFIRM, 1246 YPACKET_STATUS_DEFAULT, 0); 1247 yahoo_packet_hash(outpkt, 1, yd->user); 1248 yahoo_packet_hash(outpkt, 5, message->from); 1249 yahoo_packet_hash(outpkt, 302, "430"); 1250 yahoo_packet_hash(outpkt, 430, message->gunk); 1251 yahoo_packet_hash(outpkt, 303, "430"); 1252 yahoo_packet_hash(outpkt, 450, "0"); 1253 yahoo_send_packet(yid, outpkt, 0); 1254 1255 yahoo_packet_free(outpkt); 1256 } 1257 1258 if (!strcmp(message->msg, "<ding>")) 1259 YAHOO_CALLBACK(ext_yahoo_got_buzz) (yd->client_id, 1260 message->to, message->from, message->tm); 1261 else 1262 YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id, 1263 message->to, message->from, message->msg, 1264 message->tm, pkt->status, message->utf8); 1304 1265 } else if (pkt->status == 0xffffffff) { 1305 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0, E_SYSTEM); 1306 } 1307 free(message); 1266 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, 1267 message->msg, 0, E_SYSTEM); 1268 } 1269 FREE(message); 1308 1270 } 1309 1271 … … 1311 1273 } 1312 1274 1275 /* 1276 * Here's what multi-level packets look like. Data in brackets is the value. 1277 * 1278 * 3 level: 1279 * ======= 1280 * 1281 * 302 (318) - Beginning level 1 1282 * 300 (318) - Begin level 2 1283 * 302 (319) - End level 2 header 1284 * 300 (319) - Begin level 3 1285 * 301 (319) - End level 3 1286 * 303 (319) - End level 2 1287 * 303 (318) - End level 1 1288 * 1289 * 2 level: 1290 * ======= 1291 * 1292 * 302 (315) - Beginning level 1 1293 * 300 (315) - Begin level 2 1294 * 301 (315) - End level 2 1295 * 303 (315) - End level 1 1296 * 1297 */ 1313 1298 static void yahoo_process_status(struct yahoo_input_data *yid, 1314 1299 struct yahoo_packet *pkt) … … 1327 1312 } 1328 1313 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). */ 1314 /* 1315 * Status updates may be spread accross multiple packets and not 1316 * even on buddy boundaries, so keeping some state is important. 1317 * So, continue where we left off, and only add a user entry to 1318 * the list once it's complete (301-315 End buddy). 1319 */ 1333 1320 u = yd->half_user; 1334 1321 … … 1594 1581 } 1595 1582 1596 static void yahoo_process_verify(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1583 static void yahoo_process_verify(struct yahoo_input_data *yid, 1584 struct yahoo_packet *pkt) 1597 1585 { 1598 1586 struct yahoo_data *yd = yid->yd; 1599 1587 1600 if (pkt->status != 0x01) {1588 if (pkt->status != 0x01) { 1601 1589 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); 1590 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1591 YAHOO_LOGIN_LOCK, ""); 1592 return; 1593 } 1594 1595 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT, 1596 yd->session_id); 1607 1597 1608 1598 yahoo_packet_hash(pkt, 1, yd->user); … … 1613 1603 } 1614 1604 1615 static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1605 static void yahoo_process_picture_checksum(struct yahoo_input_data *yid, 1606 struct yahoo_packet *pkt) 1616 1607 { 1617 1608 struct yahoo_data *yd = yid->yd; … … 1621 1612 YList *l; 1622 1613 1623 for(l = pkt->hash; l; l = l->next) 1624 { 1614 for (l = pkt->hash; l; l = l->next) { 1625 1615 struct yahoo_pair *pair = l->data; 1626 1616 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) 1617 switch (pair->key) { 1618 case 1: 1619 case 4: 1620 from = pair->value; 1621 case 5: 1622 to = pair->value; 1623 break; 1624 case 212: 1625 break; 1626 case 192: 1627 checksum = atoi(pair->value); 1628 break; 1629 } 1630 } 1631 1632 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum) (yd->client_id, to, 1633 from, checksum); 1634 } 1635 1636 static void yahoo_process_picture(struct yahoo_input_data *yid, 1637 struct yahoo_packet *pkt) 1647 1638 { 1648 1639 struct yahoo_data *yd = yid->yd; … … 1653 1644 int checksum = 0; 1654 1645 YList *l; 1655 1656 for(l = pkt->hash; l; l = l->next) 1657 { 1646 1647 for (l = pkt->hash; l; l = l->next) { 1658 1648 struct yahoo_pair *pair = l->data; 1659 1649 1660 switch(pair->key) 1661 { 1650 switch (pair->key) { 1662 1651 case 1: 1663 case 4: 1652 case 4: /* sender */ 1664 1653 from = pair->value; 1665 1654 break; 1666 case 5: 1655 case 5: /* we */ 1667 1656 to = pair->value; 1668 1657 break; 1669 case 13: 1670 status = atoi( pair->value);1671 break; 1672 case 20: 1658 case 13: /* request / sending */ 1659 status = atoi(pair->value); 1660 break; 1661 case 20: /* url */ 1673 1662 url = pair->value; 1674 1663 break; 1675 1664 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) 1665 checksum = atoi(pair->value); 1666 break; 1667 } 1668 } 1669 1670 switch (status) { 1671 case 1: /* this is a request, ignore for now */ 1672 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request) (yd->client_id, 1673 to, from); 1674 break; 1675 case 2: /* this is cool - we get a picture :) */ 1676 YAHOO_CALLBACK(ext_yahoo_got_buddyicon) (yd->client_id, to, 1677 from, url, checksum); 1678 break; 1679 } 1680 } 1681 1682 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, 1683 struct yahoo_packet *pkt) 1693 1684 { 1694 1685 struct yahoo_data *yd = yid->yd; … … 1696 1687 char *url = NULL; 1697 1688 1698 if ( pkt->status != 1)1689 if (pkt->status != 1) 1699 1690 return; /* something went wrong */ 1700 1701 for(l = pkt->hash; l; l = l->next) 1702 { 1691 1692 for (l = pkt->hash; l; l = l->next) { 1703 1693 struct yahoo_pair *pair = l->data; 1704 1694 1705 switch(pair->key) 1706 { 1707 case 5: /* we */ 1708 break; 1709 case 20: /* url */ 1710 url = pair->value; 1711 break; 1712 case 27: /* local filename */ 1713 break; 1714 case 38: /* time */ 1715 break; 1716 } 1717 } 1718 1719 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url); 1720 } 1721 1722 static void yahoo_process_auth_pre_0x0b(struct yahoo_input_data *yid, 1723 const char *seed, const char *sn) 1724 { 1725 struct yahoo_data *yd = yid->yd; 1726 1727 /* So, Yahoo has stopped supporting its older clients in India, and 1728 * undoubtedly will soon do so in the rest of the world. 1729 * 1730 * The new clients use this authentication method. I warn you in 1731 * advance, it's bizzare, convoluted, inordinately complicated. 1732 * It's also no more secure than crypt() was. The only purpose this 1733 * scheme could serve is to prevent third part clients from connecting 1734 * to their servers. 1735 * 1736 * Sorry, Yahoo. 1695 switch (pair->key) { 1696 case 5: /* we */ 1697 break; 1698 case 20: /* url */ 1699 url = pair->value; 1700 break; 1701 case 27: /* local filename */ 1702 break; 1703 case 38: /* time */ 1704 break; 1705 } 1706 } 1707 1708 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded) (yd->client_id, url); 1709 } 1710 1711 void yahoo_login(int id, int initial) 1712 { 1713 struct yahoo_data *yd = find_conn_by_id(id); 1714 struct connect_callback_data *ccd; 1715 struct yahoo_server_settings *yss; 1716 int tag; 1717 1718 char *host; 1719 1720 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); 1721 yid->yd = yd; 1722 yid->type = YAHOO_CONNECTION_PAGER; 1723 inputs = y_list_prepend(inputs, yid); 1724 1725 yd->initial_status = initial; 1726 yss = yd->server_settings; 1727 1728 ccd = y_new0(struct connect_callback_data, 1); 1729 ccd->yd = yd; 1730 1731 host = yss->pager_host; 1732 1733 if (!host) 1734 host = yss->pager_host_list[0]; 1735 1736 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, 1737 host, yss->pager_port, yahoo_connected, ccd, 0); 1738 1739 /* 1740 * if tag <= 0, then callback has already been called 1741 * so ccd will have been freed 1737 1742 */ 1738 1739 struct yahoo_packet *pack; 1740 1741 md5_byte_t result[16]; 1742 md5_state_t ctx; 1743 char *crypt_result; 1744 unsigned char *password_hash = malloc(25); 1745 unsigned char *crypt_hash = malloc(25); 1746 unsigned char *hash_string_p = malloc(50 + strlen(sn)); 1747 unsigned char *hash_string_c = malloc(50 + strlen(sn)); 1748 1749 char checksum; 1750 1751 int sv; 1752 1753 unsigned char *result6 = malloc(25); 1754 unsigned char *result96 = malloc(25); 1755 1756 sv = seed[15]; 1757 sv = (sv % 8) % 5; 1758 1759 md5_init(&ctx); 1760 md5_append(&ctx, (md5_byte_t *)yd->password, strlen(yd->password)); 1761 md5_finish(&ctx, result); 1762 to_y64(password_hash, result, 16); 1763 1764 md5_init(&ctx); 1765 crypt_result = yahoo_crypt(yd->password, "$1$_2S43d5f$"); 1766 md5_append(&ctx, (md5_byte_t *)crypt_result, strlen(crypt_result)); 1767 md5_finish(&ctx, result); 1768 to_y64(crypt_hash, result, 16); 1769 free(crypt_result); 1770 1771 switch (sv) { 1772 case 0: 1773 checksum = seed[seed[7] % 16]; 1774 snprintf((char *)hash_string_p, strlen(sn) + 50, 1775 "%c%s%s%s", checksum, password_hash, yd->user, seed); 1776 snprintf((char *)hash_string_c, strlen(sn) + 50, 1777 "%c%s%s%s", checksum, crypt_hash, yd->user, seed); 1778 break; 1779 case 1: 1780 checksum = seed[seed[9] % 16]; 1781 snprintf((char *)hash_string_p, strlen(sn) + 50, 1782 "%c%s%s%s", checksum, yd->user, seed, password_hash); 1783 snprintf((char *)hash_string_c, strlen(sn) + 50, 1784 "%c%s%s%s", checksum, yd->user, seed, crypt_hash); 1785 break; 1786 case 2: 1787 checksum = seed[seed[15] % 16]; 1788 snprintf((char *)hash_string_p, strlen(sn) + 50, 1789 "%c%s%s%s", checksum, seed, password_hash, yd->user); 1790 snprintf((char *)hash_string_c, strlen(sn) + 50, 1791 "%c%s%s%s", checksum, seed, crypt_hash, yd->user); 1792 break; 1793 case 3: 1794 checksum = seed[seed[1] % 16]; 1795 snprintf((char *)hash_string_p, strlen(sn) + 50, 1796 "%c%s%s%s", checksum, yd->user, password_hash, seed); 1797 snprintf((char *)hash_string_c, strlen(sn) + 50, 1798 "%c%s%s%s", checksum, yd->user, crypt_hash, seed); 1799 break; 1800 case 4: 1801 checksum = seed[seed[3] % 16]; 1802 snprintf((char *)hash_string_p, strlen(sn) + 50, 1803 "%c%s%s%s", checksum, password_hash, seed, yd->user); 1804 snprintf((char *)hash_string_c, strlen(sn) + 50, 1805 "%c%s%s%s", checksum, crypt_hash, seed, yd->user); 1806 break; 1807 } 1808 1809 md5_init(&ctx); 1810 md5_append(&ctx, (md5_byte_t *)hash_string_p, strlen((char *)hash_string_p)); 1811 md5_finish(&ctx, result); 1812 to_y64(result6, result, 16); 1813 1814 md5_init(&ctx); 1815 md5_append(&ctx, (md5_byte_t *)hash_string_c, strlen((char *)hash_string_c)); 1816 md5_finish(&ctx, result); 1817 to_y64(result96, result, 16); 1818 1819 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id); 1820 yahoo_packet_hash(pack, 0, yd->user); 1821 yahoo_packet_hash(pack, 6, (char *)result6); 1822 yahoo_packet_hash(pack, 96, (char *)result96); 1823 yahoo_packet_hash(pack, 1, yd->user); 1824 1825 yahoo_send_packet(yid, pack, 0); 1826 1827 FREE(result6); 1828 FREE(result96); 1829 FREE(password_hash); 1830 FREE(crypt_hash); 1831 FREE(hash_string_p); 1832 FREE(hash_string_c); 1833 1834 yahoo_packet_free(pack); 1835 1836 } 1837 1838 /* 1839 * New auth protocol cracked by Cerulean Studios and sent in to Gaim 1840 */ 1841 static void yahoo_process_auth_0x0b(struct yahoo_input_data *yid, const char *seed, const char *sn) 1842 { 1843 struct yahoo_packet *pack = NULL; 1844 struct yahoo_data *yd = yid->yd; 1845 1846 md5_byte_t result[16]; 1847 md5_state_t ctx; 1848 1849 sha1_state_t ctx1; 1850 sha1_state_t ctx2; 1851 1852 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; 1853 char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; 1854 1855 char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; 1856 char *operand_lookup = "+|&%/*^-"; 1857 char *delimit_lookup = ",;"; 1858 1859 unsigned char *password_hash = malloc(25); 1860 unsigned char *crypt_hash = malloc(25); 1861 char *crypt_result = NULL; 1862 unsigned char pass_hash_xor1[64]; 1863 unsigned char pass_hash_xor2[64]; 1864 unsigned char crypt_hash_xor1[64]; 1865 unsigned char crypt_hash_xor2[64]; 1866 unsigned char chal[7]; 1867 char resp_6[100]; 1868 char resp_96[100]; 1869 1870 unsigned char digest1[20]; 1871 unsigned char digest2[20]; 1872 unsigned char magic_key_char[4]; 1873 const unsigned char *magic_ptr; 1874 1875 unsigned int magic[64]; 1876 unsigned int magic_work=0; 1877 1878 char comparison_src[20]; 1879 1880 int x, j, i; 1881 int cnt = 0; 1882 int magic_cnt = 0; 1883 int magic_len; 1884 int depth =0, table =0; 1885 1886 memset(&pass_hash_xor1, 0, 64); 1887 memset(&pass_hash_xor2, 0, 64); 1888 memset(&crypt_hash_xor1, 0, 64); 1889 memset(&crypt_hash_xor2, 0, 64); 1890 memset(&digest1, 0, 20); 1891 memset(&digest2, 0, 20); 1892 memset(&magic, 0, 64); 1893 memset(&resp_6, 0, 100); 1894 memset(&resp_96, 0, 100); 1895 memset(&magic_key_char, 0, 4); 1896 1897 /* 1898 * Magic: Phase 1. Generate what seems to be a 30 1899 * byte value (could change if base64 1900 * ends up differently? I don't remember and I'm 1901 * tired, so use a 64 byte buffer. 1902 */ 1903 1904 magic_ptr = (unsigned char *)seed; 1905 1906 while (*magic_ptr != 0) { 1907 char *loc; 1908 1909 /* Ignore parentheses. */ 1910 1911 if (*magic_ptr == '(' || *magic_ptr == ')') { 1912 magic_ptr++; 1913 continue; 1914 } 1915 1916 /* Characters and digits verify against 1917 the challenge lookup. 1918 */ 1919 1920 if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) { 1921 loc = strchr(challenge_lookup, *magic_ptr); 1922 if (!loc) { 1923 /* This isn't good */ 1924 continue; 1925 } 1926 1927 /* Get offset into lookup table and lsh 3. */ 1928 1929 magic_work = loc - challenge_lookup; 1930 magic_work <<= 3; 1931 1932 magic_ptr++; 1933 continue; 1934 } else { 1935 unsigned int local_store; 1936 1937 loc = strchr(operand_lookup, *magic_ptr); 1938 if (!loc) { 1939 /* Also not good. */ 1940 continue; 1941 } 1942 1943 local_store = loc - operand_lookup; 1944 1945 /* Oops; how did this happen? */ 1946 if (magic_cnt >= 64) 1947 break; 1948 1949 magic[magic_cnt++] = magic_work | local_store; 1950 magic_ptr++; 1951 continue; 1952 } 1953 } 1954 1955 magic_len = magic_cnt; 1956 magic_cnt = 0; 1957 1958 /* Magic: Phase 2. Take generated magic value and 1959 * sprinkle fairy dust on the values. */ 1960 1961 for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) { 1962 unsigned char byte1; 1963 unsigned char byte2; 1964 1965 /* Bad. Abort. 1966 */ 1967 if (magic_cnt >= magic_len) { 1968 WARNING(("magic_cnt(%d) magic_len(%d)", magic_cnt, magic_len)) 1969 break; 1970 } 1971 1972 byte1 = magic[magic_cnt]; 1973 byte2 = magic[magic_cnt+1]; 1974 1975 byte1 *= 0xcd; 1976 byte1 ^= byte2; 1977 1978 magic[magic_cnt+1] = byte1; 1979 } 1980 1981 /* Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic 1982 * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key 1983 * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets 1984 * into particular functions we'll later call to potentially alter the magic key. 1985 * 1986 * %-) 1987 */ 1988 1989 magic_cnt = 1; 1990 x = 0; 1991 1992 do { 1993 unsigned int bl = 0; 1994 unsigned int cl = magic[magic_cnt++]; 1995 1996 if (magic_cnt >= magic_len) 1997 break; 1998 1999 if (cl > 0x7F) { 2000 if (cl < 0xe0) 2001 bl = cl = (cl & 0x1f) << 6; 2002 else { 2003 bl = magic[magic_cnt++]; 2004 cl = (cl & 0x0f) << 6; 2005 bl = ((bl & 0x3f) + cl) << 6; 2006 } 2007 2008 cl = magic[magic_cnt++]; 2009 bl = (cl & 0x3f) + bl; 2010 } else 2011 bl = cl; 2012 2013 comparison_src[x++] = (bl & 0xff00) >> 8; 2014 comparison_src[x++] = bl & 0xff; 2015 } while (x < 20); 2016 2017 /* Dump magic key into a char for SHA1 action. */ 2018 2019 2020 for(x = 0; x < 4; x++) 2021 magic_key_char[x] = comparison_src[x]; 2022 2023 /* Compute values for recursive function table! */ 2024 memcpy( chal, magic_key_char, 4 ); 2025 x = 1; 2026 for( i = 0; i < 0xFFFF && x; i++ ) 2027 { 2028 for( j = 0; j < 5 && x; j++ ) 2029 { 2030 chal[4] = i; 2031 chal[5] = i >> 8; 2032 chal[6] = j; 2033 md5_init( &ctx ); 2034 md5_append( &ctx, chal, 7 ); 2035 md5_finish( &ctx, result ); 2036 if( memcmp( comparison_src + 4, result, 16 ) == 0 ) 2037 { 2038 depth = i; 2039 table = j; 2040 x = 0; 2041 } 2042 } 2043 } 2044 2045 /* Transform magic_key_char using transform table */ 2046 x = magic_key_char[3] << 24 | magic_key_char[2] << 16 2047 | magic_key_char[1] << 8 | magic_key_char[0]; 2048 x = yahoo_xfrm( table, depth, x ); 2049 x = yahoo_xfrm( table, depth, x ); 2050 magic_key_char[0] = x & 0xFF; 2051 magic_key_char[1] = x >> 8 & 0xFF; 2052 magic_key_char[2] = x >> 16 & 0xFF; 2053 magic_key_char[3] = x >> 24 & 0xFF; 2054 2055 /* Get password and crypt hashes as per usual. */ 2056 md5_init(&ctx); 2057 md5_append(&ctx, (md5_byte_t *)yd->password, strlen(yd->password)); 2058 md5_finish(&ctx, result); 2059 to_y64(password_hash, result, 16); 2060 2061 md5_init(&ctx); 2062 crypt_result = yahoo_crypt(yd->password, "$1$_2S43d5f$"); 2063 md5_append(&ctx, (md5_byte_t *)crypt_result, strlen(crypt_result)); 2064 md5_finish(&ctx, result); 2065 to_y64(crypt_hash, result, 16); 2066 free(crypt_result); 2067 2068 /* Our first authentication response is based off 2069 * of the password hash. */ 2070 2071 for (x = 0; x < (int)strlen((char *)password_hash); x++) 2072 pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36; 2073 2074 if (cnt < 64) 2075 memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt); 2076 2077 cnt = 0; 2078 2079 for (x = 0; x < (int)strlen((char *)password_hash); x++) 2080 pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c; 2081 2082 if (cnt < 64) 2083 memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); 2084 2085 sha1_init(&ctx1); 2086 sha1_init(&ctx2); 2087 2088 /* The first context gets the password hash XORed 2089 * with 0x36 plus a magic value 2090 * which we previously extrapolated from our 2091 * challenge. */ 2092 2093 sha1_append(&ctx1, pass_hash_xor1, 64); 2094 if (j >= 3 ) 2095 ctx1.Length_Low = 0x1ff; 2096 sha1_append(&ctx1, magic_key_char, 4); 2097 sha1_finish(&ctx1, digest1); 2098 2099 /* The second context gets the password hash XORed 2100 * with 0x5c plus the SHA-1 digest 2101 * of the first context. */ 2102 2103 sha1_append(&ctx2, pass_hash_xor2, 64); 2104 sha1_append(&ctx2, digest1, 20); 2105 sha1_finish(&ctx2, digest2); 2106 2107 /* Now that we have digest2, use it to fetch 2108 * characters from an alphabet to construct 2109 * our first authentication response. */ 2110 2111 for (x = 0; x < 20; x += 2) { 2112 unsigned int val = 0; 2113 unsigned int lookup = 0; 2114 char byte[6]; 2115 2116 memset(&byte, 0, 6); 2117 2118 /* First two bytes of digest stuffed 2119 * together. 2120 */ 2121 2122 val = digest2[x]; 2123 val <<= 8; 2124 val += digest2[x+1]; 2125 2126 lookup = (val >> 0x0b); 2127 lookup &= 0x1f; 2128 if (lookup >= strlen(alphabet1)) 2129 break; 2130 sprintf(byte, "%c", alphabet1[lookup]); 2131 strcat(resp_6, byte); 2132 strcat(resp_6, "="); 2133 2134 lookup = (val >> 0x06); 2135 lookup &= 0x1f; 2136 if (lookup >= strlen(alphabet2)) 2137 break; 2138 sprintf(byte, "%c", alphabet2[lookup]); 2139 strcat(resp_6, byte); 2140 2141 lookup = (val >> 0x01); 2142 lookup &= 0x1f; 2143 if (lookup >= strlen(alphabet2)) 2144 break; 2145 sprintf(byte, "%c", alphabet2[lookup]); 2146 strcat(resp_6, byte); 2147 2148 lookup = (val & 0x01); 2149 if (lookup >= strlen(delimit_lookup)) 2150 break; 2151 sprintf(byte, "%c", delimit_lookup[lookup]); 2152 strcat(resp_6, byte); 2153 } 2154 2155 /* Our second authentication response is based off 2156 * of the crypto hash. */ 2157 2158 cnt = 0; 2159 memset(&digest1, 0, 20); 2160 memset(&digest2, 0, 20); 2161 2162 for (x = 0; x < (int)strlen((char *)crypt_hash); x++) 2163 crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; 2164 2165 if (cnt < 64) 2166 memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); 2167 2168 cnt = 0; 2169 2170 for (x = 0; x < (int)strlen((char *)crypt_hash); x++) 2171 crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; 2172 2173 if (cnt < 64) 2174 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); 2175 2176 sha1_init(&ctx1); 2177 sha1_init(&ctx2); 2178 2179 /* The first context gets the password hash XORed 2180 * with 0x36 plus a magic value 2181 * which we previously extrapolated from our 2182 * challenge. */ 2183 2184 sha1_append(&ctx1, crypt_hash_xor1, 64); 2185 if (j >= 3 ) 2186 ctx1.Length_Low = 0x1ff; 2187 sha1_append(&ctx1, magic_key_char, 4); 2188 sha1_finish(&ctx1, digest1); 2189 2190 /* The second context gets the password hash XORed 2191 * with 0x5c plus the SHA-1 digest 2192 * of the first context. */ 2193 2194 sha1_append(&ctx2, crypt_hash_xor2, 64); 2195 sha1_append(&ctx2, digest1, 20); 2196 sha1_finish(&ctx2, digest2); 2197 2198 /* Now that we have digest2, use it to fetch 2199 * characters from an alphabet to construct 2200 * our first authentication response. */ 2201 2202 for (x = 0; x < 20; x += 2) { 2203 unsigned int val = 0; 2204 unsigned int lookup = 0; 2205 2206 char byte[6]; 2207 2208 memset(&byte, 0, 6); 2209 2210 /* First two bytes of digest stuffed 2211 * together. */ 2212 2213 val = digest2[x]; 2214 val <<= 8; 2215 val += digest2[x+1]; 2216 2217 lookup = (val >> 0x0b); 2218 lookup &= 0x1f; 2219 if (lookup >= strlen(alphabet1)) 2220 break; 2221 sprintf(byte, "%c", alphabet1[lookup]); 2222 strcat(resp_96, byte); 2223 strcat(resp_96, "="); 2224 2225 lookup = (val >> 0x06); 2226 lookup &= 0x1f; 2227 if (lookup >= strlen(alphabet2)) 2228 break; 2229 sprintf(byte, "%c", alphabet2[lookup]); 2230 strcat(resp_96, byte); 2231 2232 lookup = (val >> 0x01); 2233 lookup &= 0x1f; 2234 if (lookup >= strlen(alphabet2)) 2235 break; 2236 sprintf(byte, "%c", alphabet2[lookup]); 2237 strcat(resp_96, byte); 2238 2239 lookup = (val & 0x01); 2240 if (lookup >= strlen(delimit_lookup)) 2241 break; 2242 sprintf(byte, "%c", delimit_lookup[lookup]); 2243 strcat(resp_96, byte); 2244 } 2245 2246 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id); 2247 yahoo_packet_hash(pack, 0, sn); 2248 yahoo_packet_hash(pack, 6, resp_6); 2249 yahoo_packet_hash(pack, 96, resp_96); 2250 yahoo_packet_hash(pack, 1, sn); 2251 yahoo_send_packet(yid, pack, 0); 2252 yahoo_packet_free(pack); 2253 2254 free(password_hash); 2255 free(crypt_hash); 1743 if (tag > 0) 1744 ccd->tag = tag; 1745 else if (tag < 0) 1746 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1747 YAHOO_LOGIN_SOCK, NULL); 2256 1748 } 2257 1749 … … 2303 1795 } 2304 1796 2305 static void yahoo_ process_auth_0x10(struct yahoo_input_data *yid, const char *seed, const char *sn)1797 static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn) 2306 1798 { 2307 1799 struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1); … … 2353 1845 2354 1846 if (req->status_code != 200) { 2355 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);1847 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 2356 1848 goto fail; 2357 1849 } 2358 1850 2359 1851 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);1852 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 2361 1853 goto fail; 2362 1854 } 2363 1855 2364 1856 if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) { 2365 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL);1857 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL); 2366 1858 goto fail; 2367 1859 } … … 2409 1901 2410 1902 if (req->status_code != 200) { 2411 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);1903 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 2412 1904 goto fail; 2413 1905 } 2414 1906 2415 1907 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);1908 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 2417 1909 goto fail; 2418 1910 } … … 2421 1913 (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL || 2422 1914 (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) { 2423 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL);1915 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL); 2424 1916 goto fail; 2425 1917 } … … 2454 1946 } 2455 1947 2456 static void yahoo_process_auth(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1948 static void yahoo_process_auth(struct yahoo_input_data *yid, 1949 struct yahoo_packet *pkt) 2457 1950 { 2458 1951 char *seed = NULL; 2459 char *sn 1952 char *sn = NULL; 2460 1953 YList *l = pkt->hash; 2461 1954 int m = 0; 1955 struct yahoo_data *yd = yid->yd; 2462 1956 2463 1957 while (l) { 2464 1958 struct yahoo_pair *pair = l->data; 2465 if (pair->key == 94) 1959 1960 switch (pair->key) { 1961 case 94: 2466 1962 seed = pair->value; 2467 if (pair->key == 1) 1963 break; 1964 case 1: 2468 1965 sn = pair->value; 2469 if (pair->key == 13) 1966 break; 1967 case 13: 2470 1968 m = atoi(pair->value); 1969 break; 1970 } 2471 1971 l = l->next; 2472 1972 } 2473 1973 2474 if (!seed) 2475 return; 2476 2477 switch (m) { 2478 case 0: 2479 yahoo_process_auth_pre_0x0b(yid, seed, sn); 2480 break; 2481 case 1: 2482 yahoo_process_auth_0x0b(yid, seed, sn); 2483 break; 2484 case 2: 2485 yahoo_process_auth_0x10(yid, seed, sn); 2486 break; 2487 default: 2488 /* call error */ 2489 WARNING(("unknown auth type %d", m)); 2490 yahoo_process_auth_0x0b(yid, seed, sn); 2491 break; 2492 } 2493 } 2494 2495 static void yahoo_process_auth_resp(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1974 if (!seed) 1975 return; 1976 1977 if (m==2) 1978 yahoo_https_auth(yid, seed, sn); 1979 else { 1980 /* call error */ 1981 WARNING(("unknown auth type %d", m)); 1982 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1983 YAHOO_LOGIN_UNKNOWN, NULL); 1984 } 1985 } 1986 1987 static void yahoo_process_auth_resp(struct yahoo_input_data *yid, 1988 struct yahoo_packet *pkt) 2496 1989 { 2497 1990 struct yahoo_data *yd = yid->yd; 2498 1991 char *login_id; 2499 1992 char *handle; 2500 char *url =NULL;2501 int login_status=0;1993 char *url = NULL; 1994 int login_status = -1; 2502 1995 2503 1996 YList *l; … … 2515 2008 } 2516 2009 2517 if(pkt->status == 0xffffffff) { 2518 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, login_status, url); 2519 /* yahoo_logoff(yd->client_id);*/ 2520 } 2521 } 2522 2523 static void yahoo_process_mail(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2010 if (pkt->status == YPACKET_STATUS_DISCONNECTED) { 2011 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2012 login_status, url); 2013 /* yahoo_logoff(yd->client_id); */ 2014 } 2015 } 2016 2017 static void yahoo_process_mail(struct yahoo_input_data *yid, 2018 struct yahoo_packet *pkt) 2524 2019 { 2525 2020 struct yahoo_data *yd = yid->yd; … … 2547 2042 char from[1024]; 2548 2043 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) 2044 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, from, 2045 subj, count); 2046 } else if (count > 0) 2047 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, NULL, 2048 NULL, count); 2049 } 2050 2051 static void yahoo_process_new_contact(struct yahoo_input_data *yid, 2052 struct yahoo_packet *pkt) 2053 { 2054 struct yahoo_data *yd = yid->yd; 2055 char *me = NULL; 2056 char *who = NULL; 2057 char *msg = NULL; 2058 int online = -1; 2059 2060 YList *l; 2061 2062 for (l = pkt->hash; l; l = l->next) { 2063 struct yahoo_pair *pair = l->data; 2064 if (pair->key == 4) 2065 who = pair->value; 2066 else if (pair->key == 5) 2067 me = pair->value; 2068 else if (pair->key == 14) 2069 msg = pair->value; 2070 else if (pair->key == 13) 2071 online = strtol(pair->value, NULL, 10); 2072 } 2073 2074 if (who && online < 0) 2075 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who, 2076 msg); 2077 else if (online == 2) 2078 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg); 2079 } 2080 2081 /* UNUSED? */ 2082 static void yahoo_process_contact(struct yahoo_input_data *yid, 2083 struct yahoo_packet *pkt) 2555 2084 { 2556 2085 struct yahoo_data *yd = yid->yd; … … 2561 2090 long tm = 0L; 2562 2091 int state = YAHOO_STATUS_AVAILABLE; 2563 int online = FALSE;2092 int online = 0; 2564 2093 int away = 0; 2565 2094 int idle = 0; … … 2590 2119 else if (pair->key == 60) 2591 2120 mobile = strtol(pair->value, NULL, 10); 2592 2121 2593 2122 } 2594 2123 2595 2124 if (id) 2596 YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg); 2125 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, id, who, 2126 msg); 2597 2127 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) 2128 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, name, 2129 state, msg, away, idle, mobile); 2130 else if (pkt->status == 0x07) 2131 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg); 2132 } 2133 2134 static void yahoo_process_buddyadd(struct yahoo_input_data *yid, 2135 struct yahoo_packet *pkt) 2604 2136 { 2605 2137 struct yahoo_data *yd = yid->yd; … … 2609 2141 char *me = NULL; 2610 2142 2611 struct yahoo_buddy *bud =NULL;2143 struct yahoo_buddy *bud = NULL; 2612 2144 2613 2145 YList *l; … … 2624 2156 } 2625 2157 2626 yahoo_dump_unhandled(pkt); 2627 2628 if(!who) 2629 return; 2630 if(!where) 2158 if (!who) 2159 return; 2160 if (!where) 2631 2161 where = "Unknown"; 2632 2162 2633 /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */ 2634 if( status == 0 ) { 2635 bud = y_new0(struct yahoo_buddy, 1); 2636 bud->id = strdup(who); 2637 bud->group = strdup(where); 2638 bud->real_name = NULL; 2639 2640 yd->buddies = y_list_append(yd->buddies, bud); 2641 2642 /* Possibly called already, but at least the call above doesn't 2643 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)); */ 2648 } 2649 2650 static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2651 { 2652 char* who=NULL; 2653 char* me=NULL; 2654 char* msg=NULL; 2655 YList *l; 2656 for (l = pkt->hash; l; l = l->next) { 2657 struct yahoo_pair *pair = l->data; 2658 if (pair->key == 4) 2659 who = pair->value; 2660 else if (pair->key == 5) 2661 me = pair->value; 2662 else 2663 DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value)); 2664 } 2665 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) 2163 bud = y_new0(struct yahoo_buddy, 1); 2164 bud->id = strdup(who); 2165 bud->group = strdup(where); 2166 bud->real_name = NULL; 2167 2168 yd->buddies = y_list_append(yd->buddies, bud); 2169 2170 /* A non-zero status (i've seen 2) seems to mean the buddy is already 2171 * added and is online */ 2172 if (status) { 2173 LOG(("Setting online see packet for info")); 2174 yahoo_dump_unhandled(pkt); 2175 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who, 2176 YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0); 2177 } 2178 } 2179 2180 static void yahoo_process_buddydel(struct yahoo_input_data *yid, 2181 struct yahoo_packet *pkt) 2671 2182 { 2672 2183 struct yahoo_data *yd = yid->yd; … … 2691 2202 unk_66 = strtol(pair->value, NULL, 10); 2692 2203 else 2693 DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value)); 2694 } 2695 2696 if(!who || !where) 2697 return; 2698 2204 DEBUG_MSG(("unknown key: %d = %s", pair->key, 2205 pair->value)); 2206 } 2207 2208 if (!who || !where) 2209 return; 2210 2699 2211 bud = y_new0(struct yahoo_buddy, 1); 2700 2212 bud->id = strdup(who); … … 2707 2219 FREE(bud); 2708 2220 2709 if (buddy) {2221 if (buddy) { 2710 2222 bud = buddy->data; 2711 2223 yd->buddies = y_list_remove_link(yd->buddies, buddy); … … 2717 2229 FREE(bud); 2718 2230 2719 bud=NULL; 2720 } 2721 } 2722 2723 static void yahoo_process_ignore(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2231 bud = NULL; 2232 } 2233 } 2234 2235 static void yahoo_process_ignore(struct yahoo_input_data *yid, 2236 struct yahoo_packet *pkt) 2724 2237 { 2725 2238 char *who = NULL; 2726 int 2239 int status = 0; 2727 2240 char *me = NULL; 2728 int 2241 int un_ignore = 0; 2729 2242 2730 2243 YList *l; … … 2735 2248 if (pair->key == 1) 2736 2249 me = pair->value; 2737 if (pair->key == 13) /* 1 == ignore, 2 == unignore */2250 if (pair->key == 13) /* 1 == ignore, 2 == unignore */ 2738 2251 un_ignore = strtol(pair->value, NULL, 10); 2739 if (pair->key == 66) 2252 if (pair->key == 66) 2740 2253 status = strtol(pair->value, NULL, 10); 2741 2254 } 2742 2743 2255 2744 2256 /* 2745 2257 * status 2746 * 2747 * 2748 * 2749 * 2258 * 0 - ok 2259 * 2 - already in ignore list, could not add 2260 * 3 - not in ignore list, could not delete 2261 * 12 - is a buddy, could not add 2750 2262 */ 2751 2263 2752 2264 /* if(status) 2753 2265 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) 2266 */ 2267 } 2268 2269 static void yahoo_process_voicechat(struct yahoo_input_data *yid, 2270 struct yahoo_packet *pkt) 2758 2271 { 2759 2272 char *who = NULL; … … 2770 2283 me = pair->value; 2771 2284 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)); 2285 voice_room = pair->value; 2286 if (pair->key == 57) 2287 room = pair->value; 2288 } 2289 2290 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, 2291 me)); 2778 2292 /* 2779 2293 * send: s:0 1:me 5:who 57:room 13:1 … … 2787 2301 } 2788 2302 2789 static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2303 static void yahoo_process_ping(struct yahoo_input_data *yid, 2304 struct yahoo_packet *pkt) 2790 2305 { 2791 2306 char *errormsg = NULL; 2792 2307 2793 2308 YList *l; 2794 2309 for (l = pkt->hash; l; l = l->next) { … … 2797 2312 errormsg = pair->value; 2798 2313 } 2799 2314 2800 2315 NOTICE(("got ping packet")); 2801 YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg); 2802 } 2803 2804 static void _yahoo_webcam_get_server_connected(int fd, int error, void *d) 2316 YAHOO_CALLBACK(ext_yahoo_got_ping) (yid->yd->client_id, errormsg); 2317 } 2318 2319 static void yahoo_process_buddy_change_group(struct yahoo_input_data *yid, 2320 struct yahoo_packet *pkt) 2321 { 2322 YList *l; 2323 char *me = NULL; 2324 char *who = NULL; 2325 char *old_group = NULL; 2326 char *new_group = NULL; 2327 2328 for (l = pkt->hash; l; l = l->next) { 2329 struct yahoo_pair *pair = l->data; 2330 if (pair->key == 1) 2331 me = pair->value; 2332 if (pair->key == 7) 2333 who = pair->value; 2334 if (pair->key == 224) 2335 old_group = pair->value; 2336 if (pair->key == 264) 2337 new_group = pair->value; 2338 } 2339 2340 YAHOO_CALLBACK(ext_yahoo_got_buddy_change_group) (yid->yd->client_id, 2341 me, who, old_group, new_group); 2342 } 2343 2344 static void _yahoo_webcam_get_server_connected(void *fd, int error, void *d) 2805 2345 { 2806 2346 struct yahoo_input_data *yid = d; … … 2808 2348 char *data = NULL; 2809 2349 char *packet = NULL; 2810 unsigned char magic_nr[] = { 0, 1, 0};2350 unsigned char magic_nr[] = { 0, 1, 0 }; 2811 2351 unsigned char header_len = 8; 2812 2352 unsigned int len = 0; 2813 2353 unsigned int pos = 0; 2814 2354 2815 if (error || fd <= 0) {2355 if (error || !fd) { 2816 2356 FREE(who); 2817 2357 FREE(yid); … … 2821 2361 yid->fd = fd; 2822 2362 inputs = y_list_prepend(inputs, yid); 2823 2363 2824 2364 /* send initial packet */ 2825 2365 if (who) … … 2831 2371 2832 2372 /* send data */ 2833 if (who) 2834 { 2373 if (who) { 2835 2374 data = strdup("g="); 2836 2375 data = y_string_append(data, who); … … 2851 2390 FREE(data); 2852 2391 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) 2392 yid->read_tag = 2393 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, 2394 YAHOO_INPUT_READ, yid); 2395 } 2396 2397 static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, 2398 char *key) 2857 2399 { 2858 2400 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); … … 2862 2404 yid->yd = y->yd; 2863 2405 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;2406 yid->wcm->user = who ? strdup(who) : NULL; 2407 yid->wcm->direction = who ? YAHOO_WEBCAM_DOWNLOAD : YAHOO_WEBCAM_UPLOAD; 2866 2408 yid->wcm->key = strdup(key); 2867 2409 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) 2410 YAHOO_CALLBACK(ext_yahoo_connect_async) (yid->yd->client_id, 2411 yss->webcam_host, yss->webcam_port, 2412 _yahoo_webcam_get_server_connected, yid, 0); 2413 2414 } 2415 2416 static YList *webcam_queue = NULL; 2417 static void yahoo_process_webcam_key(struct yahoo_input_data *yid, 2418 struct yahoo_packet *pkt) 2875 2419 { 2876 2420 char *me = NULL; … … 2879 2423 2880 2424 YList *l; 2881 //yahoo_dump_unhandled(pkt);2425 yahoo_dump_unhandled(pkt); 2882 2426 for (l = pkt->hash; l; l = l->next) { 2883 2427 struct yahoo_pair *pair = l->data; 2884 2428 if (pair->key == 5) 2885 2429 me = pair->value; 2886 if (pair->key == 61) 2887 key =pair->value;2430 if (pair->key == 61) 2431 key = pair->value; 2888 2432 } 2889 2433 2890 2434 l = webcam_queue; 2891 if (!l)2435 if (!l) 2892 2436 return; 2893 2437 who = l->data; … … 2898 2442 } 2899 2443 2900 static void yahoo_packet_process(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2444 static void yahoo_packet_process(struct yahoo_input_data *yid, 2445 struct yahoo_packet *pkt) 2901 2446 { 2902 2447 DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service)); 2903 yahoo_dump_unhandled(pkt); 2904 switch (pkt->service) 2905 { 2448 switch (pkt->service) { 2906 2449 case YAHOO_SERVICE_USERSTAT: 2907 2450 case YAHOO_SERVICE_LOGON: … … 2914 2457 case YAHOO_SERVICE_IDDEACT: 2915 2458 case YAHOO_SERVICE_Y6_STATUS_UPDATE: 2916 case YAHOO_SERVICE_Y MSG15_STATUS:2459 case YAHOO_SERVICE_Y8_STATUS: 2917 2460 yahoo_process_status(yid, pkt); 2918 2461 break; … … 2928 2471 yahoo_process_mail(yid, pkt); 2929 2472 break; 2930 case YAHOO_SERVICE_REJECTCONTACT: 2473 case YAHOO_SERVICE_Y7_AUTHORIZATION: 2474 yahoo_process_new_contact(yid, pkt); 2475 break; 2931 2476 case YAHOO_SERVICE_NEWCONTACT: 2932 2477 yahoo_process_contact(yid, pkt); … … 2963 2508 break; 2964 2509 case YAHOO_SERVICE_P2PFILEXFER: 2965 case YAHOO_SERVICE_ FILETRANSFER:2510 case YAHOO_SERVICE_Y7_FILETRANSFER: 2966 2511 yahoo_process_filetransfer(yid, pkt); 2512 break; 2513 case YAHOO_SERVICE_Y7_FILETRANSFERINFO: 2514 yahoo_process_filetransferinfo(yid, pkt); 2515 break; 2516 case YAHOO_SERVICE_Y7_FILETRANSFERACCEPT: 2517 yahoo_process_filetransferaccept(yid, pkt); 2967 2518 break; 2968 2519 case YAHOO_SERVICE_ADDBUDDY: 2969 2520 yahoo_process_buddyadd(yid, pkt); 2970 break;2971 case YAHOO_SERVICE_CONTACT_YMSG13:2972 yahoo_process_contact_ymsg13(yid,pkt);2973 2521 break; 2974 2522 case YAHOO_SERVICE_REMBUDDY: … … 2987 2535 yahoo_process_ping(yid, pkt); 2988 2536 break; 2537 case YAHOO_SERVICE_Y7_CHANGE_GROUP: 2538 yahoo_process_buddy_change_group(yid, pkt); 2539 break; 2989 2540 case YAHOO_SERVICE_IDLE: 2990 2541 case YAHOO_SERVICE_MAILSTAT: … … 3000 2551 case YAHOO_SERVICE_CHATLOGOFF: 3001 2552 case YAHOO_SERVICE_CHATMSG: 2553 case YAHOO_SERVICE_REJECTCONTACT: 3002 2554 case YAHOO_SERVICE_PEERTOPEER: 3003 2555 WARNING(("unhandled service 0x%02x", pkt->service)); … … 3012 2564 case YAHOO_SERVICE_PICTURE_UPLOAD: 3013 2565 yahoo_process_picture_upload(yid, pkt); 3014 break; 3015 case YAHOO_SERVICE_Y MSG15_BUDDY_LIST: /* Buddy List */2566 break; 2567 case YAHOO_SERVICE_Y8_LIST: /* Buddy List */ 3016 2568 yahoo_process_buddy_list(yid, pkt); 2569 break; 3017 2570 default: 3018 2571 WARNING(("unknown service 0x%02x", pkt->service)); … … 3022 2575 } 3023 2576 3024 static struct yahoo_packet * yahoo_getdata(struct yahoo_input_data *yid)2577 static struct yahoo_packet *yahoo_getdata(struct yahoo_input_data *yid) 3025 2578 { 3026 2579 struct yahoo_packet *pkt; … … 3029 2582 int pktlen; 3030 2583 3031 if (!yd)2584 if (!yd) 3032 2585 return NULL; 3033 2586 … … 3038 2591 } 3039 2592 3040 pos += 4; 2593 pos += 4; /* YMSG */ 3041 2594 pos += 2; 3042 2595 pos += 2; 3043 2596 3044 pktlen = yahoo_get16(yid->rxqueue + pos); pos += 2;3045 DEBUG_MSG(("%d bytes to read, rxlen is %d",3046 2597 pktlen = yahoo_get16(yid->rxqueue + pos); 2598 pos += 2; 2599 DEBUG_MSG(("%d bytes to read, rxlen is %d", pktlen, yid->rxlen)); 3047 2600 3048 2601 if (yid->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) { … … 3056 2609 pkt = yahoo_packet_new(0, 0, 0); 3057 2610 3058 pkt->service = yahoo_get16(yid->rxqueue + pos); pos += 2; 3059 pkt->status = yahoo_get32(yid->rxqueue + pos); pos += 4; 2611 pkt->service = yahoo_get16(yid->rxqueue + pos); 2612 pos += 2; 2613 pkt->status = yahoo_get32(yid->rxqueue + pos); 2614 pos += 4; 3060 2615 DEBUG_MSG(("Yahoo Service: 0x%02x Status: %d", pkt->service, 3061 pkt->status)); 3062 pkt->id = yahoo_get32(yid->rxqueue + pos); pos += 4; 2616 pkt->status)); 2617 pkt->id = yahoo_get32(yid->rxqueue + pos); 2618 pos += 4; 3063 2619 3064 2620 yd->session_id = pkt->id; … … 3068 2624 yid->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; 3069 2625 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 2626 if (yid->rxlen > 0) { 2627 unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN 2628 + pktlen, yid->rxlen); 3073 2629 FREE(yid->rxqueue); 3074 2630 yid->rxqueue = tmp; 3075 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 2631 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2632 yid->rxqueue)); 3076 2633 } else { 3077 2634 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3082 2639 } 3083 2640 3084 static void yahoo_yab_read(struct yab *yab,unsigned char *d, int len)2641 static struct yab *yahoo_yab_read(unsigned char *d, int len) 3085 2642 { 3086 2643 char *st, *en; 3087 2644 char *data = (char *)d; 3088 data[len]='\0'; 2645 struct yab *yab = NULL; 2646 2647 data[len] = '\0'; 3089 2648 3090 2649 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'; 2650 st = en = strstr(data, "e0=\""); 2651 if (st) { 2652 yab = y_new0(struct yab, 1); 2653 2654 st += strlen("e0=\""); 2655 en = strchr(st, '"'); 2656 *en++ = '\0'; 2657 yab->email = yahoo_xmldecode(st); 2658 } 2659 2660 if (!en) 2661 return NULL; 2662 2663 st = strstr(en, "id=\""); 2664 if (st) { 2665 st += strlen("id=\""); 2666 en = strchr(st, '"'); 2667 *en++ = '\0'; 2668 yab->yid = atoi(yahoo_xmldecode(st)); 2669 } 2670 2671 st = strstr(en, "fn=\""); 2672 if (st) { 2673 st += strlen("fn=\""); 2674 en = strchr(st, '"'); 2675 *en++ = '\0'; 2676 yab->fname = yahoo_xmldecode(st); 2677 } 2678 2679 st = strstr(en, "ln=\""); 2680 if (st) { 2681 st += strlen("ln=\""); 2682 en = strchr(st, '"'); 2683 *en++ = '\0'; 2684 yab->lname = yahoo_xmldecode(st); 2685 } 2686 2687 st = strstr(en, "nn=\""); 2688 if (st) { 2689 st += strlen("nn=\""); 2690 en = strchr(st, '"'); 2691 *en++ = '\0'; 2692 yab->nname = yahoo_xmldecode(st); 2693 } 2694 2695 st = strstr(en, "yi=\""); 2696 if (st) { 2697 st += strlen("yi=\""); 2698 en = strchr(st, '"'); 2699 *en++ = '\0'; 3095 2700 yab->id = yahoo_xmldecode(st); 3096 2701 } 3097 2702 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 2703 st = strstr(en, "hphone=\""); 3127 if (st) {2704 if (st) { 3128 2705 st += strlen("hphone=\""); 3129 en = strchr(st, '"'); *en++ = '\0'; 2706 en = strchr(st, '"'); 2707 *en++ = '\0'; 3130 2708 yab->hphone = yahoo_xmldecode(st); 3131 2709 } 3132 2710 3133 2711 st = strstr(en, "wphone=\""); 3134 if (st) {2712 if (st) { 3135 2713 st += strlen("wphone=\""); 3136 en = strchr(st, '"'); *en++ = '\0'; 2714 en = strchr(st, '"'); 2715 *en++ = '\0'; 3137 2716 yab->wphone = yahoo_xmldecode(st); 3138 2717 } 3139 2718 3140 2719 st = strstr(en, "mphone=\""); 3141 if (st) {2720 if (st) { 3142 2721 st += strlen("mphone=\""); 3143 en = strchr(st, '"'); *en++ = '\0'; 2722 en = strchr(st, '"'); 2723 *en++ = '\0'; 3144 2724 yab->mphone = yahoo_xmldecode(st); 3145 2725 } 3146 2726 3147 2727 st = strstr(en, "dbid=\""); 3148 if (st) {2728 if (st) { 3149 2729 st += strlen("dbid=\""); 3150 en = strchr(st, '"'); *en++ = '\0'; 2730 en = strchr(st, '"'); 2731 *en++ = '\0'; 3151 2732 yab->dbid = atoi(st); 3152 2733 } 3153 } 3154 3155 static struct yab * yahoo_getyab(struct yahoo_input_data *yid) 2734 2735 return yab; 2736 } 2737 2738 static struct yab *yahoo_getyab(struct yahoo_input_data *yid) 3156 2739 { 3157 2740 struct yab *yab = NULL; 3158 int pos = 0, end =0;2741 int pos = 0, end = 0; 3159 2742 struct yahoo_data *yd = yid->yd; 3160 2743 3161 if (!yd)2744 if (!yd) 3162 2745 return NULL; 3163 2746 2747 do { 2748 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 2749 2750 if (yid->rxlen <= strlen("<ct")) 2751 return NULL; 2752 2753 /* start with <ct */ 2754 while (pos < yid->rxlen - strlen("<ct") + 1 2755 && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct"))) 2756 pos++; 2757 2758 if (pos >= yid->rxlen - 1) 2759 return NULL; 2760 2761 end = pos + 2; 2762 /* end with > */ 2763 while (end < yid->rxlen - strlen(">") 2764 && memcmp(yid->rxqueue + end, ">", strlen(">"))) 2765 end++; 2766 2767 if (end >= yid->rxlen - 1) 2768 return NULL; 2769 2770 yab = yahoo_yab_read(yid->rxqueue + pos, end + 2 - pos); 2771 2772 yid->rxlen -= end + 1; 2773 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, 2774 yid->rxqueue)); 2775 if (yid->rxlen > 0) { 2776 unsigned char *tmp = 2777 y_memdup(yid->rxqueue + end + 1, yid->rxlen); 2778 FREE(yid->rxqueue); 2779 yid->rxqueue = tmp; 2780 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2781 yid->rxqueue)); 2782 } else { 2783 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); 2784 FREE(yid->rxqueue); 2785 } 2786 2787 } while (!yab && end < yid->rxlen - 1); 2788 2789 return yab; 2790 } 2791 2792 static char *yahoo_getwebcam_master(struct yahoo_input_data *yid) 2793 { 2794 unsigned int pos = 0; 2795 unsigned int len = 0; 2796 unsigned int status = 0; 2797 char *server = NULL; 2798 struct yahoo_data *yd = yid->yd; 2799 2800 if (!yid || !yd) 2801 return NULL; 2802 3164 2803 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 3165 2804 3166 if(yid->rxlen <= strlen("<record")) 2805 len = yid->rxqueue[pos++]; 2806 if (yid->rxlen < len) 3167 2807 return NULL; 3168 2808 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; 2809 /* extract status (0 = ok, 6 = webcam not online) */ 2810 status = yid->rxqueue[pos++]; 2811 2812 if (status == 0) { 2813 pos += 2; /* skip next 2 bytes */ 2814 server = y_memdup(yid->rxqueue + pos, 16); 2815 pos += 16; 2816 } else if (status == 6) { 2817 YAHOO_CALLBACK(ext_yahoo_webcam_closed) 2818 (yd->client_id, yid->wcm->user, 4); 2819 } 2820 2821 /* skip rest of the data */ 2822 2823 yid->rxlen -= len; 3190 2824 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);2825 if (yid->rxlen > 0) { 2826 unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen); 3193 2827 FREE(yid->rxqueue); 3194 2828 yid->rxqueue = tmp; 3195 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 2829 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2830 yid->rxqueue)); 3196 2831 } else { 3197 2832 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3199 2834 } 3200 2835 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; 2836 return server; 2837 } 2838 2839 static int yahoo_get_webcam_data(struct yahoo_input_data *yid) 2840 { 2841 unsigned char reason = 0; 2842 unsigned int pos = 0; 2843 unsigned int begin = 0; 2844 unsigned int end = 0; 2845 unsigned int closed = 0; 2846 unsigned char header_len = 0; 2847 char *who; 2848 int connect = 0; 3211 2849 struct yahoo_data *yd = yid->yd; 3212 2850 3213 if(!yid || !yd) 3214 return NULL; 2851 if (!yd) 2852 return -1; 2853 2854 if (!yid->wcm || !yid->wcd || !yid->rxlen) 2855 return -1; 3215 2856 3216 2857 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 3217 2858 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 2859 /* 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; 2860 if (!yid->wcd->to_read) { 2861 header_len = yid->rxqueue[pos++]; 2862 yid->wcd->packet_type = 0; 3279 2863 3280 2864 if (yid->rxlen < header_len) 3281 2865 return 0; 3282 2866 3283 if (header_len >= 8) 3284 { 2867 if (header_len >= 8) { 3285 2868 reason = yid->rxqueue[pos++]; 3286 2869 /* next 2 bytes should always be 05 00 */ … … 3290 2873 yid->wcd->to_read = yid->wcd->data_size; 3291 2874 } 3292 if (header_len >= 13) 3293 { 2875 if (header_len >= 13) { 3294 2876 yid->wcd->packet_type = yid->rxqueue[pos++]; 3295 2877 yid->wcd->timestamp = yahoo_get32(yid->rxqueue + pos); … … 3303 2885 begin = pos; 3304 2886 pos += yid->wcd->to_read; 3305 if (pos > yid->rxlen) pos = yid->rxlen; 2887 if (pos > yid->rxlen) 2888 pos = yid->rxlen; 3306 2889 3307 2890 /* if it is not an image then make sure we have the whole packet */ … … 3316 2899 3317 2900 DEBUG_MSG(("packet type %.2X, data length %d", yid->wcd->packet_type, 3318 yid->wcd->data_size));2901 yid->wcd->data_size)); 3319 2902 3320 2903 /* find out what kind of packet we got */ 3321 switch (yid->wcd->packet_type) 3322 { 3323 case 0x00: 3324 /* user requests to view webcam (uploading) */ 3325 if (yid->wcd->data_size && 3326 yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) { 3327 end = begin; 3328 while (end <= yid->rxlen && 3329 yid->rxqueue[end++] != 13); 3330 if (end > begin) 3331 { 3332 who = y_memdup(yid->rxqueue + begin, end - begin); 3333 who[end - begin - 1] = 0; 3334 YAHOO_CALLBACK(ext_yahoo_webcam_viewer)(yd->client_id, who + 2, 2); 3335 FREE(who); 3336 } 3337 } 3338 3339 if (yid->wcm->direction == YAHOO_WEBCAM_DOWNLOAD) { 3340 /* timestamp/status field */ 3341 /* 0 = declined viewing permission */ 3342 /* 1 = accepted viewing permission */ 3343 if (yid->wcd->timestamp == 0) { 3344 YAHOO_CALLBACK(ext_yahoo_webcam_closed)(yd->client_id, yid->wcm->user, 3); 3345 } 3346 } 3347 break; 3348 case 0x01: /* status packets?? */ 3349 /* timestamp contains status info */ 3350 /* 00 00 00 01 = we have data?? */ 3351 break; 3352 case 0x02: /* image data */ 3353 YAHOO_CALLBACK(ext_yahoo_got_webcam_image)(yd->client_id, 3354 yid->wcm->user, yid->rxqueue + begin, 3355 yid->wcd->data_size, pos - begin, 3356 yid->wcd->timestamp); 3357 break; 3358 case 0x05: /* response packets when uploading */ 3359 if (!yid->wcd->data_size) { 3360 YAHOO_CALLBACK(ext_yahoo_webcam_data_request)(yd->client_id, yid->wcd->timestamp); 3361 } 3362 break; 3363 case 0x07: /* connection is closing */ 3364 switch(reason) 3365 { 3366 case 0x01: /* user closed connection */ 3367 closed = 1; 3368 break; 3369 case 0x0F: /* user cancelled permission */ 3370 closed = 2; 3371 break; 3372 } 3373 YAHOO_CALLBACK(ext_yahoo_webcam_closed)(yd->client_id, yid->wcm->user, closed); 3374 break; 3375 case 0x0C: /* user connected */ 3376 case 0x0D: /* user disconnected */ 3377 if (yid->wcd->data_size) { 3378 who = y_memdup(yid->rxqueue + begin, pos - begin + 1); 3379 who[pos - begin] = 0; 3380 if (yid->wcd->packet_type == 0x0C) 3381 connect=1; 3382 else 3383 connect=0; 3384 YAHOO_CALLBACK(ext_yahoo_webcam_viewer)(yd->client_id, who, connect); 2904 switch (yid->wcd->packet_type) { 2905 case 0x00: 2906 /* user requests to view webcam (uploading) */ 2907 if (yid->wcd->data_size && 2908 yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) { 2909 end = begin; 2910 while (end <= yid->rxlen && yid->rxqueue[end++] != 13) ; 2911 if (end > begin) { 2912 who = y_memdup(yid->rxqueue + begin, 2913 end - begin); 2914 who[end - begin - 1] = 0; 2915 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd-> 2916 client_id, who + 2, 2); 3385 2917 FREE(who); 3386 2918 } 3387 break; 3388 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 */ 3391 /* are viewing) */ 3392 break; 3393 case 0x17: /* ?? */ 3394 break; 2919 } 2920 2921 if (yid->wcm->direction == YAHOO_WEBCAM_DOWNLOAD) { 2922 /* timestamp/status field */ 2923 /* 0 = declined viewing permission */ 2924 /* 1 = accepted viewing permission */ 2925 if (yid->wcd->timestamp == 0) { 2926 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd-> 2927 client_id, yid->wcm->user, 3); 2928 } 2929 } 2930 break; 2931 case 0x01: /* status packets?? */ 2932 /* timestamp contains status info */ 2933 /* 00 00 00 01 = we have data?? */ 2934 break; 2935 case 0x02: /* image data */ 2936 YAHOO_CALLBACK(ext_yahoo_got_webcam_image) (yd->client_id, 2937 yid->wcm->user, yid->rxqueue + begin, 2938 yid->wcd->data_size, pos - begin, yid->wcd->timestamp); 2939 break; 2940 case 0x05: /* response packets when uploading */ 2941 if (!yid->wcd->data_size) { 2942 YAHOO_CALLBACK(ext_yahoo_webcam_data_request) (yd-> 2943 client_id, yid->wcd->timestamp); 2944 } 2945 break; 2946 case 0x07: /* connection is closing */ 2947 switch (reason) { 2948 case 0x01: /* user closed connection */ 2949 closed = 1; 2950 break; 2951 case 0x0F: /* user cancelled permission */ 2952 closed = 2; 2953 break; 2954 } 2955 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id, 2956 yid->wcm->user, closed); 2957 break; 2958 case 0x0C: /* user connected */ 2959 case 0x0D: /* user disconnected */ 2960 if (yid->wcd->data_size) { 2961 who = y_memdup(yid->rxqueue + begin, pos - begin + 1); 2962 who[pos - begin] = 0; 2963 if (yid->wcd->packet_type == 0x0C) 2964 connect = 1; 2965 else 2966 connect = 0; 2967 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, 2968 who, connect); 2969 FREE(who); 2970 } 2971 break; 2972 case 0x13: /* user data */ 2973 /* i=user_ip (ip of the user we are viewing) */ 2974 /* j=user_ext_ip (external ip of the user we */ 2975 /* are viewing) */ 2976 break; 2977 case 0x17: /* ?? */ 2978 break; 3395 2979 } 3396 2980 yid->wcd->to_read -= pos - begin; … … 3398 2982 yid->rxlen -= pos; 3399 2983 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 3400 if (yid->rxlen >0) {2984 if (yid->rxlen > 0) { 3401 2985 unsigned char *tmp = y_memdup(yid->rxqueue + pos, yid->rxlen); 3402 2986 FREE(yid->rxqueue); 3403 2987 yid->rxqueue = tmp; 3404 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, yid->rxqueue)); 2988 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2989 yid->rxqueue)); 3405 2990 } else { 3406 2991 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3415 3000 } 3416 3001 3417 int yahoo_write_ready(int id, intfd, void *data)3002 int yahoo_write_ready(int id, void *fd, void *data) 3418 3003 { 3419 3004 struct yahoo_input_data *yid = data; … … 3421 3006 struct data_queue *tx; 3422 3007 3423 LOG(("write callback: id=%d fd=% ddata=%p", id, fd, data));3424 if (!yid || !yid->txqueues || !find_conn_by_id(id))3008 LOG(("write callback: id=%d fd=%p data=%p", id, fd, data)); 3009 if (!yid || !yid->txqueues) 3425 3010 return -2; 3426 3011 3427 3012 tx = yid->txqueues->data; 3428 3013 LOG(("writing %d bytes", tx->len)); 3429 3014 len = yahoo_send_data(fd, tx->queue, MIN(1024, tx->len)); 3430 3015 3431 if (len == -1 && errno == EAGAIN)3016 if (len == -1 && errno == EAGAIN) 3432 3017 return 1; 3433 3018 3434 if (len <= 0) {3019 if (len <= 0) { 3435 3020 int e = errno; 3436 3021 DEBUG_MSG(("len == %d (<= 0)", len)); 3437 while (yid->txqueues) {3438 YList *l =yid->txqueues;3022 while (yid->txqueues) { 3023 YList *l = yid->txqueues; 3439 3024 tx = l->data; 3440 3025 free(tx->queue); 3441 3026 free(tx); 3442 yid->txqueues = y_list_remove_link(yid->txqueues, yid->txqueues); 3027 yid->txqueues = 3028 y_list_remove_link(yid->txqueues, 3029 yid->txqueues); 3443 3030 y_list_free_1(l); 3444 3031 } 3445 LOG(("yahoo_write_ready(%d, % d) len < 0", id, fd));3446 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag);3032 LOG(("yahoo_write_ready(%d, %p) len < 0", id, fd)); 3033 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag); 3447 3034 yid->write_tag = 0; 3448 errno =e;3035 errno = e; 3449 3036 return 0; 3450 3037 } … … 3452 3039 3453 3040 tx->len -= len; 3454 if (tx->len > 0) {3041 if (tx->len > 0) { 3455 3042 unsigned char *tmp = y_memdup(tx->queue + len, tx->len); 3456 3043 FREE(tx->queue); 3457 3044 tx->queue = tmp; 3458 3045 } else { 3459 YList *l =yid->txqueues;3046 YList *l = yid->txqueues; 3460 3047 free(tx->queue); 3461 3048 free(tx); 3462 yid->txqueues = y_list_remove_link(yid->txqueues, yid->txqueues); 3049 yid->txqueues = 3050 y_list_remove_link(yid->txqueues, yid->txqueues); 3463 3051 y_list_free_1(l); 3464 3052 /* 3465 if(!yid->txqueues) 3466 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3467 */ 3468 if(!yid->txqueues) { 3469 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3470 YAHOO_CALLBACK(ext_yahoo_remove_handler)(id, yid->write_tag); 3053 if(!yid->txqueues) 3054 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3055 */ 3056 if (!yid->txqueues) { 3057 LOG(("yahoo_write_ready(%d, %p) !txqueues", id, fd)); 3058 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, 3059 yid->write_tag); 3471 3060 yid->write_tag = 0; 3472 3061 } … … 3476 3065 } 3477 3066 3478 static void yahoo_process_pager_connection(struct yahoo_input_data *yid, int over) 3067 static void yahoo_process_pager_connection(struct yahoo_input_data *yid, 3068 int over) 3479 3069 { 3480 3070 struct yahoo_packet *pkt; … … 3482 3072 int id = yd->client_id; 3483 3073 3484 if (over)3485 return; 3486 3487 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER) 3488 3074 if (over) 3075 return; 3076 3077 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER) 3078 && (pkt = yahoo_getdata(yid)) != NULL) { 3489 3079 3490 3080 yahoo_packet_process(yid, pkt); … … 3494 3084 } 3495 3085 3496 static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over) 3497 { 3498 } 3499 3500 static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, int over) 3501 { 3502 if(over) 3503 return; 3504 3505 if (strstr((char*)yid->rxqueue+(yid->rxlen-20), "</content>")) { 3506 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml)(yid->yd->client_id, (char*)yid->rxqueue); 3086 static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, 3087 int over) 3088 { 3089 if (over) 3090 return; 3091 3092 if (strstr((char *)yid->rxqueue + (yid->rxlen - 20), "</content>")) { 3093 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, 3094 (char *)yid->rxqueue); 3507 3095 } 3508 3096 } … … 3513 3101 struct yab *yab; 3514 3102 YList *buds; 3515 int changed =0;3103 int changed = 0; 3516 3104 int id = yd->client_id; 3517 3518 if(over) 3519 return; 3520 3521 while(find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB) 3522 && (yab = yahoo_getyab(yid)) != NULL) { 3523 if(!yab->id) 3105 int yab_used = 0; 3106 3107 LOG(("Got data for YAB")); 3108 3109 if (over) 3110 return; 3111 3112 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB) 3113 && (yab = yahoo_getyab(yid)) != NULL) { 3114 if (!yab->id) 3524 3115 continue; 3525 changed=1; 3526 for(buds = yd->buddies; buds; buds=buds->next) { 3527 struct yahoo_buddy * bud = buds->data; 3528 if(!strcmp(bud->id, yab->id)) { 3116 3117 changed = 1; 3118 yab_used = 0; 3119 for (buds = yd->buddies; buds; buds = buds->next) { 3120 struct yahoo_buddy *bud = buds->data; 3121 if (!strcmp(bud->id, yab->id)) { 3122 yab_used = 1; 3529 3123 bud->yab_entry = yab; 3530 if (yab->nname) {3124 if (yab->nname) { 3531 3125 bud->real_name = strdup(yab->nname); 3532 } else if(yab->fname && yab->lname) { 3533 bud->real_name = y_new0(char, 3534 strlen(yab->fname)+ 3535 strlen(yab->lname)+2 3536 ); 3126 } else if (yab->fname && yab->lname) { 3127 bud->real_name = y_new0(char, 3128 strlen(yab->fname) + 3129 strlen(yab->lname) + 2); 3537 3130 sprintf(bud->real_name, "%s %s", 3538 3539 } else if (yab->fname) {3131 yab->fname, yab->lname); 3132 } else if (yab->fname) { 3540 3133 bud->real_name = strdup(yab->fname); 3541 3134 } 3542 break; 3135 break; /* for */ 3543 3136 } 3544 3137 } 3545 } 3546 3547 if(changed) 3548 YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); 3549 } 3550 3551 static void yahoo_process_search_connection(struct yahoo_input_data *yid, int over) 3552 { 3553 struct yahoo_found_contact *yct=NULL; 3138 3139 if (!yab_used) { 3140 FREE(yab->fname); 3141 FREE(yab->lname); 3142 FREE(yab->nname); 3143 FREE(yab->id); 3144 FREE(yab->email); 3145 FREE(yab->hphone); 3146 FREE(yab->wphone); 3147 FREE(yab->mphone); 3148 FREE(yab); 3149 } 3150 3151 } 3152 3153 if (changed) 3154 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, 3155 yd->buddies); 3156 } 3157 3158 static void yahoo_process_search_connection(struct yahoo_input_data *yid, 3159 int over) 3160 { 3161 struct yahoo_found_contact *yct = NULL; 3554 3162 char *p = (char *)yid->rxqueue, *np, *cp; 3555 3163 int k, n; 3556 int start=0, found=0, total=0; 3557 YList *contacts=NULL; 3558 struct yahoo_input_data *pyid = find_input_by_id_and_type(yid->yd->client_id, YAHOO_CONNECTION_PAGER); 3559 3560 if(!over || !pyid) 3561 return; 3562 3563 if(p && (p=strstr(p, "\r\n\r\n"))) { 3164 int start = 0, found = 0, total = 0; 3165 YList *contacts = NULL; 3166 struct yahoo_input_data *pyid = 3167 find_input_by_id_and_type(yid->yd->client_id, 3168 YAHOO_CONNECTION_PAGER); 3169 3170 if (!over || !pyid) 3171 return; 3172 3173 if (p && (p = strstr(p, "\r\n\r\n"))) { 3564 3174 p += 4; 3565 3175 3566 for (k = 0; (p = strchr(p, 4)) && (k < 4); k++) {3176 for (k = 0; (p = strchr(p, 4)) && (k < 4); k++) { 3567 3177 p++; 3568 3178 n = atoi(p); 3569 switch(k) { 3570 case 0: found = pyid->ys->lsearch_nfound = n; break; 3571 case 2: start = pyid->ys->lsearch_nstart = n; break; 3572 case 3: total = pyid->ys->lsearch_ntotal = n; break; 3179 switch (k) { 3180 case 0: 3181 found = pyid->ys->lsearch_nfound = n; 3182 break; 3183 case 2: 3184 start = pyid->ys->lsearch_nstart = n; 3185 break; 3186 case 3: 3187 total = pyid->ys->lsearch_ntotal = n; 3188 break; 3573 3189 } 3574 3190 } 3575 3191 3576 if (p)3192 if (p) 3577 3193 p++; 3578 3194 3579 k =0;3580 while (p && *p) {3195 k = 0; 3196 while (p && *p) { 3581 3197 cp = p; 3582 3198 np = strchr(p, 4); 3583 3199 3584 if (!np)3200 if (!np) 3585 3201 break; 3586 3202 *np = 0; 3587 p = np+1; 3588 3589 switch(k++) { 3590 case 1: 3591 if(strlen(cp) > 2 && y_list_length(contacts) < total) { 3592 yct = y_new0(struct yahoo_found_contact, 1); 3593 contacts = y_list_append(contacts, yct); 3594 yct->id = cp+2; 3595 } else { 3596 *p = 0; 3597 } 3598 break; 3599 case 2: 3600 yct->online = !strcmp(cp, "2") ? 1 : 0; 3601 break; 3602 case 3: 3603 yct->gender = cp; 3604 break; 3605 case 4: 3606 yct->age = atoi(cp); 3607 break; 3608 case 5: 3609 if(strcmp(cp, "5") != 0) 3610 yct->location = cp; 3611 k = 0; 3612 break; 3203 p = np + 1; 3204 3205 switch (k++) { 3206 case 1: 3207 if (strlen(cp) > 2 3208 && y_list_length(contacts) < total) { 3209 yct = y_new0(struct yahoo_found_contact, 3210 1); 3211 contacts = y_list_append(contacts, yct); 3212 yct->id = cp + 2; 3213 } else { 3214 *p = 0; 3215 } 3216 break; 3217 case 2: 3218 yct->online = !strcmp(cp, "2") ? 1 : 0; 3219 break; 3220 case 3: 3221 yct->gender = cp; 3222 break; 3223 case 4: 3224 yct->age = atoi(cp); 3225 break; 3226 case 5: 3227 /* not worth the context switch for strcmp */ 3228 if (cp[0] != '\005' || cp[1] != '\000') 3229 yct->location = cp; 3230 k = 0; 3231 break; 3613 3232 } 3614 3233 } 3615 3234 } 3616 3235 3617 YAHOO_CALLBACK(ext_yahoo_got_search_result)(yid->yd->client_id, found, start, total, contacts); 3618 3619 while(contacts) { 3236 YAHOO_CALLBACK(ext_yahoo_got_search_result) (yid->yd->client_id, found, 3237 start, total, contacts); 3238 3239 while (contacts) { 3620 3240 YList *node = contacts; 3621 3241 contacts = y_list_remove_link(contacts, node); … … 3625 3245 } 3626 3246 3627 static void _yahoo_webcam_connected( intfd, int error, void *d)3247 static void _yahoo_webcam_connected(void *fd, int error, void *d) 3628 3248 { 3629 3249 struct yahoo_input_data *yid = d; … … 3631 3251 struct yahoo_data *yd = yid->yd; 3632 3252 char conn_type[100]; 3633 char *data =NULL;3634 char *packet =NULL;3635 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) {3253 char *data = NULL; 3254 char *packet = NULL; 3255 unsigned char magic_nr[] = { 1, 0, 0, 0, 1 }; 3256 unsigned header_len = 0; 3257 unsigned int len = 0; 3258 unsigned int pos = 0; 3259 3260 if (error || !fd) { 3641 3261 FREE(yid); 3642 3262 return; … … 3648 3268 LOG(("Connected")); 3649 3269 /* send initial packet */ 3650 switch (wcm->direction) 3651 { 3652 case YAHOO_WEBCAM_DOWNLOAD: 3653 data = strdup("<REQIMG>"); 3654 break; 3655 case YAHOO_WEBCAM_UPLOAD: 3656 data = strdup("<SNDIMG>"); 3657 break; 3658 default: 3659 return; 3270 switch (wcm->direction) { 3271 case YAHOO_WEBCAM_DOWNLOAD: 3272 data = strdup("<REQIMG>"); 3273 break; 3274 case YAHOO_WEBCAM_UPLOAD: 3275 data = strdup("<SNDIMG>"); 3276 break; 3277 default: 3278 return; 3660 3279 } 3661 3280 yahoo_add_to_send_queue(yid, data, strlen(data)); … … 3663 3282 3664 3283 /* send data */ 3665 switch (wcm->direction) 3666 { 3667 case YAHOO_WEBCAM_DOWNLOAD: 3668 header_len = 8; 3669 data = strdup("a=2\r\nc=us\r\ne=21\r\nu="); 3670 data = y_string_append(data, yd->user); 3671 data = y_string_append(data, "\r\nt="); 3672 data = y_string_append(data, wcm->key); 3673 data = y_string_append(data, "\r\ni="); 3674 data = y_string_append(data, wcm->my_ip); 3675 data = y_string_append(data, "\r\ng="); 3676 data = y_string_append(data, wcm->user); 3677 data = y_string_append(data, "\r\no=w-2-5-1\r\np="); 3678 snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type); 3679 data = y_string_append(data, conn_type); 3680 data = y_string_append(data, "\r\n"); 3681 break; 3682 case YAHOO_WEBCAM_UPLOAD: 3683 header_len = 13; 3684 data = strdup("a=2\r\nc=us\r\nu="); 3685 data = y_string_append(data, yd->user); 3686 data = y_string_append(data, "\r\nt="); 3687 data = y_string_append(data, wcm->key); 3688 data = y_string_append(data, "\r\ni="); 3689 data = y_string_append(data, wcm->my_ip); 3690 data = y_string_append(data, "\r\no=w-2-5-1\r\np="); 3691 snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type); 3692 data = y_string_append(data, conn_type); 3693 data = y_string_append(data, "\r\nb="); 3694 data = y_string_append(data, wcm->description); 3695 data = y_string_append(data, "\r\n"); 3696 break; 3284 switch (wcm->direction) { 3285 case YAHOO_WEBCAM_DOWNLOAD: 3286 header_len = 8; 3287 data = strdup("a=2\r\nc=us\r\ne=21\r\nu="); 3288 data = y_string_append(data, yd->user); 3289 data = y_string_append(data, "\r\nt="); 3290 data = y_string_append(data, wcm->key); 3291 data = y_string_append(data, "\r\ni="); 3292 data = y_string_append(data, wcm->my_ip); 3293 data = y_string_append(data, "\r\ng="); 3294 data = y_string_append(data, wcm->user); 3295 data = y_string_append(data, "\r\no=w-2-5-1\r\np="); 3296 snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type); 3297 data = y_string_append(data, conn_type); 3298 data = y_string_append(data, "\r\n"); 3299 break; 3300 case YAHOO_WEBCAM_UPLOAD: 3301 header_len = 13; 3302 data = strdup("a=2\r\nc=us\r\nu="); 3303 data = y_string_append(data, yd->user); 3304 data = y_string_append(data, "\r\nt="); 3305 data = y_string_append(data, wcm->key); 3306 data = y_string_append(data, "\r\ni="); 3307 data = y_string_append(data, wcm->my_ip); 3308 data = y_string_append(data, "\r\no=w-2-5-1\r\np="); 3309 snprintf(conn_type, sizeof(conn_type), "%d", wcm->conn_type); 3310 data = y_string_append(data, conn_type); 3311 data = y_string_append(data, "\r\nb="); 3312 data = y_string_append(data, wcm->description); 3313 data = y_string_append(data, "\r\n"); 3314 break; 3697 3315 } 3698 3316 … … 3701 3319 packet[pos++] = header_len; 3702 3320 packet[pos++] = 0; 3703 switch (wcm->direction) 3704 { 3705 case YAHOO_WEBCAM_DOWNLOAD: 3706 packet[pos++] = 1; 3707 packet[pos++] = 0; 3708 break; 3709 case YAHOO_WEBCAM_UPLOAD: 3710 packet[pos++] = 5; 3711 packet[pos++] = 0; 3712 break; 3321 switch (wcm->direction) { 3322 case YAHOO_WEBCAM_DOWNLOAD: 3323 packet[pos++] = 1; 3324 packet[pos++] = 0; 3325 break; 3326 case YAHOO_WEBCAM_UPLOAD: 3327 packet[pos++] = 5; 3328 packet[pos++] = 0; 3329 break; 3713 3330 } 3714 3331 3715 3332 pos += yahoo_put32(packet + pos, len); 3716 if (wcm->direction == YAHOO_WEBCAM_UPLOAD) 3717 { 3333 if (wcm->direction == YAHOO_WEBCAM_UPLOAD) { 3718 3334 memcpy(packet + pos, magic_nr, sizeof(magic_nr)); 3719 3335 pos += sizeof(magic_nr); … … 3724 3340 FREE(data); 3725 3341 3726 yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid); 3342 yid->read_tag = 3343 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, 3344 yid->fd, YAHOO_INPUT_READ, yid); 3727 3345 } 3728 3346 … … 3749 3367 3750 3368 LOG(("Connecting to: %s:%d", wcm->server, wcm->port)); 3751 YAHOO_CALLBACK(ext_yahoo_connect_async)(y->yd->client_id, wcm->server, wcm->port, 3752 _yahoo_webcam_connected, yid); 3753 3754 } 3755 3756 static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid, int over) 3757 { 3758 char* server; 3369 YAHOO_CALLBACK(ext_yahoo_connect_async) (y->yd->client_id, wcm->server, 3370 wcm->port, _yahoo_webcam_connected, yid, 0); 3371 3372 } 3373 3374 static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid, 3375 int over) 3376 { 3377 char *server; 3759 3378 struct yahoo_server_settings *yss; 3760 3379 3761 if (over)3380 if (over) 3762 3381 return; 3763 3382 3764 3383 server = yahoo_getwebcam_master(yid); 3765 3384 3766 if (server) 3767 { 3385 if (server) { 3768 3386 yss = yid->yd->server_settings; 3769 3387 yid->wcm->server = strdup(server); … … 3778 3396 } 3779 3397 3780 static void yahoo_process_webcam_connection(struct yahoo_input_data *yid, int over) 3398 static void yahoo_process_webcam_connection(struct yahoo_input_data *yid, 3399 int over) 3781 3400 { 3782 3401 int id = yid->yd->client_id; 3783 intfd = yid->fd;3784 3785 if (over)3402 void *fd = yid->fd; 3403 3404 if (over) 3786 3405 return; 3787 3406 3788 3407 /* as long as we still have packets available keep processing them */ 3789 while (find_input_by_id_and_fd(id, fd) 3790 && yahoo_get_webcam_data(yid) == 1); 3791 } 3792 3793 static void (*yahoo_process_connection[])(struct yahoo_input_data *, int over) = { 3794 yahoo_process_pager_connection, 3795 yahoo_process_ft_connection, 3796 yahoo_process_yab_connection, 3797 yahoo_process_webcam_master_connection, 3798 yahoo_process_webcam_connection, 3799 yahoo_process_chatcat_connection, 3800 yahoo_process_search_connection, 3801 }; 3802 3803 int yahoo_read_ready(int id, int fd, void *data) 3408 while (find_input_by_id_and_fd(id, fd) 3409 && yahoo_get_webcam_data(yid) == 1) ; 3410 } 3411 3412 static void (*yahoo_process_connection[]) (struct yahoo_input_data *, 3413 int over) = { 3414 yahoo_process_pager_connection, yahoo_process_ft_connection, 3415 yahoo_process_yab_connection, 3416 yahoo_process_webcam_master_connection, 3417 yahoo_process_webcam_connection, 3418 yahoo_process_chatcat_connection, 3419 yahoo_process_search_connection}; 3420 3421 int yahoo_read_ready(int id, void *fd, void *data) 3804 3422 { 3805 3423 struct yahoo_input_data *yid = data; … … 3807 3425 int len; 3808 3426 3809 LOG(("read callback: id=%d fd=% ddata=%p", id, fd, data));3810 if (!yid)3427 LOG(("read callback: id=%d fd=%p data=%p", id, fd, data)); 3428 if (!yid) 3811 3429 return -2; 3812 3430 3813 3814 3431 do { 3815 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 */3432 len = YAHOO_CALLBACK(ext_yahoo_read) (fd, buf, sizeof(buf)); 3433 } while (len == -1 && errno == EINTR); 3434 3435 if (len == -1 && (errno == EAGAIN || errno == EINTR)) /* we'll try again later */ 3819 3436 return 1; 3820 3437 … … 3823 3440 DEBUG_MSG(("len == %d (<= 0)", len)); 3824 3441 3825 if(yid->type == YAHOO_CONNECTION_PAGER) { 3826 YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION); 3827 } 3828 3829 yahoo_process_connection[yid->type](yid, 1); 3442 if (yid->type == YAHOO_CONNECTION_PAGER) { 3443 YAHOO_CALLBACK(ext_yahoo_login_response) (yid->yd-> 3444 client_id, YAHOO_LOGIN_SOCK, NULL); 3445 } 3446 3447 yahoo_process_connection[yid->type] (yid, 1); 3830 3448 yahoo_input_close(yid); 3831 3449 3832 3450 /* no need to return an error, because we've already fixed it */ 3833 if (len == 0)3451 if (len == 0) 3834 3452 return 1; 3835 3453 3836 errno =e;3454 errno = e; 3837 3455 LOG(("read error: %s", strerror(errno))); 3838 3456 return -1; 3839 3457 } 3840 3458 3841 yid->rxqueue = y_renew(unsigned char, yid->rxqueue, len + yid->rxlen); 3459 yid->rxqueue = 3460 y_renew(unsigned char, yid->rxqueue, len + yid->rxlen + 1); 3842 3461 memcpy(yid->rxqueue + yid->rxlen, buf, len); 3843 3462 yid->rxlen += len; 3844 3845 yahoo_process_connection[yid->type](yid, 0); 3463 yid->rxqueue[yid->rxlen] = 0; 3464 3465 yahoo_process_connection[yid->type] (yid, 0); 3846 3466 3847 3467 return len; … … 3855 3475 yd = y_new0(struct yahoo_data, 1); 3856 3476 3857 if (!yd)3477 if (!yd) 3858 3478 return 0; 3859 3479 … … 3880 3500 } 3881 3501 3882 struct connect_callback_data { 3883 struct yahoo_data *yd; 3884 int tag; 3885 int i; 3886 }; 3887 3888 static void yahoo_connected(int fd, int error, void *data) 3502 static void yahoo_connected(void *fd, int error, void *data) 3889 3503 { 3890 3504 struct connect_callback_data *ccd = data; … … 3894 3508 struct yahoo_server_settings *yss = yd->server_settings; 3895 3509 3896 if(error) { 3897 if(fallback_ports[ccd->i]) { 3898 int tag; 3510 if (error) { 3511 int tag; 3512 if (fallback_ports[ccd->i]) { 3513 char *host = yss->pager_host; 3514 3515 if (!host) 3516 host = yss->pager_host_list[ccd->server_i]; 3517 3899 3518 yss->pager_port = fallback_ports[ccd->i++]; 3900 tag = YAHOO_CALLBACK(ext_yahoo_connect_async)(yd->client_id, yss->pager_host, 3901 yss->pager_port, yahoo_connected, ccd); 3902 3903 if(tag > 0) 3904 ccd->tag=tag; 3519 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd-> 3520 client_id, host, yss->pager_port, 3521 yahoo_connected, ccd, 0); 3522 3523 if (tag > 0) 3524 ccd->tag = tag; 3525 } else if (yss->pager_host_list 3526 && yss->pager_host_list[ccd->server_i]) { 3527 3528 /* Get back to the default port */ 3529 yss->pager_port = pager_port; 3530 ccd->server_i++; 3531 LOG(("Fallback: Connecting to %s:%d", yss->pager_host_list[ccd->server_i], yss->pager_port)); 3532 3533 ccd->i = 0; 3534 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, 3535 yss->pager_host_list[ccd->server_i], yss->pager_port, 3536 yahoo_connected, ccd, 0); 3905 3537 } else { 3906 3538 FREE(ccd); 3907 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_SOCK, NULL); 3539 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3540 YAHOO_LOGIN_SOCK, NULL); 3908 3541 } 3909 3542 return; … … 3912 3545 FREE(ccd); 3913 3546 3914 /* fd < 0 && error == 0 means connect was cancelled */ 3915 if(fd < 0) 3916 return; 3917 3918 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 3547 /* fd == NULL && error == 0 means connect was cancelled */ 3548 if (!fd) 3549 return; 3550 3551 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT, 3552 yd->session_id); 3919 3553 NOTICE(("Sending initial packet")); 3920 3554 3921 3555 yahoo_packet_hash(pkt, 1, yd->user); 3922 3556 3923 yid = y_new0(struct yahoo_input_data, 1); 3924 yid->yd = yd; 3557 yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER); 3925 3558 yid->fd = fd; 3926 inputs = y_list_prepend(inputs, yid);3927 3559 3928 3560 yahoo_send_packet(yid, pkt, 0); … … 3930 3562 yahoo_packet_free(pkt); 3931 3563 3932 yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, yid->fd, YAHOO_INPUT_READ, yid); 3933 } 3934 3935 void yahoo_login(int id, int initial) 3936 { 3937 struct yahoo_data *yd = find_conn_by_id(id); 3938 struct connect_callback_data *ccd; 3939 struct yahoo_server_settings *yss; 3940 int tag; 3941 3942 if(!yd) 3943 return; 3944 3945 yss = yd->server_settings; 3946 3947 yd->initial_status = initial; 3948 3949 ccd = y_new0(struct connect_callback_data, 1); 3950 ccd->yd = yd; 3951 tag = YAHOO_CALLBACK(ext_yahoo_connect_async)(yd->client_id, yss->pager_host, yss->pager_port, 3952 yahoo_connected, ccd); 3953 3954 /* 3955 * if tag <= 0, then callback has already been called 3956 * so ccd will have been freed 3957 */ 3958 if(tag > 0) 3959 ccd->tag = tag; 3960 else if(tag < 0) 3961 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_SOCK, NULL); 3962 } 3963 3964 3965 int yahoo_get_fd(int id) 3966 { 3967 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3968 if(!yid) 3564 yid->read_tag = 3565 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, 3566 yid->fd, YAHOO_INPUT_READ, yid); 3567 } 3568 3569 void *yahoo_get_fd(int id) 3570 { 3571 struct yahoo_input_data *yid = 3572 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3573 if (!yid) 3969 3574 return 0; 3970 3575 else … … 3972 3577 } 3973 3578 3974 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture) 3975 { 3976 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3579 void yahoo_send_buzz(int id, const char *from, const char *who) 3580 { 3581 yahoo_send_im(id, from, who, "<ding>", 1, 0); 3582 } 3583 3584 void yahoo_send_im(int id, const char *from, const char *who, const char *what, 3585 int utf8, int picture) 3586 { 3587 struct yahoo_input_data *yid = 3588 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3977 3589 struct yahoo_packet *pkt = NULL; 3978 3590 struct yahoo_data *yd; 3979 3591 char pic_str[10]; 3980 3592 3981 if (!yid)3593 if (!yid) 3982 3594 return; 3983 3595 3984 3596 yd = yid->yd; 3985 3597 3986 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); 3598 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 3599 yd->session_id); 3987 3600 3988 3601 snprintf(pic_str, sizeof(pic_str), "%d", picture); 3989 3990 if (from && strcmp(from, yd->user))3602 3603 if (from && strcmp(from, yd->user)) 3991 3604 yahoo_packet_hash(pkt, 0, yd->user); 3992 yahoo_packet_hash(pkt, 1, from ?from:yd->user);3605 yahoo_packet_hash(pkt, 1, from ? from : yd->user); 3993 3606 yahoo_packet_hash(pkt, 5, who); 3994 3607 yahoo_packet_hash(pkt, 14, what); 3995 3608 3996 if (utf8)3609 if (utf8) 3997 3610 yahoo_packet_hash(pkt, 97, "1"); 3998 3611 … … 4001 3614 yahoo_packet_hash(pkt, 206, pic_str); 4002 3615 4003 4004 3616 yahoo_send_packet(yid, pkt, 0); 4005 3617 … … 4009 3621 void yahoo_send_typing(int id, const char *from, const char *who, int typ) 4010 3622 { 4011 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3623 struct yahoo_input_data *yid = 3624 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4012 3625 struct yahoo_data *yd; 4013 3626 struct yahoo_packet *pkt = NULL; 4014 if (!yid)3627 if (!yid) 4015 3628 return; 4016 3629 4017 3630 yd = yid->yd; 4018 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_NOTIFY, yd->session_id); 3631 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY, 3632 yd->session_id); 4019 3633 4020 3634 yahoo_packet_hash(pkt, 5, who); 4021 yahoo_packet_hash(pkt, 1, from ?from:yd->user);3635 yahoo_packet_hash(pkt, 1, from ? from : yd->user); 4022 3636 yahoo_packet_hash(pkt, 14, " "); 4023 3637 yahoo_packet_hash(pkt, 13, typ ? "1" : "0"); … … 4031 3645 void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away) 4032 3646 { 4033 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3647 struct yahoo_input_data *yid = 3648 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4034 3649 struct yahoo_data *yd; 4035 3650 struct yahoo_packet *pkt = NULL; … … 4037 3652 char s[4]; 4038 3653 4039 if (!yid)3654 if (!yid) 4040 3655 return; 4041 3656 4042 3657 yd = yid->yd; 3658 4043 3659 old_status = yd->current_status; 4044 3660 yd->current_status = state; … … 4046 3662 /* Thank you libpurple :) */ 4047 3663 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 4048 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 3664 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, 3665 YAHOO_STATUS_AVAILABLE, 0); 4049 3666 yahoo_packet_hash(pkt, 13, "2"); 4050 3667 yahoo_send_packet(yid, pkt, 0); … … 4054 3671 } 4055 3672 4056 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); 3673 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, 3674 yd->current_status, yd->session_id); 4057 3675 snprintf(s, sizeof(s), "%d", yd->current_status); 4058 3676 yahoo_packet_hash(pkt, 10, s); … … 4062 3680 yahoo_packet_free(pkt); 4063 3681 4064 if(old_status == YAHOO_STATUS_INVISIBLE) { 4065 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 3682 if (old_status == YAHOO_STATUS_INVISIBLE) { 3683 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, 3684 YAHOO_STATUS_AVAILABLE, 0); 4066 3685 yahoo_packet_hash(pkt, 13, "1"); 4067 3686 yahoo_send_packet(yid, pkt, 0); … … 4072 3691 void yahoo_logoff(int id) 4073 3692 { 4074 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3693 struct yahoo_input_data *yid = 3694 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4075 3695 struct yahoo_data *yd; 4076 3696 struct yahoo_packet *pkt = NULL; 4077 3697 4078 if (!yid)3698 if (!yid) 4079 3699 return; 4080 3700 yd = yid->yd; … … 4082 3702 LOG(("yahoo_logoff: current status: %d", yd->current_status)); 4083 3703 4084 if (yd->current_status != -1 && 0) {3704 if (yd->current_status != -1 && 0) { 4085 3705 /* Meh. Don't send this. The event handlers are not going to 4086 3706 get to do this so it'll just leak memory. And the TCP 4087 3707 connection reset will hopefully be clear enough. */ 4088 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id); 3708 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, 3709 YPACKET_STATUS_DEFAULT, yd->session_id); 4089 3710 yd->current_status = -1; 4090 3711 … … 4095 3716 } 4096 3717 4097 do {3718 /* do { 4098 3719 yahoo_input_close(yid); 4099 } while((yid = find_input_by_id(id))); 3720 } while((yid = find_input_by_id(id)));*/ 3721 4100 3722 } 4101 3723 4102 3724 void yahoo_get_list(int id) 4103 3725 { 4104 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3726 struct yahoo_input_data *yid = 3727 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4105 3728 struct yahoo_data *yd; 4106 3729 struct yahoo_packet *pkt = NULL; 4107 3730 4108 if (!yid)3731 if (!yid) 4109 3732 return; 4110 3733 yd = yid->yd; 4111 3734 4112 pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_AVAILABLE, yd->session_id); 3735 pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YPACKET_STATUS_DEFAULT, 3736 yd->session_id); 4113 3737 yahoo_packet_hash(pkt, 1, yd->user); 4114 3738 if (pkt) { … … 4118 3742 } 4119 3743 4120 static void _yahoo_http_connected(int id, intfd, int error, void *data)3744 static void _yahoo_http_connected(int id, void *fd, int error, void *data) 4121 3745 { 4122 3746 struct yahoo_input_data *yid = data; 4123 if (fd <= 0) {3747 if (fd == NULL || error) { 4124 3748 inputs = y_list_remove(inputs, yid); 4125 3749 FREE(yid); … … 4128 3752 4129 3753 yid->fd = fd; 4130 yid->read_tag=YAHOO_CALLBACK(ext_yahoo_add_handler)(yid->yd->client_id, fd, YAHOO_INPUT_READ, yid); 4131 } 4132 3754 yid->read_tag = 3755 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, 3756 YAHOO_INPUT_READ, yid); 3757 } 3758 3759 /* FIXME Get address book from address.yahoo.com instead */ 4133 3760 void yahoo_get_yab(int id) 4134 3761 { 3762 struct yahoo_data *yd = find_conn_by_id(id); 3763 struct yahoo_input_data *yid; 3764 char url[1024]; 3765 char buff[2048]; 3766 3767 if (!yd) 3768 return; 3769 3770 yid = y_new0(struct yahoo_input_data, 1); 3771 yid->yd = yd; 3772 yid->type = YAHOO_CONNECTION_YAB; 3773 3774 LOG(("Sending request for Address Book")); 3775 3776 snprintf(url, 1024, 3777 "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us" 3778 "&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252"); 3779 3780 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 3781 3782 inputs = y_list_prepend(inputs, yid); 3783 3784 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 3785 _yahoo_http_connected, yid); 3786 } 3787 3788 struct yahoo_post_data { 3789 struct yahoo_input_data *yid; 3790 char *data; 3791 }; 3792 3793 static void _yahoo_http_post_connected(int id, void *fd, int error, void *data) 3794 { 3795 struct yahoo_post_data *yad = data; 3796 struct yahoo_input_data *yid = yad->yid; 3797 char *buff = yad->data; 3798 3799 if (!fd) { 3800 inputs = y_list_remove(inputs, yid); 3801 FREE(yid); 3802 return; 3803 } 3804 3805 YAHOO_CALLBACK(ext_yahoo_write) (fd, buff, strlen(buff)); 3806 3807 yid->fd = fd; 3808 yid->read_tag = 3809 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, 3810 YAHOO_INPUT_READ, yid); 3811 3812 FREE(buff); 3813 FREE(yad); 3814 } 3815 3816 /* FIXME This is also likely affected */ 3817 void yahoo_set_yab(int id, struct yab *yab) 3818 { 3819 struct yahoo_post_data *yad = y_new0(struct yahoo_post_data, 1); 4135 3820 struct yahoo_data *yd = find_conn_by_id(id); 4136 3821 struct yahoo_input_data *yid; 4137 3822 char url[1024]; 4138 3823 char buff[1024]; 4139 4140 if(!yd) 4141 return; 4142 4143 yid = y_new0(struct yahoo_input_data, 1); 4144 yid->yd = yd; 4145 yid->type = YAHOO_CONNECTION_YAB; 4146 4147 snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?ab2=0"); 4148 4149 snprintf(buff, sizeof(buff), "Y=%s; T=%s", 4150 yd->cookie_y, yd->cookie_t); 4151 4152 inputs = y_list_prepend(inputs, yid); 4153 4154 yahoo_http_get(yid->yd->client_id, url, buff, 4155 _yahoo_http_connected, yid); 4156 } 4157 4158 void yahoo_set_yab(int id, struct yab * yab) 4159 { 4160 struct yahoo_data *yd = find_conn_by_id(id); 4161 struct yahoo_input_data *yid; 4162 char url[1024]; 4163 char buff[1024]; 4164 char *temp; 4165 int size = sizeof(url)-1; 4166 4167 if(!yd) 3824 char post[1024]; 3825 int size = 0; 3826 3827 if (!yd) 4168 3828 return; 4169 3829 … … 4172 3832 yid->yd = yd; 4173 3833 4174 strncpy(url, "http://insider.msg.yahoo.com/ycontent/?addab2=0", size); 4175 4176 if(yab->dbid) { 4177 /* change existing yab */ 4178 char tmp[32]; 4179 strncat(url, "&ee=1&ow=1&id=", size - strlen(url)); 4180 snprintf(tmp, sizeof(tmp), "%d", yab->dbid); 4181 strncat(url, tmp, size - strlen(url)); 4182 } 4183 4184 if(yab->fname) { 4185 strncat(url, "&fn=", size - strlen(url)); 4186 temp = yahoo_urlencode(yab->fname); 4187 strncat(url, temp, size - strlen(url)); 4188 free(temp); 4189 } 4190 if(yab->lname) { 4191 strncat(url, "&ln=", size - strlen(url)); 4192 temp = yahoo_urlencode(yab->lname); 4193 strncat(url, temp, size - strlen(url)); 4194 free(temp); 4195 } 4196 strncat(url, "&yid=", size - strlen(url)); 4197 temp = yahoo_urlencode(yab->id); 4198 strncat(url, temp, size - strlen(url)); 4199 free(temp); 4200 if(yab->nname) { 4201 strncat(url, "&nn=", size - strlen(url)); 4202 temp = yahoo_urlencode(yab->nname); 4203 strncat(url, temp, size - strlen(url)); 4204 free(temp); 4205 } 4206 if(yab->email) { 4207 strncat(url, "&e=", size - strlen(url)); 4208 temp = yahoo_urlencode(yab->email); 4209 strncat(url, temp, size - strlen(url)); 4210 free(temp); 4211 } 4212 if(yab->hphone) { 4213 strncat(url, "&hp=", size - strlen(url)); 4214 temp = yahoo_urlencode(yab->hphone); 4215 strncat(url, temp, size - strlen(url)); 4216 free(temp); 4217 } 4218 if(yab->wphone) { 4219 strncat(url, "&wp=", size - strlen(url)); 4220 temp = yahoo_urlencode(yab->wphone); 4221 strncat(url, temp, size - strlen(url)); 4222 free(temp); 4223 } 4224 if(yab->mphone) { 4225 strncat(url, "&mp=", size - strlen(url)); 4226 temp = yahoo_urlencode(yab->mphone); 4227 strncat(url, temp, size - strlen(url)); 4228 free(temp); 4229 } 4230 strncat(url, "&pp=0", size - strlen(url)); 4231 4232 snprintf(buff, sizeof(buff), "Y=%s; T=%s", 4233 yd->cookie_y, yd->cookie_t); 3834 if(yab->yid) 3835 size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 3836 "<ab k=\"%s\" cc=\"%d\">" 3837 "<ct id=\"%d\" e=\"1\" yi=\"%s\" nn=\"%s\" />" 3838 "</ab>", yd->user, 9, yab->yid, /* Don't know why */ 3839 yab->id, yab->nname?yab->nname:""); 3840 else 3841 size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 3842 "<ab k=\"%s\" cc=\"%d\">" 3843 "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />" 3844 "</ab>", yd->user, 1, /* Don't know why */ 3845 yab->id, yab->nname?yab->nname:""); 3846 3847 yad->yid = yid; 3848 yad->data = strdup(post); 3849 3850 strcpy(url, "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us" 3851 "&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252"); 3852 3853 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 4234 3854 4235 3855 inputs = y_list_prepend(inputs, yid); 4236 3856 4237 yahoo_http_get(yid->yd->client_id, url, buff, 4238 _yahoo_http_connected, yid); 4239 } 4240 4241 void yahoo_set_identity_status(int id, const char * identity, int active) 4242 { 4243 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3857 yahoo_http_post(yid->yd->client_id, url, buff, size, 3858 _yahoo_http_post_connected, yad); 3859 } 3860 3861 void yahoo_set_identity_status(int id, const char *identity, int active) 3862 { 3863 struct yahoo_input_data *yid = 3864 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4244 3865 struct yahoo_data *yd; 4245 3866 struct yahoo_packet *pkt = NULL; 4246 3867 4247 if (!yid)3868 if (!yid) 4248 3869 return; 4249 3870 yd = yid->yd; 4250 3871 4251 pkt = yahoo_packet_new(active ?YAHOO_SERVICE_IDACT:YAHOO_SERVICE_IDDEACT,4252 YAHOO_STATUS_AVAILABLE, yd->session_id);3872 pkt = yahoo_packet_new(active ? YAHOO_SERVICE_IDACT : 3873 YAHOO_SERVICE_IDDEACT, YPACKET_STATUS_DEFAULT, yd->session_id); 4253 3874 yahoo_packet_hash(pkt, 3, identity); 4254 3875 if (pkt) { … … 4260 3881 void yahoo_refresh(int id) 4261 3882 { 4262 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3883 struct yahoo_input_data *yid = 3884 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4263 3885 struct yahoo_data *yd; 4264 3886 struct yahoo_packet *pkt = NULL; 4265 3887 4266 if (!yid)3888 if (!yid) 4267 3889 return; 4268 3890 yd = yid->yd; 4269 3891 4270 pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YAHOO_STATUS_AVAILABLE, yd->session_id); 3892 pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YPACKET_STATUS_DEFAULT, 3893 yd->session_id); 4271 3894 if (pkt) { 4272 3895 yahoo_send_packet(yid, pkt, 0); … … 4277 3900 void yahoo_keepalive(int id) 4278 3901 { 4279 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3902 struct yahoo_input_data *yid = 3903 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4280 3904 struct yahoo_data *yd; 4281 struct yahoo_packet *pkt =NULL;4282 if (!yid)3905 struct yahoo_packet *pkt = NULL; 3906 if (!yid) 4283 3907 return; 4284 3908 yd = yid->yd; 4285 3909 4286 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, yd->session_id); 3910 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YPACKET_STATUS_DEFAULT, 3911 yd->session_id); 4287 3912 yahoo_send_packet(yid, pkt, 0); 4288 3913 yahoo_packet_free(pkt); 4289 3914 } 4290 3915 4291 void yahoo_chat_keepalive (int id) 4292 { 4293 struct yahoo_input_data *yid = find_input_by_id_and_type (id, YAHOO_CONNECTION_PAGER); 3916 void yahoo_chat_keepalive(int id) 3917 { 3918 struct yahoo_input_data *yid = 3919 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4294 3920 struct yahoo_data *yd; 4295 3921 struct yahoo_packet *pkt = NULL; 4296 3922 4297 3923 if (!yid) 4298 3924 return; 4299 3925 4300 3926 yd = yid->yd; 4301 3927 4302 pkt = yahoo_packet_new (YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, yd->session_id); 4303 yahoo_send_packet (yid, pkt, 0); 4304 yahoo_packet_free (pkt); 4305 } 4306 4307 void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg) 4308 { 4309 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3928 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YPACKET_STATUS_DEFAULT, 3929 yd->session_id); 3930 yahoo_send_packet(yid, pkt, 0); 3931 yahoo_packet_free(pkt); 3932 } 3933 3934 void yahoo_add_buddy(int id, const char *who, const char *group, 3935 const char *msg) 3936 { 3937 struct yahoo_input_data *yid = 3938 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4310 3939 struct yahoo_data *yd; 4311 3940 struct yahoo_packet *pkt; 4312 3941 4313 if (!yid)3942 if (!yid) 4314 3943 return; 4315 3944 yd = yid->yd; … … 4318 3947 return; 4319 3948 4320 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, yd->session_id);4321 4322 if (msg != NULL) 3949 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, 3950 yd->session_id); 3951 if (msg != NULL) /* add message/request "it's me add me" */ 4323 3952 yahoo_packet_hash(pkt, 14, msg); 4324 3953 else 4325 yahoo_packet_hash(pkt,14,""); 4326 3954 yahoo_packet_hash(pkt, 14, ""); 4327 3955 yahoo_packet_hash(pkt, 65, group); 4328 3956 yahoo_packet_hash(pkt, 97, "1"); … … 4334 3962 yahoo_packet_hash(pkt, 301, "319"); 4335 3963 yahoo_packet_hash(pkt, 303, "319"); 4336 4337 4338 3964 yahoo_send_packet(yid, pkt, 0); 4339 3965 yahoo_packet_free(pkt); … … 4342 3968 void yahoo_remove_buddy(int id, const char *who, const char *group) 4343 3969 { 4344 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3970 struct yahoo_input_data *yid = 3971 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4345 3972 struct yahoo_data *yd; 4346 3973 struct yahoo_packet *pkt = NULL; 4347 3974 4348 if (!yid)3975 if (!yid) 4349 3976 return; 4350 3977 yd = yid->yd; 4351 3978 4352 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); 3979 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YPACKET_STATUS_DEFAULT, 3980 yd->session_id); 4353 3981 4354 3982 yahoo_packet_hash(pkt, 1, yd->user); … … 4359 3987 } 4360 3988 4361 void yahoo_accept_buddy_ymsg13(int id,const char* me,const char* who){ 4362 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3989 void yahoo_confirm_buddy(int id, const char *who, int reject, const char *msg) 3990 { 3991 struct yahoo_input_data *yid = 3992 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4363 3993 struct yahoo_data *yd; 4364 4365 if(!yid) 3994 struct yahoo_packet *pkt; 3995 3996 if (!yid) 4366 3997 return; 4367 3998 yd = yid->yd; 4368 3999 4369 struct yahoo_packet* pkt=NULL; 4370 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4371 4372 yahoo_packet_hash(pkt,1,me ?: yd->user); 4373 yahoo_packet_hash(pkt,5,who); 4374 yahoo_packet_hash(pkt,13,"1"); 4375 yahoo_packet_hash(pkt,334,"0"); 4000 if (!yd->logged_in) 4001 return; 4002 4003 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_AUTHORIZATION, 4004 YPACKET_STATUS_DEFAULT, yd->session_id); 4005 yahoo_packet_hash(pkt, 1, yd->user); 4006 yahoo_packet_hash(pkt, 5, who); 4007 if (reject) 4008 yahoo_packet_hash(pkt, 13, "2"); 4009 else { 4010 yahoo_packet_hash(pkt, 241, "0"); 4011 yahoo_packet_hash(pkt, 13, "1"); 4012 } 4013 4014 yahoo_packet_hash(pkt, 334, "0"); 4015 4016 if (reject) { 4017 yahoo_packet_hash(pkt, 14, msg ? msg : ""); 4018 yahoo_packet_hash(pkt, 97, "1"); 4019 } 4020 4376 4021 yahoo_send_packet(yid, pkt, 0); 4377 4022 yahoo_packet_free(pkt); 4378 4023 } 4379 4024 4380 void yahoo_reject_buddy_ymsg13(int id,const char* me,const char* who,const char* msg){ 4381 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4025 void yahoo_ignore_buddy(int id, const char *who, int unignore) 4026 { 4027 struct yahoo_input_data *yid = 4028 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4382 4029 struct yahoo_data *yd; 4383 4384 if(!yid) 4030 struct yahoo_packet *pkt; 4031 4032 if (!yid) 4385 4033 return; 4386 4034 yd = yid->yd; 4387 4035 4388 struct yahoo_packet* pkt=NULL; 4389 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4390 4391 yahoo_packet_hash(pkt,1,me ?: yd->user); 4392 yahoo_packet_hash(pkt,5,who); 4393 // yahoo_packet_hash(pkt,241,YAHOO_PROTO_VER); 4394 yahoo_packet_hash(pkt,13,"2"); 4395 yahoo_packet_hash(pkt,334,"0"); 4396 yahoo_packet_hash(pkt,97,"1"); 4397 yahoo_packet_hash(pkt,14,msg?:""); 4398 4036 if (!yd->logged_in) 4037 return; 4038 4039 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, 4040 YPACKET_STATUS_DEFAULT, yd->session_id); 4041 yahoo_packet_hash(pkt, 1, yd->user); 4042 yahoo_packet_hash(pkt, 7, who); 4043 yahoo_packet_hash(pkt, 13, unignore ? "2" : "1"); 4399 4044 yahoo_send_packet(yid, pkt, 0); 4400 4045 yahoo_packet_free(pkt); 4401 4402 } 4403 4404 void yahoo_reject_buddy(int id, const char *who, const char *msg) 4405 { 4406 struct yahoo_input_data *yid =find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);4046 } 4047 4048 void yahoo_stealth_buddy(int id, const char *who, int unstealth) 4049 { 4050 struct yahoo_input_data *yid = 4051 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4407 4052 struct yahoo_data *yd; 4408 4053 struct yahoo_packet *pkt; 4409 4054 4410 if (!yid)4055 if (!yid) 4411 4056 return; 4412 4057 yd = yid->yd; … … 4415 4060 return; 4416 4061 4417 pkt = yahoo_packet_new(YAHOO_SERVICE_REJECTCONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); 4062 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH_PERM, 4063 YPACKET_STATUS_DEFAULT, yd->session_id); 4418 4064 yahoo_packet_hash(pkt, 1, yd->user); 4419 4065 yahoo_packet_hash(pkt, 7, who); 4420 yahoo_packet_hash(pkt, 14, msg); 4421 yahoo_send_packet(yid, pkt, 0); 4422 yahoo_packet_free(pkt); 4423 } 4424 4425 void yahoo_ignore_buddy(int id, const char *who, int unignore) 4426 { 4427 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4428 struct yahoo_data *yd; 4429 struct yahoo_packet *pkt; 4430 4431 if(!yid) 4432 return; 4433 yd = yid->yd; 4434 4435 if (!yd->logged_in) 4436 return; 4437 4438 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); 4439 yahoo_packet_hash(pkt, 1, yd->user); 4440 yahoo_packet_hash(pkt, 7, who); 4441 yahoo_packet_hash(pkt, 13, unignore?"2":"1"); 4442 yahoo_send_packet(yid, pkt, 0); 4443 yahoo_packet_free(pkt); 4444 } 4445 4446 void yahoo_stealth_buddy(int id, const char *who, int unstealth) 4447 { 4448 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4449 struct yahoo_data *yd; 4450 struct yahoo_packet *pkt; 4451 4452 if(!yid) 4453 return; 4454 yd = yid->yd; 4455 4456 if (!yd->logged_in) 4457 return; 4458 4459 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 4460 yahoo_packet_hash(pkt, 1, yd->user); 4461 yahoo_packet_hash(pkt, 7, who); 4462 yahoo_packet_hash(pkt, 31, unstealth?"2":"1"); 4066 yahoo_packet_hash(pkt, 31, unstealth ? "2" : "1"); 4463 4067 yahoo_packet_hash(pkt, 13, "2"); 4464 4068 yahoo_send_packet(yid, pkt, 0); … … 4466 4070 } 4467 4071 4468 void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group) 4469 { 4470 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4072 void yahoo_change_buddy_group(int id, const char *who, const char *old_group, 4073 const char *new_group) 4074 { 4075 struct yahoo_input_data *yid = 4076 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4471 4077 struct yahoo_data *yd; 4472 4078 struct yahoo_packet *pkt = NULL; 4473 4079 4474 if (!yid)4080 if (!yid) 4475 4081 return; 4476 4082 yd = yid->yd; 4477 4083 4478 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); 4084 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_CHANGE_GROUP, 4085 YPACKET_STATUS_DEFAULT, yd->session_id); 4479 4086 yahoo_packet_hash(pkt, 1, yd->user); 4087 yahoo_packet_hash(pkt, 302, "240"); 4088 yahoo_packet_hash(pkt, 300, "240"); 4480 4089 yahoo_packet_hash(pkt, 7, who); 4481 yahoo_packet_hash(pkt, 65, new_group); 4482 yahoo_packet_hash(pkt, 14, " "); 4090 yahoo_packet_hash(pkt, 224, old_group); 4091 yahoo_packet_hash(pkt, 264, new_group); 4092 yahoo_packet_hash(pkt, 301, "240"); 4093 yahoo_packet_hash(pkt, 303, "240"); 4483 4094 4484 4095 yahoo_send_packet(yid, pkt, 0); 4485 4096 yahoo_packet_free(pkt); 4486 4487 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id);4488 yahoo_packet_hash(pkt, 1, yd->user);4489 yahoo_packet_hash(pkt, 7, who);4490 yahoo_packet_hash(pkt, 65, old_group);4491 yahoo_send_packet(yid, pkt, 0);4492 yahoo_packet_free(pkt);4493 4097 } 4494 4098 4495 4099 void yahoo_group_rename(int id, const char *old_group, const char *new_group) 4496 4100 { 4497 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4101 struct yahoo_input_data *yid = 4102 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4498 4103 struct yahoo_data *yd; 4499 4104 struct yahoo_packet *pkt = NULL; 4500 4105 4501 if (!yid)4106 if (!yid) 4502 4107 return; 4503 4108 yd = yid->yd; 4504 4109 4505 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, yd->session_id); 4110 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, 4111 YPACKET_STATUS_DEFAULT, yd->session_id); 4506 4112 yahoo_packet_hash(pkt, 1, yd->user); 4507 4113 yahoo_packet_hash(pkt, 65, old_group); … … 4512 4118 } 4513 4119 4514 void yahoo_conference_addinvite(int id, const char * from, const char *who, const char *room, const YList * members, const char *msg) 4515 { 4516 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4120 void yahoo_conference_addinvite(int id, const char *from, const char *who, 4121 const char *room, const YList *members, const char *msg) 4122 { 4123 struct yahoo_input_data *yid = 4124 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4517 4125 struct yahoo_data *yd; 4518 4126 struct yahoo_packet *pkt; 4519 4520 if (!yid)4127 4128 if (!yid) 4521 4129 return; 4522 4130 yd = yid->yd; 4523 4131 4524 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, yd->session_id); 4525 4526 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4132 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, 4133 YPACKET_STATUS_DEFAULT, yd->session_id); 4134 4135 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4527 4136 yahoo_packet_hash(pkt, 51, who); 4528 4137 yahoo_packet_hash(pkt, 57, room); 4529 4138 yahoo_packet_hash(pkt, 58, msg); 4530 4139 yahoo_packet_hash(pkt, 13, "0"); 4531 for (; members; members = members->next) {4140 for (; members; members = members->next) { 4532 4141 yahoo_packet_hash(pkt, 52, (char *)members->data); 4533 4142 yahoo_packet_hash(pkt, 53, (char *)members->data); … … 4540 4149 } 4541 4150 4542 void yahoo_conference_invite(int id, const char * from, YList *who, const char *room, const char *msg) 4543 { 4544 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4151 void yahoo_conference_invite(int id, const char *from, YList *who, 4152 const char *room, const char *msg) 4153 { 4154 struct yahoo_input_data *yid = 4155 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4545 4156 struct yahoo_data *yd; 4546 4157 struct yahoo_packet *pkt; 4547 4548 if (!yid)4158 4159 if (!yid) 4549 4160 return; 4550 4161 yd = yid->yd; 4551 4162 4552 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YAHOO_STATUS_AVAILABLE, yd->session_id); 4553 4554 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4163 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YPACKET_STATUS_DEFAULT, 4164 yd->session_id); 4165 4166 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4555 4167 yahoo_packet_hash(pkt, 50, yd->user); 4556 for (; who; who = who->next) {4168 for (; who; who = who->next) { 4557 4169 yahoo_packet_hash(pkt, 52, (char *)who->data); 4558 4170 } … … 4566 4178 } 4567 4179 4568 void yahoo_conference_logon(int id, const char *from, YList *who, const char *room) 4569 { 4570 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4180 void yahoo_conference_logon(int id, const char *from, YList *who, 4181 const char *room) 4182 { 4183 struct yahoo_input_data *yid = 4184 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4571 4185 struct yahoo_data *yd; 4572 4186 struct yahoo_packet *pkt; 4573 4574 if (!yid)4187 4188 if (!yid) 4575 4189 return; 4576 4190 yd = yid->yd; 4577 4191 4578 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, yd->session_id); 4579 4580 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4581 for(; who; who = who->next) { 4192 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YPACKET_STATUS_DEFAULT, 4193 yd->session_id); 4194 4195 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4196 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4197 yahoo_packet_hash(pkt, 57, room); 4198 for (; who; who = who->next) 4582 4199 yahoo_packet_hash(pkt, 3, (char *)who->data); 4583 }4584 yahoo_packet_hash(pkt, 57, room);4585 4200 4586 4201 yahoo_send_packet(yid, pkt, 0); … … 4589 4204 } 4590 4205 4591 void yahoo_conference_decline(int id, const char * from, YList *who, const char *room, const char *msg) 4592 { 4593 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4206 void yahoo_conference_decline(int id, const char *from, YList *who, 4207 const char *room, const char *msg) 4208 { 4209 struct yahoo_input_data *yid = 4210 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4594 4211 struct yahoo_data *yd; 4595 4212 struct yahoo_packet *pkt; 4596 4597 if (!yid)4213 4214 if (!yid) 4598 4215 return; 4599 4216 yd = yid->yd; 4600 4217 4601 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE, YAHOO_STATUS_AVAILABLE, yd->session_id); 4602 4603 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4604 for(; who; who = who->next) { 4218 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE, 4219 YPACKET_STATUS_DEFAULT, yd->session_id); 4220 4221 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4222 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4223 for (; who; who = who->next) 4605 4224 yahoo_packet_hash(pkt, 3, (char *)who->data); 4606 }4607 4225 yahoo_packet_hash(pkt, 57, room); 4608 4226 yahoo_packet_hash(pkt, 14, msg); … … 4613 4231 } 4614 4232 4615 void yahoo_conference_logoff(int id, const char * from, YList *who, const char *room) 4616 { 4617 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4233 void yahoo_conference_logoff(int id, const char *from, YList *who, 4234 const char *room) 4235 { 4236 struct yahoo_input_data *yid = 4237 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4618 4238 struct yahoo_data *yd; 4619 4239 struct yahoo_packet *pkt; 4620 4621 if (!yid)4240 4241 if (!yid) 4622 4242 return; 4623 4243 yd = yid->yd; 4624 4244 4625 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id); 4626 4627 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4628 for(; who; who = who->next) { 4245 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YPACKET_STATUS_DEFAULT, 4246 yd->session_id); 4247 4248 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4249 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4250 for (; who; who = who->next) 4629 4251 yahoo_packet_hash(pkt, 3, (char *)who->data); 4630 } 4252 4631 4253 yahoo_packet_hash(pkt, 57, room); 4632 4254 … … 4636 4258 } 4637 4259 4638 void yahoo_conference_message(int id, const char * from, YList *who, const char *room, const char *msg, int utf8) 4639 { 4640 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4260 void yahoo_conference_message(int id, const char *from, YList *who, 4261 const char *room, const char *msg, int utf8) 4262 { 4263 struct yahoo_input_data *yid = 4264 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4641 4265 struct yahoo_data *yd; 4642 4266 struct yahoo_packet *pkt; 4643 4644 if (!yid)4267 4268 if (!yid) 4645 4269 return; 4646 4270 yd = yid->yd; 4647 4271 4648 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, yd->session_id); 4649 4650 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4651 for(; who; who = who->next) { 4272 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YPACKET_STATUS_DEFAULT, 4273 yd->session_id); 4274 4275 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4276 yahoo_packet_hash(pkt, 53, (from ? from : yd->user)); 4277 for (; who; who = who->next) 4652 4278 yahoo_packet_hash(pkt, 53, (char *)who->data); 4653 } 4279 4654 4280 yahoo_packet_hash(pkt, 57, room); 4655 4281 yahoo_packet_hash(pkt, 14, msg); 4656 4282 4657 if (utf8)4283 if (utf8) 4658 4284 yahoo_packet_hash(pkt, 97, "1"); 4659 4285 … … 4670 4296 char buff[1024]; 4671 4297 4672 if (!yd)4298 if (!yd) 4673 4299 return; 4674 4300 … … 4678 4304 4679 4305 if (chatroomid == 0) { 4680 snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?chatcat=0"); 4306 snprintf(url, 1024, 4307 "http://insider.msg.yahoo.com/ycontent/?chatcat=0"); 4681 4308 } else { 4682 snprintf(url, 1024, "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0",chatroomid); 4309 snprintf(url, 1024, 4310 "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0", 4311 chatroomid); 4683 4312 } 4684 4313 … … 4687 4316 inputs = y_list_prepend(inputs, yid); 4688 4317 4689 yahoo_http_get(yid->yd->client_id, url, buff, _yahoo_http_connected, yid); 4690 } 4691 4692 void yahoo_chat_logon(int id, const char *from, const char *room, const char *roomid) 4693 { 4694 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4318 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 4319 _yahoo_http_connected, yid); 4320 } 4321 4322 void yahoo_chat_logon(int id, const char *from, const char *room, 4323 const char *roomid) 4324 { 4325 struct yahoo_input_data *yid = 4326 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4695 4327 struct yahoo_data *yd; 4696 4328 struct yahoo_packet *pkt; 4697 4698 if (!yid)4329 4330 if (!yid) 4699 4331 return; 4700 4332 4701 4333 yd = yid->yd; 4702 4334 4703 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE, yd->session_id); 4704 4705 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4335 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YPACKET_STATUS_DEFAULT, 4336 yd->session_id); 4337 4338 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4706 4339 yahoo_packet_hash(pkt, 109, yd->user); 4707 4340 yahoo_packet_hash(pkt, 6, "abcde"); … … 4711 4344 yahoo_packet_free(pkt); 4712 4345 4713 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, yd->session_id); 4714 4715 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4346 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YPACKET_STATUS_DEFAULT, 4347 yd->session_id); 4348 4349 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4716 4350 yahoo_packet_hash(pkt, 104, room); 4717 4351 yahoo_packet_hash(pkt, 129, roomid); 4718 yahoo_packet_hash(pkt, 62, "2"); 4352 yahoo_packet_hash(pkt, 62, "2"); /* ??? */ 4719 4353 4720 4354 yahoo_send_packet(yid, pkt, 0); … … 4723 4357 } 4724 4358 4725 4726 void yahoo_chat_message(int id, const char *from, const char *room, const char *msg, const int msgtype, const int utf8) 4727 { 4728 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4359 void yahoo_chat_message(int id, const char *from, const char *room, 4360 const char *msg, const int msgtype, const int utf8) 4361 { 4362 struct yahoo_input_data *yid = 4363 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4729 4364 struct yahoo_data *yd; 4730 4365 struct yahoo_packet *pkt; 4731 4366 char buf[2]; 4732 4733 if (!yid)4367 4368 if (!yid) 4734 4369 return; 4735 4370 4736 4371 yd = yid->yd; 4737 4372 4738 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, yd->session_id); 4739 4740 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4373 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YPACKET_STATUS_DEFAULT, 4374 yd->session_id); 4375 4376 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4741 4377 yahoo_packet_hash(pkt, 104, room); 4742 4378 yahoo_packet_hash(pkt, 117, msg); 4743 4379 4744 4380 snprintf(buf, sizeof(buf), "%d", msgtype); 4745 4381 yahoo_packet_hash(pkt, 124, buf); 4746 4382 4747 if (utf8)4383 if (utf8) 4748 4384 yahoo_packet_hash(pkt, 97, "1"); 4749 4385 … … 4753 4389 } 4754 4390 4755 4756 4391 void yahoo_chat_logoff(int id, const char *from) 4757 4392 { 4758 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4393 struct yahoo_input_data *yid = 4394 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4759 4395 struct yahoo_data *yd; 4760 4396 struct yahoo_packet *pkt; 4761 4762 if (!yid)4397 4398 if (!yid) 4763 4399 return; 4764 4400 4765 4401 yd = yid->yd; 4766 4402 4767 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YAHOO_STATUS_AVAILABLE, yd->session_id); 4768 4769 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4403 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YPACKET_STATUS_DEFAULT, 4404 yd->session_id); 4405 4406 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4770 4407 4771 4408 yahoo_send_packet(yid, pkt, 0); … … 4776 4413 void yahoo_buddyicon_request(int id, const char *who) 4777 4414 { 4778 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4415 struct yahoo_input_data *yid = 4416 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4779 4417 struct yahoo_data *yd; 4780 4418 struct yahoo_packet *pkt; 4781 4419 4782 if ( !yid)4420 if (!yid) 4783 4421 return; 4784 4422 4785 4423 yd = yid->yd; 4786 4787 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4424 4425 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT, 4426 0); 4788 4427 yahoo_packet_hash(pkt, 4, yd->user); 4789 4428 yahoo_packet_hash(pkt, 5, who); … … 4794 4433 } 4795 4434 4796 void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum) 4797 { 4798 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4435 void yahoo_send_picture_info(int id, const char *who, const char *url, 4436 int checksum) 4437 { 4438 struct yahoo_input_data *yid = 4439 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4799 4440 struct yahoo_data *yd; 4800 4441 struct yahoo_packet *pkt; 4801 4442 char checksum_str[10]; 4802 4443 4803 if ( !yid)4444 if (!yid) 4804 4445 return; 4805 4446 … … 4808 4449 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4809 4450 4810 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4451 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT, 4452 0); 4811 4453 yahoo_packet_hash(pkt, 1, yd->user); 4812 4454 yahoo_packet_hash(pkt, 4, yd->user); … … 4822 4464 void yahoo_send_picture_update(int id, const char *who, int type) 4823 4465 { 4824 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4466 struct yahoo_input_data *yid = 4467 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4825 4468 struct yahoo_data *yd; 4826 4469 struct yahoo_packet *pkt; 4827 4470 char type_str[10]; 4828 4471 4829 if ( !yid)4472 if (!yid) 4830 4473 return; 4831 4474 … … 4834 4477 snprintf(type_str, sizeof(type_str), "%d", type); 4835 4478 4836 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); 4479 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, 4480 YPACKET_STATUS_DEFAULT, 0); 4837 4481 yahoo_packet_hash(pkt, 1, yd->user); 4838 4482 yahoo_packet_hash(pkt, 5, who); … … 4845 4489 void yahoo_send_picture_checksum(int id, const char *who, int checksum) 4846 4490 { 4847 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4491 struct yahoo_input_data *yid = 4492 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4848 4493 struct yahoo_data *yd; 4849 4494 struct yahoo_packet *pkt; 4850 4495 char checksum_str[10]; 4851 4496 4852 if ( !yid)4497 if (!yid) 4853 4498 return; 4854 4499 4855 4500 yd = yid->yd; 4856 4501 4857 4502 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4858 4503 4859 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); 4504 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, 4505 YPACKET_STATUS_DEFAULT, 0); 4860 4506 yahoo_packet_hash(pkt, 1, yd->user); 4861 if ( who != 0)4507 if (who != 0) 4862 4508 yahoo_packet_hash(pkt, 5, who); 4863 4509 yahoo_packet_hash(pkt, 192, checksum_str); … … 4870 4516 void yahoo_webcam_close_feed(int id, const char *who) 4871 4517 { 4872 struct yahoo_input_data *yid = find_input_by_id_and_webcam_user(id, who); 4873 4874 if(yid) 4518 struct yahoo_input_data *yid = 4519 find_input_by_id_and_webcam_user(id, who); 4520 4521 if (yid) 4875 4522 yahoo_input_close(yid); 4876 4523 } … … 4878 4525 void yahoo_webcam_get_feed(int id, const char *who) 4879 4526 { 4880 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4527 struct yahoo_input_data *yid = 4528 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4881 4529 struct yahoo_data *yd; 4882 4530 struct yahoo_packet *pkt; 4883 4884 if (!yid)4531 4532 if (!yid) 4885 4533 return; 4886 4534 … … 4892 4540 * The queue is popped in yahoo_process_webcam_key 4893 4541 */ 4894 webcam_queue = y_list_append(webcam_queue, who ?strdup(who):NULL);4542 webcam_queue = y_list_append(webcam_queue, who ? strdup(who) : NULL); 4895 4543 4896 4544 yd = yid->yd; 4897 4545 4898 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YAHOO_STATUS_AVAILABLE, yd->session_id); 4546 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YPACKET_STATUS_DEFAULT, 4547 yd->session_id); 4899 4548 4900 4549 yahoo_packet_hash(pkt, 1, yd->user); … … 4906 4555 } 4907 4556 4908 void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, unsigned int timestamp) 4909 { 4910 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4557 void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, 4558 unsigned int timestamp) 4559 { 4560 struct yahoo_input_data *yid = 4561 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4911 4562 unsigned char *packet; 4912 4563 unsigned char header_len = 13; … … 4920 4571 packet[pos++] = header_len; 4921 4572 packet[pos++] = 0; 4922 packet[pos++] = 5; 4573 packet[pos++] = 5; /* version byte?? */ 4923 4574 packet[pos++] = 0; 4924 4575 pos += yahoo_put32(packet + pos, length); 4925 packet[pos++] = 2; 4576 packet[pos++] = 2; /* packet type, image */ 4926 4577 pos += yahoo_put32(packet + pos, timestamp); 4927 4578 yahoo_add_to_send_queue(yid, packet, header_len); … … 4932 4583 } 4933 4584 4934 void yahoo_webcam_accept_viewer(int id, const char* who, int accept) 4935 { 4936 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4585 void yahoo_webcam_accept_viewer(int id, const char *who, int accept) 4586 { 4587 struct yahoo_input_data *yid = 4588 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4937 4589 char *packet = NULL; 4938 4590 char *data = NULL; … … 4945 4597 4946 4598 data = strdup("u="); 4947 data = y_string_append(data, (char *)who);4599 data = y_string_append(data, (char *)who); 4948 4600 data = y_string_append(data, "\r\n"); 4949 4601 len = strlen(data); … … 4952 4604 packet[pos++] = header_len; 4953 4605 packet[pos++] = 0; 4954 packet[pos++] = 5; 4606 packet[pos++] = 5; /* version byte?? */ 4955 4607 packet[pos++] = 0; 4956 4608 pos += yahoo_put32(packet + pos, len); 4957 packet[pos++] = 0; 4609 packet[pos++] = 0; /* packet type */ 4958 4610 pos += yahoo_put32(packet + pos, accept); 4959 4611 memcpy(packet + pos, data, len); … … 4965 4617 void yahoo_webcam_invite(int id, const char *who) 4966 4618 { 4967 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4619 struct yahoo_input_data *yid = 4620 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4968 4621 struct yahoo_packet *pkt; 4969 4970 if(!yid) 4971 return; 4972 4973 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_NOTIFY, yid->yd->session_id); 4622 4623 if (!yid) 4624 return; 4625 4626 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY, 4627 yid->yd->session_id); 4974 4628 4975 4629 yahoo_packet_hash(pkt, 49, "WEBCAMINVITE"); … … 4983 4637 } 4984 4638 4985 static void yahoo_search_internal(int id, int t, const char *text, int g, int ar, int photo, int yahoo_only, int startpos, int total) 4639 static void yahoo_search_internal(int id, int t, const char *text, int g, 4640 int ar, int photo, int yahoo_only, int startpos, int total) 4986 4641 { 4987 4642 struct yahoo_data *yd = find_conn_by_id(id); … … 4991 4646 char *ctext, *p; 4992 4647 4993 if (!yd)4648 if (!yd) 4994 4649 return; 4995 4650 … … 4999 4654 5000 4655 /* 5001 age range 5002 .ar=1 - 13-18, 2 - 18-25, 3 - 25-35, 4 - 35-50, 5 - 50-70, 6 - 70+ 5003 */ 5004 5005 snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total, startpos); 4656 age range 4657 .ar=1 - 13-18, 2 - 18-25, 3 - 25-35, 4 - 35-50, 5 - 50-70, 6 - 70+ 4658 */ 4659 4660 snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total, 4661 startpos); 5006 4662 5007 4663 ctext = strdup(text); 5008 while ((p = strchr(ctext, ' ')))4664 while ((p = strchr(ctext, ' '))) 5009 4665 *p = '+'; 5010 4666 5011 snprintf(url, 1024, "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s", 5012 ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "", 5013 startpos ? buff : ""); 4667 snprintf(url, 1024, 4668 "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s", 4669 ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "", 4670 startpos ? buff : ""); 5014 4671 5015 4672 FREE(ctext); … … 5018 4675 5019 4676 inputs = y_list_prepend(inputs, yid); 5020 yahoo_http_get(yid->yd->client_id, url, buff, _yahoo_http_connected, yid); 5021 } 5022 5023 void yahoo_search(int id, enum yahoo_search_type t, const char *text, enum yahoo_search_gender g, enum yahoo_search_agerange ar, 5024 int photo, int yahoo_only) 5025 { 5026 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4677 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 4678 _yahoo_http_connected, yid); 4679 } 4680 4681 void yahoo_search(int id, enum yahoo_search_type t, const char *text, 4682 enum yahoo_search_gender g, enum yahoo_search_agerange ar, int photo, 4683 int yahoo_only) 4684 { 4685 struct yahoo_input_data *yid = 4686 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 5027 4687 struct yahoo_search_state *yss; 5028 4688 5029 if (!yid)5030 return; 5031 5032 if (!yid->ys)4689 if (!yid) 4690 return; 4691 4692 if (!yid->ys) 5033 4693 yid->ys = y_new0(struct yahoo_search_state, 1); 5034 4694 … … 5048 4708 void yahoo_search_again(int id, int start) 5049 4709 { 5050 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4710 struct yahoo_input_data *yid = 4711 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 5051 4712 struct yahoo_search_state *yss; 5052 4713 5053 if (!yid || !yid->ys)4714 if (!yid || !yid->ys) 5054 4715 return; 5055 4716 5056 4717 yss = yid->ys; 5057 4718 5058 if (start == -1)4719 if (start == -1) 5059 4720 start = yss->lsearch_nstart + yss->lsearch_nfound; 5060 4721 5061 yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text, 5062 yss->lsearch_gender, yss->lsearch_agerange, 5063 yss->lsearch_photo, yss->lsearch_yahoo_only, 5064 start, yss->lsearch_ntotal); 5065 } 4722 yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text, 4723 yss->lsearch_gender, yss->lsearch_agerange, 4724 yss->lsearch_photo, yss->lsearch_yahoo_only, 4725 start, yss->lsearch_ntotal); 4726 } 4727 4728 void yahoo_send_picture(int id, const char *name, unsigned long size, 4729 yahoo_get_fd_callback callback, void *data) 4730 { 4731 /* Not Implemented */ 4732 } 4733 4734 /* File Transfer */ 4735 static YList *active_file_transfers = NULL; 4736 4737 enum { 4738 FT_STATE_HEAD = 1, 4739 FT_STATE_RECV, 4740 FT_STATE_RECV_START, 4741 FT_STATE_SEND 4742 }; 5066 4743 5067 4744 struct send_file_data { 5068 struct yahoo_packet *pkt; 4745 int client_id; 4746 char *id; 4747 char *who; 4748 char *filename; 4749 char *ip_addr; 4750 char *token; 4751 int size; 4752 4753 struct yahoo_input_data *yid; 4754 int state; 4755 5069 4756 yahoo_get_fd_callback callback; 5070 void * user_data;4757 void *data; 5071 4758 }; 5072 4759 5073 static void _yahoo_send_picture_connected(int id, int fd, int error, void *data) 5074 { 5075 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); 4760 static char *yahoo_get_random(void) 4761 { 4762 int i = 0; 4763 int r = 0; 4764 int c = 0; 4765 char out[25]; 4766 4767 out[24] = '\0'; 4768 out[23] = '$'; 4769 out[22] = '$'; 4770 4771 for (i = 0; i < 22; i++) { 4772 if(r == 0) 4773 r = rand(); 4774 4775 c = r%61; 4776 4777 if(c<26) 4778 out[i] = c + 'a'; 4779 else if (c<52) 4780 out[i] = c - 26 + 'A'; 4781 else 4782 out[i] = c - 52 + '0'; 4783 4784 r /= 61; 4785 } 4786 4787 return strdup(out); 4788 } 4789 4790 static int _are_same_id(const void *sfd1, const void *id) 4791 { 4792 return strcmp(((struct send_file_data *)sfd1)->id, (char *)id); 4793 } 4794 4795 static int _are_same_yid(const void *sfd1, const void *yid) 4796 { 4797 if(((struct send_file_data *)sfd1)->yid == yid) 4798 return 0; 4799 else 4800 return 1; 4801 } 4802 4803 static struct send_file_data *yahoo_get_active_transfer(char *id) 4804 { 4805 YList *l = y_list_find_custom(active_file_transfers, id, 4806 _are_same_id); 4807 4808 if(l) 4809 return (struct send_file_data *)l->data; 4810 4811 return NULL; 4812 } 4813 4814 static struct send_file_data *yahoo_get_active_transfer_with_yid(void *yid) 4815 { 4816 YList *l = y_list_find_custom(active_file_transfers, yid, 4817 _are_same_yid); 4818 4819 if(l) 4820 return (struct send_file_data *)l->data; 4821 4822 return NULL; 4823 } 4824 4825 static void yahoo_add_active_transfer(struct send_file_data *sfd) 4826 { 4827 active_file_transfers = y_list_prepend(active_file_transfers, sfd); 4828 } 4829 4830 static void yahoo_remove_active_transfer(struct send_file_data *sfd) 4831 { 4832 active_file_transfers = y_list_remove(active_file_transfers, sfd); 4833 free(sfd->id); 4834 free(sfd->who); 4835 free(sfd->filename); 4836 free(sfd->ip_addr); 4837 FREE(sfd); 4838 } 4839 4840 static void _yahoo_ft_upload_connected(int id, void *fd, int error, void *data) 4841 { 5076 4842 struct send_file_data *sfd = data; 5077 struct yahoo_packet *pkt = sfd->pkt; 5078 unsigned char buff[1024]; 5079 5080 if(fd <= 0) { 5081 sfd->callback(id, fd, error, sfd->user_data); 5082 FREE(sfd); 5083 yahoo_packet_free(pkt); 4843 struct yahoo_input_data *yid = sfd->yid; 4844 4845 if (!fd) { 5084 4846 inputs = y_list_remove(inputs, yid); 5085 4847 FREE(yid); … … 5087 4849 } 5088 4850 4851 sfd->callback(id, fd, error, sfd->data); 4852 5089 4853 yid->fd = fd; 5090 yahoo_send_packet(yid, pkt, 8); 4854 yid->read_tag = 4855 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd, 4856 YAHOO_INPUT_READ, yid); 4857 } 4858 4859 static void yahoo_file_transfer_upload(struct yahoo_data *yd, 4860 struct send_file_data *sfd) 4861 { 4862 char url[256]; 4863 char buff[4096]; 4864 char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL; 4865 4866 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); 4867 4868 yid->yd = yd; 4869 yid->type = YAHOO_CONNECTION_FT; 4870 4871 inputs = y_list_prepend(inputs, yid); 4872 sfd->yid = yid; 4873 sfd->state = FT_STATE_SEND; 4874 4875 token_enc = yahoo_urlencode(sfd->token); 4876 sender_enc = yahoo_urlencode(yd->user); 4877 recv_enc = yahoo_urlencode(sfd->who); 4878 4879 snprintf(url, sizeof(url), 4880 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 4881 token_enc, sender_enc, recv_enc); 4882 4883 snprintf(buff, sizeof(buff), "T=%s; Y=%s", yd->cookie_t, yd->cookie_y); 4884 4885 yahoo_http_post(yd->client_id, url, buff, sfd->size, 4886 _yahoo_ft_upload_connected, sfd); 4887 4888 FREE(token_enc); 4889 FREE(sender_enc); 4890 FREE(recv_enc); 4891 } 4892 4893 static void yahoo_init_ft_recv(struct yahoo_data *yd, 4894 struct send_file_data *sfd) 4895 { 4896 char url[256]; 4897 char buff[1024]; 4898 char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL; 4899 4900 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); 4901 4902 yid->yd = yd; 4903 yid->type = YAHOO_CONNECTION_FT; 4904 4905 inputs = y_list_prepend(inputs, yid); 4906 sfd->yid = yid; 4907 sfd->state = FT_STATE_HEAD; 4908 4909 token_enc = yahoo_urlencode(sfd->token); 4910 sender_enc = yahoo_urlencode(sfd->who); 4911 recv_enc = yahoo_urlencode(yd->user); 4912 4913 snprintf(url, sizeof(url), 4914 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 4915 token_enc, sender_enc, recv_enc); 4916 4917 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 4918 4919 yahoo_http_head(yid->yd->client_id, url, buff, 0, NULL, 4920 _yahoo_http_connected, yid); 4921 4922 FREE(token_enc); 4923 FREE(sender_enc); 4924 FREE(recv_enc); 4925 } 4926 4927 static void yahoo_file_transfer_accept(struct yahoo_input_data *yid, 4928 struct send_file_data *sfd) 4929 { 4930 struct yahoo_packet *pkt; 4931 4932 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, 4933 YPACKET_STATUS_DEFAULT, yid->yd->session_id); 4934 4935 yahoo_packet_hash(pkt, 1, yid->yd->user); 4936 yahoo_packet_hash(pkt, 5, sfd->who); 4937 yahoo_packet_hash(pkt, 265, sfd->id); 4938 yahoo_packet_hash(pkt, 27, sfd->filename); 4939 yahoo_packet_hash(pkt, 249, "3"); 4940 yahoo_packet_hash(pkt, 251, sfd->token); 4941 4942 yahoo_send_packet(yid, pkt, 0); 4943 5091 4944 yahoo_packet_free(pkt); 5092 4945 5093 snprintf((char *)buff, sizeof(buff), "29"); 5094 buff[2] = 0xc0; 5095 buff[3] = 0x80; 5096 5097 write(yid->fd, buff, 4); 5098 5099 /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */ 5100 5101 sfd->callback(id, fd, error, sfd->user_data); 5102 FREE(sfd); 5103 inputs = y_list_remove(inputs, yid); 5104 /* 5105 while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 5106 if(!strcmp(buff, "")) 5107 break; 5108 } 5109 5110 */ 5111 yahoo_input_close(yid); 5112 } 5113 5114 void yahoo_send_picture(int id, const char *name, unsigned long size, 5115 yahoo_get_fd_callback callback, void *data) 5116 { 5117 struct yahoo_data *yd = find_conn_by_id(id); 4946 yahoo_init_ft_recv(yid->yd, sfd); 4947 } 4948 4949 static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid, 4950 struct yahoo_packet *pkt) 4951 { 4952 YList *l; 4953 struct send_file_data *sfd; 4954 char *who = NULL; 4955 char *filename = NULL; 4956 char *id = NULL; 4957 char *token = NULL; 4958 4959 for (l = pkt->hash; l; l = l->next) { 4960 struct yahoo_pair *pair = l->data; 4961 switch (pair->key) { 4962 case 4: 4963 who = pair->value; 4964 break; 4965 case 5: 4966 /* Me... don't care */ 4967 break; 4968 case 249: 4969 break; 4970 case 265: 4971 id = pair->value; 4972 break; 4973 case 251: 4974 token = pair->value; 4975 break; 4976 case 27: 4977 filename = pair->value; 4978 break; 4979 } 4980 } 4981 4982 sfd = yahoo_get_active_transfer(id); 4983 4984 if (sfd) { 4985 sfd->token = strdup(token); 4986 4987 yahoo_file_transfer_upload(yid->yd, sfd); 4988 } 4989 else { 4990 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 4991 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 4992 sfd->data); 4993 4994 yahoo_remove_active_transfer(sfd); 4995 } 4996 } 4997 4998 static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid, 4999 struct yahoo_packet *pkt) 5000 { 5001 YList *l; 5002 char *who = NULL; 5003 char *filename = NULL; 5004 char *id = NULL; 5005 char *token = NULL; 5006 char *ip_addr = NULL; 5007 5008 struct send_file_data *sfd; 5009 5010 for (l = pkt->hash; l; l = l->next) { 5011 struct yahoo_pair *pair = l->data; 5012 switch (pair->key) { 5013 case 1: 5014 case 4: 5015 who = pair->value; 5016 break; 5017 case 5: 5018 /* Me... don't care */ 5019 break; 5020 case 249: 5021 break; 5022 case 265: 5023 id = pair->value; 5024 break; 5025 case 250: 5026 ip_addr = pair->value; 5027 break; 5028 case 251: 5029 token = pair->value; 5030 break; 5031 case 27: 5032 filename = pair->value; 5033 break; 5034 } 5035 } 5036 5037 sfd = yahoo_get_active_transfer(id); 5038 5039 if (sfd) { 5040 sfd->token = strdup(token); 5041 sfd->ip_addr = strdup(ip_addr); 5042 5043 yahoo_file_transfer_accept(yid, sfd); 5044 } 5045 else { 5046 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5047 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 5048 sfd->data); 5049 5050 yahoo_remove_active_transfer(sfd); 5051 } 5052 } 5053 5054 static void yahoo_send_filetransferinfo(struct yahoo_data *yd, 5055 struct send_file_data *sfd) 5056 { 5118 5057 struct yahoo_input_data *yid; 5119 struct yahoo_server_settings *yss; 5058 struct yahoo_packet *pkt; 5059 5060 yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER); 5061 sfd->ip_addr = YAHOO_CALLBACK(ext_yahoo_get_ip_addr)("relay.yahoo.com"); 5062 5063 if (!sfd->ip_addr) { 5064 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5065 (yd->client_id, YAHOO_FILE_TRANSFER_RELAY, sfd->data); 5066 5067 yahoo_remove_active_transfer(sfd); 5068 5069 return; 5070 } 5071 5072 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERINFO, 5073 YPACKET_STATUS_DEFAULT, yd->session_id); 5074 5075 yahoo_packet_hash(pkt, 1, yd->user); 5076 yahoo_packet_hash(pkt, 5, sfd->who); 5077 yahoo_packet_hash(pkt, 265, sfd->id); 5078 yahoo_packet_hash(pkt, 27, sfd->filename); 5079 yahoo_packet_hash(pkt, 249, "3"); 5080 yahoo_packet_hash(pkt, 250, sfd->ip_addr); 5081 5082 yahoo_send_packet(yid, pkt, 0); 5083 5084 yahoo_packet_free(pkt); 5085 } 5086 5087 static void yahoo_process_filetransfer(struct yahoo_input_data *yid, 5088 struct yahoo_packet *pkt) 5089 { 5090 YList *l; 5091 char *who = NULL; 5092 char *filename = NULL; 5093 char *msg = NULL; 5094 char *id = NULL; 5095 int action = 0; 5096 int size = 0; 5097 struct yahoo_data *yd = yid->yd; 5098 5099 struct send_file_data *sfd; 5100 5101 for (l = pkt->hash; l; l = l->next) { 5102 struct yahoo_pair *pair = l->data; 5103 switch (pair->key) { 5104 case 4: 5105 who = pair->value; 5106 break; 5107 case 5: 5108 /* Me... don't care */ 5109 break; 5110 case 222: 5111 action = atoi(pair->value); 5112 break; 5113 case 265: 5114 id = pair->value; 5115 break; 5116 case 266: /* Don't know */ 5117 break; 5118 case 302: /* Start Data? */ 5119 break; 5120 case 300: 5121 break; 5122 case 27: 5123 filename = pair->value; 5124 break; 5125 case 28: 5126 size = atoi(pair->value); 5127 break; 5128 case 14: 5129 msg = pair->value; 5130 case 301: /* End Data? */ 5131 break; 5132 case 303: 5133 break; 5134 5135 } 5136 } 5137 5138 if (action == YAHOO_FILE_TRANSFER_INIT) { 5139 /* Received a FT request from buddy */ 5140 sfd = y_new0(struct send_file_data, 1); 5141 5142 sfd->client_id = yd->client_id; 5143 sfd->id = strdup(id); 5144 sfd->who = strdup(who); 5145 sfd->filename = strdup(filename); 5146 sfd->size = size; 5147 5148 yahoo_add_active_transfer(sfd); 5149 5150 YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, yd->user, 5151 who, msg, filename, size, sfd->id); 5152 } 5153 else { 5154 /* Response to our request */ 5155 sfd = yahoo_get_active_transfer(id); 5156 5157 if (sfd && action == YAHOO_FILE_TRANSFER_ACCEPT) { 5158 yahoo_send_filetransferinfo(yd, sfd); 5159 } 5160 else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) { 5161 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5162 (yd->client_id, YAHOO_FILE_TRANSFER_REJECT, 5163 sfd->data); 5164 5165 yahoo_remove_active_transfer(sfd); 5166 } 5167 } 5168 } 5169 5170 void yahoo_send_file(int id, const char *who, const char *msg, 5171 const char *name, unsigned long size, 5172 yahoo_get_fd_callback callback, void *data) 5173 { 5120 5174 struct yahoo_packet *pkt = NULL; 5121 5175 char size_str[10]; 5122 char expire_str[10]; 5123 long content_length=0; 5124 unsigned char buff[1024]; 5125 char url[255]; 5176 struct yahoo_input_data *yid; 5177 struct yahoo_data *yd; 5126 5178 struct send_file_data *sfd; 5127 5128 if(!yd) 5129 return; 5130 5131 yss = yd->server_settings; 5132 5133 yid = y_new0(struct yahoo_input_data, 1); 5134 yid->yd = yd; 5135 yid->type = YAHOO_CONNECTION_FT; 5136 5137 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id); 5179 5180 yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 5181 yd = find_conn_by_id(id); 5182 sfd = y_new0(struct send_file_data, 1); 5183 5184 sfd->client_id = id; 5185 sfd->id = yahoo_get_random(); 5186 sfd->who = strdup(who); 5187 sfd->filename = strdup(name); 5188 sfd->size = size; 5189 sfd->callback = callback; 5190 sfd->data = data; 5191 5192 yahoo_add_active_transfer(sfd); 5193 5194 if (!yd) 5195 return; 5196 5197 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER, 5198 YPACKET_STATUS_DEFAULT, yd->session_id); 5138 5199 5139 5200 snprintf(size_str, sizeof(size_str), "%ld", size); 5140 snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800); 5141 5142 yahoo_packet_hash(pkt, 0, yd->user); 5201 5143 5202 yahoo_packet_hash(pkt, 1, yd->user); 5144 yahoo_packet_hash(pkt, 14, ""); 5203 yahoo_packet_hash(pkt, 5, who); 5204 yahoo_packet_hash(pkt, 265, sfd->id); 5205 yahoo_packet_hash(pkt, 222, "1"); 5206 yahoo_packet_hash(pkt, 266, "1"); 5207 yahoo_packet_hash(pkt, 302, "268"); 5208 yahoo_packet_hash(pkt, 300, "268"); 5145 5209 yahoo_packet_hash(pkt, 27, name); 5146 5210 yahoo_packet_hash(pkt, 28, size_str); 5147 yahoo_packet_hash(pkt, 38, expire_str); 5211 yahoo_packet_hash(pkt, 301, "268"); 5212 yahoo_packet_hash(pkt, 303, "268"); 5213 5214 yahoo_send_packet(yid, pkt, 0); 5215 5216 yahoo_packet_free(pkt); 5217 } 5218 5219 void yahoo_send_file_transfer_response(int client_id, int response, char *id, void *data) 5220 { 5221 struct yahoo_packet *pkt = NULL; 5222 char resp[2]; 5223 struct yahoo_input_data *yid; 5148 5224 5149 5150 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 5151 5152 snprintf(url, sizeof(url), "http://%s:%d/notifyft", 5153 yss->filetransfer_host, yss->filetransfer_port); 5154 snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s", 5155 yd->cookie_y, yd->cookie_t); 5156 inputs = y_list_prepend(inputs, yid); 5157 5158 sfd = y_new0(struct send_file_data, 1); 5159 sfd->pkt = pkt; 5160 sfd->callback = callback; 5161 sfd->user_data = data; 5162 yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size, 5163 _yahoo_send_picture_connected, sfd); 5164 } 5165 5166 static void _yahoo_send_file_connected(int id, int fd, int error, void *data) 5167 { 5168 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); 5169 struct send_file_data *sfd = data; 5170 struct yahoo_packet *pkt = sfd->pkt; 5171 unsigned char buff[1024]; 5172 5173 if(fd <= 0) { 5174 sfd->callback(id, fd, error, sfd->user_data); 5175 FREE(sfd); 5176 yahoo_packet_free(pkt); 5177 inputs = y_list_remove(inputs, yid); 5178 FREE(yid); 5179 return; 5180 } 5181 5182 yid->fd = fd; 5183 yahoo_send_packet(yid, pkt, 8); 5225 struct send_file_data *sfd = yahoo_get_active_transfer(id); 5226 5227 sfd->data = data; 5228 5229 yid = find_input_by_id_and_type(client_id, YAHOO_CONNECTION_PAGER); 5230 5231 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER, 5232 YPACKET_STATUS_DEFAULT, yid->yd->session_id); 5233 5234 snprintf(resp, sizeof(resp), "%d", response); 5235 5236 yahoo_packet_hash(pkt, 1, yid->yd->user); 5237 yahoo_packet_hash(pkt, 5, sfd->who); 5238 yahoo_packet_hash(pkt, 265, sfd->id); 5239 yahoo_packet_hash(pkt, 222, resp); 5240 5241 yahoo_send_packet(yid, pkt, 0); 5242 5184 5243 yahoo_packet_free(pkt); 5185 5244 5186 snprintf((char *)buff, sizeof(buff), "29"); 5187 buff[2] = 0xc0; 5188 buff[3] = 0x80; 5245 if(response == YAHOO_FILE_TRANSFER_REJECT) 5246 yahoo_remove_active_transfer(sfd); 5247 } 5248 5249 static void yahoo_process_ft_connection(struct yahoo_input_data *yid, int over) 5250 { 5251 struct send_file_data *sfd; 5252 struct yahoo_data *yd = yid->yd; 5189 5253 5190 write(yid->fd, buff, 4); 5191 5192 /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */ 5193 5194 sfd->callback(id, fd, error, sfd->user_data); 5195 FREE(sfd); 5196 inputs = y_list_remove(inputs, yid); 5197 /* 5198 while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 5199 if(!strcmp(buff, "")) 5200 break; 5201 } 5202 5203 */ 5204 yahoo_input_close(yid); 5205 } 5206 5207 void yahoo_send_file(int id, const char *who, const char *msg, 5208 const char *name, unsigned long size, 5209 yahoo_get_fd_callback callback, void *data) 5254 sfd = yahoo_get_active_transfer_with_yid(yid); 5255 5256 if (!sfd) { 5257 LOG(("Something funny happened. yid %p has no sfd.\n", yid)); 5258 return; 5259 } 5260 5261 /* 5262 * We want to handle only the complete data with HEAD since we don't 5263 * want a situation where both the GET and HEAD are active. 5264 * With SEND, we really can't do much with partial response 5265 */ 5266 if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND) 5267 && !over) 5268 return; 5269 5270 if (sfd->state == FT_STATE_HEAD) { 5271 /* Do a GET */ 5272 char url[256]; 5273 char buff[1024]; 5274 char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL; 5275 5276 struct yahoo_input_data *yid_ft = 5277 y_new0(struct yahoo_input_data, 1); 5278 5279 yid_ft->yd = yid->yd; 5280 yid_ft->type = YAHOO_CONNECTION_FT; 5281 5282 inputs = y_list_prepend(inputs, yid_ft); 5283 sfd->yid = yid_ft; 5284 sfd->state = FT_STATE_RECV; 5285 5286 token_enc = yahoo_urlencode(sfd->token); 5287 sender_enc = yahoo_urlencode(sfd->who); 5288 recv_enc = yahoo_urlencode(yd->user); 5289 5290 snprintf(url, sizeof(url), 5291 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 5292 token_enc, sender_enc, recv_enc); 5293 5294 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, 5295 yd->cookie_t); 5296 5297 5298 yahoo_http_get(yd->client_id, url, buff, 1, 1, 5299 _yahoo_http_connected, yid_ft); 5300 5301 FREE(token_enc); 5302 FREE(sender_enc); 5303 FREE(recv_enc); 5304 } 5305 else if (sfd->state == FT_STATE_RECV || 5306 sfd->state == FT_STATE_RECV_START) { 5307 5308 unsigned char *data_begin = NULL; 5309 5310 if (yid->rxlen == 0) 5311 yahoo_remove_active_transfer(sfd); 5312 5313 if (sfd->state != FT_STATE_RECV_START && 5314 (data_begin = 5315 (unsigned char *)strstr((char *)yid->rxqueue, 5316 "\r\n\r\n"))) { 5317 5318 sfd->state = FT_STATE_RECV_START; 5319 5320 yid->rxlen -= 4+(data_begin-yid->rxqueue)/sizeof(char); 5321 data_begin += 4; 5322 5323 if (yid->rxlen > 0) 5324 YAHOO_CALLBACK(ext_yahoo_got_ft_data) 5325 (yd->client_id, data_begin, 5326 yid->rxlen, sfd->data); 5327 } 5328 else if (sfd->state == FT_STATE_RECV_START) 5329 YAHOO_CALLBACK(ext_yahoo_got_ft_data) (yd->client_id, 5330 yid->rxqueue, yid->rxlen, sfd->data); 5331 5332 FREE(yid->rxqueue); 5333 yid->rxqueue = NULL; 5334 yid->rxlen = 0; 5335 } 5336 else if (sfd->state == FT_STATE_SEND) { 5337 /* Sent file completed */ 5338 int len = 0; 5339 char *off = strstr((char *)yid->rxqueue, "Content-Length: "); 5340 5341 if (off) { 5342 off += 16; 5343 len = atoi(off); 5344 } 5345 5346 if (len < sfd->size) 5347 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5348 (yd->client_id, 5349 YAHOO_FILE_TRANSFER_FAILED, sfd->data); 5350 else 5351 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5352 (yd->client_id, 5353 YAHOO_FILE_TRANSFER_DONE, sfd->data); 5354 5355 yahoo_remove_active_transfer(sfd); 5356 } 5357 } 5358 5359 /* End File Transfer */ 5360 5361 enum yahoo_status yahoo_current_status(int id) 5210 5362 { 5211 5363 struct yahoo_data *yd = find_conn_by_id(id); 5212 struct yahoo_input_data *yid; 5213 struct yahoo_server_settings *yss; 5214 struct yahoo_packet *pkt = NULL; 5215 char size_str[10]; 5216 long content_length=0; 5217 unsigned char buff[1024]; 5218 char url[255]; 5219 struct send_file_data *sfd; 5220 5221 if(!yd) 5222 return; 5223 5224 yss = yd->server_settings; 5225 5226 yid = y_new0(struct yahoo_input_data, 1); 5227 yid->yd = yd; 5228 yid->type = YAHOO_CONNECTION_FT; 5229 5230 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, YAHOO_STATUS_AVAILABLE, yd->session_id); 5231 5232 snprintf(size_str, sizeof(size_str), "%ld", size); 5233 5234 yahoo_packet_hash(pkt, 0, yd->user); 5235 yahoo_packet_hash(pkt, 5, who); 5236 yahoo_packet_hash(pkt, 14, msg); 5237 yahoo_packet_hash(pkt, 27, name); 5238 yahoo_packet_hash(pkt, 28, size_str); 5239 5240 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 5241 5242 snprintf(url, sizeof(url), "http://%s:%d/notifyft", 5243 yss->filetransfer_host, yss->filetransfer_port); 5244 snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s", 5245 yd->cookie_y, yd->cookie_t); 5246 inputs = y_list_prepend(inputs, yid); 5247 5248 sfd = y_new0(struct send_file_data, 1); 5249 sfd->pkt = pkt; 5250 sfd->callback = callback; 5251 sfd->user_data = data; 5252 yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size, 5253 _yahoo_send_file_connected, sfd); 5254 } 5255 5256 5257 enum yahoo_status yahoo_current_status(int id) 5258 { 5259 struct yahoo_data *yd = find_conn_by_id(id); 5260 if(!yd) 5364 if (!yd) 5261 5365 return YAHOO_STATUS_OFFLINE; 5262 5366 return yd->current_status; 5263 5367 } 5264 5368 5265 const YList * 5369 const YList *yahoo_get_buddylist(int id) 5266 5370 { 5267 5371 struct yahoo_data *yd = find_conn_by_id(id); 5268 if (!yd)5372 if (!yd) 5269 5373 return NULL; 5270 5374 return yd->buddies; 5271 5375 } 5272 5376 5273 const YList * 5377 const YList *yahoo_get_ignorelist(int id) 5274 5378 { 5275 5379 struct yahoo_data *yd = find_conn_by_id(id); 5276 if (!yd)5380 if (!yd) 5277 5381 return NULL; 5278 5382 return yd->ignore; 5279 5383 } 5280 5384 5281 const YList * 5385 const YList *yahoo_get_identities(int id) 5282 5386 { 5283 5387 struct yahoo_data *yd = find_conn_by_id(id); 5284 if (!yd)5388 if (!yd) 5285 5389 return NULL; 5286 5390 return yd->identities; 5287 5391 } 5288 5392 5289 const char * 5393 const char *yahoo_get_cookie(int id, const char *which) 5290 5394 { 5291 5395 struct yahoo_data *yd = find_conn_by_id(id); 5292 if (!yd)5396 if (!yd) 5293 5397 return NULL; 5294 if (!strncasecmp(which, "y", 1))5398 if (!strncasecmp(which, "y", 1)) 5295 5399 return yd->cookie_y; 5296 if(!strncasecmp(which, "t", 1)) 5400 if (!strncasecmp(which, "b", 1)) 5401 return yd->cookie_b; 5402 if (!strncasecmp(which, "t", 1)) 5297 5403 return yd->cookie_t; 5298 if (!strncasecmp(which, "c", 1))5404 if (!strncasecmp(which, "c", 1)) 5299 5405 return yd->cookie_c; 5300 if (!strncasecmp(which, "login", 5))5406 if (!strncasecmp(which, "login", 5)) 5301 5407 return yd->login_cookie; 5302 5408 return NULL; 5303 5409 } 5304 5410 5305 void yahoo_get_url_handle(int id, const char *url, 5306 yahoo_get_url_handle_callback callback, void *data) 5307 { 5308 struct yahoo_data *yd = find_conn_by_id(id); 5309 if(!yd) 5310 return; 5311 5312 yahoo_get_url_fd(id, url, yd, callback, data); 5313 } 5314 5315 const char * yahoo_get_profile_url( void ) 5411 const char *yahoo_get_profile_url(void) 5316 5412 { 5317 5413 return profile_url; 5318 5414 } 5319 -
protocols/yahoo/yahoo.c
r938c305 rc8791f2 2 2 * libyahoo2 wrapper to BitlBee 3 3 * 4 * Mostly Copyright 2004 Wilmer van der Gaast <wilmer@gaast.net>4 * Mostly Copyright 2004-2010 Wilmer van der Gaast <wilmer@gaast.net> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 271 271 { 272 272 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 273 274 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); 273 bee_user_t *bu; 274 275 if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group ) 276 { 277 GSList *bgl; 278 279 /* If the person is in our list already, this is a group change. */ 280 yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group ); 281 282 /* No idea how often people have people in multiple groups and 283 BitlBee doesn't currently support this anyway .. but keep 284 this struct up-to-date for now. */ 285 for( bgl = yd->buddygroups; bgl; bgl = bgl->next ) 286 { 287 struct byahoo_buddygroups *bg = bgl->data; 288 289 if( g_strcasecmp( bg->buddy, who ) == 0 && 290 g_strcasecmp( bg->group, bu->group->name ) == 0 ) 291 { 292 g_free( bg->group ); 293 bg->group = g_strdup( group ); 294 } 295 } 296 } 297 else 298 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); 275 299 } 276 300 … … 341 365 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 342 366 343 yahoo_ accept_buddy_ymsg13( yd->y2_id, NULL, who);367 yahoo_confirm_buddy( yd->y2_id, who, 0, "" ); 344 368 } 345 369 … … 348 372 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 349 373 350 yahoo_ reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL);374 yahoo_confirm_buddy( yd->y2_id, who, 1, "" ); 351 375 } 352 376 … … 421 445 } 422 446 423 d->callback( d->fd, 0, d->data );447 d->callback( NULL + d->fd, 0, d->data ); 424 448 g_free( d ); 425 449 } … … 441 465 return FALSE; 442 466 443 yahoo_read_ready( d->id, d->fd, d->data );467 yahoo_read_ready( d->id, NULL + d->fd, d->data ); 444 468 445 469 return TRUE; … … 458 482 struct byahoo_write_ready_data *d = data; 459 483 460 return yahoo_write_ready( d->id, d->fd, d->data );484 return yahoo_write_ready( d->id, NULL + d->fd, d->data ); 461 485 } 462 486 … … 487 511 { 488 512 char *errstr; 489 int allow_reconnect = TRUE;513 int allow_reconnect = FALSE; 490 514 491 515 yd->logged_in = FALSE; … … 497 521 else if( succ == YAHOO_LOGIN_LOCK ) 498 522 errstr = "Yahoo! account locked"; 523 else if( succ == 1236 ) 524 errstr = "Yahoo! account locked or machine temporarily banned"; 499 525 else if( succ == YAHOO_LOGIN_DUPL ) 526 errstr = "Logged in on a different machine or device"; 527 else if( succ == YAHOO_LOGIN_SOCK ) 500 528 { 501 errstr = " Logged in on a different machine or device";502 allow_reconnect = FALSE;529 errstr = "Socket problem"; 530 allow_reconnect = TRUE; 503 531 } 504 else if( succ == YAHOO_LOGIN_SOCK )505 errstr = "Socket problem";506 532 else 507 533 errstr = "Unknown error"; … … 606 632 flags = 0; 607 633 break; 608 case YAHOO_STATUS_NOTIFY:609 state_string = "Notify";610 break;611 634 } 612 635 … … 615 638 if( stat == YAHOO_STATUS_IDLE ) 616 639 imcb_buddy_times( ic, who, 0, idle ); 640 } 641 642 void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm ) 643 { 617 644 } 618 645 … … 630 657 } 631 658 632 void ext_yahoo_got_file( int id, 633 const char *ignored, 634 const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize ) 659 void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg, 660 const char *fname, unsigned long fesize, char *trid ) 635 661 { 636 662 struct im_connection *ic = byahoo_get_ic_by_id( id ); 637 663 638 664 imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 665 } 666 667 void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data ) 668 { 669 } 670 671 void ext_yahoo_file_transfer_done( int id, int result, void *data ) 672 { 639 673 } 640 674 … … 649 683 } 650 684 651 void ext_yahoo_system_message( int id, const char *m sg )685 void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg ) 652 686 { 653 687 struct im_connection *ic = byahoo_get_ic_by_id( id ); … … 671 705 672 706 /* TODO: Clear up the mess of inp and d structures */ 673 int ext_yahoo_add_handler( int id, int fd, yahoo_input_condition cond, void *data )707 int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data ) 674 708 { 675 709 struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 ); 710 int fd = (int) fd_; 676 711 677 712 if( cond == YAHOO_INPUT_READ ) … … 700 735 { 701 736 g_free( inp ); 702 return ( -1 );737 return -1; 703 738 /* Panic... */ 704 739 } 705 740 706 741 byahoo_inputs = g_slist_append( byahoo_inputs, inp ); 707 return ( inp->h );742 return inp->h; 708 743 } 709 744 … … 729 764 } 730 765 731 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )766 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl ) 732 767 { 733 768 struct byahoo_connect_callback_data *d; … … 745 780 d->id = id; 746 781 747 return( fd ); 782 return fd; 783 } 784 785 char *ext_yahoo_get_ip_addr( const char *domain ) 786 { 787 return NULL; 788 } 789 790 int ext_yahoo_write( void *fd, char *buf, int len ) 791 { 792 return write( (int) fd, buf, len ); 793 } 794 795 int ext_yahoo_read( void *fd, char *buf, int len ) 796 { 797 return read( (int) fd, buf, len ); 798 } 799 800 void ext_yahoo_close( void *fd ) 801 { 802 close( (int) fd ); 803 } 804 805 void ext_yahoo_got_buddy_change_group( int id, const char *me, const char *who, 806 const char *old_group, const char *new_group ) 807 { 808 struct im_connection *ic = byahoo_get_ic_by_id( id ); 809 810 imcb_add_buddy( ic, who, new_group ); 748 811 } 749 812 … … 752 815 int ext_yahoo_connect(const char *host, int port) 753 816 { 754 #if 0755 struct sockaddr_in serv_addr;756 static struct hostent *server;757 static char last_host[256];758 int servfd;759 char **p;760 761 if(last_host[0] || g_strcasecmp(last_host, host)!=0) {762 if(!(server = gethostbyname(host))) {763 return -1;764 }765 strncpy(last_host, host, 255);766 }767 768 if((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {769 return -1;770 }771 772 for (p = server->h_addr_list; *p; p++)773 {774 memset(&serv_addr, 0, sizeof(serv_addr));775 serv_addr.sin_family = AF_INET;776 memcpy(&serv_addr.sin_addr.s_addr, *p, server->h_length);777 serv_addr.sin_port = htons(port);778 779 if(connect(servfd, (struct sockaddr *) &serv_addr,780 sizeof(serv_addr)) == -1) {781 return -1;782 } else {783 return servfd;784 }785 }786 787 closesocket(servfd);788 #endif789 817 return -1; 790 818 } … … 898 926 } 899 927 900 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, intfd )928 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd ) 901 929 { 902 930 } … … 926 954 } 927 955 928 void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg )929 {930 struct im_connection *ic = byahoo_get_ic_by_id( id );931 932 imcb_ask_auth( ic, who, NULL );933 }934 935 956 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) 936 957 { 937 958 struct im_connection *ic = byahoo_get_ic_by_id( id ); 938 959 939 imcb_a dd_buddy( ic, (char*) who, NULL);960 imcb_ask_auth( ic, who, msg ); 940 961 } 941 962 … … 944 965 } 945 966 946 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )967 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg ) 947 968 { 948 969 } … … 989 1010 } 990 1011 991 void ext_yahoo_got_ping( int id, const char *msg )1012 void ext_yahoo_got_ping( int id, const char *msg ) 992 1013 { 993 1014 } -
protocols/yahoo/yahoo2.h
r938c305 rc8791f2 51 51 #include "yahoo2_types.h" 52 52 53 /* returns the socket descriptor for a given pager connection. shouldn't be needed */54 intyahoo_get_fd(int id);53 /* returns the socket descriptor object for a given pager connection. shouldn't be needed */ 54 void *yahoo_get_fd(int id); 55 55 56 56 /* says how much logging to do */ 57 57 /* see yahoo2_types.h for the different values */ 58 intyahoo_set_log_level(enum yahoo_log_level level);59 enum yahoo_log_level yahoo_get_log_level( void);58 int yahoo_set_log_level(enum yahoo_log_level level); 59 enum yahoo_log_level yahoo_get_log_level(void); 60 60 61 61 /* these functions should be self explanatory */ 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 */ 199 222 /* registered by ext_yahoo_add_handler */ 200 223 /* if these return negative values, errno may be set */ 201 int yahoo_read_ready(int id, intfd, void *data);202 int yahoo_write_ready(int id, intfd, void *data);224 int yahoo_read_ready(int id, void *fd, void *data); 225 int yahoo_write_ready(int id, void *fd, void *data); 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); 221 241 222 242 #include "yahoo_httplib.h" … … 225 245 } 226 246 #endif 227 228 247 #endif -
protocols/yahoo/yahoo2_callbacks.h
r938c305 rc8791f2 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 /* … … 56 55 * 57 56 * Params: 58 * fd - The file descriptor that has been connected, or -1 on error 57 * fd - The file descriptor object that has been connected, or NULL on 58 * error 59 59 * error - The value of errno set by the call to connect or 0 if no error 60 60 * Set both fd and error to 0 if the connect was cancelled by the … … 63 63 * function 64 64 */ 65 typedef void (*yahoo_connect_callback)(int fd, int error, void *callback_data); 66 65 typedef void (*yahoo_connect_callback) (void *fd, int error, 66 void *callback_data); 67 67 68 68 /* … … 94 94 * url - url to reactivate account if locked 95 95 */ 96 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url); 97 96 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ, 97 const char *url); 98 98 99 99 /* … … 104 104 * buds - the buddy list 105 105 */ 106 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies)(int id, YList * buds); 107 106 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds); 108 107 109 108 /* … … 114 113 * igns - the ignore list 115 114 */ 116 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore)(int id, YList * igns); 117 115 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns); 118 116 119 117 /* … … 124 122 * ids - the identity list 125 123 */ 126 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities)(int id, YList * ids); 127 124 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids); 128 125 129 126 /* … … 133 130 * id - the id that identifies the server connection 134 131 */ 135 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies)(int id); 136 132 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id); 137 133 138 134 /* … … 143 139 * errormsg - optional error message 144 140 */ 145 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg); 146 141 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id, 142 const char *errormsg); 147 143 148 144 /* … … 159 155 * TODO: add support for pager, chat, and game states 160 156 */ 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 157 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id, 158 const char *who, int stat, const char *msg, int away, int idle, 159 int mobile); 160 161 /* 162 * Name: ext_yahoo_got_buzz 163 * Called when remote user sends you a buzz. 164 * Params: 165 * id - the id that identifies the server connection 166 * me - the identity the message was sent to 167 * who - the handle of the remote user 168 * tm - timestamp of message if offline 169 */ 170 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me, 171 const char *who, long tm); 163 172 164 173 /* … … 177 186 * utf8 - whether the message is encoded as utf8 or not 178 187 */ 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 188 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me, 189 const char *who, const char *msg, long tm, int stat, int utf8); 181 190 182 191 /* … … 191 200 * members - the initial members of the conference (null terminated list) 192 201 */ 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 202 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id, 203 const char *me, const char *who, const char *room, 204 const char *msg, YList *members); 195 205 196 206 /* … … 204 214 * msg - the declining message 205 215 */ 206 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg); 207 216 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id, 217 const char *me, const char *who, const char *room, 218 const char *msg); 208 219 209 220 /* … … 216 227 * room - the room joined 217 228 */ 218 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room); 219 229 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id, 230 const char *me, const char *who, const char *room); 220 231 221 232 /* … … 228 239 * room - the room left 229 240 */ 230 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room); 231 241 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id, 242 const char *me, const char *who, const char *room); 232 243 233 244 /* … … 238 249 * xml - ? 239 250 */ 240 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml); 241 251 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id, 252 const char *xml); 242 253 243 254 /* … … 252 263 * members - the initial members of the chatroom (null terminated YList 253 264 * of yahoo_chat_member's) Must be freed by the client 254 * fd - the socket where the connection is coming from (for tracking)255 */ 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 265 * fd - the object where the connection is coming from (for tracking) 266 */ 267 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me, 268 const char *room, const char *topic, YList *members, void *fd); 258 269 259 270 /* … … 266 277 * who - the user who has joined, Must be freed by the client 267 278 */ 268 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who); 269 279 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id, 280 const char *me, const char *room, 281 struct yahoo_chat_member *who); 270 282 271 283 /* … … 278 290 * who - the user who has left (Just the User ID) 279 291 */ 280 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who); 281 292 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id, 293 const char *me, const char *room, const char *who); 282 294 283 295 /* … … 294 306 * utf8 - whether the message is utf8 encoded or not 295 307 */ 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 308 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id, 309 const char *me, const char *who, const char *room, 310 const char *msg, int msgtype, int utf8); 298 311 299 312 /* … … 310 323 * nothing. 311 324 */ 312 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me); 313 325 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id, 326 const char *me); 314 327 315 328 /* … … 327 340 * nothing. 328 341 */ 329 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me); 330 342 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id, 343 const char *me); 331 344 332 345 /* … … 341 354 * utf8 - whether the message is utf8 encoded or not 342 355 */ 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 356 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id, 357 const char *me, const char *who, const char *room, 358 const char *msg, int utf8); 345 359 346 360 /* … … 351 365 * me - the identity the file was sent to 352 366 * who - the user who sent the file 353 * url - the file url354 * expires - the expiry date of the file on the server (timestamp)355 367 * msg - the message 356 368 * fname- the file name if direct transfer 357 369 * fsize- the file size if direct transfer 358 */ 359 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize); 360 361 362 /* 363 * Name: ext_yahoo_contact_auth_request 364 * Called when a contact wants to add you to his/her contact list 365 * Params: 366 * id - the id that identifies the server connection 367 * myid - the identity s/he added 368 * who - who did it 369 * msg - any message sent 370 */ 371 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_auth_request)(int id, const char *myid, const char *who, const char *msg); 372 370 * trid - transfer id. Unique for this transfer 371 * 372 * NOTE: Subsequent callbacks for file transfer do not send all of this 373 * information again since it is wasteful. Implementations are expected to 374 * save this information and supply it as callback data when the file or 375 * confirmation is sent 376 */ 377 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file) (int id, const char *me, 378 const char *who, const char *msg, const char *fname, 379 unsigned long fesize, char *trid); 380 381 /* 382 * Name: ext_yahoo_got_ft_data 383 * Called multiple times when parts of the file are received 384 * Params: 385 * id - the id that identifies the server connection 386 * in - The data 387 * len - Length of the data 388 * data - callback data 389 */ 390 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ft_data) (int id, 391 const unsigned char *in, int len, void *data); 392 393 /* 394 * Name: ext_yahoo_file_transfer_done 395 * File transfer is done 396 * Params: 397 * id - the id that identifies the server connection 398 * result - To notify if it finished successfully or with a failure 399 * data - callback data 400 */ 401 void YAHOO_CALLBACK_TYPE(ext_yahoo_file_transfer_done) (int id, 402 int result, void *data); 373 403 374 404 /* … … 381 411 * msg - any message sent 382 412 */ 383 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg); 384 413 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id, 414 const char *myid, const char *who, const char *msg); 385 415 386 416 /* … … 392 422 * msg - any message sent 393 423 */ 394 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg); 395 424 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who, 425 const char *msg); 396 426 397 427 /* … … 404 434 * stat - 1 if typing, 0 if stopped typing 405 435 */ 406 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat); 407 436 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id, 437 const char *me, const char *who, int stat); 408 438 409 439 /* … … 415 445 * who - the handle of the remote user 416 446 * stat - 1 if game, 0 if stopped gaming 417 */ 418 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const char *who, int stat); 419 447 * msg - game description and/or other text 448 */ 449 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify) (int id, const char *me, 450 const char *who, int stat, const char *msg); 420 451 421 452 /* … … 428 459 * cnt - mail count - 0 if new mail notification 429 460 */ 430 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt); 431 461 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id, 462 const char *from, const char *subj, int cnt); 432 463 433 464 /* … … 436 467 * Params: 437 468 * id - the id that identifies the server connection 469 * me - the handle of the identity the notification is sent to 470 * who - the source of the system message (there are different types) 438 471 * msg - the message 439 472 */ 440 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, const char *msg); 473 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message) (int id, 474 const char *me, const char *who, const char *msg); 441 475 442 476 /* … … 450 484 * checksum - the checksum of the icon content 451 485 */ 452 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const char *who, const char *url, int checksum); 486 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id, 487 const char *me, const char *who, const char *url, int checksum); 453 488 454 489 /* … … 461 496 * checksum - the checksum of the icon content 462 497 */ 463 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *me,const char *who, int checksum); 498 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id, 499 const char *me, const char *who, int checksum); 464 500 465 501 /* … … 471 507 * who - the yahoo id of the buddy that requested the buddy icon 472 508 */ 473 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me, const char *who); 509 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id, 510 const char *me, const char *who); 474 511 475 512 /* … … 480 517 * url - remote url, the uploaded buddy icon can be fetched from 481 518 */ 482 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url); 519 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id, 520 const char *url); 483 521 484 522 /* … … 505 543 * a timestamp to stay in sync 506 544 */ 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, 545 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id, 546 const char *who, const unsigned char *image, 547 unsigned int image_size, unsigned int real_size, 509 548 unsigned int timestamp); 510 511 549 512 550 /* … … 518 556 * from - who the invitation is from 519 557 */ 520 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from); 521 558 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id, 559 const char *me, const char *from); 522 560 523 561 /* … … 530 568 * accept - 0 (decline), 1 (accept) 531 569 */ 532 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept); 533 570 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id, 571 const char *me, const char *from, int accept); 534 572 535 573 /* … … 545 583 * 4 = user does not have webcam online 546 584 */ 547 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason); 548 585 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id, 586 const char *who, int reason); 549 587 550 588 /* … … 560 598 * if you need to use the information, make a copy 561 599 */ 562 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result)(int id, int found, int start, int total, YList *contacts); 563 600 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id, 601 int found, int start, int total, YList *contacts); 564 602 565 603 /* … … 572 610 * num - Which error is this 573 611 */ 574 void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num); 575 612 void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err, 613 int fatal, int num); 576 614 577 615 /* … … 583 621 * connect - 0=disconnect 1=connect 2=request 584 622 */ 585 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect); 586 623 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id, 624 const char *who, int connect); 587 625 588 626 /* … … 593 631 * send - whether to send images or not 594 632 */ 595 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send); 596 633 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id, 634 int send); 597 635 598 636 /* … … 604 642 * 0 605 643 */ 606 int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...); 607 644 int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...); 608 645 609 646 /* … … 614 651 * Params: 615 652 * id - the id that identifies the server connection 616 * fd - the fd o n which to listen653 * fd - the fd object on which to listen 617 654 * cond - the condition on which to call the callback 618 655 * data - callback data to pass to yahoo_*_ready … … 620 657 * Returns: a tag to be used when removing the handler 621 658 */ 622 int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler)(int id, int fd, yahoo_input_condition cond, void *data); 623 659 int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, void *fd, 660 yahoo_input_condition cond, void *data); 624 661 625 662 /* … … 630 667 * tag - the handler tag to remove 631 668 */ 632 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag); 633 669 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag); 634 670 635 671 /* … … 642 678 * a unix file descriptor to the socket 643 679 */ 644 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port); 645 680 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port); 646 681 647 682 /* 648 683 * Name: ext_yahoo_connect_async 649 * Connect to a host:port asynchronously. 684 * Connect to a host:port asynchronously. This function should return 650 685 * immediately returing a tag used to identify the connection handler, 651 686 * or a pre-connect error (eg: host name lookup failure). … … 660 695 * callback - function to call when connect completes 661 696 * callback_data - data to pass to the callback function 662 * Returns: 663 * a unix file descriptor to the socket 664 */ 665 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port, 666 yahoo_connect_callback callback, void *callback_data); 697 * use_ssl - Whether we need an SSL connection 698 * Returns: 699 * a tag signifying the connection attempt 700 */ 701 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id, 702 const char *host, int port, yahoo_connect_callback callback, 703 void *callback_data, int use_ssl); 704 705 /* 706 * Name: ext_yahoo_get_ip_addr 707 * get IP Address for a domain name 708 * Params: 709 * domain - Domain name 710 * Returns: 711 * Newly allocated string containing the IP Address in IPv4 notation 712 */ 713 char *YAHOO_CALLBACK_TYPE(ext_yahoo_get_ip_addr) (const char *domain); 714 715 /* 716 * Name: ext_yahoo_write 717 * Write data from the buffer into the socket for the specified connection 718 * Params: 719 * fd - the file descriptor object that identifies this connection 720 * buf - Buffer to write the data from 721 * len - Length of the data 722 * Returns: 723 * Number of bytes written or -1 for error 724 */ 725 int YAHOO_CALLBACK_TYPE(ext_yahoo_write) (void *fd, char *buf, int len); 726 727 /* 728 * Name: ext_yahoo_read 729 * Read data into a buffer from socket for the specified connection 730 * Params: 731 * fd - the file descriptor object that identifies this connection 732 * buf - Buffer to read the data into 733 * len - Max length to read 734 * Returns: 735 * Number of bytes read or -1 for error 736 */ 737 int YAHOO_CALLBACK_TYPE(ext_yahoo_read) (void *fd, char *buf, int len); 738 739 /* 740 * Name: ext_yahoo_close 741 * Close the file descriptor object and free its resources. Libyahoo2 will not 742 * use this object again. 743 * Params: 744 * fd - the file descriptor object that identifies this connection 745 * Returns: 746 * Nothing 747 */ 748 void YAHOO_CALLBACK_TYPE(ext_yahoo_close) (void *fd); 749 750 /* 751 * Name: ext_yahoo_got_buddy_change_group 752 * Acknowledgement of buddy changing group 753 * Params: 754 * id: client id 755 * me: The user 756 * who: Buddy name 757 * old_group: Old group name 758 * new_group: New group name 759 * Returns: 760 * Nothing 761 */ 762 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddy_change_group) (int id, 763 const char *me, const char *who, const char *old_group, 764 const char *new_group); 667 765 668 766 #ifdef USE_STRUCT_CALLBACKS … … 673 771 * before doing anything else 674 772 */ 675 void yahoo_register_callbacks(struct yahoo_callbacks * 773 void yahoo_register_callbacks(struct yahoo_callbacks *tyc); 676 774 677 775 #undef YAHOO_CALLBACK_TYPE … … 684 782 685 783 #endif 686 -
protocols/yahoo/yahoo2_types.h
r938c305 rc8791f2 29 29 #endif 30 30 31 enum yahoo_status { 32 YAHOO_STATUS_DISCONNECTED = -1, 33 YAHOO_STATUS_AVAILABLE = 0, 34 YAHOO_STATUS_BRB, 35 YAHOO_STATUS_BUSY, 36 YAHOO_STATUS_NOTATHOME, 37 YAHOO_STATUS_NOTATDESK, 38 YAHOO_STATUS_NOTINOFFICE, 39 YAHOO_STATUS_ONPHONE, 40 YAHOO_STATUS_ONVACATION, 41 YAHOO_STATUS_OUTTOLUNCH, 42 YAHOO_STATUS_STEPPEDOUT, 43 YAHOO_STATUS_INVISIBLE = 12, 44 YAHOO_STATUS_CUSTOM = 99, 45 YAHOO_STATUS_IDLE = 999, 46 YAHOO_STATUS_WEBLOGIN = 0x5a55aa55, 47 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ 48 YAHOO_STATUS_NOTIFY = 0x16 /* TYPING */ 49 }; 50 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ 51 52 enum yahoo_login_status { 53 YAHOO_LOGIN_OK = 0, 54 YAHOO_LOGIN_LOGOFF = 2, 55 YAHOO_LOGIN_UNAME = 3, 56 YAHOO_LOGIN_PASSWD = 13, 57 YAHOO_LOGIN_LOCK = 14, 58 YAHOO_LOGIN_DUPL = 99, 59 YAHOO_LOGIN_SOCK = -1, 60 }; 61 62 enum ypacket_status { 63 YPACKET_STATUS_DISCONNECTED = -1, 64 YPACKET_STATUS_DEFAULT = 0, 65 YPACKET_STATUS_SERVERACK = 1, 66 YPACKET_STATUS_GAME = 0x2, 67 YPACKET_STATUS_AWAY = 0x4, 68 YPACKET_STATUS_CONTINUED = 0x5, 69 YPACKET_STATUS_INVISIBLE = 12, 70 YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */ 71 YPACKET_STATUS_WEBLOGIN = 0x5a55aa55, 72 YPACKET_STATUS_OFFLINE = 0x5a55aa56 73 }; 74 75 enum yahoo_error { 76 E_UNKNOWN = -1, 77 E_CONNECTION = -2, 78 E_SYSTEM = -3, 79 E_CUSTOM = 0, 80 81 /* responses from ignore buddy */ 82 E_IGNOREDUP = 2, 83 E_IGNORENONE = 3, 84 E_IGNORECONF = 12, 85 86 /* conference */ 87 E_CONFNOTAVAIL = 20 88 }; 89 90 enum yahoo_log_level { 91 YAHOO_LOG_NONE = 0, 92 YAHOO_LOG_FATAL, 93 YAHOO_LOG_ERR, 94 YAHOO_LOG_WARNING, 95 YAHOO_LOG_NOTICE, 96 YAHOO_LOG_INFO, 97 YAHOO_LOG_DEBUG 98 }; 31 enum yahoo_service { /* these are easier to see in hex */ 32 YAHOO_SERVICE_LOGON = 1, 33 YAHOO_SERVICE_LOGOFF, 34 YAHOO_SERVICE_ISAWAY, 35 YAHOO_SERVICE_ISBACK, 36 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ 37 YAHOO_SERVICE_MESSAGE, 38 YAHOO_SERVICE_IDACT, 39 YAHOO_SERVICE_IDDEACT, 40 YAHOO_SERVICE_MAILSTAT, 41 YAHOO_SERVICE_USERSTAT, /* 0xa */ 42 YAHOO_SERVICE_NEWMAIL, 43 YAHOO_SERVICE_CHATINVITE, 44 YAHOO_SERVICE_CALENDAR, 45 YAHOO_SERVICE_NEWPERSONALMAIL, 46 YAHOO_SERVICE_NEWCONTACT, 47 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ 48 YAHOO_SERVICE_ADDIGNORE, 49 YAHOO_SERVICE_PING, 50 YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */ 51 YAHOO_SERVICE_SYSMESSAGE = 0x14, 52 YAHOO_SERVICE_SKINNAME = 0x15, 53 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, 54 YAHOO_SERVICE_CONFINVITE = 0x18, 55 YAHOO_SERVICE_CONFLOGON, 56 YAHOO_SERVICE_CONFDECLINE, 57 YAHOO_SERVICE_CONFLOGOFF, 58 YAHOO_SERVICE_CONFADDINVITE, 59 YAHOO_SERVICE_CONFMSG, 60 YAHOO_SERVICE_CHATLOGON, 61 YAHOO_SERVICE_CHATLOGOFF, 62 YAHOO_SERVICE_CHATMSG = 0x20, 63 YAHOO_SERVICE_GAMELOGON = 0x28, 64 YAHOO_SERVICE_GAMELOGOFF, 65 YAHOO_SERVICE_GAMEMSG = 0x2a, 66 YAHOO_SERVICE_FILETRANSFER = 0x46, 67 YAHOO_SERVICE_VOICECHAT = 0x4A, 68 YAHOO_SERVICE_NOTIFY, 69 YAHOO_SERVICE_VERIFY, 70 YAHOO_SERVICE_P2PFILEXFER, 71 YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */ 72 YAHOO_SERVICE_WEBCAM, 73 YAHOO_SERVICE_AUTHRESP = 0x54, 74 YAHOO_SERVICE_LIST, 75 YAHOO_SERVICE_AUTH = 0x57, 76 YAHOO_SERVICE_AUTHBUDDY = 0x6d, 77 YAHOO_SERVICE_ADDBUDDY = 0x83, 78 YAHOO_SERVICE_REMBUDDY, 79 YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0 */ 80 YAHOO_SERVICE_REJECTCONTACT, 81 YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ 82 YAHOO_SERVICE_Y7_PING = 0x8A, 83 YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1 */ 84 YAHOO_SERVICE_CHATGOTO, 85 YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */ 86 YAHOO_SERVICE_CHATLEAVE, 87 YAHOO_SERVICE_CHATEXIT = 0x9b, 88 YAHOO_SERVICE_CHATADDINVITE = 0x9d, 89 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 90 YAHOO_SERVICE_CHATPING, 91 YAHOO_SERVICE_COMMENT = 0xa8, 92 YAHOO_SERVICE_GAME_INVITE = 0xb7, 93 YAHOO_SERVICE_STEALTH_PERM = 0xb9, 94 YAHOO_SERVICE_STEALTH_SESSION = 0xba, 95 YAHOO_SERVICE_AVATAR = 0xbc, 96 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 97 YAHOO_SERVICE_PICTURE = 0xbe, 98 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 99 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, 100 YAHOO_SERVICE_YAB_UPDATE = 0xc4, 101 YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */ 102 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, /* YMSG13 */ 103 YAHOO_SERVICE_PICTURE_STATUS = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */ 104 YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8, 105 YAHOO_SERVICE_AUDIBLE = 0xd0, 106 YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2, 107 YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3, /* YMSG13 */ 108 YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4, 109 YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6, /* YMSG13 */ 110 YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc, /* YMSG13 */ 111 YAHOO_SERVICE_Y7_FILETRANSFERINFO, /* YMSG13 */ 112 YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, /* YMSG13 */ 113 YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */ 114 YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */ 115 YAHOO_SERVICE_MYSTERY = 0xef, /* Don't know what this is for */ 116 YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */ 117 YAHOO_SERVICE_Y8_LIST = 0Xf1, /* YMSG15 */ 118 YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb, 119 YAHOO_SERVICE_WEBLOGIN = 0x0226, 120 YAHOO_SERVICE_SMS_MSG = 0x02ea 121 }; 122 123 enum yahoo_status { 124 YAHOO_STATUS_AVAILABLE = 0, 125 YAHOO_STATUS_BRB, 126 YAHOO_STATUS_BUSY, 127 YAHOO_STATUS_NOTATHOME, 128 YAHOO_STATUS_NOTATDESK, 129 YAHOO_STATUS_NOTINOFFICE, 130 YAHOO_STATUS_ONPHONE, 131 YAHOO_STATUS_ONVACATION, 132 YAHOO_STATUS_OUTTOLUNCH, 133 YAHOO_STATUS_STEPPEDOUT, 134 YAHOO_STATUS_INVISIBLE = 12, 135 YAHOO_STATUS_CUSTOM = 99, 136 YAHOO_STATUS_IDLE = 999, 137 YAHOO_STATUS_OFFLINE = 0x5a55aa56 /* don't ask */ 138 }; 139 140 enum ypacket_status { 141 YPACKET_STATUS_DISCONNECTED = -1, 142 YPACKET_STATUS_DEFAULT = 0, 143 YPACKET_STATUS_SERVERACK = 1, 144 YPACKET_STATUS_GAME = 0x2, 145 YPACKET_STATUS_AWAY = 0x4, 146 YPACKET_STATUS_CONTINUED = 0x5, 147 YPACKET_STATUS_INVISIBLE = 12, 148 YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */ 149 YPACKET_STATUS_WEBLOGIN = 0x5a55aa55, 150 YPACKET_STATUS_OFFLINE = 0x5a55aa56 151 }; 152 153 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ 154 155 enum yahoo_login_status { 156 YAHOO_LOGIN_OK = 0, 157 YAHOO_LOGIN_LOGOFF = 1, 158 YAHOO_LOGIN_UNAME = 3, 159 YAHOO_LOGIN_PASSWD = 13, 160 YAHOO_LOGIN_LOCK = 14, 161 YAHOO_LOGIN_DUPL = 99, 162 YAHOO_LOGIN_SOCK = -1, 163 YAHOO_LOGIN_UNKNOWN = 999 164 }; 165 166 enum yahoo_error { 167 E_UNKNOWN = -1, 168 E_CONNECTION = -2, 169 E_SYSTEM = -3, 170 E_CUSTOM = 0, 171 172 /* responses from ignore buddy */ 173 E_IGNOREDUP = 2, 174 E_IGNORENONE = 3, 175 E_IGNORECONF = 12, 176 177 /* conference */ 178 E_CONFNOTAVAIL = 20 179 }; 180 181 enum yahoo_log_level { 182 YAHOO_LOG_NONE = 0, 183 YAHOO_LOG_FATAL, 184 YAHOO_LOG_ERR, 185 YAHOO_LOG_WARNING, 186 YAHOO_LOG_NOTICE, 187 YAHOO_LOG_INFO, 188 YAHOO_LOG_DEBUG 189 }; 190 191 enum yahoo_file_transfer { 192 YAHOO_FILE_TRANSFER_INIT = 1, 193 YAHOO_FILE_TRANSFER_ACCEPT = 3, 194 YAHOO_FILE_TRANSFER_REJECT = 4, 195 YAHOO_FILE_TRANSFER_DONE = 5, 196 YAHOO_FILE_TRANSFER_RELAY, 197 YAHOO_FILE_TRANSFER_FAILED, 198 YAHOO_FILE_TRANSFER_UNKNOWN 199 }; 99 200 100 201 #define YAHOO_PROTO_VER 0x0010 … … 121 222 #define YAHOO_STYLE_URLOFF "\033[xlm" 122 223 123 enum yahoo_connection_type {124 YAHOO_CONNECTION_PAGER=0,125 YAHOO_CONNECTION_FT,126 YAHOO_CONNECTION_YAB,127 YAHOO_CONNECTION_WEBCAM_MASTER,128 YAHOO_CONNECTION_WEBCAM,129 YAHOO_CONNECTION_CHATCAT,130 YAHOO_CONNECTION_SEARCH,131 YAHOO_CONNECTION_AUTH,132 };133 134 enum yahoo_webcam_direction_type {135 YAHOO_WEBCAM_DOWNLOAD=0,136 137 };138 139 enum yahoo_stealth_visibility_type {140 YAHOO_STEALTH_DEFAULT = 0,141 142 143 };224 enum yahoo_connection_type { 225 YAHOO_CONNECTION_PAGER = 0, 226 YAHOO_CONNECTION_FT, 227 YAHOO_CONNECTION_YAB, 228 YAHOO_CONNECTION_WEBCAM_MASTER, 229 YAHOO_CONNECTION_WEBCAM, 230 YAHOO_CONNECTION_CHATCAT, 231 YAHOO_CONNECTION_SEARCH, 232 YAHOO_CONNECTION_AUTH 233 }; 234 235 enum yahoo_webcam_direction_type { 236 YAHOO_WEBCAM_DOWNLOAD = 0, 237 YAHOO_WEBCAM_UPLOAD 238 }; 239 240 enum yahoo_stealth_visibility_type { 241 YAHOO_STEALTH_DEFAULT = 0, 242 YAHOO_STEALTH_ONLINE, 243 YAHOO_STEALTH_PERM_OFFLINE 244 }; 144 245 145 246 /* chat member attribs */ 146 247 #define YAHOO_CHAT_MALE 0x8000 147 248 #define YAHOO_CHAT_FEMALE 0x10000 249 #define YAHOO_CHAT_FEMALE 0x10000 148 250 #define YAHOO_CHAT_DUNNO 0x400 149 251 #define YAHOO_CHAT_WEBCAM 0x10 150 252 151 enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 }; 152 153 struct yahoo_webcam { 154 int direction; /* Uploading or downloading */ 155 int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */ 156 157 char *user; /* user we are viewing */ 158 char *server; /* webcam server to connect to */ 159 int port; /* webcam port to connect on */ 160 char *key; /* key to connect to the server with */ 161 char *description; /* webcam description */ 162 char *my_ip; /* own ip number */ 163 }; 164 165 struct yahoo_webcam_data { 166 unsigned int data_size; 167 unsigned int to_read; 168 unsigned int timestamp; 169 unsigned char packet_type; 170 }; 171 172 struct yahoo_data { 173 char *user; 174 char *password; 175 176 char *cookie_y; 177 char *cookie_t; 178 char *cookie_c; 179 char *login_cookie; 180 181 YList *buddies; 182 YList *ignore; 183 YList *identities; 184 char *login_id; 185 186 int current_status; 187 int initial_status; 188 int logged_in; 189 190 int session_id; 191 192 int client_id; 193 194 char *rawbuddylist; 195 char *ignorelist; 196 197 void *server_settings; 198 199 struct yahoo_process_status_entry *half_user; 200 }; 201 202 struct yab { 203 char *id; 204 char *fname; 205 char *lname; 206 char *nname; 207 char *email; 208 char *hphone; 209 char *wphone; 210 char *mphone; 211 int dbid; 212 }; 213 214 struct yahoo_buddy { 215 char *group; 216 char *id; 217 char *real_name; 218 struct yab *yab_entry; 219 }; 220 221 enum yahoo_search_type { 222 YAHOO_SEARCH_KEYWORD = 0, 223 YAHOO_SEARCH_YID, 224 YAHOO_SEARCH_NAME 225 }; 226 227 enum yahoo_search_gender { 228 YAHOO_GENDER_NONE = 0, 229 YAHOO_GENDER_MALE, 230 YAHOO_GENDER_FEMALE 231 }; 232 233 enum yahoo_search_agerange { 234 YAHOO_AGERANGE_NONE = 0 235 }; 236 237 struct yahoo_found_contact { 238 char *id; 239 char *gender; 240 char *location; 241 int age; 242 int online; 243 }; 253 enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 }; 254 255 struct yahoo_webcam { 256 int direction; /* Uploading or downloading */ 257 int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */ 258 259 char *user; /* user we are viewing */ 260 char *server; /* webcam server to connect to */ 261 int port; /* webcam port to connect on */ 262 char *key; /* key to connect to the server with */ 263 char *description; /* webcam description */ 264 char *my_ip; /* own ip number */ 265 }; 266 267 struct yahoo_webcam_data { 268 unsigned int data_size; 269 unsigned int to_read; 270 unsigned int timestamp; 271 unsigned char packet_type; 272 }; 273 274 struct yahoo_data { 275 char *user; 276 char *password; 277 278 char *cookie_y; 279 char *cookie_t; 280 char *cookie_c; 281 char *cookie_b; 282 char *login_cookie; 283 char *crumb; 284 char *seed; 285 286 YList *buddies; 287 YList *ignore; 288 YList *identities; 289 char *login_id; 290 291 int current_status; 292 int initial_status; 293 int logged_in; 294 295 int session_id; 296 297 int client_id; 298 299 char *rawbuddylist; 300 char *ignorelist; 301 302 void *server_settings; 303 304 struct yahoo_process_status_entry *half_user; 305 }; 306 307 struct yab { 308 int yid; 309 char *id; 310 char *fname; 311 char *lname; 312 char *nname; 313 char *email; 314 char *hphone; 315 char *wphone; 316 char *mphone; 317 int dbid; 318 }; 319 320 struct yahoo_buddy { 321 char *group; 322 char *id; 323 char *real_name; 324 struct yab *yab_entry; 325 }; 326 327 enum yahoo_search_type { 328 YAHOO_SEARCH_KEYWORD = 0, 329 YAHOO_SEARCH_YID, 330 YAHOO_SEARCH_NAME 331 }; 332 333 enum yahoo_search_gender { 334 YAHOO_GENDER_NONE = 0, 335 YAHOO_GENDER_MALE, 336 YAHOO_GENDER_FEMALE 337 }; 338 339 enum yahoo_search_agerange { 340 YAHOO_AGERANGE_NONE = 0 341 }; 342 343 struct yahoo_found_contact { 344 char *id; 345 char *gender; 346 char *location; 347 int age; 348 int online; 349 }; 244 350 245 351 /* 246 352 * Function pointer to be passed to http get/post and send file 247 353 */ 248 typedef void (*yahoo_get_fd_callback)(int id, int fd, int error, void *data); 354 typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error, 355 void *data); 249 356 250 357 /* 251 358 * Function pointer to be passed to yahoo_get_url_handle 252 359 */ 253 typedef void (*yahoo_get_url_handle_callback)(int id, int fd, int error,254 const char *filename, unsigned long size, void *data);255 256 257 struct yahoo_chat_member {258 char *id;259 intage;260 intattribs;261 char *alias;262 char *location;263 };264 265 struct yahoo_process_status_entry { 266 char *name; /* 7 name */267 int state; /* 10 state */268 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */269 int mobile; /* 60 mobile */270 char *msg; /* 19 custom status message */271 int away; /* 47 away (or invisible) */272 int buddy_session; /* 11 state */273 int f17; /* 17 in chat? then what about flags? */274 int idle; /* 137 seconds idle */275 int f138; /* 138 state */276 char *f184; /* 184 state */277 int f192; /* 192 state */278 int f10001; /* 10001 state */279 int f10002; /* 10002 state */280 int f198; /* 198 state */281 char *f197; /* 197 state */282 char *f205; /* 205 state */283 int f213; /* 213 state */284 };360 typedef void (*yahoo_get_url_handle_callback) (int id, void *fd, 361 int error, const char *filename, unsigned long size, 362 void *data); 363 364 struct yahoo_chat_member { 365 char *id; 366 int age; 367 int attribs; 368 char *alias; 369 char *location; 370 }; 371 372 struct yahoo_process_status_entry { 373 char *name; /* 7 name */ 374 int state; /* 10 state */ 375 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ 376 int mobile; /* 60 mobile */ 377 char *msg; /* 19 custom status message */ 378 int away; /* 47 away (or invisible) */ 379 int buddy_session; /* 11 state */ 380 int f17; /* 17 in chat? then what about flags? */ 381 int idle; /* 137 seconds idle */ 382 int f138; /* 138 state */ 383 char *f184; /* 184 state */ 384 int f192; /* 192 state */ 385 int f10001; /* 10001 state */ 386 int f10002; /* 10002 state */ 387 int f198; /* 198 state */ 388 char *f197; /* 197 state */ 389 char *f205; /* 205 state */ 390 int f213; /* 213 state */ 391 }; 285 392 286 393 #ifdef __cplusplus 287 394 } 288 395 #endif 289 290 396 #endif -
protocols/yahoo/yahoo_fn.h
r938c305 rc8791f2 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_httplib.c
r938c305 rc8791f2 30 30 # define strrchr rindex 31 31 # endif 32 char *strchr (), *strrchr();32 char *strchr(), *strrchr(); 33 33 # if !HAVE_MEMCPY 34 34 # define memcpy(d, s, n) bcopy ((s), (d), (n)) … … 36 36 # endif 37 37 #endif 38 39 38 40 39 #include <errno.h> … … 63 62 extern enum yahoo_log_level log_level; 64 63 65 int yahoo_tcp_readline(char *ptr, int maxlen, intfd)64 int yahoo_tcp_readline(char *ptr, int maxlen, void *fd) 66 65 { 67 66 int n, rc; … … 71 70 72 71 do { 73 rc = read(fd, &c, 1);74 } while (rc == -1 && (errno == EINTR || errno == EAGAIN));/* this is bad - it should be done asynchronously */72 rc = YAHOO_CALLBACK(ext_yahoo_read) (fd, &c, 1); 73 } while (rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */ 75 74 76 75 if (rc == 1) { 77 if (c == '\r')/* get rid of \r */76 if (c == '\r') /* get rid of \r */ 78 77 continue; 79 78 *ptr = c; … … 83 82 } else if (rc == 0) { 84 83 if (n == 1) 85 return (0); 84 return (0); /* EOF, no data */ 86 85 else 87 break; 86 break; /* EOF, w/ data */ 88 87 } else { 89 88 return -1; … … 96 95 97 96 static int url_to_host_port_path(const char *url, 98 char *host, int *port, char *path)99 { 100 char *urlcopy =NULL;101 char *slash =NULL;102 char *colon =NULL;103 97 char *host, int *port, char *path, int *ssl) 98 { 99 char *urlcopy = NULL; 100 char *slash = NULL; 101 char *colon = NULL; 102 104 103 /* 105 104 * http://hostname … … 111 110 * http://hostname:port/path 112 111 * http://hostname:port/path:foo 112 * and https:// variants of the above 113 113 */ 114 114 115 if(strstr(url, "http://") == url) { 116 urlcopy = strdup(url+7); 115 if (strstr(url, "http://") == url) { 116 urlcopy = strdup(url + 7); 117 } else if (strstr(url, "https://") == url) { 118 urlcopy = strdup(url + 8); 119 *ssl = 1; 117 120 } else { 118 121 WARNING(("Weird url - unknown protocol: %s", url)); … … 123 126 colon = strchr(urlcopy, ':'); 124 127 125 if(!colon || (slash && slash < colon)) { 126 *port = 80; 128 if (!colon || (slash && slash < colon)) { 129 if (*ssl) 130 *port = 443; 131 else 132 *port = 80; 127 133 } else { 128 134 *colon = 0; 129 *port = atoi(colon +1);130 } 131 132 if (!slash) {135 *port = atoi(colon + 1); 136 } 137 138 if (!slash) { 133 139 strcpy(path, "/"); 134 140 } else { … … 138 144 139 145 strcpy(host, urlcopy); 140 146 141 147 FREE(urlcopy); 142 148 … … 146 152 static int isurlchar(unsigned char c) 147 153 { 148 return (isalnum(c) || '-' == c || '_' == c);154 return (isalnum(c)); 149 155 } 150 156 151 157 char *yahoo_urlencode(const char *instr) 152 158 { 153 int ipos =0, bpos=0;159 int ipos = 0, bpos = 0; 154 160 char *str = NULL; 155 161 int len = strlen(instr); 156 162 157 if (!(str = y_new(char, 3*len + 1)))158 return "";159 160 while (instr[ipos]) {161 while (isurlchar(instr[ipos]))163 if (!(str = y_new(char, 3 *len + 1))) 164 return ""; 165 166 while (instr[ipos]) { 167 while (isurlchar(instr[ipos])) 162 168 str[bpos++] = instr[ipos++]; 163 if (!instr[ipos])169 if (!instr[ipos]) 164 170 break; 165 166 snprintf(&str[bpos], 4, "%%% .2x", instr[ipos]);167 bpos +=3;171 172 snprintf(&str[bpos], 4, "%%%02x", instr[ipos] & 0xff); 173 bpos += 3; 168 174 ipos++; 169 175 } 170 str[bpos] ='\0';176 str[bpos] = '\0'; 171 177 172 178 /* free extra alloc'ed mem. */ 173 179 len = strlen(str); 174 str = y_renew(char, str, len +1);180 str = y_renew(char, str, len + 1); 175 181 176 182 return (str); … … 179 185 char *yahoo_urldecode(const char *instr) 180 186 { 181 int ipos =0, bpos=0;187 int ipos = 0, bpos = 0; 182 188 char *str = NULL; 183 char entity[3] ={0,0,0};189 char entity[3] = { 0, 0, 0 }; 184 190 unsigned dec; 185 191 int len = strlen(instr); 186 192 187 if (!(str = y_new(char, len+1)))188 return "";189 190 while (instr[ipos]) {191 while (instr[ipos] && instr[ipos]!='%')192 if (instr[ipos]=='+') {193 str[bpos++] =' ';193 if (!(str = y_new(char, len + 1))) 194 return ""; 195 196 while (instr[ipos]) { 197 while (instr[ipos] && instr[ipos] != '%') 198 if (instr[ipos] == '+') { 199 str[bpos++] = ' '; 194 200 ipos++; 195 201 } else 196 202 str[bpos++] = instr[ipos++]; 197 if (!instr[ipos])203 if (!instr[ipos]) 198 204 break; 199 200 if (instr[ipos+1] && instr[ipos+2]) {205 206 if (instr[ipos + 1] && instr[ipos + 2]) { 201 207 ipos++; 202 entity[0] =instr[ipos++];203 entity[1] =instr[ipos++];208 entity[0] = instr[ipos++]; 209 entity[1] = instr[ipos++]; 204 210 sscanf(entity, "%2x", &dec); 205 211 str[bpos++] = (char)dec; … … 208 214 } 209 215 } 210 str[bpos] ='\0';216 str[bpos] = '\0'; 211 217 212 218 /* free extra alloc'ed mem. */ 213 219 len = strlen(str); 214 str = y_renew(char, str, len +1);220 str = y_renew(char, str, len + 1); 215 221 216 222 return (str); … … 219 225 char *yahoo_xmldecode(const char *instr) 220 226 { 221 int ipos =0, bpos=0, epos=0;227 int ipos = 0, bpos = 0, epos = 0; 222 228 char *str = NULL; 223 char entity[4] ={0,0,0,0};224 char *entitymap[5][2] ={225 {"amp;", "&"},229 char entity[4] = { 0, 0, 0, 0 }; 230 char *entitymap[5][2] = { 231 {"amp;", "&"}, 226 232 {"quot;", "\""}, 227 {"lt;", "<"},228 {"gt;", "<"},233 {"lt;", "<"}, 234 {"gt;", "<"}, 229 235 {"nbsp;", " "} 230 236 }; … … 232 238 int len = strlen(instr); 233 239 234 if (!(str = y_new(char, len+1)))235 return "";236 237 while (instr[ipos]) {238 while (instr[ipos] && instr[ipos]!='&')239 if (instr[ipos]=='+') {240 str[bpos++] =' ';240 if (!(str = y_new(char, len + 1))) 241 return ""; 242 243 while (instr[ipos]) { 244 while (instr[ipos] && instr[ipos] != '&') 245 if (instr[ipos] == '+') { 246 str[bpos++] = ' '; 241 247 ipos++; 242 248 } else 243 249 str[bpos++] = instr[ipos++]; 244 if (!instr[ipos] || !instr[ipos+1])250 if (!instr[ipos] || !instr[ipos + 1]) 245 251 break; 246 252 ipos++; 247 253 248 if (instr[ipos] == '#') {254 if (instr[ipos] == '#') { 249 255 ipos++; 250 epos =0;251 while (instr[ipos] != ';')252 entity[epos++] =instr[ipos++];256 epos = 0; 257 while (instr[ipos] != ';') 258 entity[epos++] = instr[ipos++]; 253 259 sscanf(entity, "%u", &dec); 254 260 str[bpos++] = (char)dec; … … 256 262 } else { 257 263 int i; 258 for (i =0; i<5; i++)259 if (!strncmp(instr+ipos, entitymap[i][0],260 261 264 for (i = 0; i < 5; i++) 265 if (!strncmp(instr + ipos, entitymap[i][0], 266 strlen(entitymap[i][0]))) { 267 str[bpos++] = entitymap[i][1][0]; 262 268 ipos += strlen(entitymap[i][0]); 263 269 break; … … 265 271 } 266 272 } 267 str[bpos] ='\0';273 str[bpos] = '\0'; 268 274 269 275 /* free extra alloc'ed mem. */ 270 276 len = strlen(str); 271 str = y_renew(char, str, len +1);277 str = y_renew(char, str, len + 1); 272 278 273 279 return (str); 274 280 } 275 281 276 typedef void (*http_connected) (int id, intfd, int error);282 typedef void (*http_connected) (int id, void *fd, int error); 277 283 278 284 struct callback_data { … … 283 289 }; 284 290 285 static void connect_complete( intfd, int error, void *data)291 static void connect_complete(void *fd, int error, void *data) 286 292 { 287 293 struct callback_data *ccd = data; 288 if(error == 0 && fd > 0) 289 write(fd, ccd->request, strlen(ccd->request)); 290 FREE(ccd->request); 294 if (error == 0) 295 YAHOO_CALLBACK(ext_yahoo_write) (fd, ccd->request, 296 strlen(ccd->request)); 297 free(ccd->request); 291 298 ccd->callback(ccd->id, fd, error, ccd->user_data); 292 299 FREE(ccd); 293 300 } 294 301 295 static void yahoo_send_http_request(int id, char *host, int port, char *request, 296 yahoo_get_fd_callback callback, void *data)297 { 298 struct callback_data *ccd =y_new0(struct callback_data, 1);302 static void yahoo_send_http_request(int id, char *host, int port, char *request, 303 yahoo_get_fd_callback callback, void *data, int use_ssl) 304 { 305 struct callback_data *ccd = y_new0(struct callback_data, 1); 299 306 ccd->callback = callback; 300 307 ccd->id = id; 301 308 ccd->request = strdup(request); 302 309 ccd->user_data = data; 303 304 YAHOO_CALLBACK(ext_yahoo_connect_async)(id, host, port, connect_complete, ccd); 305 } 306 307 void yahoo_http_post(int id, const char *url, const char *cookies, long content_length, 308 yahoo_get_fd_callback callback, void *data) 310 311 YAHOO_CALLBACK(ext_yahoo_connect_async) (id, host, port, 312 connect_complete, ccd, use_ssl); 313 } 314 315 void yahoo_http_post(int id, const char *url, const char *cookies, 316 long content_length, yahoo_get_fd_callback callback, void *data) 309 317 { 310 318 char host[255]; … … 312 320 char path[255]; 313 321 char buff[1024]; 314 315 if(!url_to_host_port_path(url, host, &port, path)) 322 int ssl = 0; 323 324 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 316 325 return; 317 326 318 snprintf(buff, sizeof(buff), 319 "POST %s HTTP/1.0\r\n" 320 "Content-length: %ld\r\n" 321 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n" 322 "Host: %s:%d\r\n" 323 "Cookie: %s\r\n" 324 "\r\n", 325 path, content_length, 326 host, port, 327 cookies); 328 329 yahoo_send_http_request(id, host, port, buff, callback, data); 330 } 331 332 void yahoo_http_get(int id, const char *url, const char *cookies, 333 yahoo_get_fd_callback callback, void *data) 327 /* thanks to kopete dumpcap */ 328 snprintf(buff, sizeof(buff), 329 "POST %s HTTP/1.1\r\n" 330 "Cookie: %s\r\n" 331 "User-Agent: Mozilla/5.0\r\n" 332 "Host: %s\r\n" 333 "Content-Length: %ld\r\n" 334 "Cache-Control: no-cache\r\n" 335 "\r\n", path, cookies, host, content_length); 336 337 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); 338 } 339 340 void yahoo_http_get(int id, const char *url, const char *cookies, int http11, 341 int keepalive, yahoo_get_fd_callback callback, void *data) 334 342 { 335 343 char host[255]; 336 344 int port = 80; 337 345 char path[255]; 338 char buff[1024]; 339 340 if(!url_to_host_port_path(url, host, &port, path)) 346 char buff[2048]; 347 char cookiebuff[1024]; 348 int ssl = 0; 349 350 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 341 351 return; 342 352 343 snprintf(buff, sizeof(buff),344 "GET %s HTTP/1.0\r\n"345 "Host: %s:%d\r\n"346 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"347 "Cookie: %s\r\n"348 "\r\n",349 path, host, port, cookies); 350 351 yahoo_send_http_request(id, host, port, buff, callback, data);352 } 353 354 struct url_data { 355 yahoo_get_url_handle_callback callback;356 void *user_data;357 }; 358 359 static void yahoo_got_url_fd(int id, int fd, int error, void *data) 360 { 361 char *tmp=NULL; 362 char buff[1024];363 unsigned long filesize=0; 364 char *filename=NULL;365 int n;366 367 struct url_data *ud = data;368 369 i f(error || fd < 0) {370 ud->callback(id, fd, error, filename, filesize, ud->user_data); 371 FREE(ud);353 /* Allow cases when we don't need to send a cookie */ 354 if (cookies) 355 snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n", 356 cookies); 357 else 358 cookiebuff[0] = '\0'; 359 360 snprintf(buff, sizeof(buff), 361 "GET %s HTTP/1.%s\r\n" 362 "%sHost: %s\r\n" 363 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n" 364 "Accept: */*\r\n" 365 "%s" "\r\n", path, http11?"1":"0", cookiebuff, host, 366 keepalive? "Connection: Keep-Alive\r\n":"Connection: close\r\n"); 367 368 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); 369 } 370 371 void yahoo_http_head(int id, const char *url, const char *cookies, int len, 372 char *payload, yahoo_get_fd_callback callback, void *data) 373 { 374 char host[255]; 375 int port = 80; 376 char path[255]; 377 char buff[2048]; 378 char cookiebuff[1024]; 379 int ssl = 0; 380 381 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 372 382 return; 373 } 374 375 while((n=yahoo_tcp_readline(buff, sizeof(buff), fd)) > 0) { 376 LOG(("Read:%s:\n", buff)); 377 if(!strcmp(buff, "")) 378 break; 379 380 if( !strncasecmp(buff, "Content-length:", 381 strlen("Content-length:")) ) { 382 tmp = strrchr(buff, ' '); 383 if(tmp) 384 filesize = atol(tmp); 385 } 386 387 if( !strncasecmp(buff, "Content-disposition:", 388 strlen("Content-disposition:")) ) { 389 tmp = strstr(buff, "name="); 390 if(tmp) { 391 tmp+=strlen("name="); 392 if(tmp[0] == '"') { 393 char *tmp2; 394 tmp++; 395 tmp2 = strchr(tmp, '"'); 396 if(tmp2) 397 *tmp2 = '\0'; 398 } else { 399 char *tmp2; 400 tmp2 = strchr(tmp, ';'); 401 if(!tmp2) 402 tmp2 = strchr(tmp, '\r'); 403 if(!tmp2) 404 tmp2 = strchr(tmp, '\n'); 405 if(tmp2) 406 *tmp2 = '\0'; 407 } 408 409 filename = strdup(tmp); 410 } 411 } 412 } 413 414 LOG(("n == %d\n", n)); 415 LOG(("Calling callback, filename:%s, size: %ld\n", filename, filesize)); 416 ud->callback(id, fd, error, filename, filesize, ud->user_data); 417 FREE(ud); 418 FREE(filename); 419 } 420 421 void yahoo_get_url_fd(int id, const char *url, const struct yahoo_data *yd, 422 yahoo_get_url_handle_callback callback, void *data) 423 { 424 char buff[1024]; 425 struct url_data *ud = y_new0(struct url_data, 1); 426 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 427 ud->callback = callback; 428 ud->user_data = data; 429 yahoo_http_get(id, url, buff, yahoo_got_url_fd, ud); 430 } 431 383 384 /* Allow cases when we don't need to send a cookie */ 385 if (cookies) 386 snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n", 387 cookies); 388 else 389 cookiebuff[0] = '\0'; 390 391 snprintf(buff, sizeof(buff), 392 "HEAD %s HTTP/1.0\r\n" 393 "Accept: */*\r\n" 394 "Host: %s:%d\r\n" 395 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n" 396 "%s" 397 "Content-Length: %d\r\n" 398 "Cache-Control: no-cache\r\n" 399 "\r\n%s", path, host, port, cookiebuff, len, 400 payload?payload:""); 401 402 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); 403 } 404 -
protocols/yahoo/yahoo_httplib.h
r938c305 rc8791f2 29 29 #include "yahoo2_types.h" 30 30 31 char *yahoo_urlencode(const char *instr);32 char *yahoo_urldecode(const char *instr);33 char *yahoo_xmldecode(const char *instr);31 char *yahoo_urlencode(const char *instr); 32 char *yahoo_urldecode(const char *instr); 33 char *yahoo_xmldecode(const char *instr); 34 34 35 int yahoo_tcp_readline(char *ptr, int maxlen, int fd); 36 void yahoo_http_post(int id, const char *url, const char *cookies, long size, 37 yahoo_get_fd_callback callback, void *data); 38 void yahoo_http_get(int id, const char *url, const char *cookies, 39 yahoo_get_fd_callback callback, void *data); 40 void yahoo_get_url_fd(int id, const char *url, const struct yahoo_data *yd, 41 yahoo_get_url_handle_callback callback, void *data); 42 35 int yahoo_tcp_readline(char *ptr, int maxlen, void *fd); 36 void yahoo_http_post(int id, const char *url, const char *cookies, 37 long size, yahoo_get_fd_callback callback, void *data); 38 void yahoo_http_get(int id, const char *url, const char *cookies, 39 int http11, int keepalive, yahoo_get_fd_callback callback, 40 void *data); 41 void yahoo_http_head(int id, const char *url, const char *cookies, 42 int size, char *payload, yahoo_get_fd_callback callback, 43 void *data); 43 44 44 45 #ifdef __cplusplus 45 46 } 46 47 #endif 47 48 48 #endif -
protocols/yahoo/yahoo_list.h
r938c305 rc8791f2 24 24 #define __YLIST_H__ 25 25 26 /* GLib has linked list already, so I don't see why libyahoo2 has to copy this... */26 /* BitlBee already uses GLib so use it. */ 27 27 28 28 typedef GList YList; -
protocols/yahoo/yahoo_util.c
r938c305 rc8791f2 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 rc8791f2 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.