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/service.c

    raf359b4 r5ebff60  
    1111int aim_clientready(aim_session_t *sess, aim_conn_t *conn)
    1212{
    13         aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
     13        aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
    1414        struct snacgroup *sg;
    1515        aim_frame_t *fr;
    1616        aim_snacid_t snacid;
    1717
    18         if (!ins)
     18        if (!ins) {
    1919                return -EINVAL;
    20 
    21         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
     20        }
     21
     22        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) {
    2223                return -ENOMEM;
     24        }
    2325
    2426        snacid = aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
     
    2729        /*
    2830         * Send only the tool versions that the server cares about (that it
    29          * marked as supporting in the server ready SNAC). 
     31         * marked as supporting in the server ready SNAC).
    3032         */
    3133        for (sg = ins->groups; sg; sg = sg->next) {
     
    3739                        aimbs_put16(&fr->data, mod->toolid);
    3840                        aimbs_put16(&fr->data, mod->toolversion);
    39                 } 
     41                }
    4042        }
    4143
     
    4749/*
    4850 * Host Online (group 1, type 3)
    49  * 
     51 *
    5052 * See comments in conn.c about how the group associations are supposed
    5153 * to work, and how they really work.
     
    5557 * We don't actually call the client here.  This starts off the connection
    5658 * initialization routine required by all AIM connections.  The next time
    57  * the client is called is the CONNINITDONE callback, which should be 
     59 * the client is called is the CONNINITDONE callback, which should be
    5860 * shortly after the rate information is acknowledged.
    59  * 
     61 *
    6062 */
    6163static int hostonline(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
     
    6567
    6668
    67         if (!(families = g_malloc(aim_bstream_empty(bs))))
     69        if (!(families = g_malloc(aim_bstream_empty(bs)))) {
    6870                return 0;
     71        }
    6972
    7073        for (famcount = 0; aim_bstream_empty(bs); famcount++) {
     
    8689        aim_setversions(sess, rx->conn);
    8790
    88         return 1; 
     91        return 1;
    8992}
    9093
     
    109112
    110113        if (!aim_gettlv(tlvlist, 0x000d, 1) ||
    111                         !aim_gettlv(tlvlist, 0x0005, 1) ||
    112                         !aim_gettlv(tlvlist, 0x0006, 1)) {
     114            !aim_gettlv(tlvlist, 0x0005, 1) ||
     115            !aim_gettlv(tlvlist, 0x0006, 1)) {
    113116                aim_freetlvchain(&tlvlist);
    114117                return 0;
     
    117120        redir.group = aim_gettlv16(tlvlist, 0x000d, 1);
    118121        redir.ip = aim_gettlv_str(tlvlist, 0x0005, 1);
    119         redir.cookie = (guint8 *)aim_gettlv_str(tlvlist, 0x0006, 1);
     122        redir.cookie = (guint8 *) aim_gettlv_str(tlvlist, 0x0006, 1);
    120123
    121124        /* Fetch original SNAC so we can get csi if needed */
     
    123126
    124127        if ((redir.group == AIM_CONN_TYPE_CHAT) && origsnac) {
    125                 struct chatsnacinfo *csi = (struct chatsnacinfo *)origsnac->data;
     128                struct chatsnacinfo *csi = (struct chatsnacinfo *) origsnac->data;
    126129
    127130                redir.chat.exchange = csi->exchange;
     
    130133        }
    131134
    132         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     135        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    133136                ret = userfunc(sess, rx, &redir);
    134 
    135         g_free((void *)redir.ip);
    136         g_free((void *)redir.cookie);
    137 
    138         if (origsnac)
     137        }
     138
     139        g_free((void *) redir.ip);
     140        g_free((void *) redir.cookie);
     141
     142        if (origsnac) {
    139143                g_free(origsnac->data);
     144        }
    140145        g_free(origsnac);
    141146
     
    157162 * it.  The rate classes, their limiting properties, and the definitions
    158163 * of which SNACs are belong to which class, are defined in the
    159  * Rate Response packet at login to each host. 
     164 * Rate Response packet at login to each host.
    160165 *
    161166 * Logically, all rate offenses within one class count against further
     
    171176 *
    172177 *  Rate class 0x0001:
    173  *      - Everything thats not in any of the other classes
     178 *      - Everything thats not in any of the other classes
    174179 *
    175180 *  Rate class 0x0002:
    176  *      - Buddy list add/remove
     181 *      - Buddy list add/remove
    177182 *      - Permit list add/remove
    178183 *      - Deny list add/remove
     
    190195 *
    191196 * The only other thing of note is that class 5 (chat) has slightly looser
    192  * limiting properties than class 3 (normal messages).  But thats just a 
     197 * limiting properties than class 3 (normal messages).  But thats just a
    193198 * small bit of trivia for you.
    194199 *
     
    196201 * system is how the actual numbers relate to the passing of time.  This
    197202 * seems to be a big mystery.
    198  * 
     203 *
    199204 */
    200205
     
    203208        struct rateclass *rc, *rc2;
    204209
    205         if (!(rc = g_malloc(sizeof(struct rateclass))))
     210        if (!(rc = g_malloc(sizeof(struct rateclass)))) {
    206211                return;
     212        }
    207213
    208214        memcpy(rc, inrc, sizeof(struct rateclass));
    209215        rc->next = NULL;
    210216
    211         for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next)
     217        for (rc2 = *head; rc2 && rc2->next; rc2 = rc2->next) {
    212218                ;
    213 
    214         if (!rc2)
     219        }
     220
     221        if (!rc2) {
    215222                *head = rc;
    216         else
     223        } else {
    217224                rc2->next = rc;
     225        }
    218226
    219227        return;
     
    225233
    226234        for (rc = *head; rc; rc = rc->next) {
    227                 if (rc->classid == id)
     235                if (rc->classid == id) {
    228236                        return rc;
     237                }
    229238        }
    230239
     
    236245        struct snacpair *sp, *sp2;
    237246
    238         if (!(sp = g_new0(struct snacpair, 1)))
     247        if (!(sp = g_new0(struct snacpair, 1))) {
    239248                return;
     249        }
    240250
    241251        sp->group = group;
     
    243253        sp->next = NULL;
    244254
    245         for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next)
     255        for (sp2 = rc->members; sp2 && sp2->next; sp2 = sp2->next) {
    246256                ;
    247 
    248         if (!sp2)
     257        }
     258
     259        if (!sp2) {
    249260                rc->members = sp;
    250         else
     261        } else {
    251262                sp2->next = sp;
     263        }
    252264
    253265        return;
     
    257269static int rateresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
    258270{
    259         aim_conn_inside_t *ins = (aim_conn_inside_t *)rx->conn->inside;
     271        aim_conn_inside_t *ins = (aim_conn_inside_t *) rx->conn->inside;
    260272        guint16 numclasses, i;
    261273        aim_rxcallback_t userfunc;
     
    284296                 * depending on the version we advertised in 1/17.  If we
    285297                 * didn't send 1/17 (evil!), then this will crash and you
    286                  * die, as it will default to the old version but we have 
    287                  * the new version hardcoded here. 
     298                 * die, as it will default to the old version but we have
     299                 * the new version hardcoded here.
    288300                 */
    289                 if (mod->version >= 3)
     301                if (mod->version >= 3) {
    290302                        aimbs_getrawbuf(bs, rc.unknown, sizeof(rc.unknown));
     303                }
    291304
    292305                rc_addclass(&ins->rates, &rc);
     
    312325                        subtype = aimbs_get16(bs);
    313326
    314                         if (rc)
     327                        if (rc) {
    315328                                rc_addpair(rc, group, subtype);
     329                        }
    316330                }
    317331        }
     
    332346         * Finally, tell the client it's ready to go...
    333347         */
    334         if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE)))
     348        if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE))) {
    335349                userfunc(sess, rx);
     350        }
    336351
    337352
     
    342357int aim_rates_addparam(aim_session_t *sess, aim_conn_t *conn)
    343358{
    344         aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
    345         aim_frame_t *fr;       
     359        aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
     360        aim_frame_t *fr;
    346361        aim_snacid_t snacid;
    347362        struct rateclass *rc;
    348363
    349         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512)))
    350                 return -ENOMEM;
     364        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 512))) {
     365                return -ENOMEM;
     366        }
    351367
    352368        snacid = aim_cachesnac(sess, 0x0001, 0x0008, 0x0000, NULL, 0);
    353369        aim_putsnac(&fr->data, 0x0001, 0x0008, 0x0000, snacid);
    354370
    355         for (rc = ins->rates; rc; rc = rc->next)
     371        for (rc = ins->rates; rc; rc = rc->next) {
    356372                aimbs_put16(&fr->data, rc->classid);
     373        }
    357374
    358375        aim_tx_enqueue(sess, fr);
     
    370387        code = aimbs_get16(bs);
    371388        rateclass = aimbs_get16(bs);
    372        
     389
    373390        windowsize = aimbs_get32(bs);
    374391        clear = aimbs_get32(bs);
     
    379396        maxavg = aimbs_get32(bs);
    380397
    381         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
    382                 return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg, maxavg);
     398        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
     399                return userfunc(sess, rx, code, rateclass, windowsize, clear, alert, limit, disconnect, currentavg,
     400                                maxavg);
     401        }
    383402
    384403        return 0;
     
    386405
    387406/*
    388  * How Migrations work. 
    389  *
    390  * The server sends a Server Pause message, which the client should respond to 
    391  * with a Server Pause Ack, which contains the families it needs on this 
    392  * connection. The server will send a Migration Notice with an IP address, and 
    393  * then disconnect. Next the client should open the connection and send the 
     407 * How Migrations work.
     408 *
     409 * The server sends a Server Pause message, which the client should respond to
     410 * with a Server Pause Ack, which contains the families it needs on this
     411 * connection. The server will send a Migration Notice with an IP address, and
     412 * then disconnect. Next the client should open the connection and send the
    394413 * cookie.  Repeat the normal login process and pretend this never happened.
    395414 *
     
    403422        aim_rxcallback_t userfunc;
    404423
    405         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     424        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    406425                return userfunc(sess, rx);
     426        }
    407427
    408428        return 0;
     
    414434        aim_rxcallback_t userfunc;
    415435
    416         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     436        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    417437                return userfunc(sess, rx);
     438        }
    418439
    419440        return 0;
     
    434455        aim_extractuserinfo(sess, bs, &userinfo);
    435456
    436         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     457        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    437458                return userfunc(sess, rx, &userinfo);
     459        }
    438460
    439461        return 0;
     
    448470
    449471        memset(&userinfo, 0, sizeof(aim_userinfo_t));
    450        
     472
    451473        newevil = aimbs_get16(bs);
    452474
    453         if (aim_bstream_empty(bs))
     475        if (aim_bstream_empty(bs)) {
    454476                aim_extractuserinfo(sess, bs, &userinfo);
    455 
    456         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     477        }
     478
     479        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    457480                return userfunc(sess, rx, newevil, &userinfo);
     481        }
    458482
    459483        return 0;
     
    464488 *
    465489 * This is the final SNAC sent on the original connection during a migration.
    466  * It contains the IP and cookie used to connect to the new server, and 
     490 * It contains the IP and cookie used to connect to the new server, and
    467491 * optionally a list of the SNAC groups being migrated.
    468492 *
     
    482506         * moves to the new server.  When not all the groups for a connection
    483507         * are migrated, or they are all migrated but some groups are moved
    484          * to a different server than others, it is called a bifurcated 
     508         * to a different server than others, it is called a bifurcated
    485509         * migration.
    486510         *
     
    497521        tl = aim_readtlvchain(bs);
    498522
    499         if (aim_gettlv(tl, 0x0005, 1))
     523        if (aim_gettlv(tl, 0x0005, 1)) {
    500524                ip = aim_gettlv_str(tl, 0x0005, 1);
     525        }
    501526
    502527        cktlv = aim_gettlv(tl, 0x0006, 1);
    503528
    504         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     529        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    505530                ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL);
     531        }
    506532
    507533        aim_freetlvchain(&tl);
     
    528554         *   3 System bulletin
    529555         *   4 Nothing's wrong ("top o the world" -- normal)
    530          *   5 Lets-break-something. 
     556         *   5 Lets-break-something.
    531557         *
    532558         */
    533559        id = aimbs_get16(bs);
    534560
    535         /* 
    536          * TLVs follow 
     561        /*
     562         * TLVs follow
    537563         */
    538564        tlvlist = aim_readtlvchain(bs);
     
    540566        msg = aim_gettlv_str(tlvlist, 0x000b, 1);
    541567
    542         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     568        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    543569                ret = userfunc(sess, rx, id, msg);
     570        }
    544571
    545572        g_free(msg);
     
    550577}
    551578
    552 /* 
     579/*
    553580 * Set privacy flags (group 1, type 0x14)
    554581 *
     
    565592
    566593
    567 /* 
    568  * Set client versions (group 1, subtype 0x17) 
    569  *
    570  * If you've seen the clientonline/clientready SNAC you're probably 
     594/*
     595 * Set client versions (group 1, subtype 0x17)
     596 *
     597 * If you've seen the clientonline/clientready SNAC you're probably
    571598 * wondering what the point of this one is.  And that point seems to be
    572599 * that the versions in the client online SNAC are sent too late for the
    573600 * server to be able to use them to change the protocol for the earlier
    574  * login packets (client versions are sent right after Host Online is 
     601 * login packets (client versions are sent right after Host Online is
    575602 * received, but client online versions aren't sent until quite a bit later).
    576603 * We can see them already making use of this by changing the format of
     
    580607int aim_setversions(aim_session_t *sess, aim_conn_t *conn)
    581608{
    582         aim_conn_inside_t *ins = (aim_conn_inside_t *)conn->inside;
     609        aim_conn_inside_t *ins = (aim_conn_inside_t *) conn->inside;
    583610        struct snacgroup *sg;
    584611        aim_frame_t *fr;
    585612        aim_snacid_t snacid;
    586613
    587         if (!ins)
     614        if (!ins) {
    588615                return -EINVAL;
    589 
    590         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
     616        }
     617
     618        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) {
    591619                return -ENOMEM;
     620        }
    592621
    593622        snacid = aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
     
    596625        /*
    597626         * Send only the versions that the server cares about (that it
    598          * marked as supporting in the server ready SNAC). 
     627         * marked as supporting in the server ready SNAC).
    599628         */
    600629        for (sg = ins->groups; sg; sg = sg->next) {
     
    630659}
    631660
    632 /* 
     661/*
    633662 * Subtype 0x001e - Extended Status
    634663 *
    635664 * Sets your ICQ status (available, away, do not disturb, etc.)
    636665 *
    637  * These are the same TLVs seen in user info.  You can 
     666 * These are the same TLVs seen in user info.  You can
    638667 * also set 0x0008 and 0x000c.
    639668 */
     
    647676
    648677        data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */
    649        
    650         if (ic && set_getbool(&ic->acc->set, "web_aware"))
     678
     679        if (ic && set_getbool(&ic->acc->set, "web_aware")) {
    651680                data |= AIM_ICQ_STATE_WEBAWARE;
     681        }
    652682
    653683        aim_addtlvtochain32(&tl, 0x0006, data); /* tlvlen */
    654684
    655         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8)))
     685        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 8))) {
    656686                return -ENOMEM;
     687        }
    657688
    658689        snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0);
    659690        aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid);
    660        
     691
    661692        aim_writetlvchain(&fr->data, &tl);
    662693        aim_freetlvchain(&tl);
    663        
     694
    664695        aim_tx_enqueue(sess, fr);
    665696
     
    688719 * the data that the specific client should have, the client will get the
    689720 * following message from "AOL Instant Messenger":
    690  *    "You have been disconnected from the AOL Instant Message Service (SM) 
     721 *    "You have been disconnected from the AOL Instant Message Service (SM)
    691722 *     for accessing the AOL network using unauthorized software.  You can
    692  *     download a FREE, fully featured, and authorized client, here 
     723 *     download a FREE, fully featured, and authorized client, here
    693724 *     http://www.aol.com/aim/download2.html"
    694725 * The connection is then closed, recieving disconnect code 1, URL
    695  * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html. 
    696  *
    697  * Note, however, that numerous inconsistencies can cause the above error, 
     726 * http://www.aim.aol.com/errors/USER_LOGGED_OFF_NEW_LOGIN.html.
     727 *
     728 * Note, however, that numerous inconsistencies can cause the above error,
    698729 * not just sending back a bad hash.  Do not immediatly suspect this code
    699730 * if you get disconnected.  AOL and the open/free software community have
     
    718749        modname = aim_gettlv_str(list, 0x0001, 1);
    719750
    720         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     751        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    721752                return userfunc(sess, rx, offset, len, modname);
     753        }
    722754
    723755        g_free(modname);
     
    730762{
    731763
    732         if (snac->subtype == 0x0003)
     764        if (snac->subtype == 0x0003) {
    733765                return hostonline(sess, mod, rx, snac, bs);
    734         else if (snac->subtype == 0x0005)
     766        } else if (snac->subtype == 0x0005) {
    735767                return redirect(sess, mod, rx, snac, bs);
    736         else if (snac->subtype == 0x0007)
     768        } else if (snac->subtype == 0x0007) {
    737769                return rateresp(sess, mod, rx, snac, bs);
    738         else if (snac->subtype == 0x000a)
     770        } else if (snac->subtype == 0x000a) {
    739771                return ratechange(sess, mod, rx, snac, bs);
    740         else if (snac->subtype == 0x000b)
     772        } else if (snac->subtype == 0x000b) {
    741773                return serverpause(sess, mod, rx, snac, bs);
    742         else if (snac->subtype == 0x000d)
     774        } else if (snac->subtype == 0x000d) {
    743775                return serverresume(sess, mod, rx, snac, bs);
    744         else if (snac->subtype == 0x000f)
     776        } else if (snac->subtype == 0x000f) {
    745777                return selfinfo(sess, mod, rx, snac, bs);
    746         else if (snac->subtype == 0x0010)
     778        } else if (snac->subtype == 0x0010) {
    747779                return evilnotify(sess, mod, rx, snac, bs);
    748         else if (snac->subtype == 0x0012)
     780        } else if (snac->subtype == 0x0012) {
    749781                return migrate(sess, mod, rx, snac, bs);
    750         else if (snac->subtype == 0x0013)
     782        } else if (snac->subtype == 0x0013) {
    751783                return motd(sess, mod, rx, snac, bs);
    752         else if (snac->subtype == 0x0018)
     784        } else if (snac->subtype == 0x0018) {
    753785                return hostversions(sess, mod, rx, snac, bs);
    754         else if (snac->subtype == 0x001f)
     786        } else if (snac->subtype == 0x001f) {
    755787                return memrequest(sess, mod, rx, snac, bs);
     788        }
    756789
    757790        return 0;
Note: See TracChangeset for help on using the changeset viewer.