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

    raf359b4 r5ebff60  
    33static void freetlv(aim_tlv_t **oldtlv)
    44{
    5         if (!oldtlv || !*oldtlv)
     5        if (!oldtlv || !*oldtlv) {
    66                return;
    7        
     7        }
     8
    89        g_free((*oldtlv)->value);
    910        g_free(*oldtlv);
     
    2223 *
    2324 * XXX There should be a flag setable here to have the tlvlist contain
    24  * bstream references, so that at least the ->value portion of each 
     25 * bstream references, so that at least the ->value portion of each
    2526 * element doesn't need to be malloc/memcpy'd.  This could prove to be
    2627 * just as effecient as the in-place TLV parsing used in a couple places
     
    4243                cur->tlv = g_new0(aim_tlv_t, 1);
    4344                cur->tlv->type = type;
    44                 if ((cur->tlv->length = length))
    45                         cur->tlv->value = aimbs_getraw(bs, length);     
     45                if ((cur->tlv->length = length)) {
     46                        cur->tlv->value = aimbs_getraw(bs, length);
     47                }
    4648
    4749                cur->next = list;
     
    6567        aim_tlvlist_t *cur;
    6668
    67         if (!list || !*list)
     69        if (!list || !*list) {
    6870                return;
     71        }
    6972
    7073        for (cur = *list; cur; ) {
    7174                aim_tlvlist_t *tmp;
    72                
     75
    7376                freetlv(&cur->tlv);
    7477
     
    9598        int count;
    9699
    97         if (!list || !*list)
    98                 return 0;
    99 
    100         for (cur = *list, count = 0; cur; cur = cur->next)
     100        if (!list || !*list) {
     101                return 0;
     102        }
     103
     104        for (cur = *list, count = 0; cur; cur = cur->next) {
    101105                count++;
     106        }
    102107
    103108        return count;
     
    108113 * @list: Chain to be sized
    109114 *
    110  * Returns the number of bytes that would be needed to 
     115 * Returns the number of bytes that would be needed to
    111116 * write the passed TLV chain to a data buffer.
    112117 *
     
    117122        int size;
    118123
    119         if (!list || !*list)
    120                 return 0;
    121 
    122         for (cur = *list, size = 0; cur; cur = cur->next)
     124        if (!list || !*list) {
     125                return 0;
     126        }
     127
     128        for (cur = *list, size = 0; cur; cur = cur->next) {
    123129                size += (4 + cur->tlv->length);
     130        }
    124131
    125132        return size;
     
    141148        aim_tlvlist_t *newtlv, *cur;
    142149
    143         if (!list)
    144                 return 0;
    145 
    146         if (!(newtlv = g_new0(aim_tlvlist_t, 1)))
    147                 return 0;
     150        if (!list) {
     151                return 0;
     152        }
     153
     154        if (!(newtlv = g_new0(aim_tlvlist_t, 1))) {
     155                return 0;
     156        }
    148157
    149158        if (!(newtlv->tlv = g_new0(aim_tlv_t, 1))) {
     
    153162        newtlv->tlv->type = t;
    154163        if ((newtlv->tlv->length = l)) {
    155                 newtlv->tlv->value = (guint8 *)g_malloc(newtlv->tlv->length);
     164                newtlv->tlv->value = (guint8 *) g_malloc(newtlv->tlv->length);
    156165                memcpy(newtlv->tlv->value, v, newtlv->tlv->length);
    157166        }
    158167
    159         if (!*list)
     168        if (!*list) {
    160169                *list = newtlv;
    161         else {
    162                 for(cur = *list; cur->next; cur = cur->next)
     170        } else {
     171                for (cur = *list; cur->next; cur = cur->next) {
    163172                        ;
     173                }
    164174                cur->next = newtlv;
    165175        }
     
    234244int aim_addtlvtochain_caps(aim_tlvlist_t **list, const guint16 t, const guint32 caps)
    235245{
    236         guint8 buf[16*16]; /* XXX icky fixed length buffer */
     246        guint8 buf[16 * 16]; /* XXX icky fixed length buffer */
    237247        aim_bstream_t bs;
    238248
    239         if (!caps)
     249        if (!caps) {
    240250                return 0; /* nothing there anyway */
    241251
     252        }
    242253        aim_bstream_init(&bs, buf, sizeof(buf));
    243254
     
    266277 *
    267278 * XXX should probably support sublists for real.
    268  * 
     279 *
    269280 * This is so neat.
    270281 *
     
    278289        buflen = aim_sizetlvchain(tl);
    279290
    280         if (buflen <= 0)
    281                 return 0;
    282 
    283         if (!(buf = g_malloc(buflen)))
    284                 return 0;
     291        if (buflen <= 0) {
     292                return 0;
     293        }
     294
     295        if (!(buf = g_malloc(buflen))) {
     296                return 0;
     297        }
    285298
    286299        aim_bstream_init(&bs, buf, buflen);
     
    295308}
    296309
    297 int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)
     310int aim_addtlvtochain_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname,
     311                               guint16 instance)
    298312{
    299313        guint8 *buf;
     
    302316
    303317        buflen = 2 + 1 + strlen(roomname) + 2;
    304        
    305         if (!(buf = g_malloc(buflen)))
    306                 return 0;
     318
     319        if (!(buf = g_malloc(buflen))) {
     320                return 0;
     321        }
    307322
    308323        aim_bstream_init(&bs, buf, buflen);
     
    310325        aimbs_put16(&bs, exchange);
    311326        aimbs_put8(&bs, strlen(roomname));
    312         aimbs_putraw(&bs, (guint8 *)roomname, strlen(roomname));
     327        aimbs_putraw(&bs, (guint8 *) roomname, strlen(roomname));
    313328        aimbs_put16(&bs, instance);
    314329
     
    327342 *
    328343 * Copies a TLV chain into a raw data buffer, writing only the number
    329  * of bytes specified. This operation does not free the chain; 
     344 * of bytes specified. This operation does not free the chain;
    330345 * aim_freetlvchain() must still be called to free up the memory used
    331346 * by the chain structures.
    332347 *
    333  * XXX clean this up, make better use of bstreams 
     348 * XXX clean this up, make better use of bstreams
    334349 */
    335350int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list)
     
    344359        }
    345360
    346         if (goodbuflen > aim_bstream_empty(bs))
     361        if (goodbuflen > aim_bstream_empty(bs)) {
    347362                return 0; /* not enough buffer */
    348363
     364        }
    349365        /* do the real write-out */
    350366        for (cur = *list; cur; cur = cur->next) {
    351367                aimbs_put16(bs, cur->tlv->type);
    352368                aimbs_put16(bs, cur->tlv->length);
    353                 if (cur->tlv->length)
     369                if (cur->tlv->length) {
    354370                        aimbs_putraw(bs, cur->tlv->value, cur->tlv->length);
     371                }
    355372        }
    356373
     
    365382 * @nth: Index of TLV of type to get
    366383 *
    367  * Returns a pointer to an aim_tlv_t of the specified type; 
     384 * Returns a pointer to an aim_tlv_t of the specified type;
    368385 * %NULL on error.  The @nth parameter is specified starting at %1.
    369386 * In most cases, there will be no more than one TLV of any type
     
    378395        for (cur = list, i = 0; cur; cur = cur->next) {
    379396                if (cur && cur->tlv) {
    380                         if (cur->tlv->type == t)
     397                        if (cur->tlv->type == t) {
    381398                                i++;
    382                         if (i >= n)
     399                        }
     400                        if (i >= n) {
    383401                                return cur->tlv;
     402                        }
    384403                }
    385404        }
     
    395414 *
    396415 * Same as aim_gettlv(), except that the return value is a %NULL-
    397  * terminated string instead of an aim_tlv_t.  This is a 
     416 * terminated string instead of an aim_tlv_t.  This is a
    398417 * dynamic buffer and must be freed by the caller.
    399418 *
     
    404423        char *newstr;
    405424
    406         if (!(tlv = aim_gettlv(list, t, n)))
     425        if (!(tlv = aim_gettlv(list, t, n))) {
    407426                return NULL;
     427        }
    408428
    409429        newstr = (char *) g_malloc(tlv->length + 1);
     
    420440 * @nth: Index of TLV to return
    421441 *
    422  * Same as aim_gettlv(), except that the return value is a 
    423  * 8bit integer instead of an aim_tlv_t. 
     442 * Same as aim_gettlv(), except that the return value is a
     443 * 8bit integer instead of an aim_tlv_t.
    424444 *
    425445 */
     
    428448        aim_tlv_t *tlv;
    429449
    430         if (!(tlv = aim_gettlv(list, t, n)))
     450        if (!(tlv = aim_gettlv(list, t, n))) {
    431451                return 0; /* erm */
     452        }
    432453        return aimutil_get8(tlv->value);
    433454}
     
    439460 * @nth: Index of TLV to return
    440461 *
    441  * Same as aim_gettlv(), except that the return value is a 
    442  * 16bit integer instead of an aim_tlv_t. 
     462 * Same as aim_gettlv(), except that the return value is a
     463 * 16bit integer instead of an aim_tlv_t.
    443464 *
    444465 */
     
    447468        aim_tlv_t *tlv;
    448469
    449         if (!(tlv = aim_gettlv(list, t, n)))
     470        if (!(tlv = aim_gettlv(list, t, n))) {
    450471                return 0; /* erm */
     472        }
    451473        return aimutil_get16(tlv->value);
    452474}
     
    458480 * @nth: Index of TLV to return
    459481 *
    460  * Same as aim_gettlv(), except that the return value is a 
    461  * 32bit integer instead of an aim_tlv_t. 
     482 * Same as aim_gettlv(), except that the return value is a
     483 * 32bit integer instead of an aim_tlv_t.
    462484 *
    463485 */
     
    466488        aim_tlv_t *tlv;
    467489
    468         if (!(tlv = aim_gettlv(list, t, n)))
     490        if (!(tlv = aim_gettlv(list, t, n))) {
    469491                return 0; /* erm */
     492        }
    470493        return aimutil_get32(tlv->value);
    471494}
     
    544567
    545568        i = aimutil_put16(buf, t);
    546         i += aimutil_put16(buf+i, l);
    547         if (l)
    548                 memcpy(buf+i, v, l);
     569        i += aimutil_put16(buf + i, l);
     570        if (l) {
     571                memcpy(buf + i, v, l);
     572        }
    549573        i += l;
    550574
Note: See TracChangeset for help on using the changeset viewer.