Ignore:
Timestamp:
2015-02-20T22:50:54Z (9 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/info.c

    raf359b4 r5ebff60  
    33 *
    44 * The functions here are responsible for requesting and parsing information-
    5  * gathering SNACs.  Or something like that. 
     5 * gathering SNACs.  Or something like that.
    66 *
    77 */
     
    1111
    1212struct aim_priv_inforeq {
    13         char sn[MAXSNLEN+1];
     13        char sn[MAXSNLEN + 1];
    1414        guint16 infotype;
    1515};
     
    2121        aim_snacid_t snacid;
    2222
    23         if (!sess || !conn || !sn)
     23        if (!sess || !conn || !sn) {
    2424                return -EINVAL;
    25 
    26         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12+1+strlen(sn))))
     25        }
     26
     27        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12 + 1 + strlen(sn)))) {
    2728                return -ENOMEM;
     29        }
    2830
    2931        strncpy(privdata.sn, sn, sizeof(privdata.sn));
    3032        privdata.infotype = infotype;
    3133        snacid = aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, &privdata, sizeof(struct aim_priv_inforeq));
    32        
     34
    3335        aim_putsnac(&fr->data, 0x0002, 0x0005, 0x0000, snacid);
    3436        aimbs_put16(&fr->data, infotype);
    3537        aimbs_put8(&fr->data, strlen(sn));
    36         aimbs_putraw(&fr->data, (guint8 *)sn, strlen(sn));
     38        aimbs_putraw(&fr->data, (guint8 *) sn, strlen(sn));
    3739
    3840        aim_tx_enqueue(sess, fr);
     
    4244
    4345/*
    44  * Capability blocks. 
     46 * Capability blocks.
    4547 *
    4648 * These are CLSIDs. They should actually be of the form:
     
    5961         * Chat is oddball.
    6062         */
    61         {AIM_CAPS_CHAT,
    62          {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
    63           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
     63        { AIM_CAPS_CHAT,
     64          { 0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
     65            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
    6466
    6567        /*
    6668         * These are mostly in order.
    6769         */
    68         {AIM_CAPS_VOICE,
    69          {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
    70           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    71 
    72         {AIM_CAPS_SENDFILE,
    73          {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
    74           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
     70        { AIM_CAPS_VOICE,
     71          { 0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
     72            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     73
     74        { AIM_CAPS_SENDFILE,
     75          { 0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
     76            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
    7577
    7678        /*
    7779         * Advertised by the EveryBuddy client.
    7880         */
    79         {AIM_CAPS_ICQ,
    80          {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
    81           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    82 
    83         {AIM_CAPS_IMIMAGE,
    84          {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
    85           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    86 
    87         {AIM_CAPS_BUDDYICON,
    88          {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
    89           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    90 
    91         {AIM_CAPS_SAVESTOCKS,
    92          {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
    93           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    94 
    95         {AIM_CAPS_GETFILE,
    96          {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
    97           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    98 
    99     /*
    100     * Client supports channel 2 extended, TLV(0x2711) based messages.
    101     * Currently used only by ICQ clients. ICQ clients and clones use this GUID
    102     * as message format sign. Trillian client use another GUID in channel 2
    103     * messages to implement its own message format (trillian doesn't use
    104     * TLV(x2711) in SecureIM channel 2 messages!).
    105     */
    106         {AIM_CAPS_ICQSERVERRELAY,
    107          {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
    108           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    109 
    110         /*
    111          * Indeed, there are two of these.  The former appears to be correct, 
    112          * but in some versions of winaim, the second one is set.  Either they 
    113          * forgot to fix endianness, or they made a typo. It really doesn't 
     81        { AIM_CAPS_ICQ,
     82          { 0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
     83            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     84
     85        { AIM_CAPS_IMIMAGE,
     86          { 0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
     87            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     88
     89        { AIM_CAPS_BUDDYICON,
     90          { 0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
     91            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     92
     93        { AIM_CAPS_SAVESTOCKS,
     94          { 0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
     95            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     96
     97        { AIM_CAPS_GETFILE,
     98          { 0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
     99            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     100
     101        /*
     102        * Client supports channel 2 extended, TLV(0x2711) based messages.
     103        * Currently used only by ICQ clients. ICQ clients and clones use this GUID
     104        * as message format sign. Trillian client use another GUID in channel 2
     105        * messages to implement its own message format (trillian doesn't use
     106        * TLV(x2711) in SecureIM channel 2 messages!).
     107        */
     108        { AIM_CAPS_ICQSERVERRELAY,
     109          { 0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
     110            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     111
     112        /*
     113         * Indeed, there are two of these.  The former appears to be correct,
     114         * but in some versions of winaim, the second one is set.  Either they
     115         * forgot to fix endianness, or they made a typo. It really doesn't
    114116         * matter which.
    115117         */
    116         {AIM_CAPS_GAMES,
    117          {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
    118           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    119         {AIM_CAPS_GAMES2,
    120          {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
    121           0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    122 
    123         {AIM_CAPS_SENDBUDDYLIST,
    124          {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
    125           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    126 
    127         {AIM_CAPS_UTF8,
    128          {0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1,
    129           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    130 
    131         {AIM_CAPS_ICQRTF,
    132          {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
    133           0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},
    134 
    135         {AIM_CAPS_ICQUNKNOWN,
    136          {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
    137           0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},
    138 
    139         {AIM_CAPS_EMPTY,
    140          {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    141           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
    142 
    143         {AIM_CAPS_TRILLIANCRYPT,
    144          {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
    145           0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},
    146 
    147         {AIM_CAPS_APINFO,
    148      {0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,
    149       0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B}},
    150 
    151         {AIM_CAPS_INTEROP,
    152          {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
    153           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    154 
    155         {AIM_CAPS_ICHAT,
    156          {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
    157           0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
    158 
    159         {AIM_CAPS_LAST}
     118        { AIM_CAPS_GAMES,
     119          { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
     120            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     121        { AIM_CAPS_GAMES2,
     122          { 0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
     123            0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     124
     125        { AIM_CAPS_SENDBUDDYLIST,
     126          { 0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
     127            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     128
     129        { AIM_CAPS_UTF8,
     130          { 0x09, 0x46, 0x13, 0x4E, 0x4C, 0x7F, 0x11, 0xD1,
     131            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     132
     133        { AIM_CAPS_ICQRTF,
     134          { 0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
     135            0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92 } },
     136
     137        { AIM_CAPS_ICQUNKNOWN,
     138          { 0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
     139            0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf } },
     140
     141        { AIM_CAPS_EMPTY,
     142          { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     143            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
     144
     145        { AIM_CAPS_TRILLIANCRYPT,
     146          { 0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
     147            0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00 } },
     148
     149        { AIM_CAPS_APINFO,
     150          { 0xAA, 0x4A, 0x32, 0xB5, 0xF8, 0x84, 0x48, 0xc6,
     151            0xA3, 0xD7, 0x8C, 0x50, 0x97, 0x19, 0xFD, 0x5B } },
     152
     153        { AIM_CAPS_INTEROP,
     154          { 0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
     155            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     156
     157        { AIM_CAPS_ICHAT,
     158          { 0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
     159            0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00 } },
     160
     161        { AIM_CAPS_LAST }
    160162};
    161163
     
    163165 * This still takes a length parameter even with a bstream because capabilities
    164166 * are not naturally bounded.
    165  * 
     167 *
    166168 */
    167169guint32 aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len)
     
    190192                        /*REMOVEME :-)
    191193                        g_strdup_printf("unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
    192                                         cap[0], cap[1], cap[2], cap[3],
    193                                         cap[4], cap[5],
    194                                         cap[6], cap[7],
    195                                         cap[8], cap[9],
    196                                         cap[10], cap[11], cap[12], cap[13],
    197                                         cap[14], cap[15]);
     194                                        cap[0], cap[1], cap[2], cap[3],
     195                                        cap[4], cap[5],
     196                                        cap[6], cap[7],
     197                                        cap[8], cap[9],
     198                                        cap[10], cap[11], cap[12], cap[13],
     199                                        cap[14], cap[15]);
    198200                        */
    199201                }
     
    209211        int i;
    210212
    211         if (!bs)
     213        if (!bs) {
    212214                return -EINVAL;
     215        }
    213216
    214217        for (i = 0; aim_bstream_empty(bs); i++) {
    215218
    216                 if (aim_caps[i].flag == AIM_CAPS_LAST)
     219                if (aim_caps[i].flag == AIM_CAPS_LAST) {
    217220                        break;
    218 
    219                 if (caps & aim_caps[i].flag)
     221                }
     222
     223                if (caps & aim_caps[i].flag) {
    220224                        aimbs_putraw(bs, aim_caps[i].data, 0x10);
     225                }
    221226
    222227        }
     
    226231
    227232/*
    228  * AIM is fairly regular about providing user info.  This is a generic 
     233 * AIM is fairly regular about providing user info.  This is a generic
    229234 * routine to extract it in its standard form.
    230235 */
     
    234239        guint8 snlen;
    235240
    236         if (!bs || !outinfo)
     241        if (!bs || !outinfo) {
    237242                return -EINVAL;
     243        }
    238244
    239245        /* Clear out old data first */
     
    241247
    242248        /*
    243          * Screen name.  Stored as an unterminated string prepended with a 
     249         * Screen name.  Stored as an unterminated string prepended with a
    244250         * byte containing its length.
    245251         */
    246252        snlen = aimbs_get8(bs);
    247         aimbs_getrawbuf(bs, (guint8 *)outinfo->sn, snlen);
     253        aimbs_getrawbuf(bs, (guint8 *) outinfo->sn, snlen);
    248254
    249255        /*
     
    253259
    254260        /*
    255          * TLV Count. Unsigned short representing the number of 
     261         * TLV Count. Unsigned short representing the number of
    256262         * Type-Length-Value triples that follow.
    257263         */
    258264        tlvcnt = aimbs_get16(bs);
    259265
    260         /* 
     266        /*
    261267         * Parse out the Type-Length-Value triples as they're found.
    262268         */
     
    273279                        /*
    274280                         * Type = 0x0001: User flags
    275                          * 
     281                         *
    276282                         * Specified as any of the following ORed together:
    277283                         *      0x0001  Trial (user less than 60days)
     
    279285                         *      0x0004  AOL Main Service user
    280286                         *      0x0008  Unknown bit 4
    281                          *      0x0010  Free (AIM) user 
     287                         *      0x0010  Free (AIM) user
    282288                         *      0x0020  Away
    283289                         *      0x0400  ActiveBuddy
     
    289295                } else if (type == 0x0002) {
    290296                        /*
    291                          * Type = 0x0002: Member-Since date. 
     297                         * Type = 0x0002: Member-Since date.
    292298                         *
    293299                         * The time/date that the user originally registered for
     
    301307                         * Type = 0x0003: On-Since date.
    302308                         *
    303                          * The time/date that the user started their current 
     309                         * The time/date that the user started their current
    304310                         * session, stored in time_t format.
    305311                         */
     
    311317                         * Type = 0x0004: Idle time.
    312318                         *
    313                          * Number of seconds since the user actively used the 
     319                         * Number of seconds since the user actively used the
    314320                         * service.
    315321                         *
    316322                         * Note that the client tells the server when to start
    317                          * counting idle times, so this may or may not be 
     323                         * counting idle times, so this may or may not be
    318324                         * related to reality.
    319325                         */
     
    325331                         * Type = 0x0006: ICQ Online Status
    326332                         *
    327                          * ICQ's Away/DND/etc "enriched" status. Some decoding 
     333                         * ICQ's Away/DND/etc "enriched" status. Some decoding
    328334                         * of values done by Scott <darkagl@pcnet.com>
    329335                         */
     
    343349
    344350                } else if (type == 0x000c) {
    345                         /* 
     351                        /*
    346352                         * Type = 0x000c
    347353                         *
     
    379385                         * Type = 0x0010: Session Length. (AOL)
    380386                         *
    381                          * The duration, in seconds, of the user's current 
     387                         * The duration, in seconds, of the user's current
    382388                         * session.
    383389                         *
     
    393399                        /*
    394400                         * Reaching here indicates that either AOL has
    395                          * added yet another TLV for us to deal with, 
     401                         * added yet another TLV for us to deal with,
    396402                         * or the parsing has gone Terribly Wrong.
    397403                         *
     
    429435        tlvlist = aim_readtlvchain(bs);
    430436
    431         if (aim_gettlv(tlvlist, 0x0001, 1))
     437        if (aim_gettlv(tlvlist, 0x0001, 1)) {
    432438                maxsiglen = aim_gettlv16(tlvlist, 0x0001, 1);
    433 
    434         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     439        }
     440
     441        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    435442                ret = userfunc(sess, rx, maxsiglen);
     443        }
    436444
    437445        aim_freetlvchain(&tlvlist);
     
    459467        }
    460468
    461         inforeq = (struct aim_priv_inforeq *)origsnac->data;
     469        inforeq = (struct aim_priv_inforeq *) origsnac->data;
    462470
    463471        if ((inforeq->infotype != AIM_GETINFO_GENERALINFO) &&
    464                         (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) &&
    465                         (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) {
     472            (inforeq->infotype != AIM_GETINFO_AWAYMESSAGE) &&
     473            (inforeq->infotype != AIM_GETINFO_CAPABILITIES)) {
    466474                imcb_error(sess->aux_data, "unknown infotype in request!");
    467475                return 0;
     
    472480        tlvlist = aim_readtlvchain(bs);
    473481
    474         /* 
     482        /*
    475483         * Depending on what informational text was requested, different
    476484         * TLVs will appear here.
     
    481489        if (inforeq->infotype == AIM_GETINFO_GENERALINFO) {
    482490                text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
    483                 if((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {
     491                if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {
    484492                        text = g_new0(char, tlv->length);
    485493                        memcpy(text, tlv->value, tlv->length);
     
    488496        } else if (inforeq->infotype == AIM_GETINFO_AWAYMESSAGE) {
    489497                text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1);
    490                 if((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {
     498                if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {
    491499                        text = g_new0(char, tlv->length);
    492500                        memcpy(text, tlv->value, tlv->length);
     
    506514        }
    507515
    508         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     516        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    509517                ret = userfunc(sess, rx, &userinfo, inforeq->infotype, text_encoding, text, text_length);
     518        }
    510519
    511520        g_free(text_encoding);
     
    514523        aim_freetlvchain(&tlvlist);
    515524
    516         if (origsnac)
     525        if (origsnac) {
    517526                g_free(origsnac->data);
     527        }
    518528        g_free(origsnac);
    519529
     
    524534{
    525535
    526         if (snac->subtype == 0x0003)
     536        if (snac->subtype == 0x0003) {
    527537                return rights(sess, mod, rx, snac, bs);
    528         else if (snac->subtype == 0x0006)
     538        } else if (snac->subtype == 0x0006) {
    529539                return userinfo(sess, mod, rx, snac, bs);
     540        }
    530541
    531542        return 0;
Note: See TracChangeset for help on using the changeset viewer.