Changeset 5ebff60 for protocols/yahoo


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

Reindent everything to K&R style with tabs

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

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

Location:
protocols/yahoo
Files:
10 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,
     5437                                sfd ? sfd->data : NULL);
    51925438
    51935439                        yahoo_remove_active_transfer(sfd);
     
    51985444#if 0
    51995445void yahoo_send_file(int id, const char *who, const char *msg,
    5200         const char *name, unsigned long size,
    5201         yahoo_get_fd_callback callback, void *data)
     5446                     const char *name, unsigned long size,
     5447                     yahoo_get_fd_callback callback, void *data)
    52025448{
    52035449        struct yahoo_packet *pkt = NULL;
     
    52065452        struct yahoo_data *yd;
    52075453        struct send_file_data *sfd;
    5208        
     5454
    52095455        yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    52105456        yd = find_conn_by_id(id);
     
    52215467        yahoo_add_active_transfer(sfd);
    52225468
    5223         if (!yd)
    5224                 return;
     5469        if (!yd) {
     5470                return;
     5471        }
    52255472
    52265473        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER,
    5227                 YPACKET_STATUS_DEFAULT, yd->session_id);
     5474                               YPACKET_STATUS_DEFAULT, yd->session_id);
    52285475
    52295476        snprintf(size_str, sizeof(size_str), "%ld", size);
     
    52515498        char resp[2];
    52525499        struct yahoo_input_data *yid;
    5253        
     5500
    52545501        struct send_file_data *sfd = yahoo_get_active_transfer(id);
    52555502
     
    52595506
    52605507        pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER,
    5261                 YPACKET_STATUS_DEFAULT, yid->yd->session_id);
     5508                               YPACKET_STATUS_DEFAULT, yid->yd->session_id);
    52625509
    52635510        snprintf(resp, sizeof(resp), "%d", response);
     
    52725519        yahoo_packet_free(pkt);
    52735520
    5274         if(response == YAHOO_FILE_TRANSFER_REJECT)
     5521        if (response == YAHOO_FILE_TRANSFER_REJECT) {
    52755522                yahoo_remove_active_transfer(sfd);
     5523        }
    52765524}
    52775525#endif
     
    52815529        struct send_file_data *sfd;
    52825530        struct yahoo_data *yd = yid->yd;
    5283        
     5531
    52845532        sfd = yahoo_get_active_transfer_with_yid(yid);
    52855533
     
    52895537        }
    52905538
    5291         /* 
     5539        /*
    52925540         * We want to handle only the complete data with HEAD since we don't
    52935541         * want a situation where both the GET and HEAD are active.
    52945542         * With SEND, we really can't do much with partial response
    52955543         */
    5296         if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND)
    5297                         && !over)
    5298                 return;
     5544        if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND)
     5545            && !over) {
     5546                return;
     5547        }
    52995548
    53005549        if (sfd->state == FT_STATE_HEAD) {
     
    53045553                char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL;
    53055554
    5306                 struct yahoo_input_data *yid_ft = 
    5307                         y_new0(struct yahoo_input_data, 1);
    5308        
     5555                struct yahoo_input_data *yid_ft =
     5556                        y_new0(struct yahoo_input_data, 1);
     5557
    53095558                yid_ft->yd = yid->yd;
    53105559                yid_ft->type = YAHOO_CONNECTION_FT;
    5311        
     5560
    53125561                inputs = y_list_prepend(inputs, yid_ft);
    53135562                sfd->yid = yid_ft;
     
    53175566                sender_enc = yahoo_urlencode(sfd->who);
    53185567                recv_enc = yahoo_urlencode(yd->user);
    5319        
    5320                 snprintf(url, sizeof(url), 
    5321                         "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
    5322                         token_enc, sender_enc, recv_enc);
     5568
     5569                snprintf(url, sizeof(url),
     5570                         "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr,
     5571                         token_enc, sender_enc, recv_enc);
    53235572
    53245573                snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y,
    5325                         yd->cookie_t);
     5574                         yd->cookie_t);
    53265575
    53275576
    53285577                yahoo_http_get(yd->client_id, url, buff, 1, 1,
    5329                         _yahoo_http_connected, yid_ft);
     5578                               _yahoo_http_connected, yid_ft);
    53305579
    53315580                FREE(token_enc);
    53325581                FREE(sender_enc);
    53335582                FREE(recv_enc);
    5334         }
    5335         else if (sfd->state == FT_STATE_RECV ||
    5336                 sfd->state == FT_STATE_RECV_START) {
     5583        } else if (sfd->state == FT_STATE_RECV ||
     5584                   sfd->state == FT_STATE_RECV_START) {
    53375585
    53385586                unsigned char *data_begin = NULL;
    53395587
    5340                 if (yid->rxlen == 0)
     5588                if (yid->rxlen == 0) {
    53415589                        yahoo_remove_active_transfer(sfd);
     5590                }
    53425591
    53435592                if (sfd->state != FT_STATE_RECV_START &&
    5344                         (data_begin =
    5345                                 (unsigned char *)strstr((char *)yid->rxqueue,
    5346                                 "\r\n\r\n"))) {
     5593                    (data_begin =
     5594                             (unsigned char *) strstr((char *) yid->rxqueue,
     5595                                                      "\r\n\r\n"))) {
    53475596
    53485597                        sfd->state = FT_STATE_RECV_START;
    53495598
    5350                         yid->rxlen -= 4+(data_begin-yid->rxqueue)/sizeof(char);
     5599                        yid->rxlen -= 4 + (data_begin - yid->rxqueue) / sizeof(char);
    53515600                        data_begin += 4;
    53525601
    5353                         if (yid->rxlen > 0)
    5354                                 YAHOO_CALLBACK(ext_yahoo_got_ft_data)
    5355                                         (yd->client_id, data_begin,
    5356                                         yid->rxlen, sfd->data);
    5357                 }
    5358                 else if (sfd->state == FT_STATE_RECV_START)
    5359                         YAHOO_CALLBACK(ext_yahoo_got_ft_data) (yd->client_id,
    5360                                 yid->rxqueue, yid->rxlen, sfd->data);
     5602                        if (yid->rxlen > 0) {
     5603                                YAHOO_CALLBACK (ext_yahoo_got_ft_data)
     5604                                        (yd->client_id, data_begin,
     5605                                        yid->rxlen, sfd->data);
     5606                        }
     5607                } else if (sfd->state == FT_STATE_RECV_START) {
     5608                        YAHOO_CALLBACK (ext_yahoo_got_ft_data) (yd->client_id,
     5609                                                                yid->rxqueue, yid->rxlen, sfd->data);
     5610                }
    53615611
    53625612                FREE(yid->rxqueue);
    53635613                yid->rxqueue = NULL;
    53645614                yid->rxlen = 0;
    5365         }
    5366         else if (sfd->state == FT_STATE_SEND) {
     5615        } else if (sfd->state == FT_STATE_SEND) {
    53675616                /* Sent file completed */
    53685617                int len = 0;
    5369                 char *off = strstr((char *)yid->rxqueue, "Content-Length: ");
     5618                char *off = strstr((char *) yid->rxqueue, "Content-Length: ");
    53705619
    53715620                if (off) {
     
    53745623                }
    53755624
    5376                 if (len < sfd->size)
    5377                         YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5378                                 (yd->client_id,
    5379                                 YAHOO_FILE_TRANSFER_FAILED, sfd->data);
    5380                 else
    5381                         YAHOO_CALLBACK(ext_yahoo_file_transfer_done)
    5382                                 (yd->client_id,
    5383                                 YAHOO_FILE_TRANSFER_DONE, sfd->data);
     5625                if (len < sfd->size) {
     5626                        YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5627                                (yd->client_id,
     5628                                YAHOO_FILE_TRANSFER_FAILED, sfd->data);
     5629                } else {
     5630                        YAHOO_CALLBACK (ext_yahoo_file_transfer_done)
     5631                                (yd->client_id,
     5632                                YAHOO_FILE_TRANSFER_DONE, sfd->data);
     5633                }
    53845634
    53855635                yahoo_remove_active_transfer(sfd);
     
    53935643{
    53945644        struct yahoo_data *yd = find_conn_by_id(id);
    5395         if (!yd)
     5645
     5646        if (!yd) {
    53965647                return YAHOO_STATUS_OFFLINE;
     5648        }
    53975649        return yd->current_status;
    53985650}
     
    54015653{
    54025654        struct yahoo_data *yd = find_conn_by_id(id);
    5403         if (!yd)
     5655
     5656        if (!yd) {
    54045657                return NULL;
     5658        }
    54055659        return yd->buddies;
    54065660}
     
    54095663{
    54105664        struct yahoo_data *yd = find_conn_by_id(id);
    5411         if (!yd)
     5665
     5666        if (!yd) {
    54125667                return NULL;
     5668        }
    54135669        return yd->ignore;
    54145670}
     
    54175673{
    54185674        struct yahoo_data *yd = find_conn_by_id(id);
    5419         if (!yd)
     5675
     5676        if (!yd) {
    54205677                return NULL;
     5678        }
    54215679        return yd->identities;
    54225680}
     
    54255683{
    54265684        struct yahoo_data *yd = find_conn_by_id(id);
    5427         if (!yd)
     5685
     5686        if (!yd) {
    54285687                return NULL;
    5429         if (!strncasecmp(which, "y", 1))
     5688        }
     5689        if (!strncasecmp(which, "y", 1)) {
    54305690                return yd->cookie_y;
    5431         if (!strncasecmp(which, "b", 1))
     5691        }
     5692        if (!strncasecmp(which, "b", 1)) {
    54325693                return yd->cookie_b;
    5433         if (!strncasecmp(which, "t", 1))
     5694        }
     5695        if (!strncasecmp(which, "t", 1)) {
    54345696                return yd->cookie_t;
    5435         if (!strncasecmp(which, "c", 1))
     5697        }
     5698        if (!strncasecmp(which, "c", 1)) {
    54365699                return yd->cookie_c;
    5437         if (!strncasecmp(which, "login", 5))
     5700        }
     5701        if (!strncasecmp(which, "login", 5)) {
    54385702                return yd->login_cookie;
     5703        }
    54395704        return NULL;
    54405705}
  • protocols/yahoo/yahoo.c

    raf359b4 r5ebff60  
    3535
    3636/* A hack to handle removal of buddies not in the group "Buddies" correctly */
    37 struct byahoo_buddygroups
    38 {
     37struct byahoo_buddygroups {
    3938        char *buddy;
    4039        char *group;
    4140};
    4241
    43 struct byahoo_data
    44 {
     42struct byahoo_data {
    4543        int y2_id;
    4644        int current_status;
     
    4947};
    5048
    51 struct byahoo_input_data
    52 {
     49struct byahoo_input_data {
    5350        int h;
    5451        void *d;
    5552};
    5653
    57 struct byahoo_conf_invitation
    58 {
     54struct byahoo_conf_invitation {
    5955        char *name;
    6056        struct groupchat *c;
     
    6763static int byahoo_chat_id = 0;
    6864
    69 static char *byahoo_strip( const char *in )
     65static char *byahoo_strip(const char *in)
    7066{
    7167        int len;
    72        
     68
    7369        /* This should get rid of the markup noise at the beginning of the string. */
    74         while( *in )
    75         {
    76                 if( g_strncasecmp( in, "<font", 5 ) == 0 ||
    77                     g_strncasecmp( in, "<fade", 5 ) == 0 ||
    78                     g_strncasecmp( in, "<alt", 4 ) == 0 )
    79                 {
    80                         char *s = strchr( in, '>' );
    81                         if( !s )
     70        while (*in) {
     71                if (g_strncasecmp(in, "<font", 5) == 0 ||
     72                    g_strncasecmp(in, "<fade", 5) == 0 ||
     73                    g_strncasecmp(in, "<alt", 4) == 0) {
     74                        char *s = strchr(in, '>');
     75                        if (!s) {
    8276                                break;
    83                        
     77                        }
     78
    8479                        in = s + 1;
    85                 }
    86                 else if( strncmp( in, "\e[", 2 ) == 0 )
    87                 {
     80                } else if (strncmp(in, "\e[", 2) == 0) {
    8881                        const char *s;
    89                        
    90                         for( s = in + 2; *s && *s != 'm'; s ++ );
    91                        
    92                         if( *s != 'm' )
     82
     83                        for (s = in + 2; *s && *s != 'm'; s++) {
     84                                ;
     85                        }
     86
     87                        if (*s != 'm') {
    9388                                break;
    94                        
     89                        }
     90
    9591                        in = s + 1;
    96                 }
    97                 else
    98                 {
     92                } else {
    9993                        break;
    10094                }
    10195        }
    102        
     96
    10397        /* This is supposed to get rid of the noise at the end of the line. */
    104         len = strlen( in );
    105         while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) )
    106         {
     98        len = strlen(in);
     99        while (len > 0 && (in[len - 1] == '>' || in[len - 1] == 'm')) {
    107100                int blen = len;
    108101                const char *search;
    109                
    110                 if( in[len-1] == '>' )
     102
     103                if (in[len - 1] == '>') {
    111104                        search = "</";
    112                 else
     105                } else {
    113106                        search = "\e[";
    114                
     107                }
     108
    115109                len -= 3;
    116                 while( len > 0 && strncmp( in + len, search, 2 ) != 0 )
    117                         len --;
    118                
    119                 if( len <= 0 && strncmp( in, search, 2 ) != 0 )
    120                 {
     110                while (len > 0 && strncmp(in + len, search, 2) != 0) {
     111                        len--;
     112                }
     113
     114                if (len <= 0 && strncmp(in, search, 2) != 0) {
    121115                        len = blen;
    122116                        break;
    123117                }
    124118        }
    125        
    126         return( g_strndup( in, len ) );
    127 }
    128 
    129 static void byahoo_init( account_t *acc )
    130 {
    131         set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
    132        
     119
     120        return(g_strndup(in, len));
     121}
     122
     123static void byahoo_init(account_t *acc)
     124{
     125        set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc);
     126
    133127        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
    134128}
    135129
    136 static void byahoo_login( account_t *acc )
    137 {
    138         struct im_connection *ic = imcb_new( acc );
    139         struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 );
     130static void byahoo_login(account_t *acc)
     131{
     132        struct im_connection *ic = imcb_new(acc);
     133        struct byahoo_data *yd = ic->proto_data = g_new0(struct byahoo_data, 1);
    140134        char *s;
    141        
     135
    142136        yd->logged_in = FALSE;
    143137        yd->current_status = YAHOO_STATUS_AVAILABLE;
    144        
    145         if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 )
    146                 imcb_error( ic, "Your Yahoo! username should just be a username. "
    147                                 "Do not include any @domain part." );
    148        
    149         imcb_log( ic, "Connecting" );
    150         yd->y2_id = yahoo_init( acc->user, acc->pass );
    151         yahoo_login( yd->y2_id, yd->current_status );
    152 }
    153 
    154 static void byahoo_logout( struct im_connection *ic )
     138
     139        if ((s = strchr(acc->user, '@')) && g_strcasecmp(s, "@yahoo.com") == 0) {
     140                imcb_error(ic, "Your Yahoo! username should just be a username. "
     141                           "Do not include any @domain part.");
     142        }
     143
     144        imcb_log(ic, "Connecting");
     145        yd->y2_id = yahoo_init(acc->user, acc->pass);
     146        yahoo_login(yd->y2_id, yd->current_status);
     147}
     148
     149static void byahoo_logout(struct im_connection *ic)
    155150{
    156151        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    157152        GSList *l;
    158        
    159         while( ic->groupchats )
    160                 imcb_chat_free( ic->groupchats->data );
    161        
    162         for( l = yd->buddygroups; l; l = l->next )
    163         {
     153
     154        while (ic->groupchats) {
     155                imcb_chat_free(ic->groupchats->data);
     156        }
     157
     158        for (l = yd->buddygroups; l; l = l->next) {
    164159                struct byahoo_buddygroups *bg = l->data;
    165                
    166                 g_free( bg->buddy );
    167                 g_free( bg->group );
    168                 g_free( bg );
    169         }
    170         g_slist_free( yd->buddygroups );
    171        
    172         yahoo_logoff( yd->y2_id );
    173        
    174         g_free( yd );
    175 }
    176 
    177 static void byahoo_get_info(struct im_connection *ic, char *who) 
     160
     161                g_free(bg->buddy);
     162                g_free(bg->group);
     163                g_free(bg);
     164        }
     165        g_slist_free(yd->buddygroups);
     166
     167        yahoo_logoff(yd->y2_id);
     168
     169        g_free(yd);
     170}
     171
     172static void byahoo_get_info(struct im_connection *ic, char *who)
    178173{
    179174        /* Just make an URL and let the user fetch the info */
    180         imcb_log(ic, "%s\n%s: %s%s", _("User Info"), 
    181                         _("For now, fetch yourself"), yahoo_get_profile_url(),
    182                         who);
    183 }
    184 
    185 static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags )
     175        imcb_log(ic, "%s\n%s: %s%s", _("User Info"),
     176                 _("For now, fetch yourself"), yahoo_get_profile_url(),
     177                 who);
     178}
     179
     180static int byahoo_buddy_msg(struct im_connection *ic, char *who, char *what, int flags)
    186181{
    187182        struct byahoo_data *yd = ic->proto_data;
    188        
    189         yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 );
    190        
     183
     184        yahoo_send_im(yd->y2_id, NULL, who, what, 1, 0);
     185
    191186        return 1;
    192187}
    193188
    194 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing )
     189static int byahoo_send_typing(struct im_connection *ic, char *who, int typing)
    195190{
    196191        struct byahoo_data *yd = ic->proto_data;
    197        
    198         yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0 );
    199        
     192
     193        yahoo_send_typing(yd->y2_id, NULL, who, (typing & OPT_TYPING) != 0);
     194
    200195        return 1;
    201196}
    202197
    203 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg )
     198static void byahoo_set_away(struct im_connection *ic, char *state, char *msg)
    204199{
    205200        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    206        
    207         if( state && msg == NULL )
    208         {
     201
     202        if (state && msg == NULL) {
    209203                /* Use these states only if msg doesn't contain additional
    210204                   info since away messages are only supported with CUSTOM. */
    211                 if( g_strcasecmp( state, "Be Right Back" ) == 0 )
     205                if (g_strcasecmp(state, "Be Right Back") == 0) {
    212206                        yd->current_status = YAHOO_STATUS_BRB;
    213                 else if( g_strcasecmp( state, "Busy" ) == 0 )
     207                } else if (g_strcasecmp(state, "Busy") == 0) {
    214208                        yd->current_status = YAHOO_STATUS_BUSY;
    215                 else if( g_strcasecmp( state, "Not At Home" ) == 0 )
     209                } else if (g_strcasecmp(state, "Not At Home") == 0) {
    216210                        yd->current_status = YAHOO_STATUS_NOTATHOME;
    217                 else if( g_strcasecmp( state, "Not At Desk" ) == 0 )
     211                } else if (g_strcasecmp(state, "Not At Desk") == 0) {
    218212                        yd->current_status = YAHOO_STATUS_NOTATDESK;
    219                 else if( g_strcasecmp( state, "Not In Office" ) == 0 )
     213                } else if (g_strcasecmp(state, "Not In Office") == 0) {
    220214                        yd->current_status = YAHOO_STATUS_NOTINOFFICE;
    221                 else if( g_strcasecmp( state, "On Phone" ) == 0 )
     215                } else if (g_strcasecmp(state, "On Phone") == 0) {
    222216                        yd->current_status = YAHOO_STATUS_ONPHONE;
    223                 else if( g_strcasecmp( state, "On Vacation" ) == 0 )
     217                } else if (g_strcasecmp(state, "On Vacation") == 0) {
    224218                        yd->current_status = YAHOO_STATUS_ONVACATION;
    225                 else if( g_strcasecmp( state, "Out To Lunch" ) == 0 )
     219                } else if (g_strcasecmp(state, "Out To Lunch") == 0) {
    226220                        yd->current_status = YAHOO_STATUS_OUTTOLUNCH;
    227                 else if( g_strcasecmp( state, "Stepped Out" ) == 0 )
     221                } else if (g_strcasecmp(state, "Stepped Out") == 0) {
    228222                        yd->current_status = YAHOO_STATUS_STEPPEDOUT;
    229                 else if( g_strcasecmp( state, "Invisible" ) == 0 )
     223                } else if (g_strcasecmp(state, "Invisible") == 0) {
    230224                        yd->current_status = YAHOO_STATUS_INVISIBLE;
    231                 else
     225                } else {
    232226                        yd->current_status = YAHOO_STATUS_CUSTOM;
    233         }
    234         else if( msg )
     227                }
     228        } else if (msg) {
    235229                yd->current_status = YAHOO_STATUS_CUSTOM;
    236         else
     230        } else {
    237231                yd->current_status = YAHOO_STATUS_AVAILABLE;
    238        
    239         yahoo_set_away( yd->y2_id, yd->current_status, msg, state ? 2 : 0 );
    240 }
    241 
    242 static GList *byahoo_away_states( struct im_connection *ic )
     232        }
     233
     234        yahoo_set_away(yd->y2_id, yd->current_status, msg, state ? 2 : 0);
     235}
     236
     237static GList *byahoo_away_states(struct im_connection *ic)
    243238{
    244239        static GList *m = NULL;
    245240
    246         if( m == NULL )
    247         {
    248                 m = g_list_append( m, "Be Right Back" );
    249                 m = g_list_append( m, "Busy" );
    250                 m = g_list_append( m, "Not At Home" );
    251                 m = g_list_append( m, "Not At Desk" );
    252                 m = g_list_append( m, "Not In Office" );
    253                 m = g_list_append( m, "On Phone" );
    254                 m = g_list_append( m, "On Vacation" );
    255                 m = g_list_append( m, "Out To Lunch" );
    256                 m = g_list_append( m, "Stepped Out" );
    257                 m = g_list_append( m, "Invisible" );
    258         }
    259        
     241        if (m == NULL) {
     242                m = g_list_append(m, "Be Right Back");
     243                m = g_list_append(m, "Busy");
     244                m = g_list_append(m, "Not At Home");
     245                m = g_list_append(m, "Not At Desk");
     246                m = g_list_append(m, "Not In Office");
     247                m = g_list_append(m, "On Phone");
     248                m = g_list_append(m, "On Vacation");
     249                m = g_list_append(m, "Out To Lunch");
     250                m = g_list_append(m, "Stepped Out");
     251                m = g_list_append(m, "Invisible");
     252        }
     253
    260254        return m;
    261255}
    262256
    263 static void byahoo_keepalive( struct im_connection *ic )
     257static void byahoo_keepalive(struct im_connection *ic)
    264258{
    265259        struct byahoo_data *yd = ic->proto_data;
    266        
    267         yahoo_keepalive( yd->y2_id );
    268 }
    269 
    270 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group )
     260
     261        yahoo_keepalive(yd->y2_id);
     262}
     263
     264static void byahoo_add_buddy(struct im_connection *ic, char *who, char *group)
    271265{
    272266        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    273267        bee_user_t *bu;
    274        
    275         if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group )
    276         {
     268
     269        if (group && (bu = bee_user_by_handle(ic->bee, ic, who)) && bu->group) {
    277270                GSList *bgl;
    278                
     271
    279272                /* If the person is in our list already, this is a group change. */
    280                 yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group );
    281                
     273                yahoo_change_buddy_group(yd->y2_id, who, bu->group->name, group);
     274
    282275                /* No idea how often people have people in multiple groups and
    283276                   BitlBee doesn't currently support this anyway .. but keep
    284277                   this struct up-to-date for now. */
    285                 for( bgl = yd->buddygroups; bgl; bgl = bgl->next )
    286                 {
     278                for (bgl = yd->buddygroups; bgl; bgl = bgl->next) {
    287279                        struct byahoo_buddygroups *bg = bgl->data;
    288                        
    289                         if( g_strcasecmp( bg->buddy, who ) == 0 &&
    290                             g_strcasecmp( bg->group, bu->group->name ) == 0 )
    291                         {
    292                                 g_free( bg->group );
    293                                 bg->group = g_strdup( group );
     280
     281                        if (g_strcasecmp(bg->buddy, who) == 0 &&
     282                            g_strcasecmp(bg->group, bu->group->name) == 0) {
     283                                g_free(bg->group);
     284                                bg->group = g_strdup(group);
    294285                        }
    295286                }
    296         }
    297         else
    298                 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
    299 }
    300 
    301 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group )
     287        } else {
     288                yahoo_add_buddy(yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL);
     289        }
     290}
     291
     292static void byahoo_remove_buddy(struct im_connection *ic, char *who, char *group)
    302293{
    303294        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    304295        GSList *bgl;
    305        
    306         yahoo_remove_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP );
    307        
    308         for( bgl = yd->buddygroups; bgl; bgl = bgl->next )
    309         {
     296
     297        yahoo_remove_buddy(yd->y2_id, who, BYAHOO_DEFAULT_GROUP);
     298
     299        for (bgl = yd->buddygroups; bgl; bgl = bgl->next) {
    310300                struct byahoo_buddygroups *bg = bgl->data;
    311                
    312                 if( g_strcasecmp( bg->buddy, who ) == 0 )
    313                         yahoo_remove_buddy( yd->y2_id, who, bg->group );
    314         }
    315 }
    316 
    317 static void byahoo_chat_msg( struct groupchat *c, char *message, int flags )
     301
     302                if (g_strcasecmp(bg->buddy, who) == 0) {
     303                        yahoo_remove_buddy(yd->y2_id, who, bg->group);
     304                }
     305        }
     306}
     307
     308static void byahoo_chat_msg(struct groupchat *c, char *message, int flags)
    318309{
    319310        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    320        
    321         yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );
    322 }
    323 
    324 static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg )
     311
     312        yahoo_conference_message(yd->y2_id, NULL, c->data, c->title, message, 1);
     313}
     314
     315static void byahoo_chat_invite(struct groupchat *c, char *who, char *msg)
    325316{
    326317        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    327        
    328         yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" );
    329 }
    330 
    331 static void byahoo_chat_leave( struct groupchat *c )
     318
     319        yahoo_conference_invite(yd->y2_id, NULL, c->data, c->title, msg ? msg : "");
     320}
     321
     322static void byahoo_chat_leave(struct groupchat *c)
    332323{
    333324        struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;
    334        
    335         yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title );
    336         imcb_chat_free( c );
    337 }
    338 
    339 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who )
     325
     326        yahoo_conference_logoff(yd->y2_id, NULL, c->data, c->title);
     327        imcb_chat_free(c);
     328}
     329
     330static struct groupchat *byahoo_chat_with(struct im_connection *ic, char *who)
    340331{
    341332        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
     
    343334        char *roomname;
    344335        YList *members;
    345        
    346         roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id );
    347        
    348         c = imcb_chat_new( ic, roomname );
    349         imcb_chat_add_buddy( c, ic->acc->user );
    350        
     336
     337        roomname = g_strdup_printf("%s-Bee-%d", ic->acc->user, byahoo_chat_id);
     338
     339        c = imcb_chat_new(ic, roomname);
     340        imcb_chat_add_buddy(c, ic->acc->user);
     341
    351342        /* FIXME: Free this thing when the chat's destroyed. We can't *always*
    352343                  do this because it's not always created here. */
    353         c->data = members = g_new0( YList, 1 );
    354         members->data = g_strdup( who );
    355        
    356         yahoo_conference_invite( yd->y2_id, NULL, members, roomname, "Please join my groupchat..." );
    357        
    358         g_free( roomname );
    359        
     344        c->data = members = g_new0(YList, 1);
     345        members->data = g_strdup(who);
     346
     347        yahoo_conference_invite(yd->y2_id, NULL, members, roomname, "Please join my groupchat...");
     348
     349        g_free(roomname);
     350
    360351        return c;
    361352}
    362353
    363 static void byahoo_auth_allow( struct im_connection *ic, const char *who )
     354static void byahoo_auth_allow(struct im_connection *ic, const char *who)
    364355{
    365356        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    366        
    367         yahoo_confirm_buddy( yd->y2_id, who, 0, "" );
    368 }
    369 
    370 static void byahoo_auth_deny( struct im_connection *ic, const char *who )
     357
     358        yahoo_confirm_buddy(yd->y2_id, who, 0, "");
     359}
     360
     361static void byahoo_auth_deny(struct im_connection *ic, const char *who)
    371362{
    372363        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    373        
    374         yahoo_confirm_buddy( yd->y2_id, who, 1, "" );
    375 }
    376 
    377 void byahoo_initmodule( )
     364
     365        yahoo_confirm_buddy(yd->y2_id, who, 1, "");
     366}
     367
     368void byahoo_initmodule()
    378369{
    379370        struct prpl *ret = g_new0(struct prpl, 1);
     371
    380372        ret->name = "yahoo";
    381     ret->mms = 832;           /* this guess taken from libotr UPGRADING file */
     373        ret->mms = 832;       /* this guess taken from libotr UPGRADING file */
    382374        ret->init = byahoo_init;
    383        
     375
    384376        ret->login = byahoo_login;
    385377        ret->keepalive = byahoo_keepalive;
    386378        ret->logout = byahoo_logout;
    387        
     379
    388380        ret->buddy_msg = byahoo_buddy_msg;
    389381        ret->get_info = byahoo_get_info;
     
    393385        ret->remove_buddy = byahoo_remove_buddy;
    394386        ret->send_typing = byahoo_send_typing;
    395        
     387
    396388        ret->chat_msg = byahoo_chat_msg;
    397389        ret->chat_invite = byahoo_chat_invite;
     
    400392
    401393        ret->handle_cmp = g_strcasecmp;
    402        
     394
    403395        ret->auth_allow = byahoo_auth_allow;
    404396        ret->auth_deny = byahoo_auth_deny;
    405        
     397
    406398        register_protocol(ret);
    407399}
    408400
    409 static struct im_connection *byahoo_get_ic_by_id( int id )
     401static struct im_connection *byahoo_get_ic_by_id(int id)
    410402{
    411403        GSList *l;
    412404        struct im_connection *ic;
    413405        struct byahoo_data *yd;
    414        
    415         for( l = get_connections(); l; l = l->next )
    416         {
     406
     407        for (l = get_connections(); l; l = l->next) {
    417408                ic = l->data;
    418409                yd = ic->proto_data;
    419                
    420                 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )
    421                         return( ic );
    422         }
    423        
    424         return( NULL );
     410
     411                if (strcmp(ic->acc->prpl->name, "yahoo") == 0 && yd->y2_id == id) {
     412                        return(ic);
     413                }
     414        }
     415
     416        return(NULL);
    425417}
    426418
     
    428420/* Now it's callback time! */
    429421
    430 struct byahoo_connect_callback_data
    431 {
     422struct byahoo_connect_callback_data {
    432423        int fd;
    433424        yahoo_connect_callback callback;
     
    436427};
    437428
    438 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond )
     429void byahoo_connect_callback(gpointer data, gint source, b_input_condition cond)
    439430{
    440431        struct byahoo_connect_callback_data *d = data;
    441        
    442         if( !byahoo_get_ic_by_id( d->id ) )
    443         {
    444                 g_free( d );
     432
     433        if (!byahoo_get_ic_by_id(d->id)) {
     434                g_free(d);
    445435                return;
    446436        }
    447        
    448         d->callback( NULL + d->fd, 0, d->data );
    449         g_free( d );
    450 }
    451 
    452 struct byahoo_read_ready_data
    453 {
     437
     438        d->callback(NULL + d->fd, 0, d->data);
     439        g_free(d);
     440}
     441
     442struct byahoo_read_ready_data {
    454443        int id;
    455444        int fd;
     
    458447};
    459448
    460 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond )
     449gboolean byahoo_read_ready_callback(gpointer data, gint source, b_input_condition cond)
    461450{
    462451        struct byahoo_read_ready_data *d = data;
    463        
    464         if( !byahoo_get_ic_by_id( d->id ) )
     452
     453        if (!byahoo_get_ic_by_id(d->id)) {
    465454                /* WTF doesn't libyahoo clean this up? */
    466455                return FALSE;
    467        
    468         yahoo_read_ready( d->id, NULL + d->fd, d->data );
    469        
     456        }
     457
     458        yahoo_read_ready(d->id, NULL + d->fd, d->data);
     459
    470460        return TRUE;
    471461}
    472462
    473 struct byahoo_write_ready_data
    474 {
     463struct byahoo_write_ready_data {
    475464        int id;
    476465        int fd;
     
    479468};
    480469
    481 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond )
     470gboolean byahoo_write_ready_callback(gpointer data, gint source, b_input_condition cond)
    482471{
    483472        struct byahoo_write_ready_data *d = data;
    484        
    485         return yahoo_write_ready( d->id, NULL + d->fd, d->data );
    486 }
    487 
    488 void ext_yahoo_login_response( int id, int succ, const char *url )
    489 {
    490         struct im_connection *ic = byahoo_get_ic_by_id( id );
     473
     474        return yahoo_write_ready(d->id, NULL + d->fd, d->data);
     475}
     476
     477void ext_yahoo_login_response(int id, int succ, const char *url)
     478{
     479        struct im_connection *ic = byahoo_get_ic_by_id(id);
    491480        struct byahoo_data *yd = NULL;
    492        
    493         if( ic == NULL )
    494         {
     481
     482        if (ic == NULL) {
    495483                /* libyahoo2 seems to call this one twice when something
    496484                   went wrong sometimes. Don't know why. Because we clean
    497485                   up the connection on the first failure, the second
    498486                   should be ignored. */
    499                
     487
    500488                return;
    501489        }
    502        
     490
    503491        yd = (struct byahoo_data *) ic->proto_data;
    504        
    505         if( succ == YAHOO_LOGIN_OK )
    506         {
    507                 imcb_connected( ic );
    508                
     492
     493        if (succ == YAHOO_LOGIN_OK) {
     494                imcb_connected(ic);
     495
    509496                yd->logged_in = TRUE;
    510         }
    511         else
    512         {
     497        } else {
    513498                char *errstr;
    514499                int allow_reconnect = FALSE;
    515                
     500
    516501                yd->logged_in = FALSE;
    517                
    518                 if( succ == YAHOO_LOGIN_UNAME )
     502
     503                if (succ == YAHOO_LOGIN_UNAME) {
    519504                        errstr = "Incorrect Yahoo! username";
    520                 else if( succ == YAHOO_LOGIN_PASSWD )
     505                } else if (succ == YAHOO_LOGIN_PASSWD) {
    521506                        errstr = "Incorrect Yahoo! password";
    522                 else if( succ == YAHOO_LOGIN_LOCK )
     507                } else if (succ == YAHOO_LOGIN_LOCK) {
    523508                        errstr = "Yahoo! account locked";
    524                 else if( succ == 1236 )
     509                } else if (succ == 1236) {
    525510                        errstr = "Yahoo! account locked or machine temporarily banned";
    526                 else if( succ == YAHOO_LOGIN_DUPL )
     511                } else if (succ == YAHOO_LOGIN_DUPL) {
    527512                        errstr = "Logged in on a different machine or device";
    528                 else if( succ == YAHOO_LOGIN_SOCK )
    529                 {
     513                } else if (succ == YAHOO_LOGIN_SOCK) {
    530514                        errstr = "Socket problem";
    531515                        allow_reconnect = TRUE;
    532                 }
    533                 else
     516                } else {
    534517                        errstr = "Unknown error";
    535                
    536                 if( url && *url )
    537                         imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url );
    538                 else
    539                         imcb_error( ic, "Error %d (%s)", succ, errstr );
    540                
    541                 imc_logout( ic, allow_reconnect );
    542         }
    543 }
    544 
    545 void ext_yahoo_got_buddies( int id, YList *buds )
    546 {
    547         struct im_connection *ic = byahoo_get_ic_by_id( id );
     518                }
     519
     520                if (url && *url) {
     521                        imcb_error(ic, "Error %d (%s). See %s for more information.", succ, errstr, url);
     522                } else {
     523                        imcb_error(ic, "Error %d (%s)", succ, errstr);
     524                }
     525
     526                imc_logout(ic, allow_reconnect);
     527        }
     528}
     529
     530void ext_yahoo_got_buddies(int id, YList *buds)
     531{
     532        struct im_connection *ic = byahoo_get_ic_by_id(id);
    548533        struct byahoo_data *yd = ic->proto_data;
    549534        YList *bl = buds;
    550        
    551         while( bl )
    552         {
     535
     536        while (bl) {
    553537                struct yahoo_buddy *b = bl->data;
    554538                struct byahoo_buddygroups *bg;
    555                
    556                 if( strcmp( b->group, BYAHOO_DEFAULT_GROUP ) != 0 )
    557                 {
    558                         bg = g_new0( struct byahoo_buddygroups, 1 );
    559                        
    560                         bg->buddy = g_strdup( b->id );
    561                         bg->group = g_strdup( b->group );
    562                         yd->buddygroups = g_slist_append( yd->buddygroups, bg );
    563                 }
    564                
    565                 imcb_add_buddy( ic, b->id, b->group );
    566                 imcb_rename_buddy( ic, b->id, b->real_name );
    567                
     539
     540                if (strcmp(b->group, BYAHOO_DEFAULT_GROUP) != 0) {
     541                        bg = g_new0(struct byahoo_buddygroups, 1);
     542
     543                        bg->buddy = g_strdup(b->id);
     544                        bg->group = g_strdup(b->group);
     545                        yd->buddygroups = g_slist_append(yd->buddygroups, bg);
     546                }
     547
     548                imcb_add_buddy(ic, b->id, b->group);
     549                imcb_rename_buddy(ic, b->id, b->real_name);
     550
    568551                bl = bl->next;
    569552        }
    570553}
    571554
    572 void ext_yahoo_got_identities( int id, YList *ids )
    573 {
    574 }
    575 
    576 void ext_yahoo_got_cookies( int id )
    577 {
    578 }
    579 
    580 void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile )
    581 {
    582         struct im_connection *ic = byahoo_get_ic_by_id( id );
     555void ext_yahoo_got_identities(int id, YList *ids)
     556{
     557}
     558
     559void ext_yahoo_got_cookies(int id)
     560{
     561}
     562
     563void ext_yahoo_status_changed(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile)
     564{
     565        struct im_connection *ic = byahoo_get_ic_by_id(id);
    583566        char *state_string = NULL;
    584567        int flags = OPT_LOGGED_IN;
    585        
    586         if( away )
     568
     569        if (away) {
    587570                flags |= OPT_AWAY;
    588         if( mobile )
     571        }
     572        if (mobile) {
    589573                flags |= OPT_MOBILE;
    590        
    591         switch (stat)
    592         {
     574        }
     575
     576        switch (stat) {
    593577        case YAHOO_STATUS_BRB:
    594578                state_string = "Be Right Back";
     
    632616                break;
    633617        }
    634        
    635         imcb_buddy_status( ic, who, flags, state_string, msg );
    636        
    637         if( stat == YAHOO_STATUS_IDLE )
    638                 imcb_buddy_times( ic, who, 0, idle );
    639 }
    640 
    641 void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm )
    642 {
    643 }
    644 
    645 void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 )
    646 {
    647         struct im_connection *ic = byahoo_get_ic_by_id( id );
     618
     619        imcb_buddy_status(ic, who, flags, state_string, msg);
     620
     621        if (stat == YAHOO_STATUS_IDLE) {
     622                imcb_buddy_times(ic, who, 0, idle);
     623        }
     624}
     625
     626void ext_yahoo_got_buzz(int id, const char *me, const char *who, long tm)
     627{
     628}
     629
     630void ext_yahoo_got_im(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8)
     631{
     632        struct im_connection *ic = byahoo_get_ic_by_id(id);
    648633        char *m;
    649        
    650         if( msg )
    651         {
    652                 m = byahoo_strip( msg );
    653                 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
    654                 g_free( m );
    655         }
    656 }
    657 
    658 void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg,
    659                          const char *fname, unsigned long fesize, char *trid )
    660 {
    661         struct im_connection *ic = byahoo_get_ic_by_id( id );
    662        
    663         imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );
    664 }
    665 
    666 void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data )
    667 {
    668 }
    669 
    670 void ext_yahoo_file_transfer_done( int id, int result, void *data )
    671 {
    672 }
    673 
    674 void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat )
    675 {
    676         struct im_connection *ic = byahoo_get_ic_by_id( id );
    677        
    678         if( stat == 1 )
    679                 imcb_buddy_typing( ic, (char*) who, OPT_TYPING );
    680         else
    681                 imcb_buddy_typing( ic, (char*) who, 0 );
    682 }
    683 
    684 void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg )
    685 {
    686         struct im_connection *ic = byahoo_get_ic_by_id( id );
    687        
    688         imcb_log( ic, "Yahoo! system message: %s", msg );
    689 }
    690 
    691 void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from )
    692 {
    693         struct im_connection *ic = byahoo_get_ic_by_id( id );
    694        
    695         imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );
    696 }
    697 
    698 void ext_yahoo_error( int id, const char *err, int fatal, int num )
    699 {
    700         struct im_connection *ic = byahoo_get_ic_by_id( id );
    701        
    702         imcb_error( ic, "%s", err );
     634
     635        if (msg) {
     636                m = byahoo_strip(msg);
     637                imcb_buddy_msg(ic, (char *) who, (char *) m, 0, 0);
     638                g_free(m);
     639        }
     640}
     641
     642void ext_yahoo_got_file(int id, const char *ignored, const char *who, const char *msg,
     643                        const char *fname, unsigned long fesize, char *trid)
     644{
     645        struct im_connection *ic = byahoo_get_ic_by_id(id);
     646
     647        imcb_log(ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who);
     648}
     649
     650void ext_yahoo_got_ft_data(int id, const unsigned char *in, int len, void *data)
     651{
     652}
     653
     654void ext_yahoo_file_transfer_done(int id, int result, void *data)
     655{
     656}
     657
     658void ext_yahoo_typing_notify(int id, const char *ignored, const char *who, int stat)
     659{
     660        struct im_connection *ic = byahoo_get_ic_by_id(id);
     661
     662        if (stat == 1) {
     663                imcb_buddy_typing(ic, (char *) who, OPT_TYPING);
     664        } else {
     665                imcb_buddy_typing(ic, (char *) who, 0);
     666        }
     667}
     668
     669void ext_yahoo_system_message(int id, const char *me, const char *who, const char *msg)
     670{
     671        struct im_connection *ic = byahoo_get_ic_by_id(id);
     672
     673        imcb_log(ic, "Yahoo! system message: %s", msg);
     674}
     675
     676void ext_yahoo_webcam_invite(int id, const char *ignored, const char *from)
     677{
     678        struct im_connection *ic = byahoo_get_ic_by_id(id);
     679
     680        imcb_log(ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from);
     681}
     682
     683void ext_yahoo_error(int id, const char *err, int fatal, int num)
     684{
     685        struct im_connection *ic = byahoo_get_ic_by_id(id);
     686
     687        imcb_error(ic, "%s", err);
    703688}
    704689
    705690/* TODO: Clear up the mess of inp and d structures */
    706 int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data )
    707 {
    708         struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1 );
     691int ext_yahoo_add_handler(int id, void *fd_, yahoo_input_condition cond, void *data)
     692{
     693        struct byahoo_input_data *inp = g_new0(struct byahoo_input_data, 1);
    709694        int fd = (long) fd_;
    710        
    711         if( cond == YAHOO_INPUT_READ )
    712         {
    713                 struct byahoo_read_ready_data *d = g_new0( struct byahoo_read_ready_data, 1 );
    714                
     695
     696        if (cond == YAHOO_INPUT_READ) {
     697                struct byahoo_read_ready_data *d = g_new0(struct byahoo_read_ready_data, 1);
     698
    715699                d->id = id;
    716700                d->fd = fd;
    717701                d->data = data;
    718                
     702
    719703                inp->d = d;
    720                 d->tag = inp->h = b_input_add( fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
    721         }
    722         else if( cond == YAHOO_INPUT_WRITE )
    723         {
    724                 struct byahoo_write_ready_data *d = g_new0( struct byahoo_write_ready_data, 1 );
    725                
     704                d->tag = inp->h = b_input_add(fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback,
     705                                              (gpointer) d);
     706        } else if (cond == YAHOO_INPUT_WRITE) {
     707                struct byahoo_write_ready_data *d = g_new0(struct byahoo_write_ready_data, 1);
     708
    726709                d->id = id;
    727710                d->fd = fd;
    728711                d->data = data;
    729                
     712
    730713                inp->d = d;
    731                 d->tag = inp->h = b_input_add( fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
    732         }
    733         else
    734         {
    735                 g_free( inp );
     714                d->tag = inp->h =
     715                                 b_input_add(fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback,
     716                                             (gpointer) d);
     717        } else {
     718                g_free(inp);
    736719                return -1;
    737720                /* Panic... */
    738721        }
    739        
    740         byahoo_inputs = g_slist_append( byahoo_inputs, inp );
     722
     723        byahoo_inputs = g_slist_append(byahoo_inputs, inp);
    741724        return inp->h;
    742725}
    743726
    744 void ext_yahoo_remove_handler( int id, int tag )
     727void ext_yahoo_remove_handler(int id, int tag)
    745728{
    746729        struct byahoo_input_data *inp;
    747730        GSList *l = byahoo_inputs;
    748        
    749         while( l )
    750         {
     731
     732        while (l) {
    751733                inp = l->data;
    752                 if( inp->h == tag )
    753                 {
    754                         g_free( inp->d );
    755                         g_free( inp );
    756                         byahoo_inputs = g_slist_remove( byahoo_inputs, inp );
     734                if (inp->h == tag) {
     735                        g_free(inp->d);
     736                        g_free(inp);
     737                        byahoo_inputs = g_slist_remove(byahoo_inputs, inp);
    757738                        break;
    758739                }
    759740                l = l->next;
    760741        }
    761        
    762         b_event_remove( tag );
    763 }
    764 
    765 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl )
     742
     743        b_event_remove(tag);
     744}
     745
     746int ext_yahoo_connect_async(int id, const char *host, int port, yahoo_connect_callback callback, void *data,
     747                            int use_ssl)
    766748{
    767749        struct byahoo_connect_callback_data *d;
    768750        int fd;
    769        
    770         d = g_new0( struct byahoo_connect_callback_data, 1 );
    771         if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 )
    772         {
    773                 g_free( d );
    774                 return( fd );
     751
     752        d = g_new0(struct byahoo_connect_callback_data, 1);
     753        if ((fd = proxy_connect(host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d)) < 0) {
     754                g_free(d);
     755                return(fd);
    775756        }
    776757        d->fd = fd;
     
    778759        d->data = data;
    779760        d->id = id;
    780        
     761
    781762        return fd;
    782763}
    783764
    784 char *ext_yahoo_get_ip_addr( const char *domain )
     765char *ext_yahoo_get_ip_addr(const char *domain)
    785766{
    786767        return NULL;
    787768}
    788769
    789 int ext_yahoo_write( void *fd, char *buf, int len )
    790 {
    791         return write( (long) fd, buf, len );
    792 }
    793 
    794 int ext_yahoo_read( void *fd, char *buf, int len )
    795 {
    796         return read( (long) fd, buf, len );
    797 }
    798 
    799 void ext_yahoo_close( void *fd )
    800 {
    801         close( (long) fd );
    802 }
    803 
    804 void ext_yahoo_got_buddy_change_group( int id, const char *me, const char *who,
    805                                        const char *old_group, const char *new_group )
    806 {
    807         struct im_connection *ic = byahoo_get_ic_by_id( id );
    808        
    809         imcb_add_buddy( ic, who, new_group );
    810 }
    811 
    812 static void byahoo_accept_conf( void *data )
     770int ext_yahoo_write(void *fd, char *buf, int len)
     771{
     772        return write((long) fd, buf, len);
     773}
     774
     775int ext_yahoo_read(void *fd, char *buf, int len)
     776{
     777        return read((long) fd, buf, len);
     778}
     779
     780void ext_yahoo_close(void *fd)
     781{
     782        close((long) fd);
     783}
     784
     785void ext_yahoo_got_buddy_change_group(int id, const char *me, const char *who,
     786                                      const char *old_group, const char *new_group)
     787{
     788        struct im_connection *ic = byahoo_get_ic_by_id(id);
     789
     790        imcb_add_buddy(ic, who, new_group);
     791}
     792
     793static void byahoo_accept_conf(void *data)
    813794{
    814795        struct byahoo_conf_invitation *inv = data;
    815796        struct groupchat *b = NULL;
    816797        GSList *l;
    817        
    818         for( l = inv->ic->groupchats; l; l = l->next )
    819         {
     798
     799        for (l = inv->ic->groupchats; l; l = l->next) {
    820800                b = l->data;
    821                 if( b == inv->c )
     801                if (b == inv->c) {
    822802                        break;
    823         }
    824        
    825         if( b != NULL )
    826         {
    827                 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name );
    828                 imcb_chat_add_buddy( inv->c, inv->ic->acc->user );
    829         }
    830         else
    831         {
    832                 imcb_log( inv->ic, "Duplicate/corrupted invitation to `%s'.", inv->name );
    833         }
    834        
    835         g_free( inv->name );
    836         g_free( inv );
    837 }
    838 
    839 static void byahoo_reject_conf( void *data )
     803                }
     804        }
     805
     806        if (b != NULL) {
     807                yahoo_conference_logon(inv->yid, NULL, inv->members, inv->name);
     808                imcb_chat_add_buddy(inv->c, inv->ic->acc->user);
     809        } else {
     810                imcb_log(inv->ic, "Duplicate/corrupted invitation to `%s'.", inv->name);
     811        }
     812
     813        g_free(inv->name);
     814        g_free(inv);
     815}
     816
     817static void byahoo_reject_conf(void *data)
    840818{
    841819        struct byahoo_conf_invitation *inv = data;
    842        
    843         yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" );
    844         imcb_chat_free( inv->c );
    845         g_free( inv->name );
    846         g_free( inv );
    847 }
    848 
    849 void ext_yahoo_got_conf_invite( int id, const char *ignored,
    850                                 const char *who, const char *room, const char *msg, YList *members )
    851 {
    852         struct im_connection *ic = byahoo_get_ic_by_id( id );
     820
     821        yahoo_conference_decline(inv->yid, NULL, inv->members, inv->name, "User rejected groupchat");
     822        imcb_chat_free(inv->c);
     823        g_free(inv->name);
     824        g_free(inv);
     825}
     826
     827void ext_yahoo_got_conf_invite(int id, const char *ignored,
     828                               const char *who, const char *room, const char *msg, YList *members)
     829{
     830        struct im_connection *ic = byahoo_get_ic_by_id(id);
    853831        struct byahoo_conf_invitation *inv;
    854832        char txt[1024];
    855833        YList *m;
    856        
    857         if( g_strcasecmp( who, ic->acc->user ) == 0 )
     834
     835        if (g_strcasecmp(who, ic->acc->user) == 0) {
    858836                /* WTF, Yahoo! seems to echo these now? */
    859837                return;
    860        
    861         inv = g_malloc( sizeof( struct byahoo_conf_invitation ) );
    862         memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
    863         inv->name = g_strdup( room );
    864         inv->c = imcb_chat_new( ic, (char*) room );
     838        }
     839
     840        inv = g_malloc(sizeof(struct byahoo_conf_invitation));
     841        memset(inv, 0, sizeof(struct byahoo_conf_invitation));
     842        inv->name = g_strdup(room);
     843        inv->c = imcb_chat_new(ic, (char *) room);
    865844        inv->c->data = members;
    866845        inv->yid = id;
    867846        inv->members = members;
    868847        inv->ic = ic;
    869        
    870         for( m = members; m; m = m->next )
    871                 if( g_strcasecmp( m->data, ic->acc->user ) != 0 )
    872                         imcb_chat_add_buddy( inv->c, m->data );
    873        
    874         g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg );
    875        
    876         imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf );
    877 }
    878 
    879 void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg )
    880 {
    881         struct im_connection *ic = byahoo_get_ic_by_id( id );
    882        
    883         imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg );
    884 }
    885 
    886 void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room )
    887 {
    888         struct im_connection *ic = byahoo_get_ic_by_id( id );
    889         struct groupchat *c = bee_chat_by_title( ic->bee, ic, room );
    890        
    891         if( c )
    892                 imcb_chat_add_buddy( c, (char*) who );
    893 }
    894 
    895 void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room )
    896 
    897 {
    898         struct im_connection *ic = byahoo_get_ic_by_id( id );
    899         struct groupchat *c = bee_chat_by_title( ic->bee, ic, room );
    900        
    901         if( c )
    902                 imcb_chat_remove_buddy( c, (char*) who, "" );
    903 }
    904 
    905 void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 )
    906 {
    907         struct im_connection *ic = byahoo_get_ic_by_id( id );
    908         char *m = byahoo_strip( msg );
    909         struct groupchat *c = bee_chat_by_title( ic->bee, ic, room );
    910        
    911         if( c )
    912                 imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 );
    913         g_free( m );
    914 }
    915 
    916 void ext_yahoo_chat_cat_xml( int id, const char *xml )
    917 {
    918 }
    919 
    920 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd )
    921 {
    922 }
    923 
    924 void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who )
     848
     849        for (m = members; m; m = m->next) {
     850                if (g_strcasecmp(m->data, ic->acc->user) != 0) {
     851                        imcb_chat_add_buddy(inv->c, m->data);
     852                }
     853        }
     854
     855        g_snprintf(txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg);
     856
     857        imcb_ask(ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf);
     858}
     859
     860void ext_yahoo_conf_userdecline(int id, const char *ignored, const char *who, const char *room, const char *msg)
     861{
     862        struct im_connection *ic = byahoo_get_ic_by_id(id);
     863
     864        imcb_log(ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg);
     865}
     866
     867void ext_yahoo_conf_userjoin(int id, const char *ignored, const char *who, const char *room)
     868{
     869        struct im_connection *ic = byahoo_get_ic_by_id(id);
     870        struct groupchat *c = bee_chat_by_title(ic->bee, ic, room);
     871
     872        if (c) {
     873                imcb_chat_add_buddy(c, (char *) who);
     874        }
     875}
     876
     877void ext_yahoo_conf_userleave(int id, const char *ignored, const char *who, const char *room)
     878
     879{
     880        struct im_connection *ic = byahoo_get_ic_by_id(id);
     881        struct groupchat *c = bee_chat_by_title(ic->bee, ic, room);
     882
     883        if (c) {
     884                imcb_chat_remove_buddy(c, (char *) who, "");
     885        }
     886}
     887
     888void ext_yahoo_conf_message(int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8)
     889{
     890        struct im_connection *ic = byahoo_get_ic_by_id(id);
     891        char *m = byahoo_strip(msg);
     892        struct groupchat *c = bee_chat_by_title(ic->bee, ic, room);
     893
     894        if (c) {
     895                imcb_chat_msg(c, (char *) who, (char *) m, 0, 0);
     896        }
     897        g_free(m);
     898}
     899
     900void ext_yahoo_chat_cat_xml(int id, const char *xml)
     901{
     902}
     903
     904void ext_yahoo_chat_join(int id, const char *who, const char *room, const char *topic, YList *members, void *fd)
     905{
     906}
     907
     908void ext_yahoo_chat_userjoin(int id, const char *me, const char *room, struct yahoo_chat_member *who)
    925909{
    926910        free(who->id);
    927911        free(who->alias);
    928912        free(who->location);
    929         free(who);
    930 }
    931 
    932 void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who )
    933 {
    934 }
    935 
    936 void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 )
    937 {
    938 }
    939 
    940 void ext_yahoo_chat_yahoologout( int id, const char *me )
    941 {
    942 }
    943 
    944 void ext_yahoo_chat_yahooerror( int id, const char *me )
    945 {
    946 }
    947 
    948 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
    949 {
    950         struct im_connection *ic = byahoo_get_ic_by_id( id );
    951        
    952         imcb_ask_auth( ic, who, msg );
    953 }
    954 
    955 void ext_yahoo_rejected( int id, const char *who, const char *msg )
    956 {
    957 }
    958 
    959 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg )
    960 {
    961 }
    962 
    963 void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt )
    964 {
    965         struct im_connection *ic = byahoo_get_ic_by_id( id );
    966        
    967         if( !set_getbool( &ic->acc->set, "mail_notifications" ) )
     913        free(who);
     914}
     915
     916void ext_yahoo_chat_userleave(int id, const char *me, const char *room, const char *who)
     917{
     918}
     919
     920void ext_yahoo_chat_message(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype,
     921                            int utf8)
     922{
     923}
     924
     925void ext_yahoo_chat_yahoologout(int id, const char *me)
     926{
     927}
     928
     929void ext_yahoo_chat_yahooerror(int id, const char *me)
     930{
     931}
     932
     933void ext_yahoo_contact_added(int id, const char *myid, const char *who, const char *msg)
     934{
     935        struct im_connection *ic = byahoo_get_ic_by_id(id);
     936
     937        imcb_ask_auth(ic, who, msg);
     938}
     939
     940void ext_yahoo_rejected(int id, const char *who, const char *msg)
     941{
     942}
     943
     944void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, const char *msg)
     945{
     946}
     947
     948void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt)
     949{
     950        struct im_connection *ic = byahoo_get_ic_by_id(id);
     951
     952        if (!set_getbool(&ic->acc->set, "mail_notifications")) {
    968953                ; /* The user doesn't care. */
    969         else if( from && subj )
    970                 imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj );
    971         else if( cnt > 0 )
    972                 imcb_log( ic, "Received %d new e-mails", cnt );
    973 }
    974 
    975 void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept )
    976 {
    977 }
    978 
    979 void ext_yahoo_webcam_closed( int id, const char *who, int reason )
    980 {
    981 }
    982 
    983 void ext_yahoo_got_search_result( int id, int found, int start, int total, YList *contacts )
    984 {
    985 }
    986 
    987 void ext_yahoo_webcam_viewer( int id, const char *who, int connect )
    988 {
    989 }
    990 
    991 void ext_yahoo_webcam_data_request( int id, int send )
    992 {
    993 }
    994 
    995 int ext_yahoo_log( const char *fmt, ... )
    996 {
    997         return( 0 );
    998 }
    999 
    1000 void ext_yahoo_got_webcam_image( int id, const char * who, const unsigned char *image, unsigned int image_size, unsigned int real_size, unsigned int timestamp )
    1001 {
    1002 }
    1003 
    1004 void ext_yahoo_got_ping( int id, const char *msg )
    1005 {
    1006 }
    1007 
    1008 void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {}
    1009 void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {}
    1010 
    1011 void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){}
    1012 void ext_yahoo_buddyicon_uploaded(int id, const char *url){}
     954        } else if (from && subj) {
     955                imcb_log(ic, "Received e-mail message from %s with subject `%s'", from, subj);
     956        } else if (cnt > 0) {
     957                imcb_log(ic, "Received %d new e-mails", cnt);
     958        }
     959}
     960
     961void ext_yahoo_webcam_invite_reply(int id, const char *me, const char *from, int accept)
     962{
     963}
     964
     965void ext_yahoo_webcam_closed(int id, const char *who, int reason)
     966{
     967}
     968
     969void ext_yahoo_got_search_result(int id, int found, int start, int total, YList *contacts)
     970{
     971}
     972
     973void ext_yahoo_webcam_viewer(int id, const char *who, int connect)
     974{
     975}
     976
     977void ext_yahoo_webcam_data_request(int id, int send)
     978{
     979}
     980
     981int ext_yahoo_log(const char *fmt, ...)
     982{
     983        return(0);
     984}
     985
     986void ext_yahoo_got_webcam_image(int id, const char * who, const unsigned char *image, unsigned int image_size,
     987                                unsigned int real_size, unsigned int timestamp)
     988{
     989}
     990
     991void ext_yahoo_got_ping(int id, const char *msg)
     992{
     993}
     994
     995void ext_yahoo_got_buddyicon(int id, const char *me, const char *who, const char *url, int checksum)
     996{
     997}
     998void ext_yahoo_got_buddyicon_checksum(int id, const char *me, const char *who, int checksum)
     999{
     1000}
     1001
     1002void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who)
     1003{
     1004}
     1005void ext_yahoo_buddyicon_uploaded(int id, const char *url)
     1006{
     1007}
  • protocols/yahoo/yahoo2.h

    raf359b4 r5ebff60  
    3030#include "bitlbee.h"
    3131#undef free
    32 #define free( x )               g_free( x )
     32#define free(x)               g_free(x)
    3333#undef malloc
    34 #define malloc( x )             g_malloc( x )
     34#define malloc(x)             g_malloc(x)
    3535#undef calloc
    36 #define calloc( x, y )          g_calloc( x, y )
     36#define calloc(x, y)          g_calloc(x, y)
    3737#undef realloc
    38 #define realloc( x, y )         g_realloc( x, y )
     38#define realloc(x, y)         g_realloc(x, y)
    3939#undef strdup
    40 #define strdup( x )             g_strdup( x )
     40#define strdup(x)             g_strdup(x)
    4141#undef strndup
    42 #define strndup( x,y )          g_strndup( x,y )
     42#define strndup(x, y)          g_strndup(x, y)
    4343#undef snprintf
    4444// #define snprintf( x... )     g_snprintf( x )
    4545#undef strcasecmp
    46 #define strcasecmp( x,y )       g_strcasecmp( x,y )
     46#define strcasecmp(x, y)       g_strcasecmp(x, y)
    4747#undef strncasecmp
    48 #define strncasecmp( x,y,z )    g_strncasecmp( x,y,z )
     48#define strncasecmp(x, y, z)    g_strncasecmp(x, y, z)
    4949
    5050
     
    5252
    5353/* returns the socket descriptor object for a given pager connection. shouldn't be needed */
    54         void *yahoo_get_fd(int id);
     54void *yahoo_get_fd(int id);
    5555
    5656/* says how much logging to do */
    5757/* see yahoo2_types.h for the different values */
    58         int yahoo_set_log_level(enum yahoo_log_level level);
    59         enum yahoo_log_level yahoo_get_log_level(void);
     58int yahoo_set_log_level(enum yahoo_log_level level);
     59enum yahoo_log_level yahoo_get_log_level(void);
    6060
    6161/* these functions should be self explanatory */
     
    6767/* you must call init before calling any other function */
    6868/*
    69  * The optional parameters to init are key/value pairs that specify 
     69 * The optional parameters to init are key/value pairs that specify
    7070 * server settings to use.  This list must be NULL terminated - even
    7171 * if the list is empty.  If a parameter isn't set, a default value
     
    7474 * are copied, so you can use const/auto/static/pointers/whatever
    7575 * you want.  Parameters are:
    76  *      NAME                    TYPE            DEFAULT
     76 *      NAME                    TYPE            DEFAULT
    7777 *      pager_host              char *          scs.msg.yahoo.com
    7878 *      pager_port              int             5050
     
    8787 * You should set at least local_host if you intend to use webcams
    8888 */
    89         int yahoo_init_with_attributes(const char *username,
    90                 const char *password, ...);
     89int yahoo_init_with_attributes(const char *username,
     90                               const char *password, ...);
    9191
    9292/* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults
    9393 * for all attributes */
    94         int yahoo_init(const char *username, const char *password);
     94int yahoo_init(const char *username, const char *password);
    9595
    9696/* release all resources held by this session */
    9797/* you need to call yahoo_close for a session only if
    9898 * yahoo_logoff is never called for it (ie, it was never logged in) */
    99         void yahoo_close(int id);
     99void yahoo_close(int id);
    100100/* login logs in to the server */
    101101/* initial is of type enum yahoo_status.  see yahoo2_types.h */
    102         void yahoo_login(int id, int initial);
    103         void yahoo_logoff(int id);
     102void yahoo_login(int id, int initial);
     103void yahoo_logoff(int id);
    104104/* reloads status of all buddies */
    105         void yahoo_refresh(int id);
     105void yahoo_refresh(int id);
    106106/* activates/deactivates an identity */
    107         void yahoo_set_identity_status(int id, const char *identity,
    108                 int active);
     107void yahoo_set_identity_status(int id, const char *identity,
     108                               int active);
    109109/* regets the entire buddy list from the server */
    110         void yahoo_get_list(int id);
     110void yahoo_get_list(int id);
    111111/* download buddy contact information from your yahoo addressbook */
    112         void yahoo_get_yab(int id);
     112void yahoo_get_yab(int id);
    113113/* add/modify an address book entry.  if yab->dbid is set, it will */
    114114/* modify that entry else it creates a new entry */
    115         void yahoo_set_yab(int id, struct yab *yab);
    116         void yahoo_keepalive(int id);
    117         void yahoo_chat_keepalive(int id);
     115void yahoo_set_yab(int id, struct yab *yab);
     116void yahoo_keepalive(int id);
     117void yahoo_chat_keepalive(int id);
    118118
    119119/* from is the identity you're sending from.  if NULL, the default is used */
    120120/* utf8 is whether msg is a utf8 string or not. */
    121         void yahoo_send_im(int id, const char *from, const char *who,
    122                 const char *msg, int utf8, int picture);
     121void yahoo_send_im(int id, const char *from, const char *who,
     122                   const char *msg, int utf8, int picture);
    123123//      void yahoo_send_buzz(int id, const char *from, const char *who);
    124124/* if type is true, send typing notice, else send stopped typing notice */
    125         void yahoo_send_typing(int id, const char *from, const char *who,
    126                 int typ);
     125void yahoo_send_typing(int id, const char *from, const char *who,
     126                       int typ);
    127127
    128128/* used to set away/back status. */
    129129/* away says whether the custom message is an away message or a sig */
    130         void yahoo_set_away(int id, enum yahoo_status state, const char *msg,
    131                 int away);
    132 
    133         void yahoo_add_buddy(int id, const char *who, const char *group,
    134                 const char *msg);
    135         void yahoo_remove_buddy(int id, const char *who, const char *group);
    136         void yahoo_confirm_buddy(int id, const char *who, int reject,
    137                 const char *msg);
    138         void yahoo_stealth_buddy(int id, const char *who, int unstealth);
     130void yahoo_set_away(int id, enum yahoo_status state, const char *msg,
     131                    int away);
     132
     133void yahoo_add_buddy(int id, const char *who, const char *group,
     134                     const char *msg);
     135void yahoo_remove_buddy(int id, const char *who, const char *group);
     136void yahoo_confirm_buddy(int id, const char *who, int reject,
     137                         const char *msg);
     138void yahoo_stealth_buddy(int id, const char *who, int unstealth);
    139139/* if unignore is true, unignore, else ignore */
    140         void yahoo_ignore_buddy(int id, const char *who, int unignore);
    141         void yahoo_change_buddy_group(int id, const char *who,
    142                 const char *old_group, const char *new_group);
    143         void yahoo_group_rename(int id, const char *old_group,
    144                 const char *new_group);
    145 
    146         void yahoo_conference_invite(int id, const char *from, YList *who,
    147                 const char *room, const char *msg);
    148         void yahoo_conference_addinvite(int id, const char *from,
    149                 const char *who, const char *room, const YList *members,
    150                 const char *msg);
    151         void yahoo_conference_decline(int id, const char *from, YList *who,
    152                 const char *room, const char *msg);
    153         void yahoo_conference_message(int id, const char *from, YList *who,
    154                 const char *room, const char *msg, int utf8);
    155         void yahoo_conference_logon(int id, const char *from, YList *who,
    156                 const char *room);
    157         void yahoo_conference_logoff(int id, const char *from, YList *who,
    158                 const char *room);
     140void yahoo_ignore_buddy(int id, const char *who, int unignore);
     141void yahoo_change_buddy_group(int id, const char *who,
     142                              const char *old_group, const char *new_group);
     143void yahoo_group_rename(int id, const char *old_group,
     144                        const char *new_group);
     145
     146void yahoo_conference_invite(int id, const char *from, YList *who,
     147                             const char *room, const char *msg);
     148void yahoo_conference_addinvite(int id, const char *from,
     149                                const char *who, const char *room, const YList *members,
     150                                const char *msg);
     151void yahoo_conference_decline(int id, const char *from, YList *who,
     152                              const char *room, const char *msg);
     153void yahoo_conference_message(int id, const char *from, YList *who,
     154                              const char *room, const char *msg, int utf8);
     155void yahoo_conference_logon(int id, const char *from, YList *who,
     156                            const char *room);
     157void yahoo_conference_logoff(int id, const char *from, YList *who,
     158                             const char *room);
    159159
    160160/* Get a list of chatrooms */
    161         void yahoo_get_chatrooms(int id, int chatroomid);
     161void yahoo_get_chatrooms(int id, int chatroomid);
    162162/* join room with specified roomname and roomid */
    163         void yahoo_chat_logon(int id, const char *from, const char *room,
    164                 const char *roomid);
     163void yahoo_chat_logon(int id, const char *from, const char *room,
     164                      const char *roomid);
    165165/* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */
    166         void yahoo_chat_message(int id, const char *from, const char *room,
    167                 const char *msg, const int msgtype, const int utf8);
     166void yahoo_chat_message(int id, const char *from, const char *room,
     167                        const char *msg, const int msgtype, const int utf8);
    168168/* Log off chat */
    169         void yahoo_chat_logoff(int id, const char *from);
     169void yahoo_chat_logoff(int id, const char *from);
    170170
    171171/* requests a webcam feed */
    172172/* who is the person who's webcam you would like to view */
    173173/* if who is null, then you're the broadcaster */
    174         void yahoo_webcam_get_feed(int id, const char *who);
    175         void yahoo_webcam_close_feed(int id, const char *who);
     174void yahoo_webcam_get_feed(int id, const char *who);
     175void yahoo_webcam_close_feed(int id, const char *who);
    176176
    177177/* sends an image when uploading */
     
    179179/* in bytes. The timestamp is the time in milliseconds since we started the */
    180180/* webcam. */
    181         void yahoo_webcam_send_image(int id, unsigned char *image,
    182                 unsigned int length, unsigned int timestamp);
     181void yahoo_webcam_send_image(int id, unsigned char *image,
     182                             unsigned int length, unsigned int timestamp);
    183183
    184184/* this function should be called if we want to allow a user to watch the */
    185185/* webcam. Who is the user we want to accept. */
    186186/* Accept user (accept = 1), decline user (accept = 0) */
    187         void yahoo_webcam_accept_viewer(int id, const char *who, int accept);
     187void yahoo_webcam_accept_viewer(int id, const char *who, int accept);
    188188
    189189/* send an invitation to a user to view your webcam */
    190         void yahoo_webcam_invite(int id, const char *who);
     190void yahoo_webcam_invite(int id, const char *who);
    191191
    192192/* will set up a connection and initiate file transfer.
     
    194194 * the file data to
    195195 */
    196         void yahoo_send_file(int id, const char *who, const char *msg,
    197                 const char *name, unsigned long size,
    198                 yahoo_get_fd_callback callback, void *data);
     196void yahoo_send_file(int id, const char *who, const char *msg,
     197                     const char *name, unsigned long size,
     198                     yahoo_get_fd_callback callback, void *data);
    199199
    200200/*
     
    202202 * since that is your only chance to recognize future callbacks
    203203 */
    204         void yahoo_send_file_transfer_response(int client_id, int response,
    205                 char *id, void *data);
     204void yahoo_send_file_transfer_response(int client_id, int response,
     205                                       char *id, void *data);
    206206
    207207
    208208/* send a search request
    209209 */
    210         void yahoo_search(int id, enum yahoo_search_type t, const char *text,
    211                 enum yahoo_search_gender g, enum yahoo_search_agerange ar,
    212                 int photo, int yahoo_only);
     210void yahoo_search(int id, enum yahoo_search_type t, const char *text,
     211                  enum yahoo_search_gender g, enum yahoo_search_agerange ar,
     212                  int photo, int yahoo_only);
    213213
    214214/* continue last search
     
    217217 * where the above three are passed to ext_yahoo_got_search_result
    218218 */
    219         void yahoo_search_again(int id, int start);
     219void yahoo_search_again(int id, int start);
    220220
    221221/* these should be called when input is available on a fd */
    222222/* registered by ext_yahoo_add_handler */
    223223/* if these return negative values, errno may be set */
    224         int yahoo_read_ready(int id, void *fd, void *data);
    225         int yahoo_write_ready(int id, void *fd, void *data);
     224int yahoo_read_ready(int id, void *fd, void *data);
     225int yahoo_write_ready(int id, void *fd, void *data);
    226226
    227227/* utility functions. these do not hit the server */
    228         enum yahoo_status yahoo_current_status(int id);
    229         const YList *yahoo_get_buddylist(int id);
    230         const YList *yahoo_get_ignorelist(int id);
    231         const YList *yahoo_get_identities(int id);
     228enum yahoo_status yahoo_current_status(int id);
     229const YList *yahoo_get_buddylist(int id);
     230const YList *yahoo_get_ignorelist(int id);
     231const YList *yahoo_get_identities(int id);
    232232/* 'which' could be y, t, c or login.  This may change in later versions. */
    233         const char *yahoo_get_cookie(int id, const char *which);
     233const char *yahoo_get_cookie(int id, const char *which);
    234234
    235235/* returns the url used to get user profiles - you must append the user id */
    236236/* as of now this is http://profiles.yahoo.com/ */
    237237/* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */
    238         const char *yahoo_get_profile_url(void);
    239 
    240         void yahoo_buddyicon_request(int id, const char *who);
     238const char *yahoo_get_profile_url(void);
     239
     240void yahoo_buddyicon_request(int id, const char *who);
    241241
    242242#include "yahoo_httplib.h"
  • protocols/yahoo/yahoo2_callbacks.h

    raf359b4 r5ebff60  
    4545 */
    4646
    47         typedef enum {
    48                 YAHOO_INPUT_READ = 1 << 0,
    49                 YAHOO_INPUT_WRITE = 1 << 1,
    50                 YAHOO_INPUT_EXCEPTION = 1 << 2
    51         } yahoo_input_condition;
     47typedef enum {
     48        YAHOO_INPUT_READ = 1 << 0,
     49                YAHOO_INPUT_WRITE = 1 << 1,
     50                YAHOO_INPUT_EXCEPTION = 1 << 2
     51} yahoo_input_condition;
    5252
    5353/*
    5454 * A callback function called when an asynchronous connect completes.
    55  * 
    56  * Params:
    57  *     fd    - The file descriptor object that has been connected, or NULL on 
     55 *
     56 * Params:
     57 *     fd    - The file descriptor object that has been connected, or NULL on
    5858 *             error
    5959 *     error - The value of errno set by the call to connect or 0 if no error
     
    6363 *             function
    6464 */
    65         typedef void (*yahoo_connect_callback) (void *fd, int error,
    66                 void *callback_data);
     65typedef void (*yahoo_connect_callback) (void *fd, int error,
     66                                        void *callback_data);
    6767
    6868/*
     
    7272 */
    7373
    74 /* 
     74/*
    7575 * should we use a callback structure or directly call functions
    7676 * if you want the structure, you *must* define USE_STRUCT_CALLBACKS
     
    8080
    8181#ifdef USE_STRUCT_CALLBACKS
    82 #define YAHOO_CALLBACK_TYPE(x)  (*x)
     82#define YAHOO_CALLBACK_TYPE(x)  (*x)
    8383struct yahoo_callbacks {
    8484#else
    85 #define YAHOO_CALLBACK_TYPE(x)  x
     85#define YAHOO_CALLBACK_TYPE(x)  x
    8686#endif
    8787
    8888/*
    8989 * Name: ext_yahoo_login_response
    90  *      Called when the login process is complete
    91  * Params:
    92  *      id   - the id that identifies the server connection
    93  *      succ - enum yahoo_login_status
    94  *      url  - url to reactivate account if locked
     90 *      Called when the login process is complete
     91 * Params:
     92 *      id   - the id that identifies the server connection
     93 *      succ - enum yahoo_login_status
     94 *      url  - url to reactivate account if locked
    9595 */
    9696        void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ,
    97                 const char *url);
     97                                                            const char *url);
    9898
    9999/*
    100100 * Name: ext_yahoo_got_buddies
    101  *      Called when the contact list is got from the server
    102  * Params:
    103  *      id   - the id that identifies the server connection
    104  *      buds - the buddy list
     101 *      Called when the contact list is got from the server
     102 * Params:
     103 *      id   - the id that identifies the server connection
     104 *      buds - the buddy list
    105105 */
    106106        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds);
     
    108108/*
    109109 * Name: ext_yahoo_got_ignore
    110  *      Called when the ignore list is got from the server
    111  * Params:
    112  *      id   - the id that identifies the server connection
    113  *      igns - the ignore list
     110 *      Called when the ignore list is got from the server
     111 * Params:
     112 *      id   - the id that identifies the server connection
     113 *      igns - the ignore list
    114114 */
    115115//      void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns);
     
    117117/*
    118118 * Name: ext_yahoo_got_identities
    119  *      Called when the contact list is got from the server
    120  * Params:
    121  *      id   - the id that identifies the server connection
    122  *      ids  - the identity list
     119 *      Called when the contact list is got from the server
     120 * Params:
     121 *      id   - the id that identifies the server connection
     122 *      ids  - the identity list
    123123 */
    124124        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids);
     
    126126/*
    127127 * Name: ext_yahoo_got_cookies
    128  *      Called when the cookie list is got from the server
    129  * Params:
    130  *      id   - the id that identifies the server connection
     128 *      Called when the cookie list is got from the server
     129 * Params:
     130 *      id   - the id that identifies the server connection
    131131 */
    132132        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id);
     
    134134/*
    135135 * Name: ext_yahoo_got_ping
    136  *      Called when the ping packet is received from the server
    137  * Params:
    138  *      id   - the id that identifies the server connection
     136 *      Called when the ping packet is received from the server
     137 * Params:
     138 *      id   - the id that identifies the server connection
    139139 *  errormsg - optional error message
    140140 */
    141141        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id,
    142                 const char *errormsg);
     142                                                      const char *errormsg);
    143143
    144144/*
    145145 * Name: ext_yahoo_status_changed
    146  *      Called when remote user's status changes.
    147  * Params:
    148  *      id   - the id that identifies the server connection
    149  *      who  - the handle of the remote user
    150  *      stat - status code (enum yahoo_status)
    151  *      msg  - the message if stat == YAHOO_STATUS_CUSTOM
    152  *      away - whether the contact is away or not (YAHOO_STATUS_CUSTOM)
    153  *      idle - this is the number of seconds he is idle [if he is idle]
     146 *      Called when remote user's status changes.
     147 * Params:
     148 *      id   - the id that identifies the server connection
     149 *      who  - the handle of the remote user
     150 *      stat - status code (enum yahoo_status)
     151 *      msg  - the message if stat == YAHOO_STATUS_CUSTOM
     152 *      away - whether the contact is away or not (YAHOO_STATUS_CUSTOM)
     153 *      idle - this is the number of seconds he is idle [if he is idle]
    154154 *      mobile - this is set for mobile users/buddies
    155155 *      TODO: add support for pager, chat, and game states
    156156 */
    157157        void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id,
    158                 const char *who, int stat, const char *msg, int away, int idle,
    159                 int mobile);
     158                                                            const char *who, int stat, const char *msg, int away,
     159                                                            int idle,
     160                                                            int mobile);
    160161
    161162/*
    162163 * Name: ext_yahoo_got_buzz
    163  *      Called when remote user sends you a buzz.
    164  * Params:
    165  *      id   - the id that identifies the server connection
    166  *      me   - the identity the message was sent to
    167  *      who  - the handle of the remote user
    168  *      tm   - timestamp of message if offline
     164 *      Called when remote user sends you a buzz.
     165 * Params:
     166 *      id   - the id that identifies the server connection
     167 *      me   - the identity the message was sent to
     168 *      who  - the handle of the remote user
     169 *      tm   - timestamp of message if offline
    169170 */
    170171        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me,
    171                 const char *who, long tm);
     172                                                      const char *who, long tm);
    172173
    173174/*
    174175 * Name: ext_yahoo_got_im
    175  *      Called when remote user sends you a message.
    176  * Params:
    177  *      id   - the id that identifies the server connection
    178  *      me   - the identity the message was sent to
    179  *      who  - the handle of the remote user
    180  *      msg  - the message - NULL if stat == 2
    181  *      tm   - timestamp of message if offline
    182  *      stat - message status - 0
    183  *                              1
    184  *                              2 == error sending message
    185  *                              5
    186  *      utf8 - whether the message is encoded as utf8 or not
     176 *      Called when remote user sends you a message.
     177 * Params:
     178 *      id   - the id that identifies the server connection
     179 *      me   - the identity the message was sent to
     180 *      who  - the handle of the remote user
     181 *      msg  - the message - NULL if stat == 2
     182 *      tm   - timestamp of message if offline
     183 *      stat - message status - 0
     184 *                              1
     185 *                              2 == error sending message
     186 *                              5
     187 *      utf8 - whether the message is encoded as utf8 or not
    187188 */
    188189        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me,
    189                 const char *who, const char *msg, long tm, int stat, int utf8);
     190                                                    const char *who, const char *msg, long tm, int stat, int utf8);
    190191
    191192/*
    192193 * Name: ext_yahoo_got_conf_invite
    193  *      Called when remote user sends you a conference invitation.
    194  * Params:
    195  *      id   - the id that identifies the server connection
    196  *      me   - the identity the invitation was sent to
    197  *      who  - the user inviting you
    198  *      room - the room to join
    199  *      msg  - the message
     194 *      Called when remote user sends you a conference invitation.
     195 * Params:
     196 *      id   - the id that identifies the server connection
     197 *      me   - the identity the invitation was sent to
     198 *      who  - the user inviting you
     199 *      room - the room to join
     200 *      msg  - the message
    200201 *      members - the initial members of the conference (null terminated list)
    201202 */
    202203        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id,
    203                 const char *me, const char *who, const char *room,
    204                 const char *msg, YList *members);
     204                                                             const char *me, const char *who, const char *room,
     205                                                             const char *msg, YList *members);
    205206
    206207/*
    207208 * Name: ext_yahoo_conf_userdecline
    208  *      Called when someone declines to join the conference.
    209  * Params:
    210  *      id   - the id that identifies the server connection
    211  *      me   - the identity in the conference
    212  *      who  - the user who has declined
    213  *      room - the room
    214  *      msg  - the declining message
     209 *      Called when someone declines to join the conference.
     210 * Params:
     211 *      id   - the id that identifies the server connection
     212 *      me   - the identity in the conference
     213 *      who  - the user who has declined
     214 *      room - the room
     215 *      msg  - the declining message
    215216 */
    216217        void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id,
    217                 const char *me, const char *who, const char *room,
    218                 const char *msg);
     218                                                              const char *me, const char *who, const char *room,
     219                                                              const char *msg);
    219220
    220221/*
    221222 * Name: ext_yahoo_conf_userjoin
    222  *      Called when someone joins the conference.
    223  * Params:
    224  *      id   - the id that identifies the server connection
    225  *      me   - the identity in the conference
    226  *      who  - the user who has joined
    227  *      room - the room joined
     223 *      Called when someone joins the conference.
     224 * Params:
     225 *      id   - the id that identifies the server connection
     226 *      me   - the identity in the conference
     227 *      who  - the user who has joined
     228 *      room - the room joined
    228229 */
    229230        void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id,
    230                 const char *me, const char *who, const char *room);
     231                                                           const char *me, const char *who, const char *room);
    231232
    232233/*
    233234 * Name: ext_yahoo_conf_userleave
    234  *      Called when someone leaves the conference.
    235  * Params:
    236  *      id   - the id that identifies the server connection
    237  *      me   - the identity in the conference
    238  *      who  - the user who has left
    239  *      room - the room left
     235 *      Called when someone leaves the conference.
     236 * Params:
     237 *      id   - the id that identifies the server connection
     238 *      me   - the identity in the conference
     239 *      who  - the user who has left
     240 *      room - the room left
    240241 */
    241242        void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id,
    242                 const char *me, const char *who, const char *room);
     243                                                            const char *me, const char *who, const char *room);
    243244
    244245/*
    245246 * Name: ext_yahoo_chat_cat_xml
    246  *      Called when ?
    247  * Params:
    248  *      id      - the id that identifies the server connection
    249  *      xml     - ?
     247 *      Called when ?
     248 * Params:
     249 *      id      - the id that identifies the server connection
     250 *      xml     - ?
    250251 */
    251252        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id,
    252                 const char *xml);
     253                                                          const char *xml);
    253254
    254255/*
    255256 * Name: ext_yahoo_chat_join
    256  *      Called when joining the chatroom.
    257  * Params:
    258  *      id      - the id that identifies the server connection
    259  *      me   - the identity in the chatroom
    260  *      room    - the room joined, used in all other chat calls, freed by
    261  *                library after call
    262  *      topic   - the topic of the room, freed by library after call
    263  *      members - the initial members of the chatroom (null terminated YList 
     257 *      Called when joining the chatroom.
     258 * Params:
     259 *      id      - the id that identifies the server connection
     260 *      me   - the identity in the chatroom
     261 *      room    - the room joined, used in all other chat calls, freed by
     262 *                library after call
     263 *      topic   - the topic of the room, freed by library after call
     264 *      members - the initial members of the chatroom (null terminated YList
    264265 *                of yahoo_chat_member's) Must be freed by the client
    265266 *      fd      - the object where the connection is coming from (for tracking)
    266267 */
    267268        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me,
    268                 const char *room, const char *topic, YList *members, void *fd);
     269                                                       const char *room, const char *topic, YList *members, void *fd);
    269270
    270271/*
    271272 * Name: ext_yahoo_chat_userjoin
    272  *      Called when someone joins the chatroom.
    273  * Params:
    274  *      id   - the id that identifies the server connection
    275  *      me   - the identity in the chatroom
    276  *      room - the room joined
    277  *      who  - the user who has joined, Must be freed by the client
     273 *      Called when someone joins the chatroom.
     274 * Params:
     275 *      id   - the id that identifies the server connection
     276 *      me   - the identity in the chatroom
     277 *      room - the room joined
     278 *      who  - the user who has joined, Must be freed by the client
    278279 */
    279280        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id,
    280                 const char *me, const char *room,
    281                 struct yahoo_chat_member *who);
     281                                                           const char *me, const char *room,
     282                                                           struct yahoo_chat_member *who);
    282283
    283284/*
    284285 * Name: ext_yahoo_chat_userleave
    285  *      Called when someone leaves the chatroom.
    286  * Params:
    287  *      id   - the id that identifies the server connection
    288  *      me   - the identity in the chatroom
    289  *      room - the room left
    290  *      who  - the user who has left (Just the User ID)
     286 *      Called when someone leaves the chatroom.
     287 * Params:
     288 *      id   - the id that identifies the server connection
     289 *      me   - the identity in the chatroom
     290 *      room - the room left
     291 *      who  - the user who has left (Just the User ID)
    291292 */
    292293        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id,
    293                 const char *me, const char *room, const char *who);
     294                                                            const char *me, const char *room, const char *who);
    294295
    295296/*
    296297 * Name: ext_yahoo_chat_message
    297  *      Called when someone messages in the chatroom.
    298  * Params:
    299  *      id   - the id that identifies the server connection
    300  *      me   - the identity in the chatroom
    301  *      room - the room
    302  *      who  - the user who messaged (Just the user id)
    303  *      msg  - the message
    304  *      msgtype  - 1 = Normal message
    305  *                 2 = /me type message
    306  *      utf8 - whether the message is utf8 encoded or not
     298 *      Called when someone messages in the chatroom.
     299 * Params:
     300 *      id   - the id that identifies the server connection
     301 *      me   - the identity in the chatroom
     302 *      room - the room
     303 *      who  - the user who messaged (Just the user id)
     304 *      msg  - the message
     305 *      msgtype  - 1 = Normal message
     306 *                 2 = /me type message
     307 *      utf8 - whether the message is utf8 encoded or not
    307308 */
    308309        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id,
    309                 const char *me, const char *who, const char *room,
    310                 const char *msg, int msgtype, int utf8);
     310                                                          const char *me, const char *who, const char *room,
     311                                                          const char *msg, int msgtype, int utf8);
    311312
    312313/*
     
    315316 *      called when yahoo disconnects your chat session
    316317 *      Note this is called whenver a disconnect happens, client or server
    317  *      requested. Care should be taken to make sure you know the origin 
     318 *      requested. Care should be taken to make sure you know the origin
    318319 *      of the disconnect request before doing anything here (auto-join's etc)
    319320 * Params:
    320321 *      id   - the id that identifies this connection
    321  *      me   - the identity in the chatroom
     322 *      me   - the identity in the chatroom
    322323 * Returns:
    323324 *      nothing.
    324325 */
    325326        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id,
    326                 const char *me);
     327                                                              const char *me);
    327328
    328329/*
     
    332333 *      Note this is called whenver chat message is sent into a room
    333334 *      in error (fd not connected, room doesn't exists etc)
    334  *      Care should be taken to make sure you know the origin 
     335 *      Care should be taken to make sure you know the origin
    335336 *      of the error before doing anything about it.
    336337 * Params:
    337338 *      id   - the id that identifies this connection
    338  *      me   - the identity in the chatroom
     339 *      me   - the identity in the chatroom
    339340 * Returns:
    340341 *      nothing.
    341342 */
    342343        void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id,
    343                 const char *me);
     344                                                             const char *me);
    344345
    345346/*
    346347 * Name: ext_yahoo_conf_message
    347  *      Called when someone messages in the conference.
    348  * Params:
    349  *      id   - the id that identifies the server connection
    350  *      me   - the identity the conf message was sent to
    351  *      who  - the user who messaged
    352  *      room - the room
    353  *      msg  - the message
    354  *      utf8 - whether the message is utf8 encoded or not
     348 *      Called when someone messages in the conference.
     349 * Params:
     350 *      id   - the id that identifies the server connection
     351 *      me   - the identity the conf message was sent to
     352 *      who  - the user who messaged
     353 *      room - the room
     354 *      msg  - the message
     355 *      utf8 - whether the message is utf8 encoded or not
    355356 */
    356357        void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id,
    357                 const char *me, const char *who, const char *room,
    358                 const char *msg, int utf8);
     358                                                          const char *me, const char *who, const char *room,
     359                                                          const char *msg, int utf8);
    359360
    360361/*
    361362 * Name: ext_yahoo_got_file
    362  *      Called when someone sends you a file
    363  * Params:
    364  *      id   - the id that identifies the server connection
    365  *      me   - the identity the file was sent to
    366  *      who  - the user who sent the file
    367  *      msg  - the message
    368  *      fname- the file name if direct transfer
    369  *      fsize- the file size if direct transfer
    370  *      trid - transfer id. Unique for this transfer
     363 *      Called when someone sends you a file
     364 * Params:
     365 *      id   - the id that identifies the server connection
     366 *      me   - the identity the file was sent to
     367 *      who  - the user who sent the file
     368 *      msg  - the message
     369 *      fname- the file name if direct transfer
     370 *      fsize- the file size if direct transfer
     371 *      trid - transfer id. Unique for this transfer
    371372 *
    372373 * NOTE: Subsequent callbacks for file transfer do not send all of this
     
    376377 */
    377378        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file) (int id, const char *me,
    378                 const char *who, const char *msg, const char *fname,
    379                 unsigned long fesize, char *trid);
     379                                                      const char *who, const char *msg, const char *fname,
     380                                                      unsigned long fesize, char *trid);
    380381
    381382/*
    382383 * Name: ext_yahoo_got_ft_data
    383  *      Called multiple times when parts of the file are received
    384  * Params:
    385  *      id   - the id that identifies the server connection
    386  *      in   - The data
    387  *      len  - Length of the data
    388  *      data - callback data
     384 *      Called multiple times when parts of the file are received
     385 * Params:
     386 *      id   - the id that identifies the server connection
     387 *      in   - The data
     388 *      len  - Length of the data
     389 *      data - callback data
    389390 */
    390391        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ft_data) (int id,
    391                 const unsigned char *in, int len, void *data);
     392                                                         const unsigned char *in, int len, void *data);
    392393
    393394/*
    394395 * Name: ext_yahoo_file_transfer_done
    395  *      File transfer is done
    396  * Params:
    397  *      id     - the id that identifies the server connection
    398  *      result - To notify if it finished successfully or with a failure
    399  *      data   - callback data
     396 *      File transfer is done
     397 * Params:
     398 *      id     - the id that identifies the server connection
     399 *      result - To notify if it finished successfully or with a failure
     400 *      data   - callback data
    400401 */
    401402        void YAHOO_CALLBACK_TYPE(ext_yahoo_file_transfer_done) (int id,
    402                 int result, void *data);
     403                                                                int result, void *data);
    403404
    404405/*
    405406 * Name: ext_yahoo_contact_added
    406  *      Called when a contact is added to your list
    407  * Params:
    408  *      id   - the id that identifies the server connection
    409  *      myid - the identity he was added to
    410  *      who  - who was added
    411  *      msg  - any message sent
     407 *      Called when a contact is added to your list
     408 * Params:
     409 *      id   - the id that identifies the server connection
     410 *      myid - the identity he was added to
     411 *      who  - who was added
     412 *      msg  - any message sent
    412413 */
    413414        void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id,
    414                 const char *myid, const char *who, const char *msg);
     415                                                           const char *myid, const char *who, const char *msg);
    415416
    416417/*
    417418 * Name: ext_yahoo_rejected
    418  *      Called when a contact rejects your add
    419  * Params:
    420  *      id   - the id that identifies the server connection
    421  *      who  - who rejected you
    422  *      msg  - any message sent
     419 *      Called when a contact rejects your add
     420 * Params:
     421 *      id   - the id that identifies the server connection
     422 *      who  - who rejected you
     423 *      msg  - any message sent
    423424 */
    424425        void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who,
    425                 const char *msg);
     426                                                      const char *msg);
    426427
    427428/*
    428429 * Name: ext_yahoo_typing_notify
    429  *      Called when remote user starts or stops typing.
    430  * Params:
    431  *      id   - the id that identifies the server connection
    432  *      me   - the handle of the identity the notification is sent to
    433  *      who  - the handle of the remote user
    434  *      stat - 1 if typing, 0 if stopped typing
     430 *      Called when remote user starts or stops typing.
     431 * Params:
     432 *      id   - the id that identifies the server connection
     433 *      me   - the handle of the identity the notification is sent to
     434 *      who  - the handle of the remote user
     435 *      stat - 1 if typing, 0 if stopped typing
    435436 */
    436437        void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id,
    437                 const char *me, const char *who, int stat);
     438                                                           const char *me, const char *who, int stat);
    438439
    439440/*
    440441 * Name: ext_yahoo_game_notify
    441  *      Called when remote user starts or stops a game.
    442  * Params:
    443  *      id   - the id that identifies the server connection
    444  *      me   - the handle of the identity the notification is sent to
    445  *      who  - the handle of the remote user
    446  *      stat - 1 if game, 0 if stopped gaming
    447  *      msg  - game description and/or other text
     442 *      Called when remote user starts or stops a game.
     443 * Params:
     444 *      id   - the id that identifies the server connection
     445 *      me   - the handle of the identity the notification is sent to
     446 *      who  - the handle of the remote user
     447 *      stat - 1 if game, 0 if stopped gaming
     448 *      msg  - game description and/or other text
    448449 */
    449450        void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify) (int id, const char *me,
    450                 const char *who, int stat, const char *msg);
     451                                                         const char *who, int stat, const char *msg);
    451452
    452453/*
    453454 * Name: ext_yahoo_mail_notify
    454  *      Called when you receive mail, or with number of messages
    455  * Params:
    456  *      id   - the id that identifies the server connection
    457  *      from - who the mail is from - NULL if only mail count
    458  *      subj - the subject of the mail - NULL if only mail count
    459  *      cnt  - mail count - 0 if new mail notification
     455 *      Called when you receive mail, or with number of messages
     456 * Params:
     457 *      id   - the id that identifies the server connection
     458 *      from - who the mail is from - NULL if only mail count
     459 *      subj - the subject of the mail - NULL if only mail count
     460 *      cnt  - mail count - 0 if new mail notification
    460461 */
    461462        void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id,
    462                 const char *from, const char *subj, int cnt);
     463                                                         const char *from, const char *subj, int cnt);
    463464
    464465/*
    465466 * Name: ext_yahoo_system_message
    466  *      System message
    467  * Params:
    468  *      id   - the id that identifies the server connection
    469  *      me   - the handle of the identity the notification is sent to
    470  *      who  - the source of the system message (there are different types)
    471  *      msg  - the message
     467 *      System message
     468 * Params:
     469 *      id   - the id that identifies the server connection
     470 *      me   - the handle of the identity the notification is sent to
     471 *      who  - the source of the system message (there are different types)
     472 *      msg  - the message
    472473 */
    473474        void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message) (int id,
    474                 const char *me, const char *who, const char *msg);
     475                                                            const char *me, const char *who, const char *msg);
    475476
    476477/*
    477478 * Name: ext_yahoo_got_buddyicon
    478  *      Buddy icon received
    479  * Params:
    480  *      id - the id that identifies the server connection
    481  *      me - the handle of the identity the notification is sent to
    482  *      who - the person the buddy icon is for
    483  *      url - the url to use to load the icon
    484  *      checksum - the checksum of the icon content
     479 *      Buddy icon received
     480 * Params:
     481 *      id - the id that identifies the server connection
     482 *      me - the handle of the identity the notification is sent to
     483 *      who - the person the buddy icon is for
     484 *      url - the url to use to load the icon
     485 *      checksum - the checksum of the icon content
    485486 */
    486487        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id,
    487                 const char *me, const char *who, const char *url, int checksum);
     488                                                           const char *me, const char *who, const char *url,
     489                                                           int checksum);
    488490
    489491/*
    490492 * Name: ext_yahoo_got_buddyicon_checksum
    491  *      Buddy icon checksum received
    492  * Params:
    493  *      id - the id that identifies the server connection
    494  *      me - the handle of the identity the notification is sent to
    495  *      who - the yahoo id of the buddy icon checksum is for
    496  *      checksum - the checksum of the icon content
     493 *      Buddy icon checksum received
     494 * Params:
     495 *      id - the id that identifies the server connection
     496 *      me - the handle of the identity the notification is sent to
     497 *      who - the yahoo id of the buddy icon checksum is for
     498 *      checksum - the checksum of the icon content
    497499 */
    498500        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id,
    499                 const char *me, const char *who, int checksum);
     501                                                                    const char *me, const char *who, int checksum);
    500502
    501503/*
    502504 * Name: ext_yahoo_got_buddyicon_request
    503  *      Buddy icon request received
    504  * Params:
    505  *      id - the id that identifies the server connection
    506  *      me - the handle of the identity the notification is sent to
    507  *      who - the yahoo id of the buddy that requested the buddy icon
     505 *      Buddy icon request received
     506 * Params:
     507 *      id - the id that identifies the server connection
     508 *      me - the handle of the identity the notification is sent to
     509 *      who - the yahoo id of the buddy that requested the buddy icon
    508510 */
    509511        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id,
    510                 const char *me, const char *who);
     512                                                                   const char *me, const char *who);
    511513
    512514/*
    513515 * Name: ext_yahoo_got_buddyicon_request
    514  *      Buddy icon request received
    515  * Params:
    516  *      id - the id that identifies the server connection
    517  *      url - remote url, the uploaded buddy icon can be fetched from
     516 *      Buddy icon request received
     517 * Params:
     518 *      id - the id that identifies the server connection
     519 *      url - remote url, the uploaded buddy icon can be fetched from
    518520 */
    519521        void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id,
    520                 const char *url);
     522                                                                const char *url);
    521523
    522524/*
    523525 * Name: ext_yahoo_got_webcam_image
    524  *      Called when you get a webcam update
     526 *      Called when you get a webcam update
    525527 *      An update can either be receiving an image, a part of an image or
    526528 *      just an update with a timestamp
    527529 * Params:
    528  *      id         - the id that identifies the server connection
    529  *      who        - the user who's webcam we're viewing
     530 *      id         - the id that identifies the server connection
     531 *      who        - the user who's webcam we're viewing
    530532 *      image      - image data
    531533 *      image_size - length of the image in bytes
     
    544546 */
    545547        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id,
    546                 const char *who, const unsigned char *image,
    547                 unsigned int image_size, unsigned int real_size,
    548                 unsigned int timestamp);
     548                                                              const char *who, const unsigned char *image,
     549                                                              unsigned int image_size, unsigned int real_size,
     550                                                              unsigned int timestamp);
    549551
    550552/*
    551553 * Name: ext_yahoo_webcam_invite
    552  *      Called when you get a webcam invitation
    553  * Params:
    554  *      id   - the id that identifies the server connection
    555  *      me   - identity the invitation is to
    556  *      from - who the invitation is from
     554 *      Called when you get a webcam invitation
     555 * Params:
     556 *      id   - the id that identifies the server connection
     557 *      me   - identity the invitation is to
     558 *      from - who the invitation is from
    557559 */
    558560        void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id,
    559                 const char *me, const char *from);
     561                                                           const char *me, const char *from);
    560562
    561563/*
    562564 * Name: ext_yahoo_webcam_invite_reply
    563  *      Called when you get a response to a webcam invitation
    564  * Params:
    565  *      id   - the id that identifies the server connection
    566  *      me   - identity the invitation response is to
    567  *      from - who the invitation response is from
     565 *      Called when you get a response to a webcam invitation
     566 * Params:
     567 *      id   - the id that identifies the server connection
     568 *      me   - identity the invitation response is to
     569 *      from - who the invitation response is from
    568570 *      accept - 0 (decline), 1 (accept)
    569571 */
    570572        void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id,
    571                 const char *me, const char *from, int accept);
     573                                                                 const char *me, const char *from, int accept);
    572574
    573575/*
    574576 * Name: ext_yahoo_webcam_closed
    575  *      Called when the webcam connection closed
    576  * Params:
    577  *      id   - the id that identifies the server connection
    578  *      who  - the user who we where connected to
     577 *      Called when the webcam connection closed
     578 * Params:
     579 *      id   - the id that identifies the server connection
     580 *      who  - the user who we where connected to
    579581 *      reason - reason why the connection closed
    580582 *               1 = user stopped broadcasting
     
    584586 */
    585587        void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id,
    586                 const char *who, int reason);
     588                                                           const char *who, int reason);
    587589
    588590/*
     
    590592 *      Called when the search result received from server
    591593 * Params:
    592  *      id      - the id that identifies the server connection
    593  *      found    - total number of results returned in the current result set
    594  *      start    - offset from where the current result set starts
    595  *      total    - total number of results available (start + found <= total)
    596  *      contacts - the list of results as a YList of yahoo_found_contact
    597  *                 these will be freed after this function returns, so
    598  *                 if you need to use the information, make a copy
     594 *      id      - the id that identifies the server connection
     595 *      found    - total number of results returned in the current result set
     596 *      start    - offset from where the current result set starts
     597 *      total    - total number of results available (start + found <= total)
     598 *      contacts - the list of results as a YList of yahoo_found_contact
     599 *                 these will be freed after this function returns, so
     600 *                 if you need to use the information, make a copy
    599601 */
    600602        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id,
    601                 int found, int start, int total, YList *contacts);
     603                                                               int found, int start, int total, YList *contacts);
    602604
    603605/*
    604606 * Name: ext_yahoo_error
    605  *      Called on error.
    606  * Params:
    607  *      id   - the id that identifies the server connection
    608  *      err  - the error message
    609  *      fatal- whether this error is fatal to the connection or not
    610  *      num  - Which error is this
     607 *      Called on error.
     608 * Params:
     609 *      id   - the id that identifies the server connection
     610 *      err  - the error message
     611 *      fatal- whether this error is fatal to the connection or not
     612 *      num  - Which error is this
    611613 */
    612614        void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err,
    613                 int fatal, int num);
     615                                                   int fatal, int num);
    614616
    615617/*
     
    622624 */
    623625        void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id,
    624                 const char *who, int connect);
     626                                                           const char *who, int connect);
    625627
    626628/*
     
    632634 */
    633635        void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id,
    634                 int send);
     636                                                                 int send);
    635637
    636638/*
    637639 * Name: ext_yahoo_log
    638  *      Called to log a message.
    639  * Params:
    640  *      fmt  - the printf formatted message
    641  * Returns:
    642  *      0
     640 *      Called to log a message.
     641 * Params:
     642 *      fmt  - the printf formatted message
     643 * Returns:
     644 *      0
    643645 */
    644646        int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...);
     
    646648/*
    647649 * Name: ext_yahoo_add_handler
    648  *      Add a listener for the fd.  Must call yahoo_read_ready
    649  *      when a YAHOO_INPUT_READ fd is ready and yahoo_write_ready
    650  *      when a YAHOO_INPUT_WRITE fd is ready.
    651  * Params:
    652  *      id   - the id that identifies the server connection
    653  *      fd   - the fd object on which to listen
    654  *      cond - the condition on which to call the callback
    655  *      data - callback data to pass to yahoo_*_ready
    656  *     
     650 *      Add a listener for the fd.  Must call yahoo_read_ready
     651 *      when a YAHOO_INPUT_READ fd is ready and yahoo_write_ready
     652 *      when a YAHOO_INPUT_WRITE fd is ready.
     653 * Params:
     654 *      id   - the id that identifies the server connection
     655 *      fd   - the fd object on which to listen
     656 *      cond - the condition on which to call the callback
     657 *      data - callback data to pass to yahoo_*_ready
     658 *
    657659 * Returns: a tag to be used when removing the handler
    658660 */
    659661        int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, void *fd,
    660                 yahoo_input_condition cond, void *data);
     662                                                        yahoo_input_condition cond, void *data);
    661663
    662664/*
    663665 * Name: ext_yahoo_remove_handler
    664  *      Remove the listener for the fd.
    665  * Params:
    666  *      id   - the id that identifies the connection
    667  *      tag  - the handler tag to remove
     666 *      Remove the listener for the fd.
     667 * Params:
     668 *      id   - the id that identifies the connection
     669 *      tag  - the handler tag to remove
    668670 */
    669671        void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag);
     
    671673/*
    672674 * Name: ext_yahoo_connect
    673  *      Connect to a host:port
    674  * Params:
    675  *      host - the host to connect to
    676  *      port - the port to connect on
    677  * Returns:
    678  *      a unix file descriptor to the socket
     675 *      Connect to a host:port
     676 * Params:
     677 *      host - the host to connect to
     678 *      port - the port to connect on
     679 * Returns:
     680 *      a unix file descriptor to the socket
    679681 */
    680682//      int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port);
     
    682684/*
    683685 * Name: ext_yahoo_connect_async
    684  *      Connect to a host:port asynchronously. This function should return
    685  *      immediately returing a tag used to identify the connection handler,
    686  *      or a pre-connect error (eg: host name lookup failure).
    687  *      Once the connect completes (successfully or unsuccessfully), callback
    688  *      should be called (see the signature for yahoo_connect_callback).
    689  *      The callback may safely be called before this function returns, but
    690  *      it should not be called twice.
    691  * Params:
    692  *      id   - the id that identifies this connection
    693  *      host - the host to connect to
    694  *      port - the port to connect on
    695  *      callback - function to call when connect completes
    696  *      callback_data - data to pass to the callback function
    697  *      use_ssl - Whether we need an SSL connection
    698  * Returns:
    699  *      a tag signifying the connection attempt
     686 *      Connect to a host:port asynchronously. This function should return
     687 *      immediately returing a tag used to identify the connection handler,
     688 *      or a pre-connect error (eg: host name lookup failure).
     689 *      Once the connect completes (successfully or unsuccessfully), callback
     690 *      should be called (see the signature for yahoo_connect_callback).
     691 *      The callback may safely be called before this function returns, but
     692 *      it should not be called twice.
     693 * Params:
     694 *      id   - the id that identifies this connection
     695 *      host - the host to connect to
     696 *      port - the port to connect on
     697 *      callback - function to call when connect completes
     698 *      callback_data - data to pass to the callback function
     699 *      use_ssl - Whether we need an SSL connection
     700 * Returns:
     701 *      a tag signifying the connection attempt
    700702 */
    701703        int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id,
    702                 const char *host, int port, yahoo_connect_callback callback,
    703                 void *callback_data, int use_ssl);
     704                                                          const char *host, int port, yahoo_connect_callback callback,
     705                                                          void *callback_data, int use_ssl);
    704706
    705707/*
    706708 * Name: ext_yahoo_get_ip_addr
    707  *      get IP Address for a domain name
    708  * Params:
    709  *      domain - Domain name
    710  * Returns:
    711  *      Newly allocated string containing the IP Address in IPv4 notation
     709 *      get IP Address for a domain name
     710 * Params:
     711 *      domain - Domain name
     712 * Returns:
     713 *      Newly allocated string containing the IP Address in IPv4 notation
    712714 */
    713715        char *YAHOO_CALLBACK_TYPE(ext_yahoo_get_ip_addr) (const char *domain);
     
    715717/*
    716718 * Name: ext_yahoo_write
    717  *      Write data from the buffer into the socket for the specified connection
    718  * Params:
    719  *      fd  - the file descriptor object that identifies this connection
    720  *      buf - Buffer to write the data from
    721  *      len - Length of the data
    722  * Returns:
    723  *      Number of bytes written or -1 for error
     719 *      Write data from the buffer into the socket for the specified connection
     720 * Params:
     721 *      fd  - the file descriptor object that identifies this connection
     722 *      buf - Buffer to write the data from
     723 *      len - Length of the data
     724 * Returns:
     725 *      Number of bytes written or -1 for error
    724726 */
    725727        int YAHOO_CALLBACK_TYPE(ext_yahoo_write) (void *fd, char *buf, int len);
     
    727729/*
    728730 * Name: ext_yahoo_read
    729  *      Read data into a buffer from socket for the specified connection
    730  * Params:
    731  *      fd  - the file descriptor object that identifies this connection
    732  *      buf - Buffer to read the data into
    733  *      len - Max length to read
    734  * Returns:
    735  *      Number of bytes read or -1 for error
     731 *      Read data into a buffer from socket for the specified connection
     732 * Params:
     733 *      fd  - the file descriptor object that identifies this connection
     734 *      buf - Buffer to read the data into
     735 *      len - Max length to read
     736 * Returns:
     737 *      Number of bytes read or -1 for error
    736738 */
    737739        int YAHOO_CALLBACK_TYPE(ext_yahoo_read) (void *fd, char *buf, int len);
     
    739741/*
    740742 * Name: ext_yahoo_close
    741  *      Close the file descriptor object and free its resources. Libyahoo2 will not
    742  *      use this object again.
    743  * Params:
    744  *      fd  - the file descriptor object that identifies this connection
    745  * Returns:
    746  *      Nothing
     743 *      Close the file descriptor object and free its resources. Libyahoo2 will not
     744 *      use this object again.
     745 * Params:
     746 *      fd  - the file descriptor object that identifies this connection
     747 * Returns:
     748 *      Nothing
    747749 */
    748750        void YAHOO_CALLBACK_TYPE(ext_yahoo_close) (void *fd);
     
    750752/*
    751753 * Name: ext_yahoo_got_buddy_change_group
    752  *      Acknowledgement of buddy changing group
    753  * Params:
    754  *      id: client id
    755  *      me: The user
    756  *      who: Buddy name
    757  *      old_group: Old group name
    758  *      new_group: New group name
    759  * Returns:
    760  *      Nothing
     754 *      Acknowledgement of buddy changing group
     755 * Params:
     756 *      id: client id
     757 *      me: The user
     758 *      who: Buddy name
     759 *      old_group: Old group name
     760 *      new_group: New group name
     761 * Returns:
     762 *      Nothing
    761763 */
    762764        void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddy_change_group) (int id,
    763                 const char *me, const char *who, const char *old_group,
    764                 const char *new_group);
     765                                                                    const char *me, const char *who,
     766                                                                    const char *old_group,
     767                                                                    const char *new_group);
    765768
    766769#ifdef USE_STRUCT_CALLBACKS
  • protocols/yahoo/yahoo2_types.h

    raf359b4 r5ebff60  
    2929#endif
    3030
    31         enum yahoo_service {    /* these are easier to see in hex */
    32                 YAHOO_SERVICE_LOGON = 1,
    33                 YAHOO_SERVICE_LOGOFF,
    34                 YAHOO_SERVICE_ISAWAY,
    35                 YAHOO_SERVICE_ISBACK,
    36                 YAHOO_SERVICE_IDLE,     /* 5 (placemarker) */
    37                 YAHOO_SERVICE_MESSAGE,
    38                 YAHOO_SERVICE_IDACT,
    39                 YAHOO_SERVICE_IDDEACT,
    40                 YAHOO_SERVICE_MAILSTAT,
    41                 YAHOO_SERVICE_USERSTAT, /* 0xa */
    42                 YAHOO_SERVICE_NEWMAIL,
    43                 YAHOO_SERVICE_CHATINVITE,
    44                 YAHOO_SERVICE_CALENDAR,
    45                 YAHOO_SERVICE_NEWPERSONALMAIL,
    46                 YAHOO_SERVICE_NEWCONTACT,
    47                 YAHOO_SERVICE_ADDIDENT, /* 0x10 */
    48                 YAHOO_SERVICE_ADDIGNORE,
    49                 YAHOO_SERVICE_PING,
    50                 YAHOO_SERVICE_GOTGROUPRENAME,   /* < 1, 36(old), 37(new) */
    51                 YAHOO_SERVICE_SYSMESSAGE = 0x14,
    52                 YAHOO_SERVICE_SKINNAME = 0x15,
    53                 YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
    54                 YAHOO_SERVICE_CONFINVITE = 0x18,
    55                 YAHOO_SERVICE_CONFLOGON,
    56                 YAHOO_SERVICE_CONFDECLINE,
    57                 YAHOO_SERVICE_CONFLOGOFF,
    58                 YAHOO_SERVICE_CONFADDINVITE,
    59                 YAHOO_SERVICE_CONFMSG,
    60                 YAHOO_SERVICE_CHATLOGON,
    61                 YAHOO_SERVICE_CHATLOGOFF,
    62                 YAHOO_SERVICE_CHATMSG = 0x20,
    63                 YAHOO_SERVICE_GAMELOGON = 0x28,
    64                 YAHOO_SERVICE_GAMELOGOFF,
    65                 YAHOO_SERVICE_GAMEMSG = 0x2a,
    66                 YAHOO_SERVICE_FILETRANSFER = 0x46,
    67                 YAHOO_SERVICE_VOICECHAT = 0x4A,
    68                 YAHOO_SERVICE_NOTIFY,
    69                 YAHOO_SERVICE_VERIFY,
    70                 YAHOO_SERVICE_P2PFILEXFER,
    71                 YAHOO_SERVICE_PEERTOPEER = 0x4F,        /* Checks if P2P possible */
    72                 YAHOO_SERVICE_WEBCAM,
    73                 YAHOO_SERVICE_AUTHRESP = 0x54,
    74                 YAHOO_SERVICE_LIST,
    75                 YAHOO_SERVICE_AUTH = 0x57,
    76                 YAHOO_SERVICE_AUTHBUDDY = 0x6d,
    77                 YAHOO_SERVICE_ADDBUDDY = 0x83,
    78                 YAHOO_SERVICE_REMBUDDY,
    79                 YAHOO_SERVICE_IGNORECONTACT,    /* > 1, 7, 13 < 1, 66, 13, 0 */
    80                 YAHOO_SERVICE_REJECTCONTACT,
    81                 YAHOO_SERVICE_GROUPRENAME = 0x89,       /* > 1, 65(new), 66(0), 67(old) */
    82                 YAHOO_SERVICE_Y7_PING = 0x8A,
    83                 YAHOO_SERVICE_CHATONLINE = 0x96,        /* > 109(id), 1, 6(abcde) < 0,1 */
    84                 YAHOO_SERVICE_CHATGOTO,
    85                 YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */
    86                 YAHOO_SERVICE_CHATLEAVE,
    87                 YAHOO_SERVICE_CHATEXIT = 0x9b,
    88                 YAHOO_SERVICE_CHATADDINVITE = 0x9d,
    89                 YAHOO_SERVICE_CHATLOGOUT = 0xa0,
    90                 YAHOO_SERVICE_CHATPING,
    91                 YAHOO_SERVICE_COMMENT = 0xa8,
    92                 YAHOO_SERVICE_GAME_INVITE = 0xb7,
    93                 YAHOO_SERVICE_STEALTH_PERM = 0xb9,
    94                 YAHOO_SERVICE_STEALTH_SESSION = 0xba,
    95                 YAHOO_SERVICE_AVATAR = 0xbc,
    96                 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
    97                 YAHOO_SERVICE_PICTURE = 0xbe,
    98                 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
    99                 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
    100                 YAHOO_SERVICE_YAB_UPDATE = 0xc4,
    101                 YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */
    102                 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6,  /* YMSG13 */
    103                 YAHOO_SERVICE_PICTURE_STATUS = 0xc7,    /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
    104                 YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
    105                 YAHOO_SERVICE_AUDIBLE = 0xd0,
    106                 YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2,
    107                 YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3,        /* YMSG13 */
    108                 YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4,
    109                 YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6,  /* YMSG13 */
    110                 YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc,   /* YMSG13 */
    111                 YAHOO_SERVICE_Y7_FILETRANSFERINFO,      /* YMSG13 */
    112                 YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,    /* YMSG13 */
    113                 YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */
    114                 YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7,   /* YMSG13 */
    115                 YAHOO_SERVICE_MYSTERY = 0xef,   /* Don't know what this is for */
    116                 YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */
    117                 YAHOO_SERVICE_Y8_LIST = 0Xf1,   /* YMSG15 */
    118                 YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb,
    119                 YAHOO_SERVICE_WEBLOGIN = 0x0226,
    120                 YAHOO_SERVICE_SMS_MSG = 0x02ea
    121         };
    122 
    123         enum yahoo_status {
    124                 YAHOO_STATUS_AVAILABLE = 0,
    125                 YAHOO_STATUS_BRB,
    126                 YAHOO_STATUS_BUSY,
    127                 YAHOO_STATUS_NOTATHOME,
    128                 YAHOO_STATUS_NOTATDESK,
    129                 YAHOO_STATUS_NOTINOFFICE,
    130                 YAHOO_STATUS_ONPHONE,
    131                 YAHOO_STATUS_ONVACATION,
    132                 YAHOO_STATUS_OUTTOLUNCH,
    133                 YAHOO_STATUS_STEPPEDOUT,
    134                 YAHOO_STATUS_INVISIBLE = 12,
    135                 YAHOO_STATUS_CUSTOM = 99,
    136                 YAHOO_STATUS_IDLE = 999,
    137                 YAHOO_STATUS_OFFLINE = 0x5a55aa56       /* don't ask */
    138         };
    139 
    140         enum ypacket_status {
    141                 YPACKET_STATUS_DISCONNECTED = -1,
    142                 YPACKET_STATUS_DEFAULT = 0,
    143                 YPACKET_STATUS_SERVERACK = 1,
    144                 YPACKET_STATUS_GAME = 0x2,
    145                 YPACKET_STATUS_AWAY = 0x4,
    146                 YPACKET_STATUS_CONTINUED = 0x5,
    147                 YPACKET_STATUS_INVISIBLE = 12,
    148                 YPACKET_STATUS_NOTIFY = 0x16,   /* TYPING */
    149                 YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
    150                 YPACKET_STATUS_OFFLINE = 0x5a55aa56
    151         };
    152 
    153 #define YAHOO_STATUS_GAME       0x2     /* Games don't fit into the regular status model */
    154 
    155         enum yahoo_login_status {
    156                 YAHOO_LOGIN_OK = 0,
    157                 YAHOO_LOGIN_LOGOFF = 1,
    158                 YAHOO_LOGIN_UNAME = 3,
    159                 YAHOO_LOGIN_PASSWD = 13,
    160                 YAHOO_LOGIN_LOCK = 14,
    161                 YAHOO_LOGIN_DUPL = 99,
    162                 YAHOO_LOGIN_SOCK = -1,
    163                 YAHOO_LOGIN_UNKNOWN = 999
    164         };
    165 
    166         enum yahoo_error {
    167                 E_UNKNOWN = -1,
    168                 E_CONNECTION = -2,
    169                 E_SYSTEM = -3,
    170                 E_CUSTOM = 0,
    171 
    172                 /* responses from ignore buddy */
    173                 E_IGNOREDUP = 2,
    174                 E_IGNORENONE = 3,
    175                 E_IGNORECONF = 12,
    176 
    177                 /* conference */
    178                 E_CONFNOTAVAIL = 20
    179         };
    180 
    181         enum yahoo_log_level {
    182                 YAHOO_LOG_NONE = 0,
    183                 YAHOO_LOG_FATAL,
    184                 YAHOO_LOG_ERR,
    185                 YAHOO_LOG_WARNING,
    186                 YAHOO_LOG_NOTICE,
    187                 YAHOO_LOG_INFO,
    188                 YAHOO_LOG_DEBUG
    189         };
    190 
    191         enum yahoo_file_transfer {
    192                 YAHOO_FILE_TRANSFER_INIT = 1,
    193                 YAHOO_FILE_TRANSFER_ACCEPT = 3,
    194                 YAHOO_FILE_TRANSFER_REJECT = 4,
    195                 YAHOO_FILE_TRANSFER_DONE = 5,
    196                 YAHOO_FILE_TRANSFER_RELAY,
    197                 YAHOO_FILE_TRANSFER_FAILED,
    198                 YAHOO_FILE_TRANSFER_UNKNOWN
    199         };
     31enum yahoo_service {            /* these are easier to see in hex */
     32        YAHOO_SERVICE_LOGON = 1,
     33        YAHOO_SERVICE_LOGOFF,
     34        YAHOO_SERVICE_ISAWAY,
     35        YAHOO_SERVICE_ISBACK,
     36        YAHOO_SERVICE_IDLE,             /* 5 (placemarker) */
     37        YAHOO_SERVICE_MESSAGE,
     38        YAHOO_SERVICE_IDACT,
     39        YAHOO_SERVICE_IDDEACT,
     40        YAHOO_SERVICE_MAILSTAT,
     41        YAHOO_SERVICE_USERSTAT,         /* 0xa */
     42        YAHOO_SERVICE_NEWMAIL,
     43        YAHOO_SERVICE_CHATINVITE,
     44        YAHOO_SERVICE_CALENDAR,
     45        YAHOO_SERVICE_NEWPERSONALMAIL,
     46        YAHOO_SERVICE_NEWCONTACT,
     47        YAHOO_SERVICE_ADDIDENT,         /* 0x10 */
     48        YAHOO_SERVICE_ADDIGNORE,
     49        YAHOO_SERVICE_PING,
     50        YAHOO_SERVICE_GOTGROUPRENAME,           /* < 1, 36(old), 37(new) */
     51        YAHOO_SERVICE_SYSMESSAGE = 0x14,
     52        YAHOO_SERVICE_SKINNAME = 0x15,
     53        YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
     54        YAHOO_SERVICE_CONFINVITE = 0x18,
     55        YAHOO_SERVICE_CONFLOGON,
     56        YAHOO_SERVICE_CONFDECLINE,
     57        YAHOO_SERVICE_CONFLOGOFF,
     58        YAHOO_SERVICE_CONFADDINVITE,
     59        YAHOO_SERVICE_CONFMSG,
     60        YAHOO_SERVICE_CHATLOGON,
     61        YAHOO_SERVICE_CHATLOGOFF,
     62        YAHOO_SERVICE_CHATMSG = 0x20,
     63        YAHOO_SERVICE_GAMELOGON = 0x28,
     64        YAHOO_SERVICE_GAMELOGOFF,
     65        YAHOO_SERVICE_GAMEMSG = 0x2a,
     66        YAHOO_SERVICE_FILETRANSFER = 0x46,
     67        YAHOO_SERVICE_VOICECHAT = 0x4A,
     68        YAHOO_SERVICE_NOTIFY,
     69        YAHOO_SERVICE_VERIFY,
     70        YAHOO_SERVICE_P2PFILEXFER,
     71        YAHOO_SERVICE_PEERTOPEER = 0x4F,                /* Checks if P2P possible */
     72        YAHOO_SERVICE_WEBCAM,
     73        YAHOO_SERVICE_AUTHRESP = 0x54,
     74        YAHOO_SERVICE_LIST,
     75        YAHOO_SERVICE_AUTH = 0x57,
     76        YAHOO_SERVICE_AUTHBUDDY = 0x6d,
     77        YAHOO_SERVICE_ADDBUDDY = 0x83,
     78        YAHOO_SERVICE_REMBUDDY,
     79        YAHOO_SERVICE_IGNORECONTACT,            /* > 1, 7, 13 < 1, 66, 13, 0 */
     80        YAHOO_SERVICE_REJECTCONTACT,
     81        YAHOO_SERVICE_GROUPRENAME = 0x89,               /* > 1, 65(new), 66(0), 67(old) */
     82        YAHOO_SERVICE_Y7_PING = 0x8A,
     83        YAHOO_SERVICE_CHATONLINE = 0x96,                /* > 109(id), 1, 6(abcde) < 0,1 */
     84        YAHOO_SERVICE_CHATGOTO,
     85        YAHOO_SERVICE_CHATJOIN,         /* > 1 104-room 129-1600326591 62-2 */
     86        YAHOO_SERVICE_CHATLEAVE,
     87        YAHOO_SERVICE_CHATEXIT = 0x9b,
     88        YAHOO_SERVICE_CHATADDINVITE = 0x9d,
     89        YAHOO_SERVICE_CHATLOGOUT = 0xa0,
     90        YAHOO_SERVICE_CHATPING,
     91        YAHOO_SERVICE_COMMENT = 0xa8,
     92        YAHOO_SERVICE_GAME_INVITE = 0xb7,
     93        YAHOO_SERVICE_STEALTH_PERM = 0xb9,
     94        YAHOO_SERVICE_STEALTH_SESSION = 0xba,
     95        YAHOO_SERVICE_AVATAR = 0xbc,
     96        YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
     97        YAHOO_SERVICE_PICTURE = 0xbe,
     98        YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
     99        YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
     100        YAHOO_SERVICE_YAB_UPDATE = 0xc4,
     101        YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5,         /* YMSG13, key 13: 2 = invisible, 1 = visible */
     102        YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6,          /* YMSG13 */
     103        YAHOO_SERVICE_PICTURE_STATUS = 0xc7,            /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
     104        YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
     105        YAHOO_SERVICE_AUDIBLE = 0xd0,
     106        YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2,
     107        YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3,                /* YMSG13 */
     108        YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4,
     109        YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6,          /* YMSG13 */
     110        YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc,           /* YMSG13 */
     111        YAHOO_SERVICE_Y7_FILETRANSFERINFO,              /* YMSG13 */
     112        YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,            /* YMSG13 */
     113        YAHOO_SERVICE_Y7_MINGLE = 0xe1,         /* YMSG13 */
     114        YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7,           /* YMSG13 */
     115        YAHOO_SERVICE_MYSTERY = 0xef,           /* Don't know what this is for */
     116        YAHOO_SERVICE_Y8_STATUS = 0xf0,         /* YMSG15 */
     117        YAHOO_SERVICE_Y8_LIST = 0Xf1,           /* YMSG15 */
     118        YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb,
     119        YAHOO_SERVICE_WEBLOGIN = 0x0226,
     120        YAHOO_SERVICE_SMS_MSG = 0x02ea
     121};
     122
     123enum yahoo_status {
     124        YAHOO_STATUS_AVAILABLE = 0,
     125        YAHOO_STATUS_BRB,
     126        YAHOO_STATUS_BUSY,
     127        YAHOO_STATUS_NOTATHOME,
     128        YAHOO_STATUS_NOTATDESK,
     129        YAHOO_STATUS_NOTINOFFICE,
     130        YAHOO_STATUS_ONPHONE,
     131        YAHOO_STATUS_ONVACATION,
     132        YAHOO_STATUS_OUTTOLUNCH,
     133        YAHOO_STATUS_STEPPEDOUT,
     134        YAHOO_STATUS_INVISIBLE = 12,
     135        YAHOO_STATUS_CUSTOM = 99,
     136        YAHOO_STATUS_IDLE = 999,
     137        YAHOO_STATUS_OFFLINE = 0x5a55aa56               /* don't ask */
     138};
     139
     140enum ypacket_status {
     141        YPACKET_STATUS_DISCONNECTED = -1,
     142        YPACKET_STATUS_DEFAULT = 0,
     143        YPACKET_STATUS_SERVERACK = 1,
     144        YPACKET_STATUS_GAME = 0x2,
     145        YPACKET_STATUS_AWAY = 0x4,
     146        YPACKET_STATUS_CONTINUED = 0x5,
     147        YPACKET_STATUS_INVISIBLE = 12,
     148        YPACKET_STATUS_NOTIFY = 0x16,           /* TYPING */
     149        YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
     150        YPACKET_STATUS_OFFLINE = 0x5a55aa56
     151};
     152
     153#define YAHOO_STATUS_GAME       0x2     /* Games don't fit into the regular status model */
     154
     155enum yahoo_login_status {
     156        YAHOO_LOGIN_OK = 0,
     157        YAHOO_LOGIN_LOGOFF = 1,
     158        YAHOO_LOGIN_UNAME = 3,
     159        YAHOO_LOGIN_PASSWD = 13,
     160        YAHOO_LOGIN_LOCK = 14,
     161        YAHOO_LOGIN_DUPL = 99,
     162        YAHOO_LOGIN_SOCK = -1,
     163        YAHOO_LOGIN_UNKNOWN = 999
     164};
     165
     166enum yahoo_error {
     167        E_UNKNOWN = -1,
     168        E_CONNECTION = -2,
     169        E_SYSTEM = -3,
     170        E_CUSTOM = 0,
     171
     172        /* responses from ignore buddy */
     173        E_IGNOREDUP = 2,
     174        E_IGNORENONE = 3,
     175        E_IGNORECONF = 12,
     176
     177        /* conference */
     178        E_CONFNOTAVAIL = 20
     179};
     180
     181enum yahoo_log_level {
     182        YAHOO_LOG_NONE = 0,
     183        YAHOO_LOG_FATAL,
     184        YAHOO_LOG_ERR,
     185        YAHOO_LOG_WARNING,
     186        YAHOO_LOG_NOTICE,
     187        YAHOO_LOG_INFO,
     188        YAHOO_LOG_DEBUG
     189};
     190
     191enum yahoo_file_transfer {
     192        YAHOO_FILE_TRANSFER_INIT = 1,
     193        YAHOO_FILE_TRANSFER_ACCEPT = 3,
     194        YAHOO_FILE_TRANSFER_REJECT = 4,
     195        YAHOO_FILE_TRANSFER_DONE = 5,
     196        YAHOO_FILE_TRANSFER_RELAY,
     197        YAHOO_FILE_TRANSFER_FAILED,
     198        YAHOO_FILE_TRANSFER_UNKNOWN
     199};
    200200
    201201#define YAHOO_PROTO_VER 0x0010
     
    222222#define YAHOO_STYLE_URLOFF "\033[xlm"
    223223
    224         enum yahoo_connection_type {
    225                 YAHOO_CONNECTION_PAGER = 0,
    226                 YAHOO_CONNECTION_FT,
    227                 YAHOO_CONNECTION_YAB,
    228                 YAHOO_CONNECTION_WEBCAM_MASTER,
    229                 YAHOO_CONNECTION_WEBCAM,
    230                 YAHOO_CONNECTION_CHATCAT,
    231                 YAHOO_CONNECTION_SEARCH,
    232                 YAHOO_CONNECTION_AUTH
    233         };
    234 
    235         enum yahoo_webcam_direction_type {
    236                 YAHOO_WEBCAM_DOWNLOAD = 0,
    237                 YAHOO_WEBCAM_UPLOAD
    238         };
    239 
    240         enum yahoo_stealth_visibility_type {
    241                 YAHOO_STEALTH_DEFAULT = 0,
    242                 YAHOO_STEALTH_ONLINE,
    243                 YAHOO_STEALTH_PERM_OFFLINE
    244         };
     224enum yahoo_connection_type {
     225        YAHOO_CONNECTION_PAGER = 0,
     226        YAHOO_CONNECTION_FT,
     227        YAHOO_CONNECTION_YAB,
     228        YAHOO_CONNECTION_WEBCAM_MASTER,
     229        YAHOO_CONNECTION_WEBCAM,
     230        YAHOO_CONNECTION_CHATCAT,
     231        YAHOO_CONNECTION_SEARCH,
     232        YAHOO_CONNECTION_AUTH
     233};
     234
     235enum yahoo_webcam_direction_type {
     236        YAHOO_WEBCAM_DOWNLOAD = 0,
     237        YAHOO_WEBCAM_UPLOAD
     238};
     239
     240enum yahoo_stealth_visibility_type {
     241        YAHOO_STEALTH_DEFAULT = 0,
     242        YAHOO_STEALTH_ONLINE,
     243        YAHOO_STEALTH_PERM_OFFLINE
     244};
    245245
    246246/* chat member attribs */
     
    251251#define YAHOO_CHAT_WEBCAM 0x10
    252252
    253         enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 };
    254 
    255         struct yahoo_webcam {
    256                 int direction;  /* Uploading or downloading */
    257                 int conn_type;  /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */
    258 
    259                 char *user;     /* user we are viewing */
    260                 char *server;   /* webcam server to connect to */
    261                 int port;       /* webcam port to connect on */
    262                 char *key;      /* key to connect to the server with */
    263                 char *description;      /* webcam description */
    264                 char *my_ip;    /* own ip number */
    265         };
    266 
    267         struct yahoo_webcam_data {
    268                 unsigned int data_size;
    269                 unsigned int to_read;
    270                 unsigned int timestamp;
    271                 unsigned char packet_type;
    272         };
    273 
    274         struct yahoo_data {
    275                 char *user;
    276                 char *password;
    277 
    278                 char *cookie_y;
    279                 char *cookie_t;
    280                 char *cookie_c;
    281                 char *cookie_b;
    282                 char *login_cookie;
    283                 char *crumb;
    284                 char *seed;
    285 
    286                 YList *buddies;
    287                 YList *ignore;
    288                 YList *identities;
    289                 char *login_id;
    290 
    291                 int current_status;
    292                 int initial_status;
    293                 int logged_in;
    294 
    295                 int session_id;
    296 
    297                 int client_id;
    298 
    299                 char *rawbuddylist;
    300                 char *ignorelist;
    301 
    302                 void *server_settings;
    303 
    304                 struct yahoo_process_status_entry *half_user;
    305         };
    306 
    307         struct yab {
    308                 int yid;
    309                 char *id;
    310                 char *fname;
    311                 char *lname;
    312                 char *nname;
    313                 char *email;
    314                 char *hphone;
    315                 char *wphone;
    316                 char *mphone;
    317                 int dbid;
    318         };
    319 
    320         struct yahoo_buddy {
    321                 char *group;
    322                 char *id;
    323                 char *real_name;
    324                 struct yab *yab_entry;
    325         };
    326 
    327         enum yahoo_search_type {
    328                 YAHOO_SEARCH_KEYWORD = 0,
    329                 YAHOO_SEARCH_YID,
    330                 YAHOO_SEARCH_NAME
    331         };
    332 
    333         enum yahoo_search_gender {
    334                 YAHOO_GENDER_NONE = 0,
    335                 YAHOO_GENDER_MALE,
    336                 YAHOO_GENDER_FEMALE
    337         };
    338 
    339         enum yahoo_search_agerange {
    340                 YAHOO_AGERANGE_NONE = 0
    341         };
    342 
    343         struct yahoo_found_contact {
    344                 char *id;
    345                 char *gender;
    346                 char *location;
    347                 int age;
    348                 int online;
    349         };
     253enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 };
     254
     255struct yahoo_webcam {
     256        int direction;          /* Uploading or downloading */
     257        int conn_type;          /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */
     258
     259        char *user;             /* user we are viewing */
     260        char *server;           /* webcam server to connect to */
     261        int port;               /* webcam port to connect on */
     262        char *key;              /* key to connect to the server with */
     263        char *description;              /* webcam description */
     264        char *my_ip;            /* own ip number */
     265};
     266
     267struct yahoo_webcam_data {
     268        unsigned int data_size;
     269        unsigned int to_read;
     270        unsigned int timestamp;
     271        unsigned char packet_type;
     272};
     273
     274struct yahoo_data {
     275        char *user;
     276        char *password;
     277
     278        char *cookie_y;
     279        char *cookie_t;
     280        char *cookie_c;
     281        char *cookie_b;
     282        char *login_cookie;
     283        char *crumb;
     284        char *seed;
     285
     286        YList *buddies;
     287        YList *ignore;
     288        YList *identities;
     289        char *login_id;
     290
     291        int current_status;
     292        int initial_status;
     293        int logged_in;
     294
     295        int session_id;
     296
     297        int client_id;
     298
     299        char *rawbuddylist;
     300        char *ignorelist;
     301
     302        void *server_settings;
     303
     304        struct yahoo_process_status_entry *half_user;
     305};
     306
     307struct yab {
     308        int yid;
     309        char *id;
     310        char *fname;
     311        char *lname;
     312        char *nname;
     313        char *email;
     314        char *hphone;
     315        char *wphone;
     316        char *mphone;
     317        int dbid;
     318};
     319
     320struct yahoo_buddy {
     321        char *group;
     322        char *id;
     323        char *real_name;
     324        struct yab *yab_entry;
     325};
     326
     327enum yahoo_search_type {
     328        YAHOO_SEARCH_KEYWORD = 0,
     329        YAHOO_SEARCH_YID,
     330        YAHOO_SEARCH_NAME
     331};
     332
     333enum yahoo_search_gender {
     334        YAHOO_GENDER_NONE = 0,
     335        YAHOO_GENDER_MALE,
     336        YAHOO_GENDER_FEMALE
     337};
     338
     339enum yahoo_search_agerange {
     340        YAHOO_AGERANGE_NONE = 0
     341};
     342
     343struct yahoo_found_contact {
     344        char *id;
     345        char *gender;
     346        char *location;
     347        int age;
     348        int online;
     349};
    350350
    351351/*
    352352 * Function pointer to be passed to http get/post and send file
    353353 */
    354         typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error,
    355                 void *data);
     354typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error,
     355                                       void *data);
    356356
    357357/*
    358358 * Function pointer to be passed to yahoo_get_url_handle
    359359 */
    360         typedef void (*yahoo_get_url_handle_callback) (int id, void *fd,
    361                 int error, const char *filename, unsigned long size,
    362                 void *data);
    363 
    364         struct yahoo_chat_member {
    365                 char *id;
    366                 int age;
    367                 int attribs;
    368                 char *alias;
    369                 char *location;
    370         };
    371 
    372         struct yahoo_process_status_entry {
    373                 char *name;     /* 7      name */
    374                 int state;      /* 10     state */
    375                 int flags;      /* 13     flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
    376                 int mobile;     /* 60     mobile */
    377                 char *msg;      /* 19     custom status message */
    378                 int away;       /* 47     away (or invisible) */
    379                 int buddy_session; /* 11  state */
    380                 int f17;        /* 17     in chat? then what about flags? */
    381                 int idle;       /* 137    seconds idle */
    382                 int f138;       /* 138    state */
    383                 char *f184;     /* 184    state */
    384                 int f192;       /* 192    state */
    385                 int f10001;     /* 10001  state */
    386                 int f10002;     /* 10002  state */
    387                 int f198;       /* 198    state */
    388                 char *f197;     /* 197    state */
    389                 char *f205;     /* 205    state */
    390                 int f213;       /* 213    state */
    391         };
     360typedef void (*yahoo_get_url_handle_callback) (int id, void *fd,
     361                                               int error, const char *filename, unsigned long size,
     362                                               void *data);
     363
     364struct yahoo_chat_member {
     365        char *id;
     366        int age;
     367        int attribs;
     368        char *alias;
     369        char *location;
     370};
     371
     372struct yahoo_process_status_entry {
     373        char *name;             /* 7      name */
     374        int state;              /* 10     state */
     375        int flags;              /* 13     flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
     376        int mobile;             /* 60     mobile */
     377        char *msg;              /* 19     custom status message */
     378        int away;               /* 47     away (or invisible) */
     379        int buddy_session;         /* 11  state */
     380        int f17;                /* 17     in chat? then what about flags? */
     381        int idle;               /* 137    seconds idle */
     382        int f138;               /* 138    state */
     383        char *f184;             /* 184    state */
     384        int f192;               /* 192    state */
     385        int f10001;             /* 10001  state */
     386        int f10002;             /* 10002  state */
     387        int f198;               /* 198    state */
     388        char *f197;             /* 197    state */
     389        char *f205;             /* 205    state */
     390        int f213;               /* 213    state */
     391};
    392392
    393393#ifdef __cplusplus
  • protocols/yahoo/yahoo_debug.h

    raf359b4 r5ebff60  
    2222extern int yahoo_log_message(char *fmt, ...);
    2323
    24 #define NOTICE(x) if(yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); }
     24#define NOTICE(x) if (yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); }
    2525
    26 #define LOG(x) if(yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \
    27         yahoo_log_message x; \
    28         yahoo_log_message("\n"); }
     26#define LOG(x) if (yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \
     27                                                              yahoo_log_message x; \
     28                                                              yahoo_log_message("\n"); }
    2929
    30 #define WARNING(x) if(yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \
    31         yahoo_log_message x; \
    32         yahoo_log_message("\n"); }
     30#define WARNING(x) if (yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, \
     31                                                                                       __LINE__); \
     32                                                                     yahoo_log_message x; \
     33                                                                     yahoo_log_message("\n"); }
    3334
    34 #define DEBUG_MSG(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \
    35         yahoo_log_message x; \
    36         yahoo_log_message("\n"); }
     35#define DEBUG_MSG(x) if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, \
     36                                                                                       __LINE__); \
     37                                                                     yahoo_log_message x; \
     38                                                                     yahoo_log_message("\n"); }
    3739
    3840
  • protocols/yahoo/yahoo_httplib.c

    raf359b4 r5ebff60  
    3232char *strchr(), *strrchr();
    3333# if !HAVE_MEMCPY
    34 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
    35 #  define memmove(d, s, n) bcopy ((s), (d), (n))
     34#  define memcpy(d, s, n) bcopy((s), (d), (n))
     35#  define memmove(d, s, n) bcopy((s), (d), (n))
    3636# endif
    3737#endif
     
    5353#ifdef USE_STRUCT_CALLBACKS
    5454extern struct yahoo_callbacks *yc;
    55 #define YAHOO_CALLBACK(x)       yc->x
     55#define YAHOO_CALLBACK(x)       yc->x
    5656#else
    57 #define YAHOO_CALLBACK(x)       x
     57#define YAHOO_CALLBACK(x)       x
    5858#endif
    5959
     
    6969
    7070                do {
    71                         rc = YAHOO_CALLBACK(ext_yahoo_read) (fd, &c, 1);
    72                 } while (rc == -1 && (errno == EINTR || errno == EAGAIN));      /* this is bad - it should be done asynchronously */
     71                        rc = YAHOO_CALLBACK (ext_yahoo_read) (fd, &c, 1);
     72                } while (rc == -1 && (errno == EINTR || errno == EAGAIN));      /* this is bad - it should be done asynchronously */
    7373
    7474                if (rc == 1) {
    75                         if (c == '\r')  /* get rid of \r */
     75                        if (c == '\r') { /* get rid of \r */
    7676                                continue;
     77                        }
    7778                        *ptr = c;
    78                         if (c == '\n')
     79                        if (c == '\n') {
    7980                                break;
     81                        }
    8082                        ptr++;
    8183                } else if (rc == 0) {
    82                         if (n == 1)
    83                                 return (0);     /* EOF, no data */
    84                         else
    85                                 break;  /* EOF, w/ data */
     84                        if (n == 1) {
     85                                return (0);     /* EOF, no data */
     86                        } else {
     87                                break;  /* EOF, w/ data */
     88                        }
    8689                } else {
    8790                        return -1;
     
    9598
    9699static int url_to_host_port_path(const char *url,
    97         char *host, int *port, char *path, int *ssl)
     100                                 char *host, int *port, char *path, int *ssl)
    98101{
    99102        char *urlcopy = NULL;
     
    127130
    128131        if (!colon || (slash && slash < colon)) {
    129                 if (*ssl)
     132                if (*ssl) {
    130133                        *port = 443;
    131                 else
     134                } else {
    132135                        *port = 80;
     136                }
    133137        } else {
    134138                *colon = 0;
     
    161165        int len = strlen(instr);
    162166
    163         if (!(str = y_new(char, 3 *len + 1)))
    164                  return "";
     167        if (!(str = y_new(char, 3 * len + 1))) {
     168                return "";
     169        }
    165170
    166171        while (instr[ipos]) {
    167                 while (isurlchar(instr[ipos]))
     172                while (isurlchar(instr[ipos])) {
    168173                        str[bpos++] = instr[ipos++];
    169                 if (!instr[ipos])
     174                }
     175                if (!instr[ipos]) {
    170176                        break;
     177                }
    171178
    172179                snprintf(&str[bpos], 4, "%%%02x", instr[ipos] & 0xff);
     
    192199        int len = strlen(instr);
    193200
    194         if (!(str = y_new(char, len + 1)))
    195                  return "";
     201        if (!(str = y_new(char, len + 1))) {
     202                return "";
     203        }
    196204
    197205        while (instr[ipos]) {
    198                 while (instr[ipos] && instr[ipos] != '%')
     206                while (instr[ipos] && instr[ipos] != '%') {
    199207                        if (instr[ipos] == '+') {
    200208                                str[bpos++] = ' ';
    201209                                ipos++;
    202                         } else
     210                        } else {
    203211                                str[bpos++] = instr[ipos++];
    204                 if (!instr[ipos])
     212                        }
     213                }
     214                if (!instr[ipos]) {
    205215                        break;
     216                }
    206217
    207218                if (instr[ipos + 1] && instr[ipos + 2]) {
     
    210221                        entity[1] = instr[ipos++];
    211222                        sscanf(entity, "%2x", &dec);
    212                         str[bpos++] = (char)dec;
     223                        str[bpos++] = (char) dec;
    213224                } else {
    214225                        str[bpos++] = instr[ipos++];
     
    230241        char entity[4] = { 0, 0, 0, 0 };
    231242        char *entitymap[5][2] = {
    232                 {"amp;", "&"},
    233                 {"quot;", "\""},
    234                 {"lt;", "<"},
    235                 {"gt;", "<"},
    236                 {"nbsp;", " "}
     243                { "amp;", "&" },
     244                { "quot;", "\"" },
     245                { "lt;", "<" },
     246                { "gt;", "<" },
     247                { "nbsp;", " " }
    237248        };
    238249        unsigned dec;
    239250        int len = strlen(instr);
    240251
    241         if (!(str = y_new(char, len + 1)))
    242                  return "";
     252        if (!(str = y_new(char, len + 1))) {
     253                return "";
     254        }
    243255
    244256        while (instr[ipos]) {
    245                 while (instr[ipos] && instr[ipos] != '&')
     257                while (instr[ipos] && instr[ipos] != '&') {
    246258                        if (instr[ipos] == '+') {
    247259                                str[bpos++] = ' ';
    248260                                ipos++;
    249                         } else
     261                        } else {
    250262                                str[bpos++] = instr[ipos++];
    251                 if (!instr[ipos] || !instr[ipos + 1])
     263                        }
     264                }
     265                if (!instr[ipos] || !instr[ipos + 1]) {
    252266                        break;
     267                }
    253268                ipos++;
    254269
     
    256271                        ipos++;
    257272                        epos = 0;
    258                         while (instr[ipos] != ';')
     273                        while (instr[ipos] != ';') {
    259274                                entity[epos++] = instr[ipos++];
     275                        }
    260276                        sscanf(entity, "%u", &dec);
    261                         str[bpos++] = (char)dec;
     277                        str[bpos++] = (char) dec;
    262278                        ipos++;
    263279                } else {
    264280                        int i;
    265                         for (i = 0; i < 5; i++)
     281                        for (i = 0; i < 5; i++) {
    266282                                if (!strncmp(instr + ipos, entitymap[i][0],
    267                                                 strlen(entitymap[i][0]))) {
     283                                             strlen(entitymap[i][0]))) {
    268284                                        str[bpos++] = entitymap[i][1][0];
    269285                                        ipos += strlen(entitymap[i][0]);
    270286                                        break;
    271287                                }
     288                        }
    272289                }
    273290        }
     
    294311{
    295312        struct callback_data *ccd = data;
    296         if (error == 0)
    297                 YAHOO_CALLBACK(ext_yahoo_write) (fd, ccd->request,
    298                         strlen(ccd->request));
     313
     314        if (error == 0) {
     315                YAHOO_CALLBACK (ext_yahoo_write) (fd, ccd->request,
     316                                                  strlen(ccd->request));
     317        }
    299318        free(ccd->request);
    300319        ccd->callback(ccd->id, fd, error, ccd->user_data);
     
    303322
    304323static void yahoo_send_http_request(int id, char *host, int port, char *request,
    305         yahoo_get_fd_callback callback, void *data, int use_ssl)
     324                                    yahoo_get_fd_callback callback, void *data, int use_ssl)
    306325{
    307326        struct callback_data *ccd = y_new0(struct callback_data, 1);
     327
    308328        ccd->callback = callback;
    309329        ccd->id = id;
     
    311331        ccd->user_data = data;
    312332
    313         YAHOO_CALLBACK(ext_yahoo_connect_async) (id, host, port,
    314                 connect_complete, ccd, use_ssl);
     333        YAHOO_CALLBACK (ext_yahoo_connect_async) (id, host, port,
     334                                                  connect_complete, ccd, use_ssl);
    315335}
    316336
    317337void yahoo_http_post(int id, const char *url, const char *cookies,
    318         long content_length, yahoo_get_fd_callback callback, void *data)
     338                     long content_length, yahoo_get_fd_callback callback, void *data)
    319339{
    320340        char host[255];
     
    324344        int ssl = 0;
    325345
    326         if (!url_to_host_port_path(url, host, &port, path, &ssl))
     346        if (!url_to_host_port_path(url, host, &port, path, &ssl)) {
    327347                return;
     348        }
    328349
    329350        /* thanks to kopete dumpcap */
    330351        snprintf(buff, sizeof(buff),
    331                 "POST %s HTTP/1.1\r\n"
    332                 "Cookie: %s\r\n"
    333                 "User-Agent: Mozilla/5.0\r\n"
    334                 "Host: %s\r\n"
    335                 "Content-Length: %ld\r\n"
    336                 "Cache-Control: no-cache\r\n"
    337                 "\r\n", path, cookies, host, content_length);
     352                 "POST %s HTTP/1.1\r\n"
     353                 "Cookie: %s\r\n"
     354                 "User-Agent: Mozilla/5.0\r\n"
     355                 "Host: %s\r\n"
     356                 "Content-Length: %ld\r\n"
     357                 "Cache-Control: no-cache\r\n"
     358                 "\r\n", path, cookies, host, content_length);
    338359
    339360        yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
     
    341362
    342363void yahoo_http_get(int id, const char *url, const char *cookies, int http11,
    343         int keepalive, yahoo_get_fd_callback callback, void *data)
     364                    int keepalive, yahoo_get_fd_callback callback, void *data)
    344365{
    345366        char host[255];
     
    350371        int ssl = 0;
    351372
    352         if (!url_to_host_port_path(url, host, &port, path, &ssl))
     373        if (!url_to_host_port_path(url, host, &port, path, &ssl)) {
    353374                return;
     375        }
    354376
    355377        /* Allow cases when we don't need to send a cookie */
    356         if (cookies)
     378        if (cookies) {
    357379                snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
    358                         cookies);
    359         else
     380                         cookies);
     381        } else {
    360382                cookiebuff[0] = '\0';
     383        }
    361384
    362385        snprintf(buff, sizeof(buff),
    363                 "GET %s HTTP/1.%s\r\n"
    364                 "%sHost: %s\r\n"
    365                 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
    366                 "Accept: */*\r\n"
    367                 "%s" "\r\n", path, http11?"1":"0", cookiebuff, host,
    368                 keepalive? "Connection: Keep-Alive\r\n":"Connection: close\r\n");
     386                 "GET %s HTTP/1.%s\r\n"
     387                 "%sHost: %s\r\n"
     388                 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
     389                 "Accept: */*\r\n"
     390                 "%s" "\r\n", path, http11 ? "1" : "0", cookiebuff, host,
     391                 keepalive ? "Connection: Keep-Alive\r\n" : "Connection: close\r\n");
    369392
    370393        yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
     
    372395
    373396void yahoo_http_head(int id, const char *url, const char *cookies, int len,
    374         char *payload, yahoo_get_fd_callback callback, void *data)
     397                     char *payload, yahoo_get_fd_callback callback, void *data)
    375398{
    376399        char host[255];
     
    381404        int ssl = 0;
    382405
    383         if (!url_to_host_port_path(url, host, &port, path, &ssl))
     406        if (!url_to_host_port_path(url, host, &port, path, &ssl)) {
    384407                return;
     408        }
    385409
    386410        /* Allow cases when we don't need to send a cookie */
    387         if (cookies)
     411        if (cookies) {
    388412                snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
    389                         cookies);
    390         else
     413                         cookies);
     414        } else {
    391415                cookiebuff[0] = '\0';
     416        }
    392417
    393418        snprintf(buff, sizeof(buff),
    394                 "HEAD %s HTTP/1.0\r\n"
    395                 "Accept: */*\r\n"
    396                 "Host: %s:%d\r\n"
    397                 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
    398                 "%s"
    399                 "Content-Length: %d\r\n"
    400                 "Cache-Control: no-cache\r\n"
    401                 "\r\n%s", path, host, port, cookiebuff, len,
    402                 payload?payload:"");
     419                 "HEAD %s HTTP/1.0\r\n"
     420                 "Accept: */*\r\n"
     421                 "Host: %s:%d\r\n"
     422                 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
     423                 "%s"
     424                 "Content-Length: %d\r\n"
     425                 "Cache-Control: no-cache\r\n"
     426                 "\r\n%s", path, host, port, cookiebuff, len,
     427                 payload ? payload : "");
    403428
    404429        yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
  • protocols/yahoo/yahoo_httplib.h

    raf359b4 r5ebff60  
    2929#include "yahoo2_types.h"
    3030
    31         char *yahoo_urlencode(const char *instr);
    32         char *yahoo_urldecode(const char *instr);
    33         char *yahoo_xmldecode(const char *instr);
     31char *yahoo_urlencode(const char *instr);
     32char *yahoo_urldecode(const char *instr);
     33char *yahoo_xmldecode(const char *instr);
    3434
    35         int yahoo_tcp_readline(char *ptr, int maxlen, void *fd);
    36         void yahoo_http_post(int id, const char *url, const char *cookies,
    37                 long size, yahoo_get_fd_callback callback, void *data);
    38         void yahoo_http_get(int id, const char *url, const char *cookies,
    39                 int http11, int keepalive, yahoo_get_fd_callback callback,
    40                 void *data);
    41         void yahoo_http_head(int id, const char *url, const char *cookies,
    42                 int size, char *payload, yahoo_get_fd_callback callback,
    43                 void *data);
     35int yahoo_tcp_readline(char *ptr, int maxlen, void *fd);
     36void yahoo_http_post(int id, const char *url, const char *cookies,
     37                     long size, yahoo_get_fd_callback callback, void *data);
     38void yahoo_http_get(int id, const char *url, const char *cookies,
     39                    int http11, int keepalive, yahoo_get_fd_callback callback,
     40                    void *data);
     41void yahoo_http_head(int id, const char *url, const char *cookies,
     42                     int size, char *payload, yahoo_get_fd_callback callback,
     43                     void *data);
    4444
    4545#ifdef __cplusplus
  • protocols/yahoo/yahoo_util.c

    raf359b4 r5ebff60  
    2727#  define strrchr rindex
    2828# endif
    29 char *strchr (), *strrchr ();
     29char *strchr(), *strrchr();
    3030# if !HAVE_MEMCPY
    31 #  define memcpy(d, s, n) bcopy ((s), (d), (n))
    32 #  define memmove(d, s, n) bcopy ((s), (d), (n))
     31#  define memcpy(d, s, n) bcopy((s), (d), (n))
     32#  define memmove(d, s, n) bcopy((s), (d), (n))
    3333# endif
    3434#endif
     
    5757{
    5858        char **v;
    59         for(v = vector; *v; v++) {
     59
     60        for (v = vector; *v; v++) {
    6061                FREE(*v);
    6162        }
     
    6768        char ** vector;
    6869        char *s, *p;
    69         int i=0;
     70        int i = 0;
    7071        int l = strlen(sep);
    71         if(nelem <= 0) {
     72
     73        if (nelem <= 0) {
    7274                char * s;
    73                 nelem=0;
     75                nelem = 0;
    7476                if (*str) {
    75                         for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++)
     77                        for (s = strstr(str, sep); s; s = strstr(s + l, sep), nelem++) {
    7678                                ;
    77                         if(strcmp(str+strlen(str)-l, sep))
     79                        }
     80                        if (strcmp(str + strlen(str) - l, sep)) {
    7881                                nelem++;
     82                        }
    7983                }
    8084        }
     
    8286        vector = y_new(char *, nelem + 1);
    8387
    84         for(p=str, s=strstr(p,sep); i<nelem && s; p=s+l, s=strstr(p,sep), i++) {
    85                 int len = s-p;
    86                 vector[i] = y_new(char, len+1);
     88        for (p = str, s = strstr(p, sep); i < nelem && s; p = s + l, s = strstr(p, sep), i++) {
     89                int len = s - p;
     90                vector[i] = y_new(char, len + 1);
    8791                strncpy(vector[i], p, len);
    8892                vector[i][len] = '\0';
    8993        }
    9094
    91         if(i<nelem && *str) /* str didn't end with sep, and str isn't empty */
     95        if (i < nelem && *str) { /* str didn't end with sep, and str isn't empty */
    9296                vector[i++] = strdup(p);
    93                        
     97        }
     98
    9499        vector[i] = NULL;
    95100
     
    100105{
    101106        void * new_chunk = malloc(n);
    102         if(new_chunk)
     107
     108        if (new_chunk) {
    103109                memcpy(new_chunk, addr, n);
     110        }
    104111        return new_chunk;
    105112}
  • protocols/yahoo/yahoo_util.h

    raf359b4 r5ebff60  
    3030# include <glib.h>
    3131
    32 # define FREE(x)        if(x) {g_free(x); x=NULL;}
     32# define FREE(x)        if (x) { g_free(x); x = NULL; }
    3333
    34 # define y_new          g_new
    35 # define y_new0         g_new0
    36 # define y_renew        g_renew
     34# define y_new          g_new
     35# define y_new0         g_new0
     36# define y_renew        g_renew
    3737
    38 # define y_memdup       g_memdup
    39 # define y_strsplit     g_strsplit
    40 # define y_strfreev     g_strfreev
     38# define y_memdup       g_memdup
     39# define y_strsplit     g_strsplit
     40# define y_strfreev     g_strfreev
    4141# ifndef strdup
    42 #  define strdup        g_strdup
     42#  define strdup        g_strdup
    4343# endif
    4444# ifndef strncasecmp
    45 #  define strncasecmp   g_strncasecmp
    46 #  define strcasecmp    g_strcasecmp
     45#  define strncasecmp   g_strncasecmp
     46#  define strcasecmp    g_strcasecmp
    4747# endif
    4848
    49 # define snprintf       g_snprintf
     49# define snprintf       g_snprintf
    5050#ifdef vsnprintf
    5151#undef vsnprintf
    5252#endif
    53 # define vsnprintf      g_vsnprintf
     53# define vsnprintf      g_vsnprintf
    5454
    5555#else
     
    5858# include <stdarg.h>
    5959
    60 # define FREE(x)                if(x) {free(x); x=NULL;}
     60# define FREE(x)                if (x) { free(x); x = NULL; }
    6161
    62 # define y_new(type, n)         (type *)malloc(sizeof(type) * (n))
    63 # define y_new0(type, n)        (type *)calloc((n), sizeof(type))
    64 # define y_renew(type, mem, n)  (type *)realloc(mem, n)
     62# define y_new(type, n)         (type *) malloc(sizeof(type) * (n))
     63# define y_new0(type, n)        (type *) calloc((n), sizeof(type))
     64# define y_renew(type, mem, n)  (type *) realloc(mem, n)
    6565
    6666void *y_memdup(const void *addr, int n);
     
    8787
    8888#ifndef MIN
    89 #define MIN(x,y) ((x)<(y)?(x):(y))
     89#define MIN(x, y) ((x) < (y) ? (x) : (y))
    9090#endif
    9191
    9292#ifndef MAX
    93 #define MAX(x,y) ((x)>(y)?(x):(y))
     93#define MAX(x, y) ((x) > (y) ? (x) : (y))
    9494#endif
    9595
    96 /* 
     96/*
    9797 * The following three functions return newly allocated memory.
    9898 * You must free it yourself
Note: See TracChangeset for help on using the changeset viewer.