Ignore:
Timestamp:
2015-02-20T22:50:54Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
0b9daac, 3d45471, 7733b8c
Parents:
af359b4
git-author:
Indent <please@…> (19-02-15 05:47:20)
git-committer:
dequis <dx@…> (20-02-15 22:50:54)
Message:

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/conn.c

    raf359b4 r5ebff60  
    77 */
    88
    9 #include <aim.h> 
     9#include <aim.h>
    1010#include "sock.h"
    1111
     
    1515 * In OSCAR, every connection has a set of SNAC groups associated
    1616 * with it.  These are the groups that you can send over this connection
    17  * without being guarenteed a "Not supported" SNAC error. 
    18  *
    19  * The grand theory of things says that these associations transcend 
     17 * without being guarenteed a "Not supported" SNAC error.
     18 *
     19 * The grand theory of things says that these associations transcend
    2020 * what libfaim calls "connection types" (conn->type).  You can probably
    21  * see the elegance here, but since I want to revel in it for a bit, you 
     21 * see the elegance here, but since I want to revel in it for a bit, you
    2222 * get to hear it all spelled out.
    2323 *
     
    2525 * of your modules has just given you a SNAC of the group 0x0004 to send
    2626 * you.  Maybe an IM destined for some twit in Greenland.  So you start
    27  * at the top of your connection list, looking for a connection that 
     27 * at the top of your connection list, looking for a connection that
    2828 * claims to support group 0x0004.  You find one.  Why, that neat BOS
    2929 * connection of yours can do that.  So you send it on its way.
     
    4343 * that connection.  One of the first things you get from this new server
    4444 * is a message saying that indeed it does support the group you were looking
    45  * for.  So you continue and send rate confirmation and all that. 
    46  * 
     45 * for.  So you continue and send rate confirmation and all that.
     46 *
    4747 * Then you remember you had that SNAC to send, and now you have a means to
    4848 * do it, and you do, and everyone is happy.  Except the Greenlander, who is
     
    5757 * to make libfaim work that way.  It would take a fair amount of effort,
    5858 * and probably some client API changes as well.  (Whenever I don't want
    59  * to do something, I just say it would change the client API.  Then I 
     59 * to do something, I just say it would change the client API.  Then I
    6060 * instantly have a couple of supporters of not doing it.)
    6161 *
     
    6969void aim_conn_addgroup(aim_conn_t *conn, guint16 group)
    7070{
    71         aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
     71        aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
    7272        struct snacgroup *sg;
    7373
    74         if (!(sg = g_malloc(sizeof(struct snacgroup))))
     74        if (!(sg = g_malloc(sizeof(struct snacgroup)))) {
    7575                return;
     76        }
    7677
    7778        sg->group = group;
     
    8889
    8990        for (cur = sess->connlist; cur; cur = cur->next) {
    90                 aim_conn_inside_t *ins = (aim_conn_inside_t *)cur->inside;
     91                aim_conn_inside_t *ins = (aim_conn_inside_t *) cur->inside;
    9192                struct snacgroup *sg;
    9293
    9394                for (sg = ins->groups; sg; sg = sg->next) {
    94                         if (sg->group == group)
     95                        if (sg->group == group) {
    9596                                return cur;
     97                        }
    9698                }
    9799        }
     
    150152        aim_tx_cleanqueue(sess, *deadconn);
    151153
    152         if ((*deadconn)->fd != -1)
     154        if ((*deadconn)->fd != -1) {
    153155                aim_conn_close(*deadconn);
     156        }
    154157
    155158        /*
     
    158161         * ->internal instead.
    159162         */
    160         if ((*deadconn)->priv)
     163        if ((*deadconn)->priv) {
    161164                g_free((*deadconn)->priv);
     165        }
    162166
    163167        /*
    164168         * This will free ->internal if it necessary...
    165169         */
    166         if ((*deadconn)->type == AIM_CONN_TYPE_CHAT)
     170        if ((*deadconn)->type == AIM_CONN_TYPE_CHAT) {
    167171                aim_conn_kill_chat(sess, *deadconn);
     172        }
    168173
    169174        if ((*deadconn)->inside) {
    170                 aim_conn_inside_t *inside = (aim_conn_inside_t *)(*deadconn)->inside;
     175                aim_conn_inside_t *inside = (aim_conn_inside_t *) (*deadconn)->inside;
    171176
    172177                connkill_snacgroups(&inside->groups);
     
    218223{
    219224
    220         if (!deadconn)
     225        if (!deadconn) {
    221226                return;
     227        }
    222228
    223229        deadconn->fd = -1;
     
    245251        aim_conn_t *newconn;
    246252
    247         if (!(newconn = g_new0(aim_conn_t,1))) 
     253        if (!(newconn = g_new0(aim_conn_t, 1))) {
    248254                return NULL;
    249 
    250         if (!(newconn->inside = g_new0(aim_conn_inside_t,1))) {
     255        }
     256
     257        if (!(newconn->inside = g_new0(aim_conn_inside_t, 1))) {
    251258                g_free(newconn);
    252259                return NULL;
     
    274281        aim_conn_t *cur, **prev;
    275282
    276         if (!deadconn || !*deadconn)   
     283        if (!deadconn || !*deadconn) {
    277284                return;
     285        }
    278286
    279287        for (prev = &sess->connlist; (cur = *prev); ) {
     
    285293        }
    286294
    287         if (!cur)
     295        if (!cur) {
    288296                return; /* oops */
    289297
     298        }
    290299        connkill_real(sess, &cur);
    291300
     
    299308 * Close (but not free) a connection.
    300309 *
    301  * This leaves everything untouched except for clearing the 
     310 * This leaves everything untouched except for clearing the
    302311 * handler list and setting the fd to -1 (used to recognize
    303312 * dead connections).  It will also remove cookies if necessary.
     
    307316{
    308317
    309         if (deadconn->fd >= 3)
     318        if (deadconn->fd >= 3) {
    310319                closesocket(deadconn->fd);
     320        }
    311321        deadconn->fd = -1;
    312         if (deadconn->handlerlist)
     322        if (deadconn->handlerlist) {
    313323                aim_clearhandlers(deadconn);
     324        }
    314325
    315326        return;
     
    321332 * @type: Type of connection to look for
    322333 *
    323  * Searches for a connection of the specified type in the 
     334 * Searches for a connection of the specified type in the
    324335 * specified session.  Returns the first connection of that
    325336 * type found.
     
    333344
    334345        for (cur = sess->connlist; cur; cur = cur->next) {
    335                 if ((cur->type == type) && 
    336                                 !(cur->status & AIM_CONN_STATUS_INPROGRESS))
     346                if ((cur->type == type) &&
     347                    !(cur->status & AIM_CONN_STATUS_INPROGRESS)) {
    337348                        break;
     349                }
    338350        }
    339351
     
    346358
    347359        for (cur = sess->connlist; cur; cur = cur->next) {
    348                 if (cur->type == type)
     360                if (cur->type == type) {
    349361                        break;
     362                }
    350363        }
    351364
     
    361374 * Opens a new connection to the specified dest host of specified
    362375 * type, using the proxy settings if available.  If @host is %NULL,
    363  * the connection is allocated and returned, but no connection 
     376 * the connection is allocated and returned, but no connection
    364377 * is made.
    365378 *
     
    374387        int i;
    375388
    376         if (!(connstruct = aim_conn_getnext(sess)))
     389        if (!(connstruct = aim_conn_getnext(sess))) {
    377390                return NULL;
    378 
    379         connstruct->sessv = (void *)sess;
     391        }
     392
     393        connstruct->sessv = (void *) sess;
    380394        connstruct->type = type;
    381395
     
    386400        }
    387401
    388         /* 
    389          * As of 23 Jul 1999, AOL now sends the port number, preceded by a 
    390          * colon, in the BOS redirect.  This fatally breaks all previous 
     402        /*
     403         * As of 23 Jul 1999, AOL now sends the port number, preceded by a
     404         * colon, in the BOS redirect.  This fatally breaks all previous
    391405         * libfaims.  Bad, bad AOL.
    392406         *
    393          * We put this here to catch every case. 
     407         * We put this here to catch every case.
    394408         *
    395409         */
    396410
    397         for(i = 0; i < (int)strlen(dest); i++) {
     411        for (i = 0; i < (int) strlen(dest); i++) {
    398412                if (dest[i] == ':') {
    399                         port = atoi(&(dest[i+1]));
     413                        port = atoi(&(dest[i + 1]));
    400414                        break;
    401415                }
    402416        }
    403417
    404         host = (char *)g_malloc(i+1);
     418        host = (char *) g_malloc(i + 1);
    405419        strncpy(host, dest, i);
    406420        host[i] = '\0';
     
    421435 *
    422436 * This is my lame attempt at overcoming not understanding the rate
    423  * limiting. 
     437 * limiting.
    424438 *
    425439 * XXX: This should really be replaced with something that scales and
     
    430444{
    431445
    432         if (!conn)
     446        if (!conn) {
    433447                return -1;
     448        }
    434449
    435450        conn->forcedlatency = newval;
     
    451466{
    452467
    453         if (!sess)
     468        if (!sess) {
    454469                return;
     470        }
    455471
    456472        memset(sess, 0, sizeof(aim_session_t));
     
    471487        sess->ssi.revision = 0;
    472488        sess->ssi.items = NULL;
    473         sess->ssi.timestamp = (time_t)0;
     489        sess->ssi.timestamp = (time_t) 0;
    474490
    475491        sess->locate.userinfo = NULL;
     
    487503         * Default to SNAC login unless XORLOGIN is explicitly set.
    488504         */
    489         if (!(flags & AIM_SESS_FLAGS_XORLOGIN))
     505        if (!(flags & AIM_SESS_FLAGS_XORLOGIN)) {
    490506                sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
     507        }
    491508        sess->flags |= flags;
    492509
    493510        /*
    494511         * This must always be set.  Default to the queue-based
    495          * version for back-compatibility. 
     512         * version for back-compatibility.
    496513         */
    497514        aim_tx_setenqueue(sess, AIM_TX_QUEUED, NULL);
     
    548565        aim_rxcallback_t userfunc;
    549566
    550         if (!conn || (conn->fd == -1))
     567        if (!conn || (conn->fd == -1)) {
    551568                return -1;
    552 
    553         if (!(conn->status & AIM_CONN_STATUS_INPROGRESS))
     569        }
     570
     571        if (!(conn->status & AIM_CONN_STATUS_INPROGRESS)) {
    554572                return -1;
     573        }
    555574
    556575        FD_ZERO(&fds);
     
    561580        tv.tv_usec = 0;
    562581
    563         if ((res = select(conn->fd+1, &fds, &wfds, NULL, &tv)) == -1) {
     582        if ((res = select(conn->fd + 1, &fds, &wfds, NULL, &tv)) == -1) {
    564583                error = errno;
    565584                aim_conn_close(conn);
     
    568587        } else if (res == 0) {
    569588                return 0; /* hasn't really completed yet... */
    570         } 
     589        }
    571590
    572591        if (FD_ISSET(conn->fd, &fds) || FD_ISSET(conn->fd, &wfds)) {
    573592                socklen_t len = sizeof(error);
    574593
    575                 if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
     594                if (getsockopt(conn->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    576595                        error = errno;
     596                }
    577597        }
    578598
     
    587607        conn->status &= ~AIM_CONN_STATUS_INPROGRESS;
    588608
    589         if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE)))
     609        if ((userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNCOMPLETE))) {
    590610                userfunc(sess, NULL, conn);
     611        }
    591612
    592613        /* Flush out the queues if there was something waiting for this conn  */
     
    599620{
    600621
    601         if (!conn)
     622        if (!conn) {
    602623                return NULL;
    603 
    604         return (aim_session_t *)conn->sessv;
     624        }
     625
     626        return (aim_session_t *) conn->sessv;
    605627}
    606628
     
    624646 *
    625647 * No-op.  WinAIM 4.x sends these _every minute_ to keep
    626  * the connection alive. 
     648 * the connection alive.
    627649 */
    628650int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn)
     
    630652        aim_frame_t *fr;
    631653
    632         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x05, 0)))
     654        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x05, 0))) {
    633655                return -ENOMEM;
     656        }
    634657
    635658        aim_tx_enqueue(sess, fr);
Note: See TracChangeset for help on using the changeset viewer.