Changeset 7869e48 for libfaim/ft.c


Ignore:
Timestamp:
Jan 12, 2013, 1:43:13 PM (11 years ago)
Author:
Jason Gross <jgross@mit.edu>
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)
Message:
Remove trailing whitespace

This commit was made with the command sequence

    for i in $(git ls-files | tr '\n' ' ');
    do
      echo $i; sed -i s'/\s\+$//g' "$(readlink -f $i)";
    done
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/ft.c

    rfa8f439 r7869e48  
    33 * (ODC is also referred to as DirectIM and IM Image.)
    44 *
    5  * There are a few static helper functions at the top, then 
     5 * There are a few static helper functions at the top, then
    66 * ODC stuff, then ft stuff.
    77 *
    8  * I feel like this is a good place to explain OFT, so I'm going to 
    9  * do just that.  Each OFT packet has a header type.  I guess this 
    10  * is pretty similar to the subtype of a SNAC packet.  The type 
    11  * basically tells the other client the meaning of the OFT packet. 
    12  * There are two distinct types of file transfer, which I usually 
    13  * call "sendfile" and "getfile."  Sendfile is when you send a file 
    14  * to another AIM user.  Getfile is when you share a group of files, 
     8 * I feel like this is a good place to explain OFT, so I'm going to
     9 * do just that.  Each OFT packet has a header type.  I guess this
     10 * is pretty similar to the subtype of a SNAC packet.  The type
     11 * basically tells the other client the meaning of the OFT packet.
     12 * There are two distinct types of file transfer, which I usually
     13 * call "sendfile" and "getfile."  Sendfile is when you send a file
     14 * to another AIM user.  Getfile is when you share a group of files,
    1515 * and other users request that you send them the files.
    1616 *
    1717 * A typical sendfile file transfer goes like this:
    18  *   1) Sender sends a channel 2 ICBM telling the other user that 
    19  *      we want to send them a file.  At the same time, we open a 
    20  *      listener socket (this should be done before sending the 
    21  *      ICBM) on some port, and wait for them to connect to us. 
    22  *      The ICBM we sent should contain our IP address and the port 
     18 *   1) Sender sends a channel 2 ICBM telling the other user that
     19 *      we want to send them a file.  At the same time, we open a
     20 *      listener socket (this should be done before sending the
     21 *      ICBM) on some port, and wait for them to connect to us.
     22 *      The ICBM we sent should contain our IP address and the port
    2323 *      number that we're listening on.
    24  *   2) The receiver connects to the sender on the given IP address 
    25  *      and port.  After the connection is established, the receiver 
     24 *   2) The receiver connects to the sender on the given IP address
     25 *      and port.  After the connection is established, the receiver
    2626 *      sends an ICBM signifying that we are ready and waiting.
    27  *   3) The sender sends an OFT PROMPT message over the OFT 
     27 *   3) The sender sends an OFT PROMPT message over the OFT
    2828 *      connection.
    29  *   4) The receiver of the file sends back an exact copy of this 
    30  *      OFT packet, except the cookie is filled in with the cookie 
    31  *      from the ICBM.  I think this might be an attempt to verify 
    32  *      that the user that is connected is actually the guy that 
     29 *   4) The receiver of the file sends back an exact copy of this
     30 *      OFT packet, except the cookie is filled in with the cookie
     31 *      from the ICBM.  I think this might be an attempt to verify
     32 *      that the user that is connected is actually the guy that
    3333 *      we sent the ICBM to.  Oh, I've been calling this the ACK.
    34  *   5) The sender starts sending raw data across the connection 
     34 *   5) The sender starts sending raw data across the connection
    3535 *      until the entire file has been sent.
    36  *   6) The receiver knows the file is finished because the sender 
    37  *      sent the file size in an earlier OFT packet.  So then the 
    38  *      receiver sends the DONE thingy (after filling in the 
     36 *   6) The receiver knows the file is finished because the sender
     37 *      sent the file size in an earlier OFT packet.  So then the
     38 *      receiver sends the DONE thingy (after filling in the
    3939 *      "received" checksum and size) and closes the connection.
    4040 */
     
    102102 * Calculate oft checksum of buffer
    103103 *
    104  * Prevcheck should be 0xFFFF0000 when starting a checksum of a file.  The 
    105  * checksum is kind of a rolling checksum thing, so each time you get bytes 
    106  * of a file you just call this puppy and it updates the checksum.  You can 
    107  * calculate the checksum of an entire file by calling this in a while or a 
     104 * Prevcheck should be 0xFFFF0000 when starting a checksum of a file.  The
     105 * checksum is kind of a rolling checksum thing, so each time you get bytes
     106 * of a file you just call this puppy and it updates the checksum.  You can
     107 * calculate the checksum of an entire file by calling this in a while or a
    108108 * for loop, or something.
    109109 *
    110  * Thanks to Graham Booker for providing this improved checksum routine, 
    111  * which is simpler and should be more accurate than Josh Myer's original 
     110 * Thanks to Graham Booker for providing this improved checksum routine,
     111 * which is simpler and should be more accurate than Josh Myer's original
    112112 * code. -- wtm
    113113 *
    114  * This algorithim works every time I have tried it.  The other fails 
    115  * sometimes.  So, AOL who thought this up?  It has got to be the weirdest 
     114 * This algorithim works every time I have tried it.  The other fails
     115 * sometimes.  So, AOL who thought this up?  It has got to be the weirdest
    116116 * checksum I have ever seen.
    117117 *
     
    134134                check -= val;
    135135                /*
    136                  * The following appears to be necessary.... It happens 
     136                 * The following appears to be necessary.... It happens
    137137                 * every once in a while and the checksum doesn't fail.
    138138                 */
     
    164164 * Create a listening socket on a given port.
    165165 *
    166  * XXX - Give the client author the responsibility of setting up a 
    167  *       listener, then we no longer have a libfaim problem with broken 
     166 * XXX - Give the client author the responsibility of setting up a
     167 *       listener, then we no longer have a libfaim problem with broken
    168168 *       solaris *innocent smile* -- jbm
    169169 *
     
    187187                perror("getaddrinfo");
    188188                return -1;
    189         } 
     189        }
    190190        ressave = res;
    191         do { 
     191        do {
    192192                listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
    193193                if (listenfd < 0)
     
    313313 * @param sess The session.
    314314 * @param conn The already-connected ODC connection.
    315  * @param typing If 0x0002, sends a "typing" message, 0x0001 sends "typed," and 
     315 * @param typing If 0x0002, sends a "typing" message, 0x0001 sends "typed," and
    316316 *        0x0000 sends "stopped."
    317317 * @return Return 0 if no errors, otherwise return the error number.
     
    386386 * Send client-to-client IM over an established direct connection.
    387387 * Call this just like you would aim_send_im, to send a directim.
    388  * 
     388 *
    389389 * @param sess The session.
    390390 * @param conn The already-connected ODC connection.
     
    453453        /* end of hdr2 */
    454454
    455 #if 0 /* XXX - this is how you send buddy icon info... */       
     455#if 0 /* XXX - this is how you send buddy icon info... */
    456456        aimbs_put16(hdrbs, 0x0008);
    457457        aimbs_put16(hdrbs, 0x000c);
     
    472472/**
    473473 * Get the screen name of the peer of a direct connection.
    474  * 
     474 *
    475475 * @param conn The ODC connection.
    476476 * @return The screen name of the dude, or NULL if there was an anomaly.
     
    483483                return NULL;
    484484
    485         if ((conn->type != AIM_CONN_TYPE_RENDEZVOUS) || 
     485        if ((conn->type != AIM_CONN_TYPE_RENDEZVOUS) ||
    486486                        (conn->subtype != AIM_CONN_SUBTYPE_OFT_DIRECTIM))
    487487                return NULL;
     
    497497 * @param sess The session.
    498498 * @param sn The screen name of the buddy whose direct connection you want to find.
    499  * @return The conn for the direct connection with the given buddy, or NULL if no 
     499 * @return The conn for the direct connection with the given buddy, or NULL if no
    500500 *         connection was found.
    501501 */
     
    522522 * For those times when we want to open up the direct connection channel ourselves.
    523523 *
    524  * You'll want to set up some kind of watcher on this socket. 
    525  * When the state changes, call aim_handlerendconnection with 
    526  * the connection returned by this.  aim_handlerendconnection 
     524 * You'll want to set up some kind of watcher on this socket.
     525 * When the state changes, call aim_handlerendconnection with
     526 * the connection returned by this.  aim_handlerendconnection
    527527 * will accept the pending connection and stop listening.
    528528 *
     
    586586 * This is a wrapper for aim_newconn.
    587587 *
    588  * If addr is NULL, the socket is not created, but the connection is 
     588 * If addr is NULL, the socket is not created, but the connection is
    589589 * allocated and setup to connect.
    590590 *
     
    683683                        if (payloadlength - recvd >= 1024)
    684684                                i = aim_recv(conn->fd, &msg[recvd], 1024);
    685                         else 
     685                        else
    686686                                i = aim_recv(conn->fd, &msg[recvd], payloadlength - recvd);
    687687                        if (i <= 0) {
     
    694694                                ret = userfunc(sess, &fr, snptr, (double)recvd / payloadlength);
    695695                }
    696                
     696
    697697                if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)))
    698698                        ret = userfunc(sess, &fr, snptr, msg, payloadlength, encoding, isawaymsg);
     
    746746
    747747/**
    748  * Remove the given oft_info struct from the oft_info linked list, and 
     748 * Remove the given oft_info struct from the oft_info linked list, and
    749749 * then free its memory.
    750750 *
     
    781781 * Creates a listener socket so the other dude can connect to us.
    782782 *
    783  * You'll want to set up some kind of watcher on this socket. 
    784  * When the state changes, call aim_handlerendconnection with 
    785  * the connection returned by this.  aim_handlerendconnection 
     783 * You'll want to set up some kind of watcher on this socket.
     784 * When the state changes, call aim_handlerendconnection with
     785 * the connection returned by this.  aim_handlerendconnection
    786786 * will accept the pending connection and stop listening.
    787787 *
    788788 * @param sess The session.
    789  * @param oft_info File transfer information associated with this 
     789 * @param oft_info File transfer information associated with this
    790790 *        connection.
    791791 * @return Return 0 if no errors, otherwise return the error number.
     
    855855
    856856        return fh;
    857 } 
     857}
    858858
    859859/**
     
    865865 */
    866866static int aim_oft_buildheader(aim_bstream_t *bs, struct aim_fileheader_t *fh)
    867 { 
     867{
    868868        fu8_t *hdr;
    869869
     
    910910 * @param sess The session.
    911911 * @param type The subtype of the OFT packet we're sending.
    912  * @param oft_info The aim_oft_info struct with the connection and OFT 
     912 * @param oft_info The aim_oft_info struct with the connection and OFT
    913913 *        info we're sending.
    914914 * @return Return 0 if no errors, otherwise return the error number.
     
    923923#if 0
    924924        /*
    925          * If you are receiving a file, the cookie should be null, if you are sending a 
    926          * file, the cookie should be the same as the one used in the ICBM negotiation 
     925         * If you are receiving a file, the cookie should be null, if you are sending a
     926         * file, the cookie should be the same as the one used in the ICBM negotiation
    927927         * SNACs.
    928928         */
     
    956956
    957957/**
    958  * Handle incoming data on a rendezvous connection.  This is analogous to the 
    959  * consumesnac function in rxhandlers.c, and I really think this should probably 
     958 * Handle incoming data on a rendezvous connection.  This is analogous to the
     959 * consumesnac function in rxhandlers.c, and I really think this should probably
    960960 * be in rxhandlers.c as well, but I haven't finished cleaning everything up yet.
    961961 *
    962962 * @param sess The session.
    963963 * @param fr The frame allocated for the incoming data.
    964  * @return Return 0 if the packet was handled correctly, otherwise return the 
     964 * @return Return 0 if the packet was handled correctly, otherwise return the
    965965 *         error number.
    966966 */
Note: See TracChangeset for help on using the changeset viewer.