Changeset 7869e48 for libfaim/conn.c
- Timestamp:
- Jan 12, 2013, 1:43:13 PM (11 years ago)
- Children:
- e3a0d71, 4485285
- Parents:
- 4626016
- git-author:
- Jason Gross <jgross@mit.edu> (01/12/13 13:13:18)
- git-committer:
- Jason Gross <jgross@mit.edu> (01/12/13 13:43:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/conn.c
rcf02dd6 r7869e48 8 8 #define FAIM_INTERNAL 9 9 #define FAIM_NEED_CONN_INTERNAL 10 #include <aim.h> 10 #include <aim.h> 11 11 12 12 #ifndef _WIN32 … … 23 23 * In OSCAR, every connection has a set of SNAC groups associated 24 24 * with it. These are the groups that you can send over this connection 25 * without being guarenteed a "Not supported" SNAC error. 26 * 27 * The grand theory of things says that these associations transcend 25 * without being guarenteed a "Not supported" SNAC error. 26 * 27 * The grand theory of things says that these associations transcend 28 28 * what libfaim calls "connection types" (conn->type). You can probably 29 * see the elegance here, but since I want to revel in it for a bit, you 29 * see the elegance here, but since I want to revel in it for a bit, you 30 30 * get to hear it all spelled out. 31 31 * … … 33 33 * of your modules has just given you a SNAC of the group 0x0004 to send 34 34 * you. Maybe an IM destined for some twit in Greenland. So you start 35 * at the top of your connection list, looking for a connection that 35 * at the top of your connection list, looking for a connection that 36 36 * claims to support group 0x0004. You find one. Why, that neat BOS 37 37 * connection of yours can do that. So you send it on its way. … … 51 51 * that connection. One of the first things you get from this new server 52 52 * is a message saying that indeed it does support the group you were looking 53 * for. So you continue and send rate confirmation and all that. 54 * 53 * for. So you continue and send rate confirmation and all that. 54 * 55 55 * Then you remember you had that SNAC to send, and now you have a means to 56 56 * do it, and you do, and everyone is happy. Except the Greenlander, who is … … 65 65 * to make libfaim work that way. It would take a fair amount of effort, 66 66 * and probably some client API changes as well. (Whenever I don't want 67 * to do something, I just say it would change the client API. Then I 67 * to do something, I just say it would change the client API. Then I 68 68 * instantly have a couple of supporters of not doing it.) 69 69 * … … 159 159 aim_tx_cleanqueue(sess, *deadconn); 160 160 161 if ((*deadconn)->fd != -1) 161 if ((*deadconn)->fd != -1) 162 162 aim_conn_close(*deadconn); 163 163 … … 251 251 aim_conn_t *newconn; 252 252 253 if (!(newconn = malloc(sizeof(aim_conn_t)))) 253 if (!(newconn = malloc(sizeof(aim_conn_t)))) 254 254 return NULL; 255 255 memset(newconn, 0, sizeof(aim_conn_t)); … … 282 282 aim_conn_t *cur, **prev; 283 283 284 if (!deadconn || !*deadconn) 284 if (!deadconn || !*deadconn) 285 285 return; 286 286 … … 307 307 * Close (but not free) a connection. 308 308 * 309 * This leaves everything untouched except for clearing the 309 * This leaves everything untouched except for clearing the 310 310 * handler list and setting the fd to -1 (used to recognize 311 311 * dead connections). It will also remove cookies if necessary. … … 335 335 * @type: Type of connection to look for 336 336 * 337 * Searches for a connection of the specified type in the 337 * Searches for a connection of the specified type in the 338 338 * specified session. Returns the first connection of that 339 339 * type found. … … 347 347 348 348 for (cur = sess->connlist; cur; cur = cur->next) { 349 if ((cur->type == type) && 349 if ((cur->type == type) && 350 350 !(cur->status & AIM_CONN_STATUS_INPROGRESS)) 351 351 break; … … 381 381 382 382 /** 383 * aim_proxyconnect - An extrememly quick and dirty SOCKS5 interface. 383 * aim_proxyconnect - An extrememly quick and dirty SOCKS5 interface. 384 384 * @sess: Session to connect 385 385 * @host: Host to connect to … … 584 584 * this function only gets called for some of that rendezvous 585 585 * crap, and not on SNAC connections, its probably okay for 586 * now. 586 * now. 587 587 * 588 588 */ … … 600 600 * Opens a new connection to the specified dest host of specified 601 601 * type, using the proxy settings if available. If @host is %NULL, 602 * the connection is allocated and returned, but no connection 602 * the connection is allocated and returned, but no connection 603 603 * is made. 604 604 * … … 625 625 } 626 626 627 /* 628 * As of 23 Jul 1999, AOL now sends the port number, preceded by a 629 * colon, in the BOS redirect. This fatally breaks all previous 627 /* 628 * As of 23 Jul 1999, AOL now sends the port number, preceded by a 629 * colon, in the BOS redirect. This fatally breaks all previous 630 630 * libfaims. Bad, bad AOL. 631 631 * 632 * We put this here to catch every case. 632 * We put this here to catch every case. 633 633 * 634 634 */ … … 662 662 * @sess: Session to search 663 663 * 664 * Returns the highest valued filed descriptor of all open 664 * Returns the highest valued filed descriptor of all open 665 665 * connections in @sess. 666 666 * … … 708 708 * Waits for a socket with data or for timeout, whichever comes first. 709 709 * See select(2). 710 * 710 * 711 711 * Return codes in *status: 712 712 * -1 error in select() (%NULL returned) … … 715 715 * 2 incoming data pending (connection with pending data returned) 716 716 * 717 */ 717 */ 718 718 faim_export aim_conn_t *aim_select(aim_session_t *sess, struct timeval *timeout, int *status) 719 719 { … … 745 745 } 746 746 747 /* 747 /* 748 748 * If we have data waiting to be sent, return 749 749 * … … 762 762 *status = 1; 763 763 return NULL; 764 } 764 } 765 765 766 766 if ((i = select(maxfd+1, &fds, &wfds, NULL, timeout))>=1) { 767 767 for (cur = sess->connlist; cur; cur = cur->next) { 768 if ((FD_ISSET(cur->fd, &fds)) || 769 ((cur->status & AIM_CONN_STATUS_INPROGRESS) && 768 if ((FD_ISSET(cur->fd, &fds)) || 769 ((cur->status & AIM_CONN_STATUS_INPROGRESS) && 770 770 FD_ISSET(cur->fd, &wfds))) { 771 771 *status = 2; … … 790 790 * 791 791 * This is my lame attempt at overcoming not understanding the rate 792 * limiting. 792 * limiting. 793 793 * 794 794 * XXX: This should really be replaced with something that scales and … … 817 817 * Call this with your SOCKS5 proxy server parameters before 818 818 * the first call to aim_newconn(). If called with all %NULL 819 * args, it will clear out a previously set proxy. 819 * args, it will clear out a previously set proxy. 820 820 * 821 821 * Set username and password to %NULL if not applicable. … … 833 833 834 834 strncpy(sess->socksproxy.server, server, sizeof(sess->socksproxy.server)); 835 if (username && strlen(username)) 835 if (username && strlen(username)) 836 836 strncpy(sess->socksproxy.username, username, sizeof(sess->socksproxy.username)); 837 837 if (password && strlen(password)) … … 850 850 851 851 /** 852 * Initializes a session structure by setting the initial values 852 * Initializes a session structure by setting the initial values 853 853 * stuff in the aim_session_t struct. 854 854 * … … 893 893 /* 894 894 * This must always be set. Default to the queue-based 895 * version for back-compatibility. 895 * version for back-compatibility. 896 896 */ 897 897 aim_tx_setenqueue(sess, AIM_TX_QUEUED, NULL);
Note: See TracChangeset
for help on using the changeset viewer.