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

Reindent everything to K&R style with tabs

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/auth.c

    raf359b4 r5ebff60  
    44 */
    55
    6 #include <aim.h> 
     6#include <aim.h>
    77
    88#include "md5.h"
     
    1010static int aim_encode_password(const char *password, unsigned char *encoded);
    1111
    12 /* 
     12/*
    1313 * This just pushes the passed cookie onto the passed connection, without
    1414 * the SNAC header or any of that.
     
    2323        aim_tlvlist_t *tl = NULL;
    2424
    25         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4+2+2+AIM_COOKIELEN)))
     25        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4 + 2 + 2 + AIM_COOKIELEN))) {
    2626                return -ENOMEM;
     27        }
    2728
    2829        aimbs_put32(&fr->data, 0x00000001);
    29         aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);   
     30        aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);
    3031        aim_writetlvchain(&fr->data, &tl);
    3132        aim_freetlvchain(&tl);
     
    4849        aim_frame_t *fr;
    4950
    50         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4)))
     51        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 4))) {
    5152                return -ENOMEM;
     53        }
    5254
    5355        aimbs_put32(&fr->data, 0x00000001);
     
    9597        aim_frame_t fr;
    9698        aim_rxcallback_t userfunc;
    97        
     99
    98100        sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN;
    99101        sess->flags |= AIM_SESS_FLAGS_XORLOGIN;
    100102
    101103        fr.conn = conn;
    102        
    103         if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007)))
     104
     105        if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) {
    104106                userfunc(sess, &fr, "");
    105 
    106         return 0;
    107 }
    108 
    109 /*
    110  * In AIM 3.5 protocol, the first stage of login is to request login from the
    111  * Authorizer, passing it the screen name for verification.  If the name is
    112  * invalid, a 0017/0003 is spit back, with the standard error contents.  If
    113  * valid, a 0017/0007 comes back, which is the signal to send it the main
    114  * login command (0017/0002).
     107        }
     108
     109        return 0;
     110}
     111
     112/*
     113 * In AIM 3.5 protocol, the first stage of login is to request login from the
     114 * Authorizer, passing it the screen name for verification.  If the name is
     115 * invalid, a 0017/0003 is spit back, with the standard error contents.  If
     116 * valid, a 0017/0007 comes back, which is the signal to send it the main
     117 * login command (0017/0002).
    115118 *
    116119 */
     
    121124        aim_tlvlist_t *tl = NULL;
    122125        struct im_connection *ic = sess->aux_data;
    123        
    124         if (!sess || !conn || !sn)
     126
     127        if (!sess || !conn || !sn) {
    125128                return -EINVAL;
    126 
    127         if (g_ascii_isdigit(sn[0]) && set_getbool(&ic->acc->set, "old_icq_auth"))
     129        }
     130
     131        if (g_ascii_isdigit(sn[0]) && set_getbool(&ic->acc->set, "old_icq_auth")) {
    128132                return goddamnicq(sess, conn, sn);
     133        }
    129134
    130135        sess->flags |= AIM_SESS_FLAGS_SNACLOGIN;
     
    132137        aim_sendflapver(sess, conn);
    133138
    134         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn))))
     139        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2 + 2 + strlen(sn)))) {
    135140                return -ENOMEM;
     141        }
    136142
    137143        snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0);
    138144        aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid);
    139145
    140         aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
     146        aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
    141147        aim_writetlvchain(&fr->data, &tl);
    142148        aim_freetlvchain(&tl);
     
    152158static int goddamnicq2(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password)
    153159{
    154         static const char clientstr[] = {"ICQ Inc. - Product of ICQ (TM) 2001b.5.17.1.3642.85"};
    155         static const char lang[] = {"en"};
    156         static const char country[] = {"us"};
     160        static const char clientstr[] = { "ICQ Inc. - Product of ICQ (TM) 2001b.5.17.1.3642.85" };
     161        static const char lang[] = { "en" };
     162        static const char country[] = { "us" };
    157163        aim_frame_t *fr;
    158164        aim_tlvlist_t *tl = NULL;
    159165        guint8 *password_encoded;
    160166
    161         if (!(password_encoded = (guint8 *) g_malloc(strlen(password))))
     167        if (!(password_encoded = (guint8 *) g_malloc(strlen(password)))) {
    162168                return -ENOMEM;
     169        }
    163170
    164171        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) {
     
    170177
    171178        aimbs_put32(&fr->data, 0x00000001);
    172         aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
     179        aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
    173180        aim_addtlvtochain_raw(&tl, 0x0002, strlen(password), password_encoded);
    174         aim_addtlvtochain_raw(&tl, 0x0003, strlen(clientstr), (guint8 *)clientstr);
     181        aim_addtlvtochain_raw(&tl, 0x0003, strlen(clientstr), (guint8 *) clientstr);
    175182        aim_addtlvtochain16(&tl, 0x0016, 0x010a); /* cliend ID */
    176183        aim_addtlvtochain16(&tl, 0x0017, 0x0005); /* major version */
     
    179186        aim_addtlvtochain16(&tl, 0x001a, 0x0e3a); /* build */
    180187        aim_addtlvtochain32(&tl, 0x0014, 0x00000055); /* distribution chan */
    181         aim_addtlvtochain_raw(&tl, 0x000f, strlen(lang), (guint8 *)lang);
    182         aim_addtlvtochain_raw(&tl, 0x000e, strlen(country), (guint8 *)country);
     188        aim_addtlvtochain_raw(&tl, 0x000f, strlen(lang), (guint8 *) lang);
     189        aim_addtlvtochain_raw(&tl, 0x000e, strlen(country), (guint8 *) country);
    183190
    184191        aim_writetlvchain(&fr->data, &tl);
     
    194201/*
    195202 * send_login(int socket, char *sn, char *password)
    196  * 
     203 *
    197204 * This is the initial login request packet.
    198205 *
     
    249256 *   build  = 0x0013
    250257 *   unknown= (not sent)
    251  *   
     258 *
    252259 * AIM for Linux 1.1.112:
    253260 *   clientstring = "AOL Instant Messenger (SM)"
     
    261268 *
    262269 */
    263 int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci, const char *key)
     270int aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password,
     271                   struct client_info_s *ci, const char *key)
    264272{
    265273        aim_frame_t *fr;
     
    268276        aim_snacid_t snacid;
    269277
    270         if (!ci || !sn || !password)
     278        if (!ci || !sn || !password) {
    271279                return -EINVAL;
     280        }
    272281
    273282        /*
     
    276285         *
    277286         */
    278         if (sess->flags & AIM_SESS_FLAGS_XORLOGIN)
     287        if (sess->flags & AIM_SESS_FLAGS_XORLOGIN) {
    279288                return goddamnicq2(sess, conn, sn, password);
    280 
    281 
    282         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152)))
     289        }
     290
     291
     292        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) {
    283293                return -ENOMEM;
     294        }
    284295
    285296        snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0);
    286297        aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid);
    287298
    288         aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *)sn);
     299        aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (guint8 *) sn);
    289300
    290301        aim_encode_password_md5(password, key, digest);
     
    295306         */
    296307
    297         if (ci->clientstring)
    298                 aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), (guint8 *)ci->clientstring);
    299         aim_addtlvtochain16(&tl, 0x0016, (guint16)ci->clientid);
    300         aim_addtlvtochain16(&tl, 0x0017, (guint16)ci->major);
    301         aim_addtlvtochain16(&tl, 0x0018, (guint16)ci->minor);
    302         aim_addtlvtochain16(&tl, 0x0019, (guint16)ci->point);
    303         aim_addtlvtochain16(&tl, 0x001a, (guint16)ci->build);
    304         aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), (guint8 *)ci->country);
    305         aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), (guint8 *)ci->lang);
     308        if (ci->clientstring) {
     309                aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), (guint8 *) ci->clientstring);
     310        }
     311        aim_addtlvtochain16(&tl, 0x0016, (guint16) ci->clientid);
     312        aim_addtlvtochain16(&tl, 0x0017, (guint16) ci->major);
     313        aim_addtlvtochain16(&tl, 0x0018, (guint16) ci->minor);
     314        aim_addtlvtochain16(&tl, 0x0019, (guint16) ci->point);
     315        aim_addtlvtochain16(&tl, 0x001a, (guint16) ci->build);
     316        aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), (guint8 *) ci->country);
     317        aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), (guint8 *) ci->lang);
    306318
    307319        /*
     
    314326
    315327        aim_freetlvchain(&tl);
    316        
     328
    317329        aim_tx_enqueue(sess, fr);
    318330
     
    324336        md5_state_t state;
    325337
    326         md5_init(&state);       
    327         md5_append(&state, (const md5_byte_t *)key, strlen(key));
    328         md5_append(&state, (const md5_byte_t *)password, strlen(password));
    329         md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));
    330         md5_finish(&state, (md5_byte_t *)digest);
     338        md5_init(&state);
     339        md5_append(&state, (const md5_byte_t *) key, strlen(key));
     340        md5_append(&state, (const md5_byte_t *) password, strlen(password));
     341        md5_append(&state, (const md5_byte_t *) AIM_MD5_STRING, strlen(AIM_MD5_STRING));
     342        md5_finish(&state, (md5_byte_t *) digest);
    331343
    332344        return 0;
     
    345357 *
    346358 * The encoding_table seems to be a fixed set of values.  We'll
    347  * hope it doesn't change over time! 
     359 * hope it doesn't change over time!
    348360 *
    349361 * This is only used for the XOR method, not the better MD5 method.
     
    353365{
    354366        guint8 encoding_table[] = {
    355         /* v2.1 table, also works for ICQ */
     367                /* v2.1 table, also works for ICQ */
    356368                0xf3, 0x26, 0x81, 0xc4,
    357369                0x39, 0x86, 0xdb, 0x92,
     
    361373        int i;
    362374
    363         for (i = 0; i < strlen(password); i++)
     375        for (i = 0; i < strlen(password); i++) {
    364376                encoded[i] = (password[i] ^ encoding_table[i]);
     377        }
    365378
    366379        return 0;
     
    370383 * This is sent back as a general response to the login command.
    371384 * It can be either an error or a success, depending on the
    372  * precense of certain TLVs. 
     385 * precense of certain TLVs.
    373386 *
    374387 * The client should check the value passed as errorcode. If
     
    404417         * have an error url.
    405418         */
    406         if (aim_gettlv(tlvlist, 0x0008, 1))
     419        if (aim_gettlv(tlvlist, 0x0008, 1)) {
    407420                info.errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
    408         if (aim_gettlv(tlvlist, 0x0004, 1))
     421        }
     422        if (aim_gettlv(tlvlist, 0x0004, 1)) {
    409423                info.errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);
     424        }
    410425
    411426        /*
    412427         * BOS server address.
    413428         */
    414         if (aim_gettlv(tlvlist, 0x0005, 1))
     429        if (aim_gettlv(tlvlist, 0x0005, 1)) {
    415430                info.bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
     431        }
    416432
    417433        /*
     
    430446         *   Not available for ICQ logins.
    431447         */
    432         if (aim_gettlv(tlvlist, 0x0011, 1))
     448        if (aim_gettlv(tlvlist, 0x0011, 1)) {
    433449                info.email = aim_gettlv_str(tlvlist, 0x0011, 1);
     450        }
    434451
    435452        /*
     
    445462         *
    446463         */
    447         if (aim_gettlv(tlvlist, 0x0013, 1))
     464        if (aim_gettlv(tlvlist, 0x0013, 1)) {
    448465                info.regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
    449 
    450         if (aim_gettlv(tlvlist, 0x0040, 1))
     466        }
     467
     468        if (aim_gettlv(tlvlist, 0x0040, 1)) {
    451469                info.latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1);
    452         if (aim_gettlv(tlvlist, 0x0041, 1))
     470        }
     471        if (aim_gettlv(tlvlist, 0x0041, 1)) {
    453472                info.latestbeta.url = aim_gettlv_str(tlvlist, 0x0041, 1);
    454         if (aim_gettlv(tlvlist, 0x0042, 1))
     473        }
     474        if (aim_gettlv(tlvlist, 0x0042, 1)) {
    455475                info.latestbeta.info = aim_gettlv_str(tlvlist, 0x0042, 1);
    456         if (aim_gettlv(tlvlist, 0x0043, 1))
     476        }
     477        if (aim_gettlv(tlvlist, 0x0043, 1)) {
    457478                info.latestbeta.name = aim_gettlv_str(tlvlist, 0x0043, 1);
    458         if (aim_gettlv(tlvlist, 0x0048, 1))
     479        }
     480        if (aim_gettlv(tlvlist, 0x0048, 1)) {
    459481                ; /* no idea what this is */
    460482
    461         if (aim_gettlv(tlvlist, 0x0044, 1))
     483        }
     484        if (aim_gettlv(tlvlist, 0x0044, 1)) {
    462485                info.latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1);
    463         if (aim_gettlv(tlvlist, 0x0045, 1))
     486        }
     487        if (aim_gettlv(tlvlist, 0x0045, 1)) {
    464488                info.latestrelease.url = aim_gettlv_str(tlvlist, 0x0045, 1);
    465         if (aim_gettlv(tlvlist, 0x0046, 1))
     489        }
     490        if (aim_gettlv(tlvlist, 0x0046, 1)) {
    466491                info.latestrelease.info = aim_gettlv_str(tlvlist, 0x0046, 1);
    467         if (aim_gettlv(tlvlist, 0x0047, 1))
     492        }
     493        if (aim_gettlv(tlvlist, 0x0047, 1)) {
    468494                info.latestrelease.name = aim_gettlv_str(tlvlist, 0x0047, 1);
    469         if (aim_gettlv(tlvlist, 0x0049, 1))
     495        }
     496        if (aim_gettlv(tlvlist, 0x0049, 1)) {
    470497                ; /* no idea what this is */
    471498
    472499
    473         if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003)))
     500        }
     501        if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) {
    474502                ret = userfunc(sess, rx, &info);
     503        }
    475504
    476505        g_free(info.sn);
     
    506535        keystr = aimbs_getstr(bs, keylen);
    507536
    508         if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
     537        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) {
    509538                ret = userfunc(sess, rx, keystr);
    510 
    511         g_free(keystr);
     539        }
     540
     541        g_free(keystr);
    512542
    513543        return ret;
     
    517547{
    518548
    519         if (snac->subtype == 0x0003)
     549        if (snac->subtype == 0x0003) {
    520550                return parse(sess, mod, rx, snac, bs);
    521         else if (snac->subtype == 0x0007)
     551        } else if (snac->subtype == 0x0007) {
    522552                return keyparse(sess, mod, rx, snac, bs);
     553        }
    523554
    524555        return 0;
Note: See TracChangeset for help on using the changeset viewer.