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/yahoo/libyahoo2.c

    raf359b4 r5ebff60  
    33 *
    44 * Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
    5  * YMSG16 code copyright (C) 2009, 
    6  *              Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
     5 * YMSG16 code copyright (C) 2009,
     6 *              Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
    77 *
    88 * Yahoo Search copyright (C) 2003, Konstantin Klyagin <konst AT konst.org.ua>
    99 *
    1010 * Much of this code was taken and adapted from the yahoo module for
    11  * gaim released under the GNU GPL.  This code is also released under the 
     11 * gaim released under the GNU GPL.  This code is also released under the
    1212 * GNU GPL.
    1313 *
     
    3030 *
    3131 * YMSG16 authentication code based mostly on write-up at:
    32  *      http://www.carbonize.co.uk/ymsg16.html
     32 *      http://www.carbonize.co.uk/ymsg16.html
    3333 *
    3434 * This program is free software; you can redistribute it and/or modify
     
    6060#  define strrchr rindex
    6161# endif
    62 char *strchr (), *strrchr ();
     62char *strchr(), *strrchr();
    6363# if !HAVE_MEMCPY
    64 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
    65 #  define memmove(d, s, n) bcopy ((s), (d), (n))
     64#  define memcpy(d, s, n) bcopy((s), (d), (n))
     65#  define memmove(d, s, n) bcopy((s), (d), (n))
    6666# endif
    6767#endif
     
    100100}
    101101
    102 #define YAHOO_CALLBACK(x)       yc->x
     102#define YAHOO_CALLBACK(x)       yc->x
    103103#else
    104 #define YAHOO_CALLBACK(x)       x
     104#define YAHOO_CALLBACK(x)       x
    105105#endif
    106106
     
    113113        char out[1024];
    114114        va_list ap;
     115
    115116        va_start(ap, fmt);
    116117        vsnprintf(out, sizeof(out), fmt, ap);
    117118        va_end(ap);
    118         return YAHOO_CALLBACK(ext_yahoo_log) ("%s", out);
     119        return YAHOO_CALLBACK (ext_yahoo_log) ("%s", out);
    119120}
    120121
     
    129130{
    130131        enum yahoo_log_level l = log_level;
     132
    131133        log_level = level;
    132134        return l;
     
    134136
    135137/* default values for servers */
    136 static char *default_pager_hosts[] = {  "scs.msg.yahoo.com",
    137                                         "scsa.msg.yahoo.com",
    138                                         "scsb.msg.yahoo.com",
    139                                         "scsc.msg.yahoo.com",
    140                                         NULL};
     138static char *default_pager_hosts[] = {  "scs.msg.yahoo.com",
     139                                        "scsa.msg.yahoo.com",
     140                                        "scsb.msg.yahoo.com",
     141                                        "scsc.msg.yahoo.com",
     142                                        NULL };
    141143
    142144static int pager_port = 5050;
     
    222224
    223225static void yahoo_process_filetransfer(struct yahoo_input_data *yid,
    224         struct yahoo_packet *pkt);
     226                                       struct yahoo_packet *pkt);
    225227static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid,
    226         struct yahoo_packet *pkt);
     228                                           struct yahoo_packet *pkt);
    227229static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid,
    228         struct yahoo_packet *pkt);
     230                                             struct yahoo_packet *pkt);
    229231
    230232static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn);
     
    233235{
    234236        struct yahoo_server_settings *yss =
    235                 y_new0(struct yahoo_server_settings, 1);
     237                y_new0(struct yahoo_server_settings, 1);
    236238
    237239        /* Give preference to the default host list
    238          * Make sure that only one of the two is set at any time 
     240         * Make sure that only one of the two is set at any time
    239241         */
    240242        yss->pager_host = NULL;
     
    263265        while (1) {
    264266                key = va_arg(ap, char *);
    265                 if (key == NULL)
    266                         break;
     267                if (key == NULL) {
     268                        break;
     269                }
    267270
    268271                if (!strcmp(key, "pager_host")) {
     
    306309                } else {
    307310                        WARNING(("Unknown key passed to yahoo_init, "
    308                                         "perhaps you didn't terminate the list "
    309                                         "with NULL"));
     311                                 "perhaps you didn't terminate the list "
     312                                 "with NULL"));
    310313                }
    311314        }
     
    316319static void yahoo_free_server_settings(struct yahoo_server_settings *yss)
    317320{
    318         if (!yss)
    319                 return;
     321        if (!yss) {
     322                return;
     323        }
    320324
    321325        free(yss->pager_host);
     
    340344{
    341345        YList *l;
     346
    342347        for (l = conns; l; l = y_list_next(l)) {
    343348                struct yahoo_data *yd = l->data;
    344                 if (yd->client_id == id)
     349                if (yd->client_id == id) {
    345350                        return yd;
     351                }
    346352        }
    347353        return NULL;
     
    357363static struct yahoo_input_data * find_input_by_id(int id)
    358364{
    359         YList *l;
    360         for(l = inputs; l; l = y_list_next(l)) {
    361                 struct yahoo_input_data *yid = l->data;
    362                 if(yid->yd->client_id == id)
    363                         return yid;
    364         }
    365         return NULL;
     365        YList *l;
     366        for(l = inputs; l; l = y_list_next(l)) {
     367                struct yahoo_input_data *yid = l->data;
     368                if(yid->yd->client_id == id)
     369                        return yid;
     370        }
     371        return NULL;
    366372}
    367373*/
     
    369375#if 0
    370376static struct yahoo_input_data *find_input_by_id_and_webcam_user(int id,
    371         const char *who)
     377                                                                 const char *who)
    372378{
    373379        YList *l;
     380
    374381        LOG(("find_input_by_id_and_webcam_user"));
    375382        for (l = inputs; l; l = y_list_next(l)) {
    376383                struct yahoo_input_data *yid = l->data;
    377384                if (yid->type == YAHOO_CONNECTION_WEBCAM
    378                         && yid->yd->client_id == id && yid->wcm && ((who
    379                                         && yid->wcm->user
    380                                         && !strcmp(who, yid->wcm->user))
    381                                 || !(yid->wcm->user && !who)))
     385                    && yid->yd->client_id == id && yid->wcm && ((who
     386                                                                 && yid->wcm->user
     387                                                                 && !strcmp(who, yid->wcm->user))
     388                                                                || !(yid->wcm->user && !who))) {
    382389                        return yid;
     390                }
    383391        }
    384392        return NULL;
     
    387395
    388396static struct yahoo_input_data *find_input_by_id_and_type(int id,
    389         enum yahoo_connection_type type)
     397                                                          enum yahoo_connection_type type)
    390398{
    391399        YList *l;
     400
    392401        LOG(("find_input_by_id_and_type"));
    393402        for (l = inputs; l; l = y_list_next(l)) {
    394403                struct yahoo_input_data *yid = l->data;
    395                 if (yid->type == type && yid->yd->client_id == id)
     404                if (yid->type == type && yid->yd->client_id == id) {
    396405                        return yid;
     406                }
    397407        }
    398408        return NULL;
     
    402412{
    403413        YList *l;
     414
    404415        LOG(("find_input_by_id_and_fd"));
    405416        for (l = inputs; l; l = y_list_next(l)) {
    406417                struct yahoo_input_data *yid = l->data;
    407                 if (yid->fd == fd && yid->yd->client_id == id)
     418                if (yid->fd == fd && yid->yd->client_id == id) {
    408419                        return yid;
     420                }
    409421        }
    410422        return NULL;
     
    415427        int c = 0;
    416428        YList *l;
     429
    417430        LOG(("counting %d", id));
    418431        for (l = inputs; l; l = y_list_next(l)) {
    419432                struct yahoo_input_data *yid = l->data;
    420                 if (yid->yd->client_id == id)
     433                if (yid->yd->client_id == id) {
    421434                        c++;
     435                }
    422436        }
    423437        LOG(("%d", c));
     
    432446        for (l = list; l; l = l->next) {
    433447                struct yahoo_buddy *bud = l->data;
    434                 if (!bud)
     448                if (!bud) {
    435449                        continue;
     450                }
    436451
    437452                FREE(bud->group);
     
    503518
    504519static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service,
    505         enum ypacket_status status, int id)
     520                                             enum ypacket_status status, int id)
    506521{
    507522        struct yahoo_packet *pkt = y_new0(struct yahoo_packet, 1);
     
    515530
    516531static void yahoo_packet_hash(struct yahoo_packet *pkt, int key,
    517         const char *value)
     532                              const char *value)
    518533{
    519534        struct yahoo_pair *pair = y_new0(struct yahoo_pair, 1);
     535
    520536        pair->key = key;
    521537        pair->value = strdup(value);
     
    545561
    546562#define yahoo_put16(buf, data) ( \
    547                 (*(buf) = (unsigned char)((data)>>8)&0xff), \
    548                 (*((buf)+1) = (unsigned char)(data)&0xff),  \
    549                 2)
    550 #define yahoo_get16(buf) ((((*(buf))&0xff)<<8) + ((*((buf)+1)) & 0xff))
     563                (*(buf) = (unsigned char) ((data) >> 8) & 0xff), \
     564                (*((buf) + 1) = (unsigned char) (data) & 0xff),  \
     565                2)
     566#define yahoo_get16(buf) ((((*(buf)) & 0xff) << 8) + ((*((buf) + 1)) & 0xff))
    551567#define yahoo_put32(buf, data) ( \
    552                 (*((buf)) = (unsigned char)((data)>>24)&0xff), \
    553                 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
    554                 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
    555                 (*((buf)+3) = (unsigned char)(data)&0xff), \
    556                 4)
    557 #define yahoo_get32(buf) ((((*(buf)   )&0xff)<<24) + \
    558                          (((*((buf)+1))&0xff)<<16) + \
    559                          (((*((buf)+2))&0xff)<< 8) + \
    560                          (((*((buf)+3))&0xff)))
     568                (*((buf)) = (unsigned char) ((data) >> 24) & 0xff), \
     569                (*((buf) + 1) = (unsigned char) ((data) >> 16) & 0xff), \
     570                (*((buf) + 2) = (unsigned char) ((data) >> 8) & 0xff), \
     571                (*((buf) + 3) = (unsigned char) (data) & 0xff), \
     572                4)
     573#define yahoo_get32(buf) ((((*(buf)) & 0xff) << 24) + \
     574                          (((*((buf) + 1)) & 0xff) << 16) + \
     575                          (((*((buf) + 2)) & 0xff) << 8) + \
     576                          (((*((buf) + 3)) & 0xff)))
    561577
    562578static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data,
    563         int len)
     579                              int len)
    564580{
    565581        int pos = 0;
     
    575591                x = 0;
    576592                while (pos + 1 < len) {
    577                         if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
     593                        if (data[pos] == 0xc0 && data[pos + 1] == 0x80) {
    578594                                break;
     595                        }
    579596                        key[x++] = data[pos++];
    580597                }
     
    583600                pair->key = strtol(key, NULL, 10);
    584601                free(key);
    585                
     602
    586603                /* Libyahoo2 developer(s) don't seem to have the time to fix
    587604                   this problem, so for now try to work around it:
    588                    
     605
    589606                   Sometimes we receive an invalid packet with not any more
    590607                   data at this point. I don't know how to handle this in a
    591608                   clean way, but let's hope this is clean enough: */
    592                
     609
    593610                if (pos + 1 < len) {
    594                         accept = x; 
     611                        accept = x;
    595612                        /* if x is 0 there was no key, so don't accept it */
    596                         if (accept)
     613                        if (accept) {
    597614                                value = malloc(len - pos + 1);
     615                        }
    598616                        x = 0;
    599617                        while (pos + 1 < len) {
    600                                 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
     618                                if (data[pos] == 0xc0 && data[pos + 1] == 0x80) {
    601619                                        break;
    602                                 if (accept)
     620                                }
     621                                if (accept) {
    603622                                        value[x++] = data[pos++];
     623                                }
    604624                        }
    605                         if (accept)
     625                        if (accept) {
    606626                                value[x] = 0;
     627                        }
    607628                        pos += 2;
    608629                } else {
    609630                        accept = 0;
    610631                }
    611                
     632
    612633                if (accept) {
    613634                        pair->value = strdup(value);
     
    615636                        pkt->hash = y_list_append(pkt->hash, pair);
    616637                        DEBUG_MSG(("Key: %d  \tValue: %s", pair->key,
    617                                         pair->value));
     638                                   pair->value));
    618639                } else {
    619640                        FREE(pair);
     
    631652                unsigned char buf[100];
    632653
    633                 snprintf((char *)buf, sizeof(buf), "%d", pair->key);
    634                 strcpy((char *)data + pos, (char *)buf);
    635                 pos += strlen((char *)buf);
     654                snprintf((char *) buf, sizeof(buf), "%d", pair->key);
     655                strcpy((char *) data + pos, (char *) buf);
     656                pos += strlen((char *) buf);
    636657                data[pos++] = 0xc0;
    637658                data[pos++] = 0x80;
    638659
    639                 strcpy((char *)data + pos, pair->value);
     660                strcpy((char *) data + pos, pair->value);
    640661                pos += strlen(pair->value);
    641662                data[pos++] = 0xc0;
     
    660681                int i;
    661682                for (i = 0; i < len; i++) {
    662                         if ((i % 8 == 0) && i)
    663                                 YAHOO_CALLBACK(ext_yahoo_log) (" ");
    664                         if ((i % 16 == 0) && i)
    665                                 YAHOO_CALLBACK(ext_yahoo_log) ("\n");
    666                         YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]);
    667                 }
    668                 YAHOO_CALLBACK(ext_yahoo_log) ("\n");
     683                        if ((i % 8 == 0) && i) {
     684                                YAHOO_CALLBACK (ext_yahoo_log) (" ");
     685                        }
     686                        if ((i % 16 == 0) && i) {
     687                                YAHOO_CALLBACK (ext_yahoo_log) ("\n");
     688                        }
     689                        YAHOO_CALLBACK (ext_yahoo_log) ("%02x ", data[i]);
     690                }
     691                YAHOO_CALLBACK (ext_yahoo_log) ("\n");
    669692                for (i = 0; i < len; i++) {
    670                         if ((i % 8 == 0) && i)
    671                                 YAHOO_CALLBACK(ext_yahoo_log) (" ");
    672                         if ((i % 16 == 0) && i)
    673                                 YAHOO_CALLBACK(ext_yahoo_log) ("\n");
    674                         if (isprint(data[i]))
    675                                 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]);
    676                         else
    677                                 YAHOO_CALLBACK(ext_yahoo_log) (" . ");
    678                 }
    679                 YAHOO_CALLBACK(ext_yahoo_log) ("\n");
     693                        if ((i % 8 == 0) && i) {
     694                                YAHOO_CALLBACK (ext_yahoo_log) (" ");
     695                        }
     696                        if ((i % 16 == 0) && i) {
     697                                YAHOO_CALLBACK (ext_yahoo_log) ("\n");
     698                        }
     699                        if (isprint(data[i])) {
     700                                YAHOO_CALLBACK (ext_yahoo_log) (" %c ", data[i]);
     701                        } else {
     702                                YAHOO_CALLBACK (ext_yahoo_log) (" . ");
     703                        }
     704                }
     705                YAHOO_CALLBACK (ext_yahoo_log) ("\n");
    680706        }
    681707}
     
    703729
    704730static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data,
    705         int length)
     731                                    int length)
    706732{
    707733        struct data_queue *tx = y_new0(struct data_queue, 1);
     734
    708735        tx->queue = y_new0(unsigned char, length);
    709736        tx->len = length;
     
    712739        yid->txqueues = y_list_append(yid->txqueues, tx);
    713740
    714         if (!yid->write_tag)
     741        if (!yid->write_tag) {
    715742                yid->write_tag =
    716                         YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->
    717                         client_id, yid->fd, YAHOO_INPUT_WRITE, yid);
     743                        YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->
     744                                                                client_id, yid->fd, YAHOO_INPUT_WRITE, yid);
     745        }
    718746}
    719747
    720748static void yahoo_send_packet(struct yahoo_input_data *yid,
    721         struct yahoo_packet *pkt, int extra_pad)
     749                              struct yahoo_packet *pkt, int extra_pad)
    722750{
    723751        int pktlen = yahoo_packet_length(pkt);
     
    726754        int pos = 0;
    727755
    728         if (yid->fd < 0)
    729                 return;
     756        if (yid->fd < 0) {
     757                return;
     758        }
    730759
    731760        data = y_new0(unsigned char, len + 1);
     
    733762        memcpy(data + pos, "YMSG", 4);
    734763        pos += 4;
    735         pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);        /* version [latest 12 0x000c] */
    736         pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */
    737         pos += yahoo_put16(data + pos, pktlen + extra_pad);     /* LOWORD pkt length? */
    738         pos += yahoo_put16(data + pos, pkt->service);   /* service */
    739         pos += yahoo_put32(data + pos, pkt->status);    /* status [4bytes] */
    740         pos += yahoo_put32(data + pos, pkt->id);        /* session [4bytes] */
     764        pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);        /* version [latest 12 0x000c] */
     765        pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */
     766        pos += yahoo_put16(data + pos, pktlen + extra_pad);     /* LOWORD pkt length? */
     767        pos += yahoo_put16(data + pos, pkt->service);   /* service */
     768        pos += yahoo_put32(data + pos, pkt->status);    /* status [4bytes] */
     769        pos += yahoo_put32(data + pos, pkt->id);        /* session [4bytes] */
    741770
    742771        yahoo_packet_write(pkt, data + pos);
     
    744773        yahoo_packet_dump(data, len);
    745774
    746         if (yid->type == YAHOO_CONNECTION_FT)
     775        if (yid->type == YAHOO_CONNECTION_FT) {
    747776                yahoo_send_data(yid->fd, data, len);
    748         else
     777        } else {
    749778                yahoo_add_to_send_queue(yid, data, len);
     779        }
    750780        FREE(data);
    751781}
     
    770800        int e;
    771801
    772         if (fd == NULL)
     802        if (fd == NULL) {
    773803                return -1;
     804        }
    774805
    775806        yahoo_packet_dump(data, len);
    776807
    777808        do {
    778                 ret = YAHOO_CALLBACK(ext_yahoo_write) (fd, data, len);
     809                ret = YAHOO_CALLBACK (ext_yahoo_write) (fd, data, len);
    779810        } while (ret == -1 && errno == EINTR);
    780811        e = errno;
     
    793824{
    794825        struct yahoo_data *yd = find_conn_by_id(id);
    795         if (!yd)
    796                 return;
     826
     827        if (!yd) {
     828                return;
     829        }
    797830
    798831        del_from_list(yd);
    799832
    800833        yahoo_free_data(yd);
    801         if (id == last_id)
     834        if (id == last_id) {
    802835                last_id--;
     836        }
    803837}
    804838
     
    808842
    809843        LOG(("yahoo_input_close(read)"));
    810         YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id,
    811                 yid->read_tag);
     844        YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id,
     845                                                   yid->read_tag);
    812846        LOG(("yahoo_input_close(write)"));
    813         YAHOO_CALLBACK(ext_yahoo_remove_handler) (yid->yd->client_id,
    814                 yid->write_tag);
     847        YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id,
     848                                                   yid->write_tag);
    815849        yid->read_tag = yid->write_tag = 0;
    816         if (yid->fd)
    817                 YAHOO_CALLBACK(ext_yahoo_close) (yid->fd);
     850        if (yid->fd) {
     851                YAHOO_CALLBACK (ext_yahoo_close) (yid->fd);
     852        }
    818853        yid->fd = 0;
    819854        FREE(yid->rxqueue);
     
    823858        }
    824859        yahoo_free_webcam(yid->wcm);
    825         if (yid->wcd)
     860        if (yid->wcd) {
    826861                FREE(yid->wcd);
     862        }
    827863        if (yid->ys) {
    828864                FREE(yid->ys->lsearch_text);
     
    846882        char *cookieend;
    847883
    848         if (strlen(rawcookie) < 2)
     884        if (strlen(rawcookie) < 2) {
    849885                return NULL;
     886        }
    850887
    851888        tmpcookie = strdup(rawcookie + 2);
    852889        cookieend = strchr(tmpcookie, ';');
    853890
    854         if (cookieend)
     891        if (cookieend) {
    855892                *cookieend = '\0';
     893        }
    856894
    857895        cookie = strdup(tmpcookie);
     
    872910                tmp = strdup(tmpend + 2);
    873911                tmpend = strchr(tmp, '&');
    874                 if (tmpend)
     912                if (tmpend) {
    875913                        *tmpend = '\0';
     914                }
    876915                login_cookie = strdup(tmp);
    877916                FREE(tmp);
     
    882921
    883922static void yahoo_process_notify(struct yahoo_input_data *yid,
    884         struct yahoo_packet *pkt)
     923                                 struct yahoo_packet *pkt)
    885924{
    886925        struct yahoo_data *yd = yid->yd;
     
    892931        char *ind = NULL;
    893932        YList *l;
     933
    894934        for (l = pkt->hash; l; l = l->next) {
    895935                struct yahoo_pair *pair = l->data;
    896                 if (pair->key == 4)
     936                if (pair->key == 4) {
    897937                        from = pair->value;
    898                 if (pair->key == 5)
     938                }
     939                if (pair->key == 5) {
    899940                        to = pair->value;
    900                 if (pair->key == 49)
     941                }
     942                if (pair->key == 49) {
    901943                        msg = pair->value;
    902                 if (pair->key == 13)
     944                }
     945                if (pair->key == 13) {
    903946                        stat = atoi(pair->value);
    904                 if (pair->key == 14)
     947                }
     948                if (pair->key == 14) {
    905949                        ind = pair->value;
    906                 if (pair->key == 16) {  /* status == -1 */
     950                }
     951                if (pair->key == 16) {  /* status == -1 */
    907952                        NOTICE((pair->value));
    908953                        return;
     
    911956        }
    912957
    913         if (!msg)
    914                 return;
    915 
    916         if (!strncasecmp(msg, "TYPING", strlen("TYPING")))
    917                 YAHOO_CALLBACK(ext_yahoo_typing_notify) (yd->client_id, to,
    918                         from, stat);
    919         else if (!strncasecmp(msg, "GAME", strlen("GAME")))
    920                 YAHOO_CALLBACK(ext_yahoo_game_notify) (yd->client_id, to, from,
    921                         stat, ind);
    922         else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) {
     958        if (!msg) {
     959                return;
     960        }
     961
     962        if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) {
     963                YAHOO_CALLBACK (ext_yahoo_typing_notify) (yd->client_id, to,
     964                                                          from, stat);
     965        } else if (!strncasecmp(msg, "GAME", strlen("GAME"))) {
     966                YAHOO_CALLBACK (ext_yahoo_game_notify) (yd->client_id, to, from,
     967                                                        stat, ind);
     968        } else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) {
    923969                if (!strcmp(ind, " ")) {
    924                         YAHOO_CALLBACK(ext_yahoo_webcam_invite) (yd->client_id,
    925                                 to, from);
     970                        YAHOO_CALLBACK (ext_yahoo_webcam_invite) (yd->client_id,
     971                                                                  to, from);
    926972                } else {
    927973                        accept = atoi(ind);
    928974                        /* accept the invitation (-1 = deny 1 = accept) */
    929                         if (accept < 0)
     975                        if (accept < 0) {
    930976                                accept = 0;
    931                         YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd->
    932                                 client_id, to, from, accept);
    933                 }
    934         } else
     977                        }
     978                        YAHOO_CALLBACK (ext_yahoo_webcam_invite_reply) (yd->
     979                                                                        client_id, to, from, accept);
     980                }
     981        } else {
    935982                LOG(("Got unknown notification: %s", msg));
     983        }
    936984}
    937985
    938986static void yahoo_process_conference(struct yahoo_input_data *yid,
    939         struct yahoo_packet *pkt)
     987                                     struct yahoo_packet *pkt)
    940988{
    941989        struct yahoo_data *yd = yid->yd;
     
    951999        for (l = pkt->hash; l; l = l->next) {
    9521000                struct yahoo_pair *pair = l->data;
    953                 if (pair->key == 50)
     1001                if (pair->key == 50) {
    9541002                        host = pair->value;
    955 
    956                 if (pair->key == 52) {  /* invite */
     1003                }
     1004
     1005                if (pair->key == 52) {  /* invite */
    9571006                        members = y_list_append(members, strdup(pair->value));
    9581007                }
    959                 if (pair->key == 53)    /* logon */
     1008                if (pair->key == 53) {  /* logon */
    9601009                        who = pair->value;
    961                 if (pair->key == 54)    /* decline */
     1010                }
     1011                if (pair->key == 54) {  /* decline */
    9621012                        who = pair->value;
    963                 if (pair->key == 55)    /* unavailable (status == 2) */
     1013                }
     1014                if (pair->key == 55) {  /* unavailable (status == 2) */
    9641015                        who = pair->value;
    965                 if (pair->key == 56)    /* logoff */
     1016                }
     1017                if (pair->key == 56) {  /* logoff */
    9661018                        who = pair->value;
    967 
    968                 if (pair->key == 57)
     1019                }
     1020
     1021                if (pair->key == 57) {
    9691022                        room = pair->value;
    970 
    971                 if (pair->key == 58)    /* join message */
     1023                }
     1024
     1025                if (pair->key == 58) {  /* join message */
    9721026                        msg = pair->value;
    973                 if (pair->key == 14)    /* decline/conf message */
     1027                }
     1028                if (pair->key == 14) {  /* decline/conf message */
    9741029                        msg = pair->value;
    975 
    976                 if (pair->key == 13)
     1030                }
     1031
     1032                if (pair->key == 13) {
    9771033                        ;
    978                 if (pair->key == 16)    /* error */
     1034                }
     1035                if (pair->key == 16) {  /* error */
    9791036                        msg = pair->value;
    980 
    981                 if (pair->key == 1)     /* my id */
     1037                }
     1038
     1039                if (pair->key == 1) {   /* my id */
    9821040                        id = pair->value;
    983                 if (pair->key == 3)     /* message sender */
     1041                }
     1042                if (pair->key == 3) {   /* message sender */
    9841043                        who = pair->value;
    985 
    986                 if (pair->key == 97)
     1044                }
     1045
     1046                if (pair->key == 97) {
    9871047                        utf8 = atoi(pair->value);
    988         }
    989 
    990         if (!room)
    991                 return;
     1048                }
     1049        }
     1050
     1051        if (!room) {
     1052                return;
     1053        }
    9921054
    9931055        if (host) {
    9941056                for (l = members; l; l = l->next) {
    9951057                        char *w = l->data;
    996                         if (!strcmp(w, host))
     1058                        if (!strcmp(w, host)) {
    9971059                                break;
    998                 }
    999                 if (!l)
     1060                        }
     1061                }
     1062                if (!l) {
    10001063                        members = y_list_append(members, strdup(host));
     1064                }
    10011065        }
    10021066        /* invite, decline, join, left, message -> status == 1 */
     
    10041068        switch (pkt->service) {
    10051069        case YAHOO_SERVICE_CONFINVITE:
    1006                 if (pkt->status == 2) ;
    1007                 else if (members)
    1008                         YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->
    1009                                 client_id, id, host, room, msg, members);
    1010                 else if (msg)
    1011                         YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, msg, 0,
    1012                                 E_CONFNOTAVAIL);
     1070                if (pkt->status == 2) {
     1071                        ;
     1072                } else if (members) {
     1073                        YAHOO_CALLBACK (ext_yahoo_got_conf_invite) (yd->
     1074                                                                    client_id, id, host, room, msg, members);
     1075                } else if (msg) {
     1076                        YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id, msg, 0,
     1077                                                          E_CONFNOTAVAIL);
     1078                }
    10131079                break;
    10141080        case YAHOO_SERVICE_CONFADDINVITE:
    1015                 if (pkt->status == 1)
    1016                         YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd->
    1017                                 client_id, id, host, room, msg, members);
     1081                if (pkt->status == 1) {
     1082                        YAHOO_CALLBACK (ext_yahoo_got_conf_invite) (yd->
     1083                                                                    client_id, id, host, room, msg, members);
     1084                }
    10181085                break;
    10191086        case YAHOO_SERVICE_CONFDECLINE:
    1020                 if (who)
    1021                         YAHOO_CALLBACK(ext_yahoo_conf_userdecline) (yd->
    1022                                 client_id, id, who, room, msg);
     1087                if (who) {
     1088                        YAHOO_CALLBACK (ext_yahoo_conf_userdecline) (yd->
     1089                                                                     client_id, id, who, room, msg);
     1090                }
    10231091                break;
    10241092        case YAHOO_SERVICE_CONFLOGON:
    1025                 if (who)
    1026                         YAHOO_CALLBACK(ext_yahoo_conf_userjoin) (yd->client_id,
    1027                                 id, who, room);
     1093                if (who) {
     1094                        YAHOO_CALLBACK (ext_yahoo_conf_userjoin) (yd->client_id,
     1095                                                                  id, who, room);
     1096                }
    10281097                break;
    10291098        case YAHOO_SERVICE_CONFLOGOFF:
    1030                 if (who)
    1031                         YAHOO_CALLBACK(ext_yahoo_conf_userleave) (yd->client_id,
    1032                                 id, who, room);
     1099                if (who) {
     1100                        YAHOO_CALLBACK (ext_yahoo_conf_userleave) (yd->client_id,
     1101                                                                   id, who, room);
     1102                }
    10331103                break;
    10341104        case YAHOO_SERVICE_CONFMSG:
    1035                 if (who)
    1036                         YAHOO_CALLBACK(ext_yahoo_conf_message) (yd->client_id,
    1037                                 id, who, room, msg, utf8);
     1105                if (who) {
     1106                        YAHOO_CALLBACK (ext_yahoo_conf_message) (yd->client_id,
     1107                                                                 id, who, room, msg, utf8);
     1108                }
    10381109                break;
    10391110        }
     
    10411112
    10421113static void yahoo_process_chat(struct yahoo_input_data *yid,
    1043         struct yahoo_packet *pkt)
     1114                               struct yahoo_packet *pkt)
    10441115{
    10451116        char *msg = NULL;
     
    10871158                        if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
    10881159                                currentmember =
    1089                                         y_new0(struct yahoo_chat_member, 1);
     1160                                        y_new0(struct yahoo_chat_member, 1);
    10901161                                currentmember->id = strdup(pair->value);
    10911162                                members = y_list_append(members, currentmember);
     
    10951166                if (pair->key == 110) {
    10961167                        /* age */
    1097                         if (pkt->service == YAHOO_SERVICE_CHATJOIN)
     1168                        if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
    10981169                                currentmember->age = atoi(pair->value);
     1170                        }
    10991171                }
    11001172
    11011173                if (pair->key == 113) {
    11021174                        /* attribs */
    1103                         if (pkt->service == YAHOO_SERVICE_CHATJOIN)
     1175                        if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
    11041176                                currentmember->attribs = atoi(pair->value);
     1177                        }
    11051178                }
    11061179
    11071180                if (pair->key == 141) {
    11081181                        /* alias */
    1109                         if (pkt->service == YAHOO_SERVICE_CHATJOIN)
     1182                        if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
    11101183                                currentmember->alias = strdup(pair->value);
     1184                        }
    11111185                }
    11121186
    11131187                if (pair->key == 142) {
    11141188                        /* location */
    1115                         if (pkt->service == YAHOO_SERVICE_CHATJOIN)
     1189                        if (pkt->service == YAHOO_SERVICE_CHATJOIN) {
    11161190                                currentmember->location = strdup(pair->value);
     1191                        }
    11171192                }
    11181193
     
    11391214
    11401215        if (!room) {
    1141                 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */
    1142                         YAHOO_CALLBACK(ext_yahoo_chat_yahoologout) (yid->yd->
    1143                                 client_id, id);
     1216                if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */
     1217                        YAHOO_CALLBACK (ext_yahoo_chat_yahoologout) (yid->yd->
     1218                                                                     client_id, id);
    11441219                        return;
    11451220                }
    11461221                if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) {
    1147                         YAHOO_CALLBACK(ext_yahoo_chat_yahooerror) (yid->yd->
    1148                                 client_id, id);
     1222                        YAHOO_CALLBACK (ext_yahoo_chat_yahooerror) (yid->yd->
     1223                                                                    client_id, id);
    11491224                        return;
    11501225                }
     
    11601235                }
    11611236                if (firstjoin && members) {
    1162                         YAHOO_CALLBACK(ext_yahoo_chat_join) (yid->yd->client_id,
    1163                                 id, room, topic, members, yid->fd);
     1237                        YAHOO_CALLBACK (ext_yahoo_chat_join) (yid->yd->client_id,
     1238                                                              id, room, topic, members, yid->fd);
    11641239                } else if (who) {
    11651240                        if (y_list_length(members) != 1) {
     
    11701245                                YList *n = members->next;
    11711246                                currentmember = members->data;
    1172                                 YAHOO_CALLBACK(ext_yahoo_chat_userjoin) (yid->
    1173                                         yd->client_id, id, room, currentmember);
     1247                                YAHOO_CALLBACK (ext_yahoo_chat_userjoin) (yid->
     1248                                                                          yd->client_id, id, room, currentmember);
    11741249                                y_list_free_1(members);
    11751250                                members = n;
     
    11791254        case YAHOO_SERVICE_CHATEXIT:
    11801255                if (who) {
    1181                         YAHOO_CALLBACK(ext_yahoo_chat_userleave) (yid->yd->
    1182                                 client_id, id, room, who);
     1256                        YAHOO_CALLBACK (ext_yahoo_chat_userleave) (yid->yd->
     1257                                                                   client_id, id, room, who);
    11831258                }
    11841259                break;
    11851260        case YAHOO_SERVICE_COMMENT:
    11861261                if (who) {
    1187                         YAHOO_CALLBACK(ext_yahoo_chat_message) (yid->yd->
    1188                                 client_id, id, who, room, msg, msgtype, utf8);
     1262                        YAHOO_CALLBACK (ext_yahoo_chat_message) (yid->yd->
     1263                                                                 client_id, id, who, room, msg, msgtype, utf8);
    11891264                }
    11901265                break;
     
    11931268
    11941269static void yahoo_process_message(struct yahoo_input_data *yid,
    1195         struct yahoo_packet *pkt)
     1270                                  struct yahoo_packet *pkt)
    11961271{
    11971272        struct yahoo_data *yd = yid->yd;
     
    12131288                struct yahoo_pair *pair = l->data;
    12141289                if (pair->key == 1 || pair->key == 4) {
    1215                         if (!message->from)
     1290                        if (!message->from) {
    12161291                                message->from = pair->value;
    1217                 } else if (pair->key == 5)
     1292                        }
     1293                } else if (pair->key == 5) {
    12181294                        message->to = pair->value;
    1219                 else if (pair->key == 15)
     1295                } else if (pair->key == 15) {
    12201296                        message->tm = strtol(pair->value, NULL, 10);
    1221                 else if (pair->key == 97)
     1297                } else if (pair->key == 97) {
    12221298                        message->utf8 = atoi(pair->value);
     1299                }
    12231300                /* This comes when the official client sends us a message */
    1224                 else if (pair->key == 429)
     1301                else if (pair->key == 429) {
    12251302                        message->gunk = pair->value;
     1303                }
    12261304                /* user message *//* sys message */
    1227                 else if (pair->key == 14 || pair->key == 16)
     1305                else if (pair->key == 14 || pair->key == 16) {
    12281306                        message->msg = pair->value;
    1229                 else if (pair->key == 31) {
     1307                } else if (pair->key == 31) {
    12301308                        if (message->i_31) {
    12311309                                messages = y_list_append(messages, message);
     
    12331311                        }
    12341312                        message->i_31 = atoi(pair->value);
    1235                 } else if (pair->key == 32)
     1313                } else if (pair->key == 32) {
    12361314                        message->i_32 = atoi(pair->value);
    1237                 else
    1238                         LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key, pair->value));
     1315                } else {
     1316                        LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key,
     1317                             pair->value));
     1318                }
    12391319        }
    12401320
     
    12441324                message = l->data;
    12451325                if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) {
    1246                         YAHOO_CALLBACK(ext_yahoo_system_message) (yd->client_id,
    1247                                 message->to, message->from, message->msg);
     1326                        YAHOO_CALLBACK (ext_yahoo_system_message) (yd->client_id,
     1327                                                                   message->to, message->from, message->msg);
    12481328                } else if (pkt->status <= 2 || pkt->status == 5) {
    12491329                        /* Confirm message receipt if we got the gunk */
    1250                         if(message->gunk) {
     1330                        if (message->gunk) {
    12511331                                struct yahoo_packet *outpkt;
    1252                        
     1332
    12531333                                outpkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_CONFIRM,
    1254                                         YPACKET_STATUS_DEFAULT, 0);
     1334                                                          YPACKET_STATUS_DEFAULT, 0);
    12551335                                yahoo_packet_hash(outpkt, 1, yd->user);
    12561336                                yahoo_packet_hash(outpkt, 5, message->from);
     
    12601340                                yahoo_packet_hash(outpkt, 450, "0");
    12611341                                yahoo_send_packet(yid, outpkt, 0);
    1262                        
     1342
    12631343                                yahoo_packet_free(outpkt);
    12641344                        }
    12651345
    1266                         if (!strcmp(message->msg, "<ding>"))
    1267                                 YAHOO_CALLBACK(ext_yahoo_got_buzz) (yd->client_id,
    1268                                         message->to, message->from, message->tm);
    1269                         else
    1270                                 YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id,
    1271                                         message->to, message->from, message->msg,
    1272                                         message->tm, pkt->status, message->utf8);
     1346                        if (!strcmp(message->msg, "<ding>")) {
     1347                                YAHOO_CALLBACK (ext_yahoo_got_buzz) (yd->client_id,
     1348                                                                     message->to, message->from, message->tm);
     1349                        } else {
     1350                                YAHOO_CALLBACK (ext_yahoo_got_im) (yd->client_id,
     1351                                                                   message->to, message->from, message->msg,
     1352                                                                   message->tm, pkt->status, message->utf8);
     1353                        }
    12731354                } else if (pkt->status == 0xffffffff) {
    1274                         YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id,
    1275                                 message->msg, 0, E_SYSTEM);
     1355                        YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id,
     1356                                                          message->msg, 0, E_SYSTEM);
    12761357                }
    12771358                FREE(message);
     
    12861367 * 3 level:
    12871368 * =======
    1288  * 
     1369 *
    12891370 * 302 (318) - Beginning level 1
    1290  *      300 (318) - Begin level 2
    1291  *      302 (319) - End level 2 header
    1292  *              300 (319) - Begin level 3
    1293  *              301 (319) - End level 3
    1294  *      303 (319) - End level 2
     1371 *      300 (318) - Begin level 2
     1372 *      302 (319) - End level 2 header
     1373 *              300 (319) - Begin level 3
     1374 *              301 (319) - End level 3
     1375 *      303 (319) - End level 2
    12951376 * 303 (318) - End level 1
    12961377 *
     
    12991380 *
    13001381 * 302 (315) - Beginning level 1
    1301  *      300 (315) - Begin level 2
    1302  *      301 (315) - End level 2
     1382 *      300 (315) - Begin level 2
     1383 *      301 (315) - End level 2
    13031384 * 303 (315) - End level 1
    13041385 *
    13051386 */
    13061387static void yahoo_process_status(struct yahoo_input_data *yid,
    1307         struct yahoo_packet *pkt)
     1388                                 struct yahoo_packet *pkt)
    13081389{
    13091390        YList *l;
     
    13151396
    13161397        if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
    1317                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    1318                         YAHOO_LOGIN_DUPL, NULL);
    1319                 return;
    1320         }
    1321 
    1322         /* 
    1323          * Status updates may be spread accross multiple packets and not 
    1324          * even on buddy boundaries, so keeping some state is important. 
    1325          * So, continue where we left off, and only add a user entry to 
     1398                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     1399                                                           YAHOO_LOGIN_DUPL, NULL);
     1400                return;
     1401        }
     1402
     1403        /*
     1404         * Status updates may be spread accross multiple packets and not
     1405         * even on buddy boundaries, so keeping some state is important.
     1406         * So, continue where we left off, and only add a user entry to
    13261407         * the list once it's complete (301-315 End buddy).
    13271408         */
     
    13321413
    13331414                switch (pair->key) {
    1334                 case 300:       /* Begin buddy */
     1415                case 300:       /* Begin buddy */
    13351416                        if (!strcmp(pair->value, "315") && !u) {
    13361417                                u = yd->half_user = y_new0(struct yahoo_process_status_entry, 1);
    13371418                        }
    13381419                        break;
    1339                 case 301:       /* End buddy */
     1420                case 301:       /* End buddy */
    13401421                        if (!strcmp(pair->value, "315") && u) {
    13411422                                /* Sometimes user info comes in an odd format with no
    13421423                                   "begin buddy" but *with* an "end buddy". Don't add
    13431424                                   it twice. */
    1344                                 if (!y_list_find(users, u))
     1425                                if (!y_list_find(users, u)) {
    13451426                                        users = y_list_prepend(users, u);
     1427                                }
    13461428                                u = yd->half_user = NULL;
    13471429                        }
    13481430                        break;
    1349                 case 0: /* we won't actually do anything with this */
     1431                case 0: /* we won't actually do anything with this */
    13501432                        NOTICE(("key %d:%s", pair->key, pair->value));
    13511433                        break;
    1352                 case 1: /* we don't get the full buddy list here. */
     1434                case 1: /* we don't get the full buddy list here. */
    13531435                        if (!yd->logged_in) {
    13541436                                yd->logged_in = 1;
    1355                                 if (yd->current_status < 0)
     1437                                if (yd->current_status < 0) {
    13561438                                        yd->current_status = yd->initial_status;
    1357                                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->
    1358                                         client_id, YAHOO_LOGIN_OK, NULL);
     1439                                }
     1440                                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->
     1441                                                                           client_id, YAHOO_LOGIN_OK, NULL);
    13591442                        }
    13601443                        break;
    1361                 case 8: /* how many online buddies we have */
     1444                case 8: /* how many online buddies we have */
    13621445                        NOTICE(("key %d:%s", pair->key, pair->value));
    13631446                        break;
    1364                 case 7: /* the current buddy */
     1447                case 7: /* the current buddy */
    13651448                        if (!u) {
    13661449                                /* This will only happen in case of a single level message */
     
    13701453                        u->name = pair->value;
    13711454                        break;
    1372                 case 10:        /* state */
     1455                case 10:        /* state */
    13731456                        u->state = strtol(pair->value, NULL, 10);
    13741457                        break;
    1375                 case 19:        /* custom status message */
     1458                case 19:        /* custom status message */
    13761459                        u->msg = pair->value;
    13771460                        break;
    1378                 case 47:        /* is it an away message or not. Not applicable for YMSG16 anymore */
     1461                case 47:        /* is it an away message or not. Not applicable for YMSG16 anymore */
    13791462                        u->away = atoi(pair->value);
    13801463                        break;
    1381                 case 137:       /* seconds idle */
     1464                case 137:       /* seconds idle */
    13821465                        u->idle = atoi(pair->value);
    13831466                        break;
    1384                 case 11:        /* this is the buddy's session id */
     1467                case 11:        /* this is the buddy's session id */
    13851468                        u->buddy_session = atoi(pair->value);
    13861469                        break;
    1387                 case 17:        /* in chat? */
     1470                case 17:        /* in chat? */
    13881471                        u->f17 = atoi(pair->value);
    13891472                        break;
    1390                 case 13:        /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
     1473                case 13:        /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
    13911474                        u->flags = atoi(pair->value);
    13921475                        break;
    1393                 case 60:        /* SMS -> 1 MOBILE USER */
     1476                case 60:        /* SMS -> 1 MOBILE USER */
    13941477                        /* sometimes going offline makes this 2, but invisible never sends it */
    13951478                        u->mobile = atoi(pair->value);
     
    14221505                        u->f213 = atoi(pair->value);
    14231506                        break;
    1424                 case 16:        /* Custom error message */
    1425                         YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id,
    1426                                 pair->value, 0, E_CUSTOM);
     1507                case 16:        /* Custom error message */
     1508                        YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id,
     1509                                                          pair->value, 0, E_CUSTOM);
    14271510                        break;
    14281511                default:
    14291512                        WARNING(("unknown status key %d:%s", pair->key,
    1430                                         pair->value));
     1513                                 pair->value));
    14311514                        break;
    14321515                }
     
    14391522                if (u->name != NULL) {
    14401523                        if (pkt->service ==
    1441                                 YAHOO_SERVICE_LOGOFF
    1442                                 /*|| u->flags == 0 No flags for YMSG16 */ ) {
    1443                                 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->
    1444                                         client_id, u->name,
    1445                                         YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
     1524                            YAHOO_SERVICE_LOGOFF
     1525                            /*|| u->flags == 0 No flags for YMSG16 */) {
     1526                                YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->
     1527                                                                           client_id, u->name,
     1528                                                                           YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
    14461529                        } else {
    14471530                                /* Key 47 always seems to be 1 for YMSG16 */
    1448                                 if (!u->state)
     1531                                if (!u->state) {
    14491532                                        u->away = 0;
    1450                                 else
     1533                                } else {
    14511534                                        u->away = 1;
    1452 
    1453                                 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->
    1454                                         client_id, u->name, u->state, u->msg,
    1455                                         u->away, u->idle, u->mobile);
     1535                                }
     1536
     1537                                YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->
     1538                                                                           client_id, u->name, u->state, u->msg,
     1539                                                                           u->away, u->idle, u->mobile);
    14561540                        }
    14571541                }
     
    14641548
    14651549static void yahoo_process_buddy_list(struct yahoo_input_data *yid,
    1466         struct yahoo_packet *pkt)
     1550                                     struct yahoo_packet *pkt)
    14671551{
    14681552        struct yahoo_data *yd = yid->yd;
     
    14801564                case 301:
    14811565                case 302:
    1482                         break;  /* Separators. Our logic does not need them */
     1566                        break;  /* Separators. Our logic does not need them */
    14831567                case 303:
    1484                         if (318 == atoi(pair->value))
     1568                        if (318 == atoi(pair->value)) {
    14851569                                last_packet = 1;
     1570                        }
    14861571                        break;
    14871572                case 65:
     
    14911576                        newbud = y_new0(struct yahoo_buddy, 1);
    14921577                        newbud->id = strdup(pair->value);
    1493                         if (cur_group)
     1578                        if (cur_group) {
    14941579                                newbud->group = strdup(cur_group);
    1495                         else if (yd->buddies) {
     1580                        } else if (yd->buddies) {
    14961581                                struct yahoo_buddy *lastbud =
    1497                                         (struct yahoo_buddy *)y_list_nth(yd->
    1498                                         buddies,
    1499                                         y_list_length(yd->buddies) - 1)->data;
     1582                                        (struct yahoo_buddy *) y_list_nth(yd->
     1583                                                                          buddies,
     1584                                                                          y_list_length(yd->buddies) - 1)->data;
    15001585                                newbud->group = strdup(lastbud->group);
    1501                         } else
     1586                        } else {
    15021587                                newbud->group = strdup("Buddies");
     1588                        }
    15031589
    15041590                        yd->buddies = y_list_append(yd->buddies, newbud);
     
    15091595
    15101596        /* we could be getting multiple packets here */
    1511         if (pkt->hash && !last_packet)
    1512                 return;
    1513 
    1514         YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies);
     1597        if (pkt->hash && !last_packet) {
     1598                return;
     1599        }
     1600
     1601        YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, yd->buddies);
    15151602
    15161603        /* Logged in */
    15171604        if (!yd->logged_in) {
    15181605                yd->logged_in = 1;
    1519                 if (yd->current_status < 0)
     1606                if (yd->current_status < 0) {
    15201607                        yd->current_status = yd->initial_status;
    1521                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    1522                         YAHOO_LOGIN_OK, NULL);
     1608                }
     1609                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     1610                                                           YAHOO_LOGIN_OK, NULL);
    15231611
    15241612                /*
    15251613                yahoo_set_away(yd->client_id, yd->initial_status, NULL,
    1526                         (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1);
     1614                        (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1);
    15271615
    15281616                yahoo_get_yab(yd->client_id);
     
    15331621
    15341622static void yahoo_process_list(struct yahoo_input_data *yid,
    1535         struct yahoo_packet *pkt)
     1623                               struct yahoo_packet *pkt)
    15361624{
    15371625        struct yahoo_data *yd = yid->yd;
     
    15431631
    15441632                switch (pair->key) {
    1545                 case 89:        /* identities */
    1546                         {
    1547                                 char **identities =
    1548                                         y_strsplit(pair->value, ",", -1);
    1549                                 int i;
    1550                                 for (i = 0; identities[i]; i++)
    1551                                         yd->identities =
    1552                                                 y_list_append(yd->identities,
    1553                                                 strdup(identities[i]));
    1554                                 y_strfreev(identities);
     1633                case 89:        /* identities */
     1634                {
     1635                        char **identities =
     1636                                y_strsplit(pair->value, ",", -1);
     1637                        int i;
     1638                        for (i = 0; identities[i]; i++) {
     1639                                yd->identities =
     1640                                        y_list_append(yd->identities,
     1641                                                      strdup(identities[i]));
    15551642                        }
    1556                         YAHOO_CALLBACK(ext_yahoo_got_identities) (yd->client_id,
    1557                                 yd->identities);
    1558                         break;
    1559                 case 59:        /* cookies */
     1643                        y_strfreev(identities);
     1644                }
     1645                        YAHOO_CALLBACK (ext_yahoo_got_identities) (yd->client_id,
     1646                                                                   yd->identities);
     1647                        break;
     1648                case 59:        /* cookies */
    15601649                        if (pair->value[0] == 'Y') {
    15611650                                FREE(yd->cookie_y);
     
    15751664
    15761665                        break;
    1577                 case 3: /* my id */
    1578                 case 90:        /* 1 */
    1579                 case 100:       /* 0 */
    1580                 case 101:       /* NULL */
    1581                 case 102:       /* NULL */
    1582                 case 93:        /* 86400/1440 */
    1583                         break;
    1584                 }
    1585         }
    1586 
    1587         if (yd->cookie_y && yd->cookie_t)       /* We don't get cookie_c anymore */
    1588                 YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id);
     1666                case 3: /* my id */
     1667                case 90:        /* 1 */
     1668                case 100:       /* 0 */
     1669                case 101:       /* NULL */
     1670                case 102:       /* NULL */
     1671                case 93:        /* 86400/1440 */
     1672                        break;
     1673                }
     1674        }
     1675
     1676        if (yd->cookie_y && yd->cookie_t) {     /* We don't get cookie_c anymore */
     1677                YAHOO_CALLBACK (ext_yahoo_got_cookies) (yd->client_id);
     1678        }
    15891679}
    15901680
    15911681static void yahoo_process_verify(struct yahoo_input_data *yid,
    1592         struct yahoo_packet *pkt)
     1682                                 struct yahoo_packet *pkt)
    15931683{
    15941684        struct yahoo_data *yd = yid->yd;
     
    15961686        if (pkt->status != 0x01) {
    15971687                DEBUG_MSG(("expected status: 0x01, got: %d", pkt->status));
    1598                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    1599                         YAHOO_LOGIN_LOCK, "");
     1688                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     1689                                                           YAHOO_LOGIN_LOCK, "");
    16001690                return;
    16011691        }
    16021692
    16031693        pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT,
    1604                 yd->session_id);
     1694                               yd->session_id);
    16051695
    16061696        yahoo_packet_hash(pkt, 1, yd->user);
     
    16121702
    16131703static void yahoo_process_picture_checksum(struct yahoo_input_data *yid,
    1614         struct yahoo_packet *pkt)
     1704                                           struct yahoo_packet *pkt)
    16151705{
    16161706        struct yahoo_data *yd = yid->yd;
     
    16381728        }
    16391729
    1640         YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum) (yd->client_id, to,
    1641                 from, checksum);
     1730        YAHOO_CALLBACK (ext_yahoo_got_buddyicon_checksum) (yd->client_id, to,
     1731                                                           from, checksum);
    16421732}
    16431733
    16441734static void yahoo_process_picture(struct yahoo_input_data *yid,
    1645         struct yahoo_packet *pkt)
     1735                                  struct yahoo_packet *pkt)
    16461736{
    16471737        struct yahoo_data *yd = yid->yd;
     
    16581748                switch (pair->key) {
    16591749                case 1:
    1660                 case 4: /* sender */
     1750                case 4: /* sender */
    16611751                        from = pair->value;
    16621752                        break;
    1663                 case 5: /* we */
     1753                case 5: /* we */
    16641754                        to = pair->value;
    16651755                        break;
    1666                 case 13:        /* request / sending */
     1756                case 13:        /* request / sending */
    16671757                        status = atoi(pair->value);
    16681758                        break;
    1669                 case 20:        /* url */
     1759                case 20:        /* url */
    16701760                        url = pair->value;
    16711761                        break;
    1672                 case 192:       /*checksum */
     1762                case 192:       /*checksum */
    16731763                        checksum = atoi(pair->value);
    16741764                        break;
     
    16771767
    16781768        switch (status) {
    1679         case 1:         /* this is a request, ignore for now */
    1680                 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request) (yd->client_id,
    1681                         to, from);
     1769        case 1:         /* this is a request, ignore for now */
     1770                YAHOO_CALLBACK (ext_yahoo_got_buddyicon_request) (yd->client_id,
     1771                                                                  to, from);
    16821772                break;
    1683         case 2:         /* this is cool - we get a picture :) */
    1684                 YAHOO_CALLBACK(ext_yahoo_got_buddyicon) (yd->client_id, to,
    1685                         from, url, checksum);
     1773        case 2:         /* this is cool - we get a picture :) */
     1774                YAHOO_CALLBACK (ext_yahoo_got_buddyicon) (yd->client_id, to,
     1775                                                          from, url, checksum);
    16861776                break;
    16871777        }
     
    16891779
    16901780static void yahoo_process_picture_upload(struct yahoo_input_data *yid,
    1691         struct yahoo_packet *pkt)
     1781                                         struct yahoo_packet *pkt)
    16921782{
    16931783        struct yahoo_data *yd = yid->yd;
     
    16951785        char *url = NULL;
    16961786
    1697         if (pkt->status != 1)
    1698                 return;         /* something went wrong */
    1699 
     1787        if (pkt->status != 1) {
     1788                return;         /* something went wrong */
     1789
     1790        }
    17001791        for (l = pkt->hash; l; l = l->next) {
    17011792                struct yahoo_pair *pair = l->data;
    17021793
    17031794                switch (pair->key) {
    1704                 case 5: /* we */
    1705                         break;
    1706                 case 20:        /* url */
     1795                case 5: /* we */
     1796                        break;
     1797                case 20:        /* url */
    17071798                        url = pair->value;
    17081799                        break;
    1709                 case 27:        /* local filename */
    1710                         break;
    1711                 case 38:        /* time */
    1712                         break;
    1713                 }
    1714         }
    1715 
    1716         YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded) (yd->client_id, url);
     1800                case 27:        /* local filename */
     1801                        break;
     1802                case 38:        /* time */
     1803                        break;
     1804                }
     1805        }
     1806
     1807        YAHOO_CALLBACK (ext_yahoo_buddyicon_uploaded) (yd->client_id, url);
    17171808}
    17181809
     
    17271818
    17281819        struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
     1820
    17291821        yid->yd = yd;
    17301822        yid->type = YAHOO_CONNECTION_PAGER;
     
    17391831        host = yss->pager_host;
    17401832
    1741         if (!host)
     1833        if (!host) {
    17421834                host = yss->pager_host_list[0];
    1743 
    1744         tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id,
    1745                 host, yss->pager_port, yahoo_connected, ccd, 0);
     1835        }
     1836
     1837        tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->client_id,
     1838                                                        host, yss->pager_port, yahoo_connected, ccd, 0);
    17461839
    17471840        /*
     
    17491842         * so ccd will have been freed
    17501843         */
    1751         if (tag > 0)
     1844        if (tag > 0) {
    17521845                ccd->tag = tag;
    1753         else if (tag < 0)
    1754                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    1755                         YAHOO_LOGIN_SOCK, NULL);
    1756 }
    1757 
    1758 struct yahoo_https_auth_data
    1759 {
     1846        } else if (tag < 0) {
     1847                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     1848                                                           YAHOO_LOGIN_SOCK, NULL);
     1849        }
     1850}
     1851
     1852struct yahoo_https_auth_data {
    17601853        struct yahoo_input_data *yid;
    17611854        char *token;
     
    17741867        char *s, *end;
    17751868        int len = strlen(key);
    1776        
     1869
    17771870        s = response;
    17781871        do {
    17791872                if (strncmp(s, key, len) == 0 && s[len] == '=') {
    17801873                        s += len + 1;
    1781                         if ((end = strchr(s, '\r')))
     1874                        if ((end = strchr(s, '\r'))) {
    17821875                                return g_strndup(s, end - s);
    1783                         else
     1876                        } else {
    17841877                                return g_strdup(s);
    1785                 }
    1786                
    1787                 if ((s = strchr(s, '\n')))
    1788                         s ++;
     1878                        }
     1879                }
     1880
     1881                if ((s = strchr(s, '\n'))) {
     1882                        s++;
     1883                }
    17891884        } while (s && *s);
    1790        
     1885
    17911886        return NULL;
    17921887}
     
    17941889static enum yahoo_status yahoo_https_status_parse(int code)
    17951890{
    1796         switch (code)
    1797         {
    1798                 case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD;
    1799                 case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK;
    1800                 case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME;
    1801                 default: return (enum yahoo_status) code;
     1891        switch (code) {
     1892        case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD;
     1893        case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK;
     1894        case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME;
     1895        default: return (enum yahoo_status) code;
    18021896        }
    18031897}
     
    18061900{
    18071901        struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1);
    1808        
     1902
    18091903        had->yid = yid;
    18101904        had->chal = g_strdup(seed);
    1811        
     1905
    18121906        yahoo_https_auth_token_init(had);
    18131907}
     
    18191913        char *login, *passwd, *chal;
    18201914        char *url;
    1821        
     1915
    18221916        login = g_strndup(yd->user, 3 * strlen(yd->user));
    18231917        http_encode(login);
     
    18261920        chal = g_strndup(had->chal, 3 * strlen(had->chal));
    18271921        http_encode(chal);
    1828        
     1922
    18291923        url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=%d&login=%s&passwd=%s&chal=%s",
    1830                                (int) time(NULL), login, passwd, chal);
    1831        
     1924                              (int) time(NULL), login, passwd, chal);
     1925
    18321926        http_dorequest_url(url, yahoo_https_auth_token_finish, had);
    1833        
     1927
    18341928        g_free(url);
    18351929        g_free(chal);
     
    18441938        struct yahoo_data *yd;
    18451939        int st;
    1846        
    1847         if (y_list_find(inputs, had->yid) == NULL)
    1848                 return;
    1849        
     1940
     1941        if (y_list_find(inputs, had->yid) == NULL) {
     1942                return;
     1943        }
     1944
    18501945        yid = had->yid;
    18511946        yd = yid->yd;
    1852        
     1947
    18531948        if (req->status_code != 200) {
    1854                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
     1949                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
    18551950                goto fail;
    18561951        }
    1857        
     1952
    18581953        if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) {
    1859                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
     1954                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
    18601955                goto fail;
    18611956        }
    1862        
     1957
    18631958        if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) {
    1864                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3001, NULL);
     1959                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3001, NULL);
    18651960                goto fail;
    18661961        }
    1867        
     1962
    18681963        yahoo_https_auth_init(had);
    18691964        return;
    1870        
     1965
    18711966fail:
    18721967        g_free(had->token);
     
    18781973{
    18791974        char *url;
    1880        
     1975
    18811976        url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=%d&token=%s",
    18821977                              (int) time(NULL), had->token);
    1883        
     1978
    18841979        http_dorequest_url(url, yahoo_https_auth_finish, had);
    1885        
     1980
    18861981        g_free(url);
    18871982}
     
    18951990        char *crumb = NULL;
    18961991        int st;
    1897        
    1898         if (y_list_find(inputs, had->yid) == NULL)
    1899                 return;
    1900        
     1992
     1993        if (y_list_find(inputs, had->yid) == NULL) {
     1994                return;
     1995        }
     1996
    19011997        yid = had->yid;
    19021998        yd = yid->yd;
    1903        
     1999
    19042000        md5_byte_t result[16];
    19052001        md5_state_t ctx;
    1906        
     2002
    19072003        unsigned char yhash[32];
    19082004
    19092005        if (req->status_code != 200) {
    1910                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
     2006                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);
    19112007                goto fail;
    19122008        }
    1913        
     2009
    19142010        if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) {
    1915                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
     2011                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);
    19162012                goto fail;
    19172013        }
    1918        
     2014
    19192015        if ((yd->cookie_y = yahoo_ha_find_key(req->reply_body, "Y")) == NULL ||
    19202016            (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL ||
    19212017            (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) {
    1922                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 3002, NULL);
     2018                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3002, NULL);
    19232019                goto fail;
    19242020        }
    1925        
    1926         md5_init(&ctx); 
    1927         md5_append(&ctx, (unsigned char*) crumb, 11);
    1928         md5_append(&ctx, (unsigned char*) had->chal, strlen(had->chal));
     2021
     2022        md5_init(&ctx);
     2023        md5_append(&ctx, (unsigned char *) crumb, 11);
     2024        md5_append(&ctx, (unsigned char *) had->chal, strlen(had->chal));
    19292025        md5_finish(&ctx, result);
    19302026        to_y64(yhash, result, 16);
     
    19352031        yahoo_packet_hash(pack, 277, yd->cookie_y);
    19362032        yahoo_packet_hash(pack, 278, yd->cookie_t);
    1937         yahoo_packet_hash(pack, 307, (char*) yhash);
     2033        yahoo_packet_hash(pack, 307, (char *) yhash);
    19382034        yahoo_packet_hash(pack, 244, "524223");
    19392035        yahoo_packet_hash(pack, 2, yd->user);
     
    19412037        yahoo_packet_hash(pack, 98, "us");
    19422038        yahoo_packet_hash(pack, 135, "7.5.0.647");
    1943        
     2039
    19442040        yahoo_send_packet(yid, pack, 0);
    1945                
     2041
    19462042        yahoo_packet_free(pack);
    1947        
     2043
    19482044fail:
    19492045        g_free(crumb);
     
    19542050
    19552051static void yahoo_process_auth(struct yahoo_input_data *yid,
    1956         struct yahoo_packet *pkt)
     2052                               struct yahoo_packet *pkt)
    19572053{
    19582054        char *seed = NULL;
     
    19792075        }
    19802076
    1981         if (!seed)
    1982                 return;
    1983 
    1984         if (m==2)
     2077        if (!seed) {
     2078                return;
     2079        }
     2080
     2081        if (m == 2) {
    19852082                yahoo_https_auth(yid, seed, sn);
    1986         else {
     2083        } else {
    19872084                /* call error */
    19882085                WARNING(("unknown auth type %d", m));
    1989                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    1990                         YAHOO_LOGIN_UNKNOWN, NULL);
     2086                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     2087                                                           YAHOO_LOGIN_UNKNOWN, NULL);
    19912088        }
    19922089}
    19932090
    19942091static void yahoo_process_auth_resp(struct yahoo_input_data *yid,
    1995         struct yahoo_packet *pkt)
     2092                                    struct yahoo_packet *pkt)
    19962093{
    19972094        struct yahoo_data *yd = yid->yd;
     
    20032100        for (l = pkt->hash; l; l = l->next) {
    20042101                struct yahoo_pair *pair = l->data;
    2005                 if (pair->key == 0)
     2102                if (pair->key == 0) {
    20062103                        ; /* login_id */
    2007                 else if (pair->key == 1)
     2104                } else if (pair->key == 1) {
    20082105                        ; /* handle */
    2009                 else if (pair->key == 20)
     2106                } else if (pair->key == 20) {
    20102107                        url = pair->value;
    2011                 else if (pair->key == 66)
     2108                } else if (pair->key == 66) {
    20122109                        login_status = atoi(pair->value);
     2110                }
    20132111        }
    20142112
    20152113        if (pkt->status == YPACKET_STATUS_DISCONNECTED) {
    2016                 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    2017                         login_status, url);
     2114                YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     2115                                                           login_status, url);
    20182116                /*      yahoo_logoff(yd->client_id); */
    20192117        }
     
    20212119
    20222120static void yahoo_process_mail(struct yahoo_input_data *yid,
    2023         struct yahoo_packet *pkt)
     2121                               struct yahoo_packet *pkt)
    20242122{
    20252123        struct yahoo_data *yd = yid->yd;
     
    20322130        for (l = pkt->hash; l; l = l->next) {
    20332131                struct yahoo_pair *pair = l->data;
    2034                 if (pair->key == 9)
     2132                if (pair->key == 9) {
    20352133                        count = strtol(pair->value, NULL, 10);
    2036                 else if (pair->key == 43)
     2134                } else if (pair->key == 43) {
    20372135                        who = pair->value;
    2038                 else if (pair->key == 42)
     2136                } else if (pair->key == 42) {
    20392137                        email = pair->value;
    2040                 else if (pair->key == 18)
     2138                } else if (pair->key == 18) {
    20412139                        subj = pair->value;
    2042                 else
     2140                } else {
    20432141                        LOG(("key: %d => value: %s", pair->key, pair->value));
     2142                }
    20442143        }
    20452144
     
    20472146                char from[1024];
    20482147                snprintf(from, sizeof(from), "%s (%s)", who, email);
    2049                 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, from,
    2050                         subj, count);
    2051         } else if (count > 0)
    2052                 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, NULL,
    2053                         NULL, count);
     2148                YAHOO_CALLBACK (ext_yahoo_mail_notify) (yd->client_id, from,
     2149                                                        subj, count);
     2150        } else if (count > 0) {
     2151                YAHOO_CALLBACK (ext_yahoo_mail_notify) (yd->client_id, NULL,
     2152                                                        NULL, count);
     2153        }
    20542154}
    20552155
    20562156static void yahoo_process_new_contact(struct yahoo_input_data *yid,
    2057         struct yahoo_packet *pkt)
     2157                                      struct yahoo_packet *pkt)
    20582158{
    20592159        struct yahoo_data *yd = yid->yd;
     
    20672167        for (l = pkt->hash; l; l = l->next) {
    20682168                struct yahoo_pair *pair = l->data;
    2069                 if (pair->key == 4)
     2169                if (pair->key == 4) {
    20702170                        who = pair->value;
    2071                 else if (pair->key == 5)
     2171                } else if (pair->key == 5) {
    20722172                        me = pair->value;
    2073                 else if (pair->key == 14)
     2173                } else if (pair->key == 14) {
    20742174                        msg = pair->value;
    2075                 else if (pair->key == 13)
     2175                } else if (pair->key == 13) {
    20762176                        online = strtol(pair->value, NULL, 10);
    2077         }
    2078 
    2079         if (who && online < 0)
    2080                 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who,
    2081                         msg);
    2082         else if (online == 2)
    2083                 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg);
     2177                }
     2178        }
     2179
     2180        if (who && online < 0) {
     2181                YAHOO_CALLBACK (ext_yahoo_contact_added) (yd->client_id, me, who,
     2182                                                          msg);
     2183        } else if (online == 2) {
     2184                YAHOO_CALLBACK (ext_yahoo_rejected) (yd->client_id, who, msg);
     2185        }
    20842186}
    20852187
    20862188/* UNUSED? */
    20872189static void yahoo_process_contact(struct yahoo_input_data *yid,
    2088         struct yahoo_packet *pkt)
     2190                                  struct yahoo_packet *pkt)
    20892191{
    20902192        struct yahoo_data *yd = yid->yd;
     
    21022204        for (l = pkt->hash; l; l = l->next) {
    21032205                struct yahoo_pair *pair = l->data;
    2104                 if (pair->key == 1)
     2206                if (pair->key == 1) {
    21052207                        id = pair->value;
    2106                 else if (pair->key == 3)
     2208                } else if (pair->key == 3) {
    21072209                        who = pair->value;
    2108                 else if (pair->key == 14)
     2210                } else if (pair->key == 14) {
    21092211                        msg = pair->value;
    2110                 else if (pair->key == 7)
     2212                } else if (pair->key == 7) {
    21112213                        name = pair->value;
    2112                 else if (pair->key == 10)
     2214                } else if (pair->key == 10) {
    21132215                        state = strtol(pair->value, NULL, 10);
    2114                 else if (pair->key == 15)
     2216                } else if (pair->key == 15) {
    21152217                        ; /* tm */
    2116                 else if (pair->key == 13)
     2218                } else if (pair->key == 13) {
    21172219                        ; /* online */
    2118                 else if (pair->key == 47)
     2220                } else if (pair->key == 47) {
    21192221                        away = strtol(pair->value, NULL, 10);
    2120                 else if (pair->key == 137)
     2222                } else if (pair->key == 137) {
    21212223                        idle = strtol(pair->value, NULL, 10);
    2122                 else if (pair->key == 60)
     2224                } else if (pair->key == 60) {
    21232225                        mobile = strtol(pair->value, NULL, 10);
    2124 
    2125         }
    2126 
    2127         if (id)
    2128                 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, id, who,
    2129                         msg);
    2130         else if (name)
    2131                 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, name,
    2132                         state, msg, away, idle, mobile);
    2133         else if (pkt->status == 0x07)
    2134                 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg);
     2226                }
     2227
     2228        }
     2229
     2230        if (id) {
     2231                YAHOO_CALLBACK (ext_yahoo_contact_added) (yd->client_id, id, who,
     2232                                                          msg);
     2233        } else if (name) {
     2234                YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->client_id, name,
     2235                                                           state, msg, away, idle, mobile);
     2236        } else if (pkt->status == 0x07) {
     2237                YAHOO_CALLBACK (ext_yahoo_rejected) (yd->client_id, who, msg);
     2238        }
    21352239}
    21362240
    21372241static void yahoo_process_buddyadd(struct yahoo_input_data *yid,
    2138         struct yahoo_packet *pkt)
     2242                                   struct yahoo_packet *pkt)
    21392243{
    21402244        struct yahoo_data *yd = yid->yd;
     
    21462250
    21472251        YList *l;
     2252
    21482253        for (l = pkt->hash; l; l = l->next) {
    21492254                struct yahoo_pair *pair = l->data;
    2150                 if (pair->key == 1)
     2255                if (pair->key == 1) {
    21512256                        ; /* Me... don't care */
    2152                 if (pair->key == 7)
     2257                }
     2258                if (pair->key == 7) {
    21532259                        who = pair->value;
    2154                 if (pair->key == 65)
     2260                }
     2261                if (pair->key == 65) {
    21552262                        where = pair->value;
    2156                 if (pair->key == 66)
     2263                }
     2264                if (pair->key == 66) {
    21572265                        status = strtol(pair->value, NULL, 10);
    2158         }
    2159 
    2160         if (!who)
    2161                 return;
    2162         if (!where)
     2266                }
     2267        }
     2268
     2269        if (!who) {
     2270                return;
     2271        }
     2272        if (!where) {
    21632273                where = "Unknown";
     2274        }
    21642275
    21652276        bud = y_new0(struct yahoo_buddy, 1);
     
    21812292           accepted. Couldn't find any test account that doesn't require auth.
    21822293           unfortunately (if there is even such a thing?) */
    2183            
    2184         /* A non-zero status (i've seen 2) seems to mean the buddy is already 
     2294
     2295        /* A non-zero status (i've seen 2) seems to mean the buddy is already
    21852296         * added and is online */
    21862297        if (status) {
    21872298                LOG(("Setting online see packet for info"));
    21882299                yahoo_dump_unhandled(pkt);
    2189                 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who,
    2190                         YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0);
     2300                YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->client_id, who,
     2301                                                           YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0);
    21912302        }
    21922303#endif
     
    21942305        if (status == 0) {
    21952306                YList *tmp = y_list_append(NULL, bud);
    2196                 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, tmp);
     2307                YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, tmp);
    21972308                y_list_free(tmp);
    21982309        }
     
    22002311
    22012312static void yahoo_process_buddydel(struct yahoo_input_data *yid,
    2202         struct yahoo_packet *pkt)
     2313                                   struct yahoo_packet *pkt)
    22032314{
    22042315        struct yahoo_data *yd = yid->yd;
     
    22102321
    22112322        YList *l;
     2323
    22122324        for (l = pkt->hash; l; l = l->next) {
    22132325                struct yahoo_pair *pair = l->data;
    2214                 if (pair->key == 1)
     2326                if (pair->key == 1) {
    22152327                        ; /* Me... don't care */
    2216                 else if (pair->key == 7)
     2328                } else if (pair->key == 7) {
    22172329                        who = pair->value;
    2218                 else if (pair->key == 65)
     2330                } else if (pair->key == 65) {
    22192331                        where = pair->value;
    2220                 else if (pair->key == 66)
     2332                } else if (pair->key == 66) {
    22212333                        ; /* unk_66 */
    2222                 else
     2334                } else {
    22232335                        DEBUG_MSG(("unknown key: %d = %s", pair->key,
    2224                                         pair->value));
    2225         }
    2226 
    2227         if (!who || !where)
    2228                 return;
     2336                                   pair->value));
     2337                }
     2338        }
     2339
     2340        if (!who || !where) {
     2341                return;
     2342        }
    22292343
    22302344        bud = y_new0(struct yahoo_buddy, 1);
     
    22532367
    22542368static void yahoo_process_ignore(struct yahoo_input_data *yid,
    2255         struct yahoo_packet *pkt)
     2369                                 struct yahoo_packet *pkt)
    22562370{
    22572371        YList *l;
     2372
    22582373        for (l = pkt->hash; l; l = l->next) {
    22592374                struct yahoo_pair *pair = l->data;
    2260                 if (pair->key == 0)
     2375                if (pair->key == 0) {
    22612376                        ; /* who */
    2262                 if (pair->key == 1)
     2377                }
     2378                if (pair->key == 1) {
    22632379                        ; /* Me... don't care */
    2264                 if (pair->key == 13)    /* 1 == ignore, 2 == unignore */
     2380                }
     2381                if (pair->key == 13) {  /* 1 == ignore, 2 == unignore */
    22652382                        ;
    2266                 if (pair->key == 66)
     2383                }
     2384                if (pair->key == 66) {
    22672385                        ; /* status */
     2386                }
    22682387        }
    22692388
     
    22772396
    22782397/*      if(status)
    2279                 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status);
     2398                YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status);
    22802399*/
    22812400}
    22822401
    22832402static void yahoo_process_voicechat(struct yahoo_input_data *yid,
    2284         struct yahoo_packet *pkt)
     2403                                    struct yahoo_packet *pkt)
    22852404{
    22862405        char *who = NULL;
     
    22892408
    22902409        YList *l;
     2410
    22912411        for (l = pkt->hash; l; l = l->next) {
    22922412                struct yahoo_pair *pair = l->data;
    2293                 if (pair->key == 4)
     2413                if (pair->key == 4) {
    22942414                        who = pair->value;
    2295                 if (pair->key == 5)
     2415                }
     2416                if (pair->key == 5) {
    22962417                        me = pair->value;
    2297                 if (pair->key == 13)
     2418                }
     2419                if (pair->key == 13) {
    22982420                        ; /* voice room */
    2299                 if (pair->key == 57)
     2421                }
     2422                if (pair->key == 57) {
    23002423                        room = pair->value;
     2424                }
    23012425        }
    23022426
    23032427        NOTICE(("got voice chat invite from %s in %s to identity %s", who, room,
    2304                         me));
    2305         /* 
     2428                me));
     2429        /*
    23062430         * send: s:0 1:me 5:who 57:room 13:1
    23072431         * ????  s:4 5:who 10:99 19:-1615114531
     
    23152439
    23162440static void yahoo_process_ping(struct yahoo_input_data *yid,
    2317         struct yahoo_packet *pkt)
     2441                               struct yahoo_packet *pkt)
    23182442{
    23192443        char *errormsg = NULL;
    23202444
    23212445        YList *l;
     2446
    23222447        for (l = pkt->hash; l; l = l->next) {
    23232448                struct yahoo_pair *pair = l->data;
    2324                 if (pair->key == 16)
     2449                if (pair->key == 16) {
    23252450                        errormsg = pair->value;
     2451                }
    23262452        }
    23272453
    23282454        NOTICE(("got ping packet"));
    2329         YAHOO_CALLBACK(ext_yahoo_got_ping) (yid->yd->client_id, errormsg);
     2455        YAHOO_CALLBACK (ext_yahoo_got_ping) (yid->yd->client_id, errormsg);
    23302456}
    23312457
    23322458static void yahoo_process_buddy_change_group(struct yahoo_input_data *yid,
    2333         struct yahoo_packet *pkt)
     2459                                             struct yahoo_packet *pkt)
    23342460{
    23352461        YList *l;
     
    23412467        for (l = pkt->hash; l; l = l->next) {
    23422468                struct yahoo_pair *pair = l->data;
    2343                 if (pair->key == 1)
     2469                if (pair->key == 1) {
    23442470                        me = pair->value;
    2345                 if (pair->key == 7)
     2471                }
     2472                if (pair->key == 7) {
    23462473                        who = pair->value;
    2347                 if (pair->key == 224)
     2474                }
     2475                if (pair->key == 224) {
    23482476                        old_group = pair->value;
    2349                 if (pair->key == 264)
     2477                }
     2478                if (pair->key == 264) {
    23502479                        new_group = pair->value;
    2351         }
    2352 
    2353         YAHOO_CALLBACK(ext_yahoo_got_buddy_change_group) (yid->yd->client_id,
    2354                 me, who, old_group, new_group);
     2480                }
     2481        }
     2482
     2483        YAHOO_CALLBACK (ext_yahoo_got_buddy_change_group) (yid->yd->client_id,
     2484                                                           me, who, old_group, new_group);
    23552485}
    23562486
     
    23762506
    23772507        /* send initial packet */
    2378         if (who)
     2508        if (who) {
    23792509                data = strdup("<RVWCFG>");
    2380         else
     2510        } else {
    23812511                data = strdup("<RUPCFG>");
     2512        }
    23822513        yahoo_add_to_send_queue(yid, data, strlen(data));
    23832514        FREE(data);
     
    24042535
    24052536        yid->read_tag =
    2406                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
    2407                 YAHOO_INPUT_READ, yid);
     2537                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd,
     2538                                                        YAHOO_INPUT_READ, yid);
    24082539}
    24092540
    24102541static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who,
    2411         char *key)
     2542                                    char *key)
    24122543{
    24132544        struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1);
     
    24212552        yid->wcm->key = strdup(key);
    24222553
    2423         YAHOO_CALLBACK(ext_yahoo_connect_async) (yid->yd->client_id,
    2424                 yss->webcam_host, yss->webcam_port,
    2425                 _yahoo_webcam_get_server_connected, yid, 0);
     2554        YAHOO_CALLBACK (ext_yahoo_connect_async) (yid->yd->client_id,
     2555                                                  yss->webcam_host, yss->webcam_port,
     2556                                                  _yahoo_webcam_get_server_connected, yid, 0);
    24262557
    24272558}
     
    24292560static YList *webcam_queue = NULL;
    24302561static void yahoo_process_webcam_key(struct yahoo_input_data *yid,
    2431         struct yahoo_packet *pkt)
     2562                                     struct yahoo_packet *pkt)
    24322563{
    24332564        char *key = NULL;
     
    24352566
    24362567        YList *l;
     2568
    24372569        yahoo_dump_unhandled(pkt);
    24382570        for (l = pkt->hash; l; l = l->next) {
    24392571                struct yahoo_pair *pair = l->data;
    2440                 if (pair->key == 5)
     2572                if (pair->key == 5) {
    24412573                        ; /* me */
    2442                 if (pair->key == 61)
     2574                }
     2575                if (pair->key == 61) {
    24432576                        key = pair->value;
     2577                }
    24442578        }
    24452579
    24462580        l = webcam_queue;
    2447         if (!l)
    2448                 return;
     2581        if (!l) {
     2582                return;
     2583        }
    24492584        who = l->data;
    24502585        webcam_queue = y_list_remove_link(webcam_queue, webcam_queue);
     
    24552590
    24562591static void yahoo_packet_process(struct yahoo_input_data *yid,
    2457         struct yahoo_packet *pkt)
     2592                                 struct yahoo_packet *pkt)
    24582593{
    24592594        DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service));
     
    25772712                yahoo_process_picture_upload(yid, pkt);
    25782713                break;
    2579         case YAHOO_SERVICE_Y8_LIST:     /* Buddy List */
     2714        case YAHOO_SERVICE_Y8_LIST:     /* Buddy List */
    25802715                yahoo_process_buddy_list(yid, pkt);
    25812716                break;
     
    25942729        int pktlen;
    25952730
    2596         if (!yd)
     2731        if (!yd) {
    25972732                return NULL;
     2733        }
    25982734
    25992735        DEBUG_MSG(("rxlen is %d", yid->rxlen));
     
    26032739        }
    26042740
    2605         pos += 4;               /* YMSG */
     2741        pos += 4;               /* YMSG */
    26062742        pos += 2;
    26072743        pos += 2;
     
    26262762        pos += 4;
    26272763        DEBUG_MSG(("Yahoo Service: 0x%02x Status: %d", pkt->service,
    2628                         pkt->status));
     2764                   pkt->status));
    26292765        pkt->id = yahoo_get32(yid->rxqueue + pos);
    26302766        pos += 4;
     
    26382774        if (yid->rxlen > 0) {
    26392775                unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN
    2640                         + pktlen, yid->rxlen);
     2776                                              + pktlen, yid->rxlen);
    26412777                FREE(yid->rxqueue);
    26422778                yid->rxqueue = tmp;
    26432779                DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
    2644                                 yid->rxqueue));
     2780                           yid->rxqueue));
    26452781        } else {
    26462782                DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
     
    26552791{
    26562792        char *st, *en;
    2657         char *data = (char *)d;
     2793        char *data = (char *) d;
    26582794        struct yab *yab = NULL;
    26592795
     
    26712807        }
    26722808
    2673         if (!en)
     2809        if (!en) {
    26742810                return NULL;
     2811        }
    26752812
    26762813        st = strstr(en, "id=\"");
     
    27552892        struct yahoo_data *yd = yid->yd;
    27562893
    2757         if (!yd)
     2894        if (!yd) {
    27582895                return NULL;
     2896        }
    27592897
    27602898        do {
    27612899                DEBUG_MSG(("rxlen is %d", yid->rxlen));
    27622900
    2763                 if (yid->rxlen <= strlen("<ct"))
     2901                if (yid->rxlen <= strlen("<ct")) {
    27642902                        return NULL;
     2903                }
    27652904
    27662905                /* start with <ct */
    27672906                while (pos < yid->rxlen - strlen("<ct") + 1
    2768                         && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct")))
     2907                       && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct"))) {
    27692908                        pos++;
    2770 
    2771                 if (pos >= yid->rxlen - 1)
     2909                }
     2910
     2911                if (pos >= yid->rxlen - 1) {
    27722912                        return NULL;
     2913                }
    27732914
    27742915                end = pos + 2;
    27752916                /* end with > */
    27762917                while (end < yid->rxlen - strlen(">")
    2777                         && memcmp(yid->rxqueue + end, ">", strlen(">")))
     2918                       && memcmp(yid->rxqueue + end, ">", strlen(">"))) {
    27782919                        end++;
    2779 
    2780                 if (end >= yid->rxlen - 1)
     2920                }
     2921
     2922                if (end >= yid->rxlen - 1) {
    27812923                        return NULL;
     2924                }
    27822925
    27832926                yab = yahoo_yab_read(yid->rxqueue + pos, end + 2 - pos);
     
    27852928                yid->rxlen -= end + 1;
    27862929                DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen,
    2787                                 yid->rxqueue));
     2930                           yid->rxqueue));
    27882931                if (yid->rxlen > 0) {
    27892932                        unsigned char *tmp =
    2790                                 y_memdup(yid->rxqueue + end + 1, yid->rxlen);
     2933                                y_memdup(yid->rxqueue + end + 1, yid->rxlen);
    27912934                        FREE(yid->rxqueue);
    27922935                        yid->rxqueue = tmp;
    27932936                        DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
    2794                                         yid->rxqueue));
     2937                                   yid->rxqueue));
    27952938                } else {
    27962939                        DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
     
    28122955        struct yahoo_data *yd = yid->yd;
    28132956
    2814         if (!yid || !yd)
     2957        if (!yid || !yd) {
    28152958                return NULL;
     2959        }
    28162960
    28172961        DEBUG_MSG(("rxlen is %d", yid->rxlen));
    28182962
    28192963        len = yid->rxqueue[pos++];
    2820         if (yid->rxlen < len)
     2964        if (yid->rxlen < len) {
    28212965                return NULL;
     2966        }
    28222967
    28232968        /* extract status (0 = ok, 6 = webcam not online) */
     
    28252970
    28262971        if (status == 0) {
    2827                 pos += 2;       /* skip next 2 bytes */
     2972                pos += 2;       /* skip next 2 bytes */
    28282973                server = y_memdup(yid->rxqueue + pos, 16);
    28292974                pos += 16;
    28302975        } else if (status == 6) {
    2831                 YAHOO_CALLBACK(ext_yahoo_webcam_closed)
    2832                         (yd->client_id, yid->wcm->user, 4);
     2976                YAHOO_CALLBACK (ext_yahoo_webcam_closed)
     2977                        (yd->client_id, yid->wcm->user, 4);
    28332978        }
    28342979
     
    28422987                yid->rxqueue = tmp;
    28432988                DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
    2844                                 yid->rxqueue));
     2989                           yid->rxqueue));
    28452990        } else {
    28462991                DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
     
    28633008        struct yahoo_data *yd = yid->yd;
    28643009
    2865         if (!yd)
     3010        if (!yd) {
    28663011                return -1;
    2867 
    2868         if (!yid->wcm || !yid->wcd || !yid->rxlen)
     3012        }
     3013
     3014        if (!yid->wcm || !yid->wcd || !yid->rxlen) {
    28693015                return -1;
     3016        }
    28703017
    28713018        DEBUG_MSG(("rxlen is %d", yid->rxlen));
     
    28763023                yid->wcd->packet_type = 0;
    28773024
    2878                 if (yid->rxlen < header_len)
     3025                if (yid->rxlen < header_len) {
    28793026                        return 0;
     3027                }
    28803028
    28813029                if (header_len >= 8) {
     
    28993047        begin = pos;
    29003048        pos += yid->wcd->to_read;
    2901         if (pos > yid->rxlen)
     3049        if (pos > yid->rxlen) {
    29023050                pos = yid->rxlen;
     3051        }
    29033052
    29043053        /* if it is not an image then make sure we have the whole packet */
     
    29133062
    29143063        DEBUG_MSG(("packet type %.2X, data length %d", yid->wcd->packet_type,
    2915                         yid->wcd->data_size));
     3064                   yid->wcd->data_size));
    29163065
    29173066        /* find out what kind of packet we got */
     
    29203069                /* user requests to view webcam (uploading) */
    29213070                if (yid->wcd->data_size &&
    2922                         yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) {
     3071                    yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) {
    29233072                        end = begin;
    2924                         while (end <= yid->rxlen && yid->rxqueue[end++] != 13) ;
     3073                        while (end <= yid->rxlen && yid->rxqueue[end++] != 13) {
     3074                                ;
     3075                        }
    29253076                        if (end > begin) {
    29263077                                who = y_memdup(yid->rxqueue + begin,
    2927                                         end - begin);
     3078                                               end - begin);
    29283079                                who[end - begin - 1] = 0;
    2929                                 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->
    2930                                         client_id, who + 2, 2);
     3080                                YAHOO_CALLBACK (ext_yahoo_webcam_viewer) (yd->
     3081                                                                          client_id, who + 2, 2);
    29313082                                FREE(who);
    29323083                        }
     
    29383089                        /* 1 = accepted viewing permission */
    29393090                        if (yid->wcd->timestamp == 0) {
    2940                                 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->
    2941                                         client_id, yid->wcm->user, 3);
     3091                                YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd->
     3092                                                                          client_id, yid->wcm->user, 3);
    29423093                        }
    29433094                }
    29443095                break;
    2945         case 0x01:              /* status packets?? */
     3096        case 0x01:              /* status packets?? */
    29463097                /* timestamp contains status info */
    29473098                /* 00 00 00 01 = we have data?? */
    29483099                break;
    2949         case 0x02:              /* image data */
    2950                 YAHOO_CALLBACK(ext_yahoo_got_webcam_image) (yd->client_id,
    2951                         yid->wcm->user, yid->rxqueue + begin,
    2952                         yid->wcd->data_size, pos - begin, yid->wcd->timestamp);
     3100        case 0x02:              /* image data */
     3101                YAHOO_CALLBACK (ext_yahoo_got_webcam_image) (yd->client_id,
     3102                                                             yid->wcm->user, yid->rxqueue + begin,
     3103                                                             yid->wcd->data_size, pos - begin, yid->wcd->timestamp);
    29533104                break;
    2954         case 0x05:              /* response packets when uploading */
     3105        case 0x05:              /* response packets when uploading */
    29553106                if (!yid->wcd->data_size) {
    2956                         YAHOO_CALLBACK(ext_yahoo_webcam_data_request) (yd->
    2957                                 client_id, yid->wcd->timestamp);
     3107                        YAHOO_CALLBACK (ext_yahoo_webcam_data_request) (yd->
     3108                                                                        client_id, yid->wcd->timestamp);
    29583109                }
    29593110                break;
    2960         case 0x07:              /* connection is closing */
     3111        case 0x07:              /* connection is closing */
    29613112                switch (reason) {
    2962                 case 0x01:      /* user closed connection */
     3113                case 0x01:      /* user closed connection */
    29633114                        closed = 1;
    29643115                        break;
    2965                 case 0x0F:      /* user cancelled permission */
     3116                case 0x0F:      /* user cancelled permission */
    29663117                        closed = 2;
    29673118                        break;
    29683119                }
    2969                 YAHOO_CALLBACK(ext_yahoo_webcam_closed) (yd->client_id,
    2970                         yid->wcm->user, closed);
     3120                YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd->client_id,
     3121                                                          yid->wcm->user, closed);
    29713122                break;
    2972         case 0x0C:              /* user connected */
    2973         case 0x0D:              /* user disconnected */
     3123        case 0x0C:              /* user connected */
     3124        case 0x0D:              /* user disconnected */
    29743125                if (yid->wcd->data_size) {
    29753126                        who = y_memdup(yid->rxqueue + begin, pos - begin + 1);
    29763127                        who[pos - begin] = 0;
    2977                         if (yid->wcd->packet_type == 0x0C)
     3128                        if (yid->wcd->packet_type == 0x0C) {
    29783129                                connect = 1;
    2979                         else
     3130                        } else {
    29803131                                connect = 0;
    2981                         YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id,
    2982                                 who, connect);
     3132                        }
     3133                        YAHOO_CALLBACK (ext_yahoo_webcam_viewer) (yd->client_id,
     3134                                                                  who, connect);
    29833135                        FREE(who);
    29843136                }
    29853137                break;
    2986         case 0x13:              /* user data */
     3138        case 0x13:              /* user data */
    29873139                /* i=user_ip (ip of the user we are viewing) */
    29883140                /* j=user_ext_ip (external ip of the user we */
    29893141                /*                are viewing) */
    29903142                break;
    2991         case 0x17:              /* ?? */
     3143        case 0x17:              /* ?? */
    29923144                break;
    29933145        }
     
    30013153                yid->rxqueue = tmp;
    30023154                DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen,
    3003                                 yid->rxqueue));
     3155                           yid->rxqueue));
    30043156        } else {
    30053157                DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue));
     
    30083160
    30093161        /* If we read a complete packet return success */
    3010         if (!yid->wcd->to_read)
     3162        if (!yid->wcd->to_read) {
    30113163                return 1;
     3164        }
    30123165
    30133166        return 0;
     
    30213174
    30223175        LOG(("write callback: id=%d fd=%p data=%p", id, fd, data));
    3023         if (!yid || !yid->txqueues)
     3176        if (!yid || !yid->txqueues) {
    30243177                return -2;
     3178        }
    30253179
    30263180        tx = yid->txqueues->data;
     
    30283182        len = yahoo_send_data(fd, tx->queue, MIN(1024, tx->len));
    30293183
    3030         if (len == -1 && errno == EAGAIN)
     3184        if (len == -1 && errno == EAGAIN) {
    30313185                return 1;
     3186        }
    30323187
    30333188        if (len <= 0) {
     
    30403195                        free(tx);
    30413196                        yid->txqueues =
    3042                                 y_list_remove_link(yid->txqueues,
    3043                                 yid->txqueues);
     3197                                y_list_remove_link(yid->txqueues,
     3198                                                   yid->txqueues);
    30443199                        y_list_free_1(l);
    30453200                }
    30463201                LOG(("yahoo_write_ready(%d, %p) len < 0", id, fd));
    3047                 YAHOO_CALLBACK(ext_yahoo_remove_handler) (id, yid->write_tag);
     3202                YAHOO_CALLBACK (ext_yahoo_remove_handler) (id, yid->write_tag);
    30483203                yid->write_tag = 0;
    30493204                errno = e;
     
    30623217                free(tx);
    30633218                yid->txqueues =
    3064                         y_list_remove_link(yid->txqueues, yid->txqueues);
     3219                        y_list_remove_link(yid->txqueues, yid->txqueues);
    30653220                y_list_free_1(l);
    30663221                /*
    3067                    if(!yid->txqueues) 
     3222                   if(!yid->txqueues)
    30683223                   LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd));
    30693224                 */
    30703225                if (!yid->txqueues) {
    30713226                        LOG(("yahoo_write_ready(%d, %p) !txqueues", id, fd));
    3072                         YAHOO_CALLBACK(ext_yahoo_remove_handler) (id,
    3073                                 yid->write_tag);
     3227                        YAHOO_CALLBACK (ext_yahoo_remove_handler) (id,
     3228                                                                   yid->write_tag);
    30743229                        yid->write_tag = 0;
    30753230                }
     
    30803235
    30813236static void yahoo_process_pager_connection(struct yahoo_input_data *yid,
    3082         int over)
     3237                                           int over)
    30833238{
    30843239        struct yahoo_packet *pkt;
     
    30863241        int id = yd->client_id;
    30873242
    3088         if (over)
    3089                 return;
     3243        if (over) {
     3244                return;
     3245        }
    30903246
    30913247        while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER)
    3092                 && (pkt = yahoo_getdata(yid)) != NULL) {
     3248               && (pkt = yahoo_getdata(yid)) != NULL) {
    30933249
    30943250                yahoo_packet_process(yid, pkt);
     
    30993255
    31003256static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid,
    3101         int over)
    3102 {
    3103         if (over)
    3104                 return;
    3105 
    3106         if (strstr((char *)yid->rxqueue + (yid->rxlen - 20), "</content>")) {
    3107                 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id,
    3108                         (char *)yid->rxqueue);
     3257                                             int over)
     3258{
     3259        if (over) {
     3260                return;
     3261        }
     3262
     3263        if (strstr((char *) yid->rxqueue + (yid->rxlen - 20), "</content>")) {
     3264                YAHOO_CALLBACK (ext_yahoo_chat_cat_xml) (yid->yd->client_id,
     3265                                                         (char *) yid->rxqueue);
    31093266        }
    31103267}
     
    31223279        LOG(("Got data for YAB"));
    31233280
    3124         if (over)
    3125                 return;
     3281        if (over) {
     3282                return;
     3283        }
    31263284
    31273285        while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB)
    3128                 && (yab = yahoo_getyab(yid)) != NULL) {
    3129                 if (!yab->id)
     3286               && (yab = yahoo_getyab(yid)) != NULL) {
     3287                if (!yab->id) {
    31303288                        continue;
     3289                }
    31313290
    31323291                changed = 1;
     
    31413300                                } else if (yab->fname && yab->lname) {
    31423301                                        bud->real_name = y_new0(char,
    3143                                                 strlen(yab->fname) +
    3144                                                 strlen(yab->lname) + 2);
     3302                                                                strlen(yab->fname) +
     3303                                                                strlen(yab->lname) + 2);
    31453304                                        sprintf(bud->real_name, "%s %s",
    3146                                                 yab->fname, yab->lname);
     3305                                                yab->fname, yab->lname);
    31473306                                } else if (yab->fname) {
    31483307                                        bud->real_name = strdup(yab->fname);
    31493308                                }
    3150                                 break;  /* for */
     3309                                break;  /* for */
    31513310                        }
    31523311                }
     
    31663325        }
    31673326
    3168         if (changed)
    3169                 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id,
    3170                         yd->buddies);
     3327        if (changed) {
     3328                YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id,
     3329                                                        yd->buddies);
     3330        }
    31713331}
    31723332#endif
    31733333
    31743334static void yahoo_process_search_connection(struct yahoo_input_data *yid,
    3175         int over)
     3335                                            int over)
    31763336{
    31773337        struct yahoo_found_contact *yct = NULL;
    3178         char *p = (char *)yid->rxqueue, *np, *cp;
     3338        char *p = (char *) yid->rxqueue, *np, *cp;
    31793339        int k, n;
    31803340        int start = 0, found = 0, total = 0;
    31813341        YList *contacts = NULL;
    31823342        struct yahoo_input_data *pyid =
    3183                 find_input_by_id_and_type(yid->yd->client_id,
    3184                 YAHOO_CONNECTION_PAGER);
    3185 
    3186         if (!over || !pyid)
    3187                 return;
     3343                find_input_by_id_and_type(yid->yd->client_id,
     3344                                          YAHOO_CONNECTION_PAGER);
     3345
     3346        if (!over || !pyid) {
     3347                return;
     3348        }
    31883349
    31893350        if (p && (p = strstr(p, "\r\n\r\n"))) {
     
    32063367                }
    32073368
    3208                 if (p)
     3369                if (p) {
    32093370                        p++;
     3371                }
    32103372
    32113373                k = 0;
     
    32143376                        np = strchr(p, 4);
    32153377
    3216                         if (!np)
     3378                        if (!np) {
    32173379                                break;
     3380                        }
    32183381                        *np = 0;
    32193382                        p = np + 1;
     
    32223385                        case 1:
    32233386                                if (strlen(cp) > 2
    3224                                         && y_list_length(contacts) < total) {
     3387                                    && y_list_length(contacts) < total) {
    32253388                                        yct = y_new0(struct yahoo_found_contact,
    3226                                                 1);
     3389                                                     1);
    32273390                                        contacts = y_list_append(contacts, yct);
    32283391                                        yct->id = cp + 2;
     
    32423405                        case 5:
    32433406                                /* not worth the context switch for strcmp */
    3244                                 if (cp[0] != '\005' || cp[1] != '\000')
     3407                                if (cp[0] != '\005' || cp[1] != '\000') {
    32453408                                        yct->location = cp;
     3409                                }
    32463410                                k = 0;
    32473411                                break;
     
    32503414        }
    32513415
    3252         YAHOO_CALLBACK(ext_yahoo_got_search_result) (yid->yd->client_id, found,
    3253                 start, total, contacts);
     3416        YAHOO_CALLBACK (ext_yahoo_got_search_result) (yid->yd->client_id, found,
     3417                                                      start, total, contacts);
    32543418
    32553419        while (contacts) {
     
    33573521
    33583522        yid->read_tag =
    3359                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,
    3360                 yid->fd, YAHOO_INPUT_READ, yid);
     3523                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id,
     3524                                                        yid->fd, YAHOO_INPUT_READ, yid);
    33613525}
    33623526
     
    33663530        struct yahoo_input_data *yid;
    33673531
    3368         if (!wcm || !wcm->server || !wcm->key)
    3369                 return;
     3532        if (!wcm || !wcm->server || !wcm->key) {
     3533                return;
     3534        }
    33703535
    33713536        yid = y_new0(struct yahoo_input_data, 1);
     
    33803545
    33813546        LOG(("Connecting to: %s:%d", wcm->server, wcm->port));
    3382         YAHOO_CALLBACK(ext_yahoo_connect_async) (y->yd->client_id, wcm->server,
    3383                 wcm->port, _yahoo_webcam_connected, yid, 0);
     3547        YAHOO_CALLBACK (ext_yahoo_connect_async) (y->yd->client_id, wcm->server,
     3548                                                  wcm->port, _yahoo_webcam_connected, yid, 0);
    33843549
    33853550}
    33863551
    33873552static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid,
    3388         int over)
     3553                                                   int over)
    33893554{
    33903555        char *server;
    33913556        struct yahoo_server_settings *yss;
    33923557
    3393         if (over)
    3394                 return;
     3558        if (over) {
     3559                return;
     3560        }
    33953561
    33963562        server = yahoo_getwebcam_master(yid);
     
    34023568                yid->wcm->conn_type = yss->conn_type;
    34033569                yid->wcm->my_ip = strdup(yss->local_host);
    3404                 if (yid->wcm->direction == YAHOO_WEBCAM_UPLOAD)
     3570                if (yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) {
    34053571                        yid->wcm->description = strdup(yss->webcam_description);
     3572                }
    34063573                yahoo_webcam_connect(yid);
    34073574                FREE(server);
     
    34103577
    34113578static void yahoo_process_webcam_connection(struct yahoo_input_data *yid,
    3412         int over)
     3579                                            int over)
    34133580{
    34143581        int id = yid->yd->client_id;
    34153582        void *fd = yid->fd;
    34163583
    3417         if (over)
    3418                 return;
     3584        if (over) {
     3585                return;
     3586        }
    34193587
    34203588        /* as long as we still have packets available keep processing them */
    34213589        while (find_input_by_id_and_fd(id, fd)
    3422                 && yahoo_get_webcam_data(yid) == 1) ;
    3423 }
    3424 
    3425 static void (*yahoo_process_connection[]) (struct yahoo_input_data *,
    3426         int over) = {
    3427 yahoo_process_pager_connection, yahoo_process_ft_connection,
    3428                 NULL, /*yahoo_process_yab_connection, */
    3429                 yahoo_process_webcam_master_connection,
    3430                 yahoo_process_webcam_connection,
    3431                 yahoo_process_chatcat_connection,
    3432                 yahoo_process_search_connection};
     3590               && yahoo_get_webcam_data(yid) == 1) {
     3591                ;
     3592        }
     3593}
     3594
     3595static void(*yahoo_process_connection[]) (struct yahoo_input_data *,
     3596                                          int over) = {
     3597        yahoo_process_pager_connection, yahoo_process_ft_connection,
     3598        NULL,         /*yahoo_process_yab_connection, */
     3599        yahoo_process_webcam_master_connection,
     3600        yahoo_process_webcam_connection,
     3601        yahoo_process_chatcat_connection,
     3602        yahoo_process_search_connection
     3603};
    34333604
    34343605int yahoo_read_ready(int id, void *fd, void *data)
     
    34393610
    34403611        LOG(("read callback: id=%d fd=%p data=%p", id, fd, data));
    3441         if (!yid)
     3612        if (!yid) {
    34423613                return -2;
     3614        }
    34433615
    34443616        do {
    3445                 len = YAHOO_CALLBACK(ext_yahoo_read) (fd, buf, sizeof(buf));
     3617                len = YAHOO_CALLBACK (ext_yahoo_read) (fd, buf, sizeof(buf));
    34463618        } while (len == -1 && errno == EINTR);
    34473619
    3448         if (len == -1 && (errno == EAGAIN || errno == EINTR))   /* we'll try again later */
     3620        if (len == -1 && (errno == EAGAIN || errno == EINTR)) { /* we'll try again later */
    34493621                return 1;
     3622        }
    34503623
    34513624        if (len <= 0) {
     
    34543627
    34553628                if (yid->type == YAHOO_CONNECTION_PAGER) {
    3456                         YAHOO_CALLBACK(ext_yahoo_login_response) (yid->yd->
    3457                                 client_id, YAHOO_LOGIN_SOCK, NULL);
     3629                        YAHOO_CALLBACK (ext_yahoo_login_response) (yid->yd->
     3630                                                                   client_id, YAHOO_LOGIN_SOCK, NULL);
    34583631                }
    34593632
     
    34623635
    34633636                /* no need to return an error, because we've already fixed it */
    3464                 if (len == 0)
     3637                if (len == 0) {
    34653638                        return 1;
     3639                }
    34663640
    34673641                errno = e;
     
    34713645
    34723646        yid->rxqueue =
    3473                 y_renew(unsigned char, yid->rxqueue, len + yid->rxlen + 1);
     3647                y_renew(unsigned char, yid->rxqueue, len + yid->rxlen + 1);
    34743648        memcpy(yid->rxqueue + yid->rxlen, buf, len);
    34753649        yid->rxlen += len;
     
    34883662        yd = y_new0(struct yahoo_data, 1);
    34893663
    3490         if (!yd)
     3664        if (!yd) {
    34913665                return 0;
     3666        }
    34923667
    34933668        yd->user = strdup(username);
     
    35263701                        char *host = yss->pager_host;
    35273702
    3528                         if (!host)
     3703                        if (!host) {
    35293704                                host = yss->pager_host_list[ccd->server_i];
     3705                        }
    35303706
    35313707                        yss->pager_port = fallback_ports[ccd->i++];
    3532                         tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->
    3533                                 client_id, host, yss->pager_port,
    3534                                 yahoo_connected, ccd, 0);
    3535 
    3536                         if (tag > 0)
     3708                        tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->
     3709                                                                        client_id, host, yss->pager_port,
     3710                                                                        yahoo_connected, ccd, 0);
     3711
     3712                        if (tag > 0) {
    35373713                                ccd->tag = tag;
     3714                        }
    35383715                } else if (yss->pager_host_list
    3539                                 && yss->pager_host_list[ccd->server_i]) {
     3716                           && yss->pager_host_list[ccd->server_i]) {
    35403717
    35413718                        /* Get back to the default port */
     
    35453722
    35463723                        ccd->i = 0;
    3547                         tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id,
    3548                                 yss->pager_host_list[ccd->server_i], yss->pager_port,
    3549                                 yahoo_connected, ccd, 0);
     3724                        tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->client_id,
     3725                                                                        yss->pager_host_list[ccd->server_i],
     3726                                                                        yss->pager_port,
     3727                                                                        yahoo_connected, ccd, 0);
    35503728                } else {
    35513729                        FREE(ccd);
    3552                         YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id,
    3553                                 YAHOO_LOGIN_SOCK, NULL);
     3730                        YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,
     3731                                                                   YAHOO_LOGIN_SOCK, NULL);
    35543732                }
    35553733                return;
     
    35593737
    35603738        /* fd == NULL && error == 0 means connect was cancelled */
    3561         if (!fd)
    3562                 return;
     3739        if (!fd) {
     3740                return;
     3741        }
    35633742
    35643743        pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT,
    3565                 yd->session_id);
     3744                               yd->session_id);
    35663745        NOTICE(("Sending initial packet"));
    35673746
     
    35763755
    35773756        yid->read_tag =
    3578                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,
    3579                 yid->fd, YAHOO_INPUT_READ, yid);
     3757                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id,
     3758                                                        yid->fd, YAHOO_INPUT_READ, yid);
    35803759}
    35813760
     
    35833762{
    35843763        struct yahoo_input_data *yid =
    3585                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    3586         if (!yid)
     3764                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3765
     3766        if (!yid) {
    35873767                return 0;
    3588         else
     3768        } else {
    35893769                return yid->fd;
     3770        }
    35903771}
    35913772
     
    35983779
    35993780void yahoo_send_im(int id, const char *from, const char *who, const char *what,
    3600         int utf8, int picture)
     3781                   int utf8, int picture)
    36013782{
    36023783        struct yahoo_input_data *yid =
    3603                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3784                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    36043785        struct yahoo_packet *pkt = NULL;
    36053786        struct yahoo_data *yd;
    36063787        char pic_str[10];
    36073788
    3608         if (!yid)
    3609                 return;
     3789        if (!yid) {
     3790                return;
     3791        }
    36103792
    36113793        yd = yid->yd;
    36123794
    36133795        pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, (enum ypacket_status) YAHOO_STATUS_OFFLINE,
    3614                 yd->session_id);
     3796                               yd->session_id);
    36153797
    36163798        snprintf(pic_str, sizeof(pic_str), "%d", picture);
    36173799
    3618         if (from && strcmp(from, yd->user))
     3800        if (from && strcmp(from, yd->user)) {
    36193801                yahoo_packet_hash(pkt, 0, yd->user);
     3802        }
    36203803        yahoo_packet_hash(pkt, 1, from ? from : yd->user);
    36213804        yahoo_packet_hash(pkt, 5, who);
    36223805        yahoo_packet_hash(pkt, 14, what);
    36233806
    3624         if (utf8)
     3807        if (utf8) {
    36253808                yahoo_packet_hash(pkt, 97, "1");
    3626 
    3627         yahoo_packet_hash(pkt, 63, ";0");       /* imvironment name; or ;0 */
     3809        }
     3810
     3811        yahoo_packet_hash(pkt, 63, ";0");       /* imvironment name; or ;0 */
    36283812        yahoo_packet_hash(pkt, 64, "0");
    36293813        yahoo_packet_hash(pkt, 206, pic_str);
     
    36373821{
    36383822        struct yahoo_input_data *yid =
    3639                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3823                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    36403824        struct yahoo_data *yd;
    36413825        struct yahoo_packet *pkt = NULL;
    3642         if (!yid)
    3643                 return;
     3826
     3827        if (!yid) {
     3828                return;
     3829        }
    36443830
    36453831        yd = yid->yd;
    36463832        pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY,
    3647                 yd->session_id);
     3833                               yd->session_id);
    36483834
    36493835        yahoo_packet_hash(pkt, 5, who);
     
    36613847{
    36623848        struct yahoo_input_data *yid =
    3663                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3849                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    36643850        struct yahoo_data *yd;
    36653851        struct yahoo_packet *pkt = NULL;
     
    36673853        char s[4];
    36683854
    3669         if (!yid)
    3670                 return;
     3855        if (!yid) {
     3856                return;
     3857        }
    36713858
    36723859        yd = yid->yd;
     
    36783865        if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
    36793866                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3680                         (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
     3867                                       (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    36813868                yahoo_packet_hash(pkt, 13, "2");
    36823869                yahoo_send_packet(yid, pkt, 0);
     
    36873874
    36883875        pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE,
    3689                 yd->current_status, yd->session_id);
     3876                               yd->current_status, yd->session_id);
    36903877        snprintf(s, sizeof(s), "%d", yd->current_status);
    36913878        yahoo_packet_hash(pkt, 10, s);
    36923879        yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : "");
    3693         yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0");
     3880        yahoo_packet_hash(pkt, 47, (away == 2) ? "2" : (away) ? "1" : "0");
    36943881        yahoo_send_packet(yid, pkt, 0);
    36953882        yahoo_packet_free(pkt);
     
    36973884        if (old_status == YAHOO_STATUS_INVISIBLE) {
    36983885                pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE,
    3699                         (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
     3886                                       (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0);
    37003887                yahoo_packet_hash(pkt, 13, "1");
    37013888                yahoo_send_packet(yid, pkt, 0);
     
    37073894{
    37083895        struct yahoo_input_data *yid =
    3709                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3896                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    37103897        struct yahoo_data *yd;
    37113898        struct yahoo_packet *pkt = NULL;
    37123899
    3713         if (!yid)
    3714                 return;
     3900        if (!yid) {
     3901                return;
     3902        }
    37153903        yd = yid->yd;
    37163904
     
    37223910                   connection reset will hopefully be clear enough. */
    37233911                pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF,
    3724                         YPACKET_STATUS_DEFAULT, yd->session_id);
     3912                                       YPACKET_STATUS_DEFAULT, yd->session_id);
    37253913                yd->current_status = -1;
    37263914
     
    37323920
    37333921/*      do {
    3734                 yahoo_input_close(yid);
    3735         } while((yid = find_input_by_id(id)));*/
     3922                yahoo_input_close(yid);
     3923        } while((yid = find_input_by_id(id)));*/
    37363924
    37373925}
     
    37413929{
    37423930        struct yahoo_input_data *yid =
    3743                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     3931                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    37443932        struct yahoo_data *yd;
    37453933        struct yahoo_packet *pkt = NULL;
    37463934
    3747         if (!yid)
    3748                 return;
     3935        if (!yid) {
     3936                return;
     3937        }
    37493938        yd = yid->yd;
    37503939
    37513940        pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YPACKET_STATUS_DEFAULT,
    3752                 yd->session_id);
     3941                               yd->session_id);
    37533942        yahoo_packet_hash(pkt, 1, yd->user);
    37543943        if (pkt) {
     
    37623951{
    37633952        struct yahoo_input_data *yid = data;
     3953
    37643954        if (fd == NULL || error) {
    37653955                inputs = y_list_remove(inputs, yid);
     
    37703960        yid->fd = fd;
    37713961        yid->read_tag =
    3772                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
    3773                 YAHOO_INPUT_READ, yid);
     3962                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd,
     3963                                                        YAHOO_INPUT_READ, yid);
    37743964}
    37753965
     
    37833973        char buff[2048];
    37843974
    3785         if (!yd)
    3786                 return;
     3975        if (!yd) {
     3976                return;
     3977        }
    37873978
    37883979        yid = y_new0(struct yahoo_input_data, 1);
     
    37933984
    37943985        snprintf(url, 1024,
    3795                 "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us"
    3796                 "&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252");
     3986                 "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us"
     3987                 "&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252");
    37973988
    37983989        snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
     
    38013992
    38023993        yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
    3803                 _yahoo_http_connected, yid);
     3994                       _yahoo_http_connected, yid);
    38043995}
    38053996
     
    38214012        }
    38224013
    3823         YAHOO_CALLBACK(ext_yahoo_write) (fd, buff, strlen(buff));
     4014        YAHOO_CALLBACK (ext_yahoo_write) (fd, buff, strlen(buff));
    38244015
    38254016        yid->fd = fd;
    38264017        yid->read_tag =
    3827                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
    3828                 YAHOO_INPUT_READ, yid);
     4018                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd,
     4019                                                        YAHOO_INPUT_READ, yid);
    38294020
    38304021        FREE(buff);
     
    38434034        int size = 0;
    38444035
    3845         if (!yd)
    3846                 return;
     4036        if (!yd) {
     4037                return;
     4038        }
    38474039
    38484040        yid = y_new0(struct yahoo_input_data, 1);
     
    38504042        yid->yd = yd;
    38514043
    3852         if(yab->yid)
     4044        if (yab->yid) {
    38534045                size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    3854                         "<ab k=\"%s\" cc=\"%d\">"
    3855                         "<ct id=\"%d\" e=\"1\" yi=\"%s\" nn=\"%s\" />"
    3856                         "</ab>", yd->user, 9, yab->yid, /* Don't know why */
    3857                         yab->id, yab->nname?yab->nname:"");
    3858         else
     4046                                "<ab k=\"%s\" cc=\"%d\">"
     4047                                "<ct id=\"%d\" e=\"1\" yi=\"%s\" nn=\"%s\" />"
     4048                                "</ab>", yd->user, 9, yab->yid, /* Don't know why */
     4049                                yab->id, yab->nname ? yab->nname : "");
     4050        } else {
    38594051                size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    3860                         "<ab k=\"%s\" cc=\"%d\">"
    3861                         "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />"
    3862                         "</ab>", yd->user, 1,   /* Don't know why */
    3863                         yab->id, yab->nname?yab->nname:"");
     4052                                "<ab k=\"%s\" cc=\"%d\">"
     4053                                "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />"
     4054                                "</ab>", yd->user, 1, /* Don't know why */
     4055                                yab->id, yab->nname ? yab->nname : "");
     4056        }
    38644057
    38654058        yad->yid = yid;
     
    38674060
    38684061        strcpy(url, "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us"
    3869                 "&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252");
     4062               "&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252");
    38704063
    38714064        snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
     
    38744067
    38754068        yahoo_http_post(yid->yd->client_id, url, buff, size,
    3876                 _yahoo_http_post_connected, yad);
     4069                        _yahoo_http_post_connected, yad);
    38774070}
    38784071
     
    38804073{
    38814074        struct yahoo_input_data *yid =
    3882                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4075                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    38834076        struct yahoo_data *yd;
    38844077        struct yahoo_packet *pkt = NULL;
    38854078
    3886         if (!yid)
    3887                 return;
     4079        if (!yid) {
     4080                return;
     4081        }
    38884082        yd = yid->yd;
    38894083
    38904084        pkt = yahoo_packet_new(active ? YAHOO_SERVICE_IDACT :
    3891                 YAHOO_SERVICE_IDDEACT, YPACKET_STATUS_DEFAULT, yd->session_id);
     4085                               YAHOO_SERVICE_IDDEACT, YPACKET_STATUS_DEFAULT, yd->session_id);
    38924086        yahoo_packet_hash(pkt, 3, identity);
    38934087        if (pkt) {
     
    39004094{
    39014095        struct yahoo_input_data *yid =
    3902                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4096                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    39034097        struct yahoo_data *yd;
    39044098        struct yahoo_packet *pkt = NULL;
    39054099
    3906         if (!yid)
    3907                 return;
     4100        if (!yid) {
     4101                return;
     4102        }
    39084103        yd = yid->yd;
    39094104
    39104105        pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YPACKET_STATUS_DEFAULT,
    3911                 yd->session_id);
     4106                               yd->session_id);
    39124107        if (pkt) {
    39134108                yahoo_send_packet(yid, pkt, 0);
     
    39204115{
    39214116        struct yahoo_input_data *yid =
    3922                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4117                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    39234118        struct yahoo_data *yd;
    39244119        struct yahoo_packet *pkt = NULL;
    3925         if (!yid)
    3926                 return;
     4120
     4121        if (!yid) {
     4122                return;
     4123        }
    39274124        yd = yid->yd;
    39284125
    39294126        pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YPACKET_STATUS_DEFAULT,
    3930                 yd->session_id);
     4127                               yd->session_id);
    39314128        yahoo_send_packet(yid, pkt, 0);
    39324129        yahoo_packet_free(pkt);
     
    39374134{
    39384135        struct yahoo_input_data *yid =
    3939                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4136                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    39404137        struct yahoo_data *yd;
    39414138        struct yahoo_packet *pkt = NULL;
    39424139
    3943         if (!yid)
    3944                 return;
     4140        if (!yid) {
     4141                return;
     4142        }
    39454143
    39464144        yd = yid->yd;
    39474145
    39484146        pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YPACKET_STATUS_DEFAULT,
    3949                 yd->session_id);
     4147                               yd->session_id);
    39504148        yahoo_send_packet(yid, pkt, 0);
    39514149        yahoo_packet_free(pkt);
     
    39544152
    39554153void yahoo_add_buddy(int id, const char *who, const char *group,
    3956         const char *msg)
     4154                     const char *msg)
    39574155{
    39584156        struct yahoo_input_data *yid =
    3959                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4157                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    39604158        struct yahoo_data *yd;
    39614159        struct yahoo_packet *pkt;
    39624160
    3963         if (!yid)
    3964                 return;
     4161        if (!yid) {
     4162                return;
     4163        }
    39654164        yd = yid->yd;
    39664165
    3967         if (!yd->logged_in)
    3968                 return;
     4166        if (!yd->logged_in) {
     4167                return;
     4168        }
    39694169
    39704170        pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT,
    3971                 yd->session_id);
    3972         if (msg != NULL)        /* add message/request "it's me add me" */
     4171                               yd->session_id);
     4172        if (msg != NULL) {      /* add message/request "it's me add me" */
    39734173                yahoo_packet_hash(pkt, 14, msg);
    3974         else
     4174        } else {
    39754175                yahoo_packet_hash(pkt, 14, "");
     4176        }
    39764177        yahoo_packet_hash(pkt, 65, group);
    39774178        yahoo_packet_hash(pkt, 97, "1");
     
    39904191{
    39914192        struct yahoo_input_data *yid =
    3992                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4193                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    39934194        struct yahoo_data *yd;
    39944195        struct yahoo_packet *pkt = NULL;
    39954196
    3996         if (!yid)
    3997                 return;
     4197        if (!yid) {
     4198                return;
     4199        }
    39984200        yd = yid->yd;
    39994201
    40004202        pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YPACKET_STATUS_DEFAULT,
    4001                 yd->session_id);
     4203                               yd->session_id);
    40024204
    40034205        yahoo_packet_hash(pkt, 1, yd->user);
     
    40114213{
    40124214        struct yahoo_input_data *yid =
    4013                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4215                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    40144216        struct yahoo_data *yd;
    40154217        struct yahoo_packet *pkt;
    40164218
    4017         if (!yid)
    4018                 return;
     4219        if (!yid) {
     4220                return;
     4221        }
    40194222        yd = yid->yd;
    40204223
    4021         if (!yd->logged_in)
    4022                 return;
     4224        if (!yd->logged_in) {
     4225                return;
     4226        }
    40234227
    40244228        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_AUTHORIZATION,
    4025                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4229                               YPACKET_STATUS_DEFAULT, yd->session_id);
    40264230        yahoo_packet_hash(pkt, 1, yd->user);
    40274231        yahoo_packet_hash(pkt, 5, who);
    4028         if (reject)
     4232        if (reject) {
    40294233                yahoo_packet_hash(pkt, 13, "2");
    4030         else {
     4234        } else {
    40314235                yahoo_packet_hash(pkt, 241, "0");
    40324236                yahoo_packet_hash(pkt, 13, "1");
     
    40484252{
    40494253        struct yahoo_input_data *yid =
    4050                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4254                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    40514255        struct yahoo_data *yd;
    40524256        struct yahoo_packet *pkt;
    40534257
    4054         if (!yid)
    4055                 return;
     4258        if (!yid) {
     4259                return;
     4260        }
    40564261        yd = yid->yd;
    40574262
    4058         if (!yd->logged_in)
    4059                 return;
     4263        if (!yd->logged_in) {
     4264                return;
     4265        }
    40604266
    40614267        pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT,
    4062                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4268                               YPACKET_STATUS_DEFAULT, yd->session_id);
    40634269        yahoo_packet_hash(pkt, 1, yd->user);
    40644270        yahoo_packet_hash(pkt, 7, who);
     
    40714277{
    40724278        struct yahoo_input_data *yid =
    4073                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4279                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    40744280        struct yahoo_data *yd;
    40754281        struct yahoo_packet *pkt;
    40764282
    4077         if (!yid)
    4078                 return;
     4283        if (!yid) {
     4284                return;
     4285        }
    40794286        yd = yid->yd;
    40804287
    4081         if (!yd->logged_in)
    4082                 return;
     4288        if (!yd->logged_in) {
     4289                return;
     4290        }
    40834291
    40844292        pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH_PERM,
    4085                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4293                               YPACKET_STATUS_DEFAULT, yd->session_id);
    40864294        yahoo_packet_hash(pkt, 1, yd->user);
    40874295        yahoo_packet_hash(pkt, 7, who);
     
    40944302
    40954303void yahoo_change_buddy_group(int id, const char *who, const char *old_group,
    4096         const char *new_group)
     4304                              const char *new_group)
    40974305{
    40984306        struct yahoo_input_data *yid =
    4099                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4307                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    41004308        struct yahoo_data *yd;
    41014309        struct yahoo_packet *pkt = NULL;
    41024310
    4103         if (!yid)
    4104                 return;
     4311        if (!yid) {
     4312                return;
     4313        }
    41054314        yd = yid->yd;
    41064315
    41074316        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_CHANGE_GROUP,
    4108                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4317                               YPACKET_STATUS_DEFAULT, yd->session_id);
    41094318        yahoo_packet_hash(pkt, 1, yd->user);
    41104319        yahoo_packet_hash(pkt, 302, "240");
     
    41244333{
    41254334        struct yahoo_input_data *yid =
    4126                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4335                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    41274336        struct yahoo_data *yd;
    41284337        struct yahoo_packet *pkt = NULL;
    41294338
    4130         if (!yid)
    4131                 return;
     4339        if (!yid) {
     4340                return;
     4341        }
    41324342        yd = yid->yd;
    41334343
    41344344        pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME,
    4135                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4345                               YPACKET_STATUS_DEFAULT, yd->session_id);
    41364346        yahoo_packet_hash(pkt, 1, yd->user);
    41374347        yahoo_packet_hash(pkt, 65, old_group);
     
    41434353
    41444354void yahoo_conference_addinvite(int id, const char *from, const char *who,
    4145         const char *room, const YList *members, const char *msg)
     4355                                const char *room, const YList *members, const char *msg)
    41464356{
    41474357        struct yahoo_input_data *yid =
    4148                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4358                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    41494359        struct yahoo_data *yd;
    41504360        struct yahoo_packet *pkt;
    41514361
    4152         if (!yid)
    4153                 return;
     4362        if (!yid) {
     4363                return;
     4364        }
    41544365        yd = yid->yd;
    41554366
    41564367        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE,
    4157                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4368                               YPACKET_STATUS_DEFAULT, yd->session_id);
    41584369
    41594370        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
     
    41634374        yahoo_packet_hash(pkt, 13, "0");
    41644375        for (; members; members = members->next) {
    4165                 yahoo_packet_hash(pkt, 52, (char *)members->data);
    4166                 yahoo_packet_hash(pkt, 53, (char *)members->data);
     4376                yahoo_packet_hash(pkt, 52, (char *) members->data);
     4377                yahoo_packet_hash(pkt, 53, (char *) members->data);
    41674378        }
    41684379        /* 52, 53 -> other members? */
     
    41754386
    41764387void yahoo_conference_invite(int id, const char *from, YList *who,
    4177         const char *room, const char *msg)
     4388                             const char *room, const char *msg)
    41784389{
    41794390        struct yahoo_input_data *yid =
    4180                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4391                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    41814392        struct yahoo_data *yd;
    41824393        struct yahoo_packet *pkt;
    41834394
    4184         if (!yid)
    4185                 return;
     4395        if (!yid) {
     4396                return;
     4397        }
    41864398        yd = yid->yd;
    41874399
    41884400        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YPACKET_STATUS_DEFAULT,
    4189                 yd->session_id);
     4401                               yd->session_id);
    41904402
    41914403        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    41924404        yahoo_packet_hash(pkt, 50, yd->user);
    41934405        for (; who; who = who->next) {
    4194                 yahoo_packet_hash(pkt, 52, (char *)who->data);
     4406                yahoo_packet_hash(pkt, 52, (char *) who->data);
    41954407        }
    41964408        yahoo_packet_hash(pkt, 57, room);
     
    42044416
    42054417void yahoo_conference_logon(int id, const char *from, YList *who,
    4206         const char *room)
     4418                            const char *room)
    42074419{
    42084420        struct yahoo_input_data *yid =
    4209                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4421                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    42104422        struct yahoo_data *yd;
    42114423        struct yahoo_packet *pkt;
    42124424
    4213         if (!yid)
    4214                 return;
     4425        if (!yid) {
     4426                return;
     4427        }
    42154428        yd = yid->yd;
    42164429
    42174430        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YPACKET_STATUS_DEFAULT,
    4218                 yd->session_id);
     4431                               yd->session_id);
    42194432
    42204433        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    42214434        yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
    42224435        yahoo_packet_hash(pkt, 57, room);
    4223         for (; who; who = who->next)
    4224                 yahoo_packet_hash(pkt, 3, (char *)who->data);
     4436        for (; who; who = who->next) {
     4437                yahoo_packet_hash(pkt, 3, (char *) who->data);
     4438        }
    42254439
    42264440        yahoo_send_packet(yid, pkt, 0);
     
    42304444
    42314445void yahoo_conference_decline(int id, const char *from, YList *who,
    4232         const char *room, const char *msg)
     4446                              const char *room, const char *msg)
    42334447{
    42344448        struct yahoo_input_data *yid =
    4235                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4449                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    42364450        struct yahoo_data *yd;
    42374451        struct yahoo_packet *pkt;
    42384452
    4239         if (!yid)
    4240                 return;
     4453        if (!yid) {
     4454                return;
     4455        }
    42414456        yd = yid->yd;
    42424457
    42434458        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE,
    4244                 YPACKET_STATUS_DEFAULT, yd->session_id);
     4459                               YPACKET_STATUS_DEFAULT, yd->session_id);
    42454460
    42464461        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    42474462        yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
    4248         for (; who; who = who->next)
    4249                 yahoo_packet_hash(pkt, 3, (char *)who->data);
     4463        for (; who; who = who->next) {
     4464                yahoo_packet_hash(pkt, 3, (char *) who->data);
     4465        }
    42504466        yahoo_packet_hash(pkt, 57, room);
    42514467        yahoo_packet_hash(pkt, 14, msg);
     
    42574473
    42584474void yahoo_conference_logoff(int id, const char *from, YList *who,
    4259         const char *room)
     4475                             const char *room)
    42604476{
    42614477        struct yahoo_input_data *yid =
    4262                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4478                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    42634479        struct yahoo_data *yd;
    42644480        struct yahoo_packet *pkt;
    42654481
    4266         if (!yid)
    4267                 return;
     4482        if (!yid) {
     4483                return;
     4484        }
    42684485        yd = yid->yd;
    42694486
    42704487        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YPACKET_STATUS_DEFAULT,
    4271                 yd->session_id);
     4488                               yd->session_id);
    42724489
    42734490        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    42744491        yahoo_packet_hash(pkt, 3, (from ? from : yd->user));
    4275         for (; who; who = who->next)
    4276                 yahoo_packet_hash(pkt, 3, (char *)who->data);
     4492        for (; who; who = who->next) {
     4493                yahoo_packet_hash(pkt, 3, (char *) who->data);
     4494        }
    42774495
    42784496        yahoo_packet_hash(pkt, 57, room);
     
    42844502
    42854503void yahoo_conference_message(int id, const char *from, YList *who,
    4286         const char *room, const char *msg, int utf8)
     4504                              const char *room, const char *msg, int utf8)
    42874505{
    42884506        struct yahoo_input_data *yid =
    4289                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4507                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    42904508        struct yahoo_data *yd;
    42914509        struct yahoo_packet *pkt;
    42924510
    4293         if (!yid)
    4294                 return;
     4511        if (!yid) {
     4512                return;
     4513        }
    42954514        yd = yid->yd;
    42964515
    42974516        pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YPACKET_STATUS_DEFAULT,
    4298                 yd->session_id);
     4517                               yd->session_id);
    42994518
    43004519        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    43014520        yahoo_packet_hash(pkt, 53, (from ? from : yd->user));
    4302         for (; who; who = who->next)
    4303                 yahoo_packet_hash(pkt, 53, (char *)who->data);
     4521        for (; who; who = who->next) {
     4522                yahoo_packet_hash(pkt, 53, (char *) who->data);
     4523        }
    43044524
    43054525        yahoo_packet_hash(pkt, 57, room);
    43064526        yahoo_packet_hash(pkt, 14, msg);
    43074527
    4308         if (utf8)
     4528        if (utf8) {
    43094529                yahoo_packet_hash(pkt, 97, "1");
     4530        }
    43104531
    43114532        yahoo_send_packet(yid, pkt, 0);
     
    43224543        char buff[1024];
    43234544
    4324         if (!yd)
    4325                 return;
     4545        if (!yd) {
     4546                return;
     4547        }
    43264548
    43274549        yid = y_new0(struct yahoo_input_data, 1);
     
    43314553        if (chatroomid == 0) {
    43324554                snprintf(url, 1024,
    4333                         "http://insider.msg.yahoo.com/ycontent/?chatcat=0");
     4555                         "http://insider.msg.yahoo.com/ycontent/?chatcat=0");
    43344556        } else {
    43354557                snprintf(url, 1024,
    4336                         "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0",
    4337                         chatroomid);
     4558                         "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0",
     4559                         chatroomid);
    43384560        }
    43394561
     
    43434565
    43444566        yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
    4345                 _yahoo_http_connected, yid);
     4567                       _yahoo_http_connected, yid);
    43464568}
    43474569
    43484570void yahoo_chat_logon(int id, const char *from, const char *room,
    4349         const char *roomid)
     4571                      const char *roomid)
    43504572{
    43514573        struct yahoo_input_data *yid =
    4352                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4574                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    43534575        struct yahoo_data *yd;
    43544576        struct yahoo_packet *pkt;
    43554577
    4356         if (!yid)
    4357                 return;
     4578        if (!yid) {
     4579                return;
     4580        }
    43584581
    43594582        yd = yid->yd;
    43604583
    43614584        pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YPACKET_STATUS_DEFAULT,
    4362                 yd->session_id);
     4585                               yd->session_id);
    43634586
    43644587        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
     
    43714594
    43724595        pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YPACKET_STATUS_DEFAULT,
    4373                 yd->session_id);
     4596                               yd->session_id);
    43744597
    43754598        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
    43764599        yahoo_packet_hash(pkt, 104, room);
    43774600        yahoo_packet_hash(pkt, 129, roomid);
    4378         yahoo_packet_hash(pkt, 62, "2");        /* ??? */
     4601        yahoo_packet_hash(pkt, 62, "2");        /* ??? */
    43794602
    43804603        yahoo_send_packet(yid, pkt, 0);
     
    43844607
    43854608void yahoo_chat_message(int id, const char *from, const char *room,
    4386         const char *msg, const int msgtype, const int utf8)
     4609                        const char *msg, const int msgtype, const int utf8)
    43874610{
    43884611        struct yahoo_input_data *yid =
    4389                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4612                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    43904613        struct yahoo_data *yd;
    43914614        struct yahoo_packet *pkt;
    43924615        char buf[2];
    43934616
    4394         if (!yid)
    4395                 return;
     4617        if (!yid) {
     4618                return;
     4619        }
    43964620
    43974621        yd = yid->yd;
    43984622
    43994623        pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YPACKET_STATUS_DEFAULT,
    4400                 yd->session_id);
     4624                               yd->session_id);
    44014625
    44024626        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
     
    44074631        yahoo_packet_hash(pkt, 124, buf);
    44084632
    4409         if (utf8)
     4633        if (utf8) {
    44104634                yahoo_packet_hash(pkt, 97, "1");
     4635        }
    44114636
    44124637        yahoo_send_packet(yid, pkt, 0);
     
    44184643{
    44194644        struct yahoo_input_data *yid =
    4420                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4645                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    44214646        struct yahoo_data *yd;
    44224647        struct yahoo_packet *pkt;
    44234648
    4424         if (!yid)
    4425                 return;
     4649        if (!yid) {
     4650                return;
     4651        }
    44264652
    44274653        yd = yid->yd;
    44284654
    44294655        pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YPACKET_STATUS_DEFAULT,
    4430                 yd->session_id);
     4656                               yd->session_id);
    44314657
    44324658        yahoo_packet_hash(pkt, 1, (from ? from : yd->user));
     
    44404666{
    44414667        struct yahoo_input_data *yid =
    4442                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4668                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    44434669        struct yahoo_data *yd;
    44444670        struct yahoo_packet *pkt;
    44454671
    4446         if (!yid)
    4447                 return;
     4672        if (!yid) {
     4673                return;
     4674        }
    44484675
    44494676        yd = yid->yd;
    44504677
    44514678        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT,
    4452                 0);
     4679                               0);
    44534680        yahoo_packet_hash(pkt, 4, yd->user);
    44544681        yahoo_packet_hash(pkt, 5, who);
     
    44604687
    44614688void yahoo_send_picture_info(int id, const char *who, const char *url,
    4462         int checksum)
     4689                             int checksum)
    44634690{
    44644691        struct yahoo_input_data *yid =
    4465                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4692                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    44664693        struct yahoo_data *yd;
    44674694        struct yahoo_packet *pkt;
    44684695        char checksum_str[10];
    44694696
    4470         if (!yid)
    4471                 return;
     4697        if (!yid) {
     4698                return;
     4699        }
    44724700
    44734701        yd = yid->yd;
     
    44764704
    44774705        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT,
    4478                 0);
     4706                               0);
    44794707        yahoo_packet_hash(pkt, 1, yd->user);
    44804708        yahoo_packet_hash(pkt, 4, yd->user);
     
    44914719{
    44924720        struct yahoo_input_data *yid =
    4493                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4721                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    44944722        struct yahoo_data *yd;
    44954723        struct yahoo_packet *pkt;
    44964724        char type_str[10];
    44974725
    4498         if (!yid)
    4499                 return;
     4726        if (!yid) {
     4727                return;
     4728        }
    45004729
    45014730        yd = yid->yd;
     
    45044733
    45054734        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE,
    4506                 YPACKET_STATUS_DEFAULT, 0);
     4735                               YPACKET_STATUS_DEFAULT, 0);
    45074736        yahoo_packet_hash(pkt, 1, yd->user);
    45084737        yahoo_packet_hash(pkt, 5, who);
     
    45164745{
    45174746        struct yahoo_input_data *yid =
    4518                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4747                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    45194748        struct yahoo_data *yd;
    45204749        struct yahoo_packet *pkt;
    45214750        char checksum_str[10];
    45224751
    4523         if (!yid)
    4524                 return;
     4752        if (!yid) {
     4753                return;
     4754        }
    45254755
    45264756        yd = yid->yd;
     
    45294759
    45304760        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM,
    4531                 YPACKET_STATUS_DEFAULT, 0);
     4761                               YPACKET_STATUS_DEFAULT, 0);
    45324762        yahoo_packet_hash(pkt, 1, yd->user);
    4533         if (who != 0)
     4763        if (who != 0) {
    45344764                yahoo_packet_hash(pkt, 5, who);
     4765        }
    45354766        yahoo_packet_hash(pkt, 192, checksum_str);
    45364767        yahoo_packet_hash(pkt, 212, "1");
     
    45434774{
    45444775        struct yahoo_input_data *yid =
    4545                 find_input_by_id_and_webcam_user(id, who);
    4546 
    4547         if (yid)
     4776                find_input_by_id_and_webcam_user(id, who);
     4777
     4778        if (yid) {
    45484779                yahoo_input_close(yid);
     4780        }
    45494781}
    45504782
     
    45524784{
    45534785        struct yahoo_input_data *yid =
    4554                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4786                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    45554787        struct yahoo_data *yd;
    45564788        struct yahoo_packet *pkt;
    45574789
    4558         if (!yid)
    4559                 return;
    4560 
    4561         /*
     4790        if (!yid) {
     4791                return;
     4792        }
     4793
     4794        /*
    45624795         * add the user to the queue.  this is a dirty hack, since
    45634796         * the yahoo server doesn't tell us who's key it's returning,
    4564          * we have to just hope that it sends back keys in the same 
     4797         * we have to just hope that it sends back keys in the same
    45654798         * order that we request them.
    45664799         * The queue is popped in yahoo_process_webcam_key
     
    45714804
    45724805        pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YPACKET_STATUS_DEFAULT,
    4573                 yd->session_id);
     4806                               yd->session_id);
    45744807
    45754808        yahoo_packet_hash(pkt, 1, yd->user);
    4576         if (who != NULL)
     4809        if (who != NULL) {
    45774810                yahoo_packet_hash(pkt, 5, who);
     4811        }
    45784812        yahoo_send_packet(yid, pkt, 0);
    45794813
     
    45824816
    45834817void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length,
    4584         unsigned int timestamp)
     4818                             unsigned int timestamp)
    45854819{
    45864820        struct yahoo_input_data *yid =
    4587                 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
     4821                find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
    45884822        unsigned char *packet;
    45894823        unsigned char header_len = 13;
    45904824        unsigned int pos = 0;
    45914825
    4592         if (!yid)
    4593                 return;
     4826        if (!yid) {
     4827                return;
     4828        }
    45944829
    45954830        packet = y_new0(unsigned char, header_len);
     
    45974832        packet[pos++] = header_len;
    45984833        packet[pos++] = 0;
    4599         packet[pos++] = 5;      /* version byte?? */
     4834        packet[pos++] = 5;      /* version byte?? */
    46004835        packet[pos++] = 0;
    46014836        pos += yahoo_put32(packet + pos, length);
    4602         packet[pos++] = 2;      /* packet type, image */
     4837        packet[pos++] = 2;      /* packet type, image */
    46034838        pos += yahoo_put32(packet + pos, timestamp);
    46044839        yahoo_add_to_send_queue(yid, packet, header_len);
    46054840        FREE(packet);
    46064841
    4607         if (length)
     4842        if (length) {
    46084843                yahoo_add_to_send_queue(yid, image, length);
     4844        }
    46094845}
    46104846
     
    46124848{
    46134849        struct yahoo_input_data *yid =
    4614                 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
     4850                find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM);
    46154851        char *packet = NULL;
    46164852        char *data = NULL;
     
    46194855        unsigned int len = 0;
    46204856
    4621         if (!yid)
    4622                 return;
     4857        if (!yid) {
     4858                return;
     4859        }
    46234860
    46244861        data = strdup("u=");
    4625         data = y_string_append(data, (char *)who);
     4862        data = y_string_append(data, (char *) who);
    46264863        data = y_string_append(data, "\r\n");
    46274864        len = strlen(data);
     
    46304867        packet[pos++] = header_len;
    46314868        packet[pos++] = 0;
    4632         packet[pos++] = 5;      /* version byte?? */
     4869        packet[pos++] = 5;      /* version byte?? */
    46334870        packet[pos++] = 0;
    46344871        pos += yahoo_put32(packet + pos, len);
    4635         packet[pos++] = 0;      /* packet type */
     4872        packet[pos++] = 0;      /* packet type */
    46364873        pos += yahoo_put32(packet + pos, accept);
    46374874        memcpy(packet + pos, data, len);
     
    46444881{
    46454882        struct yahoo_input_data *yid =
    4646                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4883                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    46474884        struct yahoo_packet *pkt;
    46484885
    4649         if (!yid)
    4650                 return;
     4886        if (!yid) {
     4887                return;
     4888        }
    46514889
    46524890        pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY,
    4653                 yid->yd->session_id);
     4891                               yid->yd->session_id);
    46544892
    46554893        yahoo_packet_hash(pkt, 49, "WEBCAMINVITE");
     
    46644902
    46654903static void yahoo_search_internal(int id, int t, const char *text, int g,
    4666         int ar, int photo, int yahoo_only, int startpos, int total)
     4904                                  int ar, int photo, int yahoo_only, int startpos, int total)
    46674905{
    46684906        struct yahoo_data *yd = find_conn_by_id(id);
     
    46724910        char *ctext, *p;
    46734911
    4674         if (!yd)
    4675                 return;
     4912        if (!yd) {
     4913                return;
     4914        }
    46764915
    46774916        yid = y_new0(struct yahoo_input_data, 1);
     
    46854924
    46864925        snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total,
    4687                 startpos);
     4926                 startpos);
    46884927
    46894928        ctext = strdup(text);
    4690         while ((p = strchr(ctext, ' ')))
     4929        while ((p = strchr(ctext, ' '))) {
    46914930                *p = '+';
     4931        }
    46924932
    46934933        snprintf(url, 1024,
    4694                 "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s",
    4695                 ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "",
    4696                 startpos ? buff : "");
     4934                 "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s",
     4935                 ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "",
     4936                 startpos ? buff : "");
    46974937
    46984938        FREE(ctext);
     
    47024942        inputs = y_list_prepend(inputs, yid);
    47034943        yahoo_http_get(yid->yd->client_id, url, buff, 0, 0,
    4704                 _yahoo_http_connected, yid);
     4944                       _yahoo_http_connected, yid);
    47054945}
    47064946
    47074947void yahoo_search(int id, enum yahoo_search_type t, const char *text,
    4708         enum yahoo_search_gender g, enum yahoo_search_agerange ar, int photo,
    4709         int yahoo_only)
     4948                  enum yahoo_search_gender g, enum yahoo_search_agerange ar, int photo,
     4949                  int yahoo_only)
    47104950{
    47114951        struct yahoo_input_data *yid =
    4712                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4952                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    47134953        struct yahoo_search_state *yss;
    47144954
    4715         if (!yid)
    4716                 return;
    4717 
    4718         if (!yid->ys)
     4955        if (!yid) {
     4956                return;
     4957        }
     4958
     4959        if (!yid->ys) {
    47194960                yid->ys = y_new0(struct yahoo_search_state, 1);
     4961        }
    47204962
    47214963        yss = yid->ys;
     
    47354977{
    47364978        struct yahoo_input_data *yid =
    4737                 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     4979                find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    47384980        struct yahoo_search_state *yss;
    47394981
    4740         if (!yid || !yid->ys)
    4741                 return;
     4982        if (!yid || !yid->ys) {
     4983                return;
     4984        }
    47424985
    47434986        yss = yid->ys;
    47444987
    4745         if (start == -1)
     4988        if (start == -1) {
    47464989                start = yss->lsearch_nstart + yss->lsearch_nfound;
     4990        }
    47474991
    47484992        yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text,
    4749                 yss->lsearch_gender, yss->lsearch_agerange,
    4750                 yss->lsearch_photo, yss->lsearch_yahoo_only,
    4751                 start, yss->lsearch_ntotal);
     4993                              yss->lsearch_gender, yss->lsearch_agerange,
     4994                              yss->lsearch_photo, yss->lsearch_yahoo_only,
     4995                              start, yss->lsearch_ntotal);
    47524996}
    47534997
    47544998void yahoo_send_picture(int id, const char *name, unsigned long size,
    4755         yahoo_get_fd_callback callback, void *data)
     4999                        yahoo_get_fd_callback callback, void *data)
    47565000{
    47575001        /* Not Implemented */
     
    47965040        out[23] = '$';
    47975041        out[22] = '$';
    4798        
     5042
    47995043        for (i = 0; i < 22; i++) {
    4800                 if(r == 0)
     5044                if (r == 0) {
    48015045                        r = rand();
    4802 
    4803                 c = r%61;
    4804 
    4805                 if(c<26)
     5046                }
     5047
     5048                c = r % 61;
     5049
     5050                if (c < 26) {
    48065051                        out[i] = c + 'a';
    4807                 else if (c<52)
     5052                } else if (c < 52) {
    48085053                        out[i] = c - 26 + 'A';
    4809                 else
     5054                } else {
    48105055                        out[i] = c - 52 + '0';
     5056                }
    48115057
    48125058                r /= 61;
     
    48195065static int _are_same_id(const void *sfd1, const void *id)
    48205066{
    4821         return strcmp(((struct send_file_data *)sfd1)->id, (char *)id);
     5067        return strcmp(((struct send_file_data *) sfd1)->id, (char *) id);
    48225068}
    48235069
    48245070static int _are_same_yid(const void *sfd1, const void *yid)
    48255071{
    4826         if(((struct send_file_data *)sfd1)->yid == yid)
     5072        if (((struct send_file_data *) sfd1)->yid == yid) {
    48275073                return 0;
    4828         else
     5074        } else {
    48295075                return 1;
     5076        }
    48305077}
    48315078
     
    48335080{
    48345081        YList *l = y_list_find_custom(active_file_transfers, id,
    4835                 _are_same_id);
    4836 
    4837         if(l)
    4838                 return (struct send_file_data *)l->data;
    4839        
     5082                                      _are_same_id);
     5083
     5084        if (l) {
     5085                return (struct send_file_data *) l->data;
     5086        }
     5087
    48405088        return NULL;
    48415089}
     
    48445092{
    48455093        YList *l = y_list_find_custom(active_file_transfers, yid,
    4846                 _are_same_yid);
    4847 
    4848         if(l)
    4849                 return (struct send_file_data *)l->data;
    4850        
     5094                                      _are_same_yid);
     5095
     5096        if (l) {
     5097                return (struct send_file_data *) l->data;
     5098        }
     5099
    48515100        return NULL;
    48525101}
     
    48595108static void yahoo_remove_active_transfer(struct send_file_data *sfd)
    48605109{
    4861         if (sfd == NULL)
    4862                 return;
    4863        
     5110        if (sfd == NULL) {
     5111                return;
     5112        }
     5113
    48645114        active_file_transfers = y_list_remove(active_file_transfers, sfd);
    48655115        free(sfd->id);
     
    48855135        yid->fd = fd;
    48865136        yid->read_tag =
    4887                 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,
    4888                 YAHOO_INPUT_READ, yid);
     5137                YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd,
     5138                                                        YAHOO_INPUT_READ, yid);
    48895139}
    48905140
    48915141static void yahoo_file_transfer_upload(struct yahoo_data *yd,
    4892         struct send_file_data *sfd)
     5142                                       struct send_file_data *sfd)
    48935143{
    48945144        char url[256];
     
    49095159        recv_enc = yahoo_urlencode(sfd->who);
    49105160
    4911         snprintf(url, sizeof(url), 
    4912                 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
    4913                 token_enc, sender_enc, recv_enc);
     5161        snprintf(url, sizeof(url),
     5162                 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
     5163                 token_enc, sender_enc, recv_enc);
    49145164
    49155165        snprintf(buff, sizeof(buff), "T=%s; Y=%s", yd->cookie_t, yd->cookie_y);
    49165166
    49175167        yahoo_http_post(yd->client_id, url, buff, sfd->size,
    4918                 _yahoo_ft_upload_connected, sfd);
     5168                        _yahoo_ft_upload_connected, sfd);
    49195169
    49205170        FREE(token_enc);
     
    49245174
    49255175static void yahoo_init_ft_recv(struct yahoo_data *yd,
    4926         struct send_file_data *sfd)
     5176                               struct send_file_data *sfd)
    49275177{
    49285178        char url[256];
     
    49435193        recv_enc = yahoo_urlencode(yd->user);
    49445194
    4945         snprintf(url, sizeof(url), 
    4946                 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
    4947                 token_enc, sender_enc, recv_enc);
     5195        snprintf(url, sizeof(url),
     5196                 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
     5197                 token_enc, sender_enc, recv_enc);
    49485198
    49495199        snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
    49505200
    49515201        yahoo_http_head(yid->yd->client_id, url, buff, 0, NULL,
    4952                 _yahoo_http_connected, yid);
     5202                        _yahoo_http_connected, yid);
    49535203
    49545204        FREE(token_enc);
     
    49585208
    49595209static void yahoo_file_transfer_accept(struct yahoo_input_data *yid,
    4960         struct send_file_data *sfd)
     5210                                       struct send_file_data *sfd)
    49615211{
    49625212        struct yahoo_packet *pkt;
    49635213
    49645214        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,
    4965                 YPACKET_STATUS_DEFAULT, yid->yd->session_id);
     5215                               YPACKET_STATUS_DEFAULT, yid->yd->session_id);
    49665216
    49675217        yahoo_packet_hash(pkt, 1, yid->yd->user);
     
    49805230
    49815231static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid,
    4982         struct yahoo_packet *pkt)
     5232                                             struct yahoo_packet *pkt)
    49835233{
    49845234        YList *l;
     
    50165266
    50175267                yahoo_file_transfer_upload(yid->yd, sfd);
    5018         }
    5019         else {
    5020                 YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5021                         (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
    5022                         sfd ? sfd->data : NULL);
     5268        } else {
     5269                YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5270                        (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
     5271                        sfd ? sfd->data : NULL);
    50235272
    50245273                yahoo_remove_active_transfer(sfd);
     
    50275276
    50285277static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid,
    5029         struct yahoo_packet *pkt)
     5278                                           struct yahoo_packet *pkt)
    50305279{
    50315280        YList *l;
     
    50705319
    50715320                yahoo_file_transfer_accept(yid, sfd);
    5072         }
    5073         else {
    5074                 YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5075                         (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
    5076                         sfd ? sfd->data : NULL);
     5321        } else {
     5322                YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5323                        (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN,
     5324                        sfd ? sfd->data : NULL);
    50775325
    50785326                yahoo_remove_active_transfer(sfd);
     
    50815329
    50825330static void yahoo_send_filetransferinfo(struct yahoo_data *yd,
    5083         struct send_file_data *sfd)
     5331                                        struct send_file_data *sfd)
    50845332{
    50855333        struct yahoo_input_data *yid;
     
    50875335
    50885336        yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER);
    5089         sfd->ip_addr = YAHOO_CALLBACK(ext_yahoo_get_ip_addr)("relay.yahoo.com");
     5337        sfd->ip_addr = YAHOO_CALLBACK (ext_yahoo_get_ip_addr)("relay.yahoo.com");
    50905338
    50915339        if (!sfd->ip_addr) {
    5092                 YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5093                         (yd->client_id, YAHOO_FILE_TRANSFER_RELAY, sfd->data);
     5340                YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5341                        (yd->client_id, YAHOO_FILE_TRANSFER_RELAY, sfd->data);
    50945342
    50955343                yahoo_remove_active_transfer(sfd);
     
    50995347
    51005348        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERINFO,
    5101                 YPACKET_STATUS_DEFAULT, yd->session_id);
     5349                               YPACKET_STATUS_DEFAULT, yd->session_id);
    51025350
    51035351        yahoo_packet_hash(pkt, 1, yd->user);
     
    51145362
    51155363static void yahoo_process_filetransfer(struct yahoo_input_data *yid,
    5116         struct yahoo_packet *pkt)
     5364                                       struct yahoo_packet *pkt)
    51175365{
    51185366        YList *l;
     
    51675415                /* Received a FT request from buddy */
    51685416                sfd = y_new0(struct send_file_data, 1);
    5169        
     5417
    51705418                sfd->client_id = yd->client_id;
    51715419                sfd->id = strdup(id);
     
    51735421                sfd->filename = strdup(filename);
    51745422                sfd->size = size;
    5175        
     5423
    51765424                yahoo_add_active_transfer(sfd);
    51775425
    5178                 YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, yd->user,
    5179                         who, msg, filename, size, sfd->id);
    5180         }
    5181         else {
     5426                YAHOO_CALLBACK (ext_yahoo_got_file) (yd->client_id, yd->user,
     5427                                                     who, msg, filename, size, sfd->id);
     5428        } else {
    51825429                /* Response to our request */
    51835430                sfd = yahoo_get_active_transfer(id);
     
    51855432                if (sfd && action == YAHOO_FILE_TRANSFER_ACCEPT) {
    51865433                        yahoo_send_filetransferinfo(yd, sfd);
    5187                 }
    5188                 else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) {
    5189                         YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5190                                 (yd->client_id, YAHOO_FILE_TRANSFER_REJECT,
    5191                                 sfd ? sfd->data : NULL);
     5434                } else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) {
     5435                        YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5436                                (yd->client_id, YAHOO_FILE_TRANSFER_REJECT,