Changes in / [fc5cf88:ca60550]


Ignore:
Files:
1 added
38 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    rfc5cf88 rca60550  
    4848        hints.ai_family = PF_UNSPEC;
    4949        hints.ai_socktype = SOCK_STREAM;
    50         hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
     50        hints.ai_flags = AI_PASSIVE
     51#ifdef AI_ADDRCONFIG
     52                       | AI_ADDRCONFIG
     53#endif
     54        ;
    5155
    5256        i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind );
     
    279283                        child_list = g_slist_append( child_list, child );
    280284                       
    281                         log_message( LOGLVL_INFO, "Creating new subprocess with pid %d.", client_pid );
     285                        log_message( LOGLVL_INFO, "Creating new subprocess with pid %d.", (int) client_pid );
    282286                       
    283287                        /* Close some things we don't need in the parent process. */
  • bitlbee.h

    rfc5cf88 rca60550  
    9999#endif
    100100
     101#ifndef G_GNUC_MALLOC
     102/* Doesn't exist in GLib <=2.4 while everything else in BitlBee should
     103   work with it, so let's fake this one. */
     104#define G_GNUC_MALLOC
     105#endif
     106
    101107#define _( x ) x
    102108
     
    115121#define HELP_FILE VARDIR "help.txt"
    116122#define CONF_FILE_DEF ETCDIR "bitlbee.conf"
    117 
    118 extern char *CONF_FILE;
    119123
    120124#include "irc.h"
     
    139143        gint listen_watch_source_id;
    140144        help_t *help;
     145        char *conf_file;
    141146        conf_t *conf;
    142147        GList *storage; /* The first backend in the list will be used for saving */
  • conf.c

    rfc5cf88 rca60550  
    3636#include "proxy.h"
    3737
    38 char *CONF_FILE;
    39 
    4038static int conf_loadini( conf_t *conf, char *file );
    4139
     
    4341{
    4442        conf_t *conf;
    45         int opt, i;
     43        int opt, i, config_missing = 0;
    4644       
    4745        conf = g_new0( conf_t, 1 );
     
    6664        proxytype = 0;
    6765       
    68         i = conf_loadini( conf, CONF_FILE );
     66        i = conf_loadini( conf, global.conf_file );
    6967        if( i == 0 )
    7068        {
    71                 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE );
    72                 return( NULL );
     69                fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file );
     70                return NULL;
    7371        }
    7472        else if( i == -1 )
    7573        {
    76                 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE );
     74                config_missing ++;
     75                /* Whine after parsing the options if there was no -c pointing
     76                   at a *valid* configuration file. */
    7777        }
    7878       
     
    106106                else if( opt == 'c' )
    107107                {
    108                         if( strcmp( CONF_FILE, optarg ) != 0 )
    109                         {
    110                                 g_free( CONF_FILE );
    111                                 CONF_FILE = g_strdup( optarg );
     108                        if( strcmp( global.conf_file, optarg ) != 0 )
     109                        {
     110                                g_free( global.conf_file );
     111                                global.conf_file = g_strdup( optarg );
    112112                                g_free( conf );
    113113                                /* Re-evaluate arguments. Don't use this option twice,
     
    115115                                   works with all libcs BTW.. */
    116116                                optind = 1;
    117                                 return( conf_load( argc, argv ) );
     117                                return conf_load( argc, argv );
    118118                        }
    119119                }
     
    143143                                "  -d  Specify alternative user configuration directory\n"
    144144                                "  -h  Show this help page.\n" );
    145                         return( NULL );
     145                        return NULL;
    146146                }
    147147                else if( opt == 'R' )
     
    169169        }
    170170       
    171         return( conf );
     171        if( config_missing )
     172                fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file );
     173       
     174        return conf;
    172175}
    173176
     
    178181       
    179182        ini = ini_open( file );
    180         if( ini == NULL ) return( -1 );
     183        if( ini == NULL ) return -1;
    181184        while( ini_read( ini ) )
    182185        {
     
    256259                                {
    257260                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    258                                         return( 0 );
     261                                        return 0;
    259262                                }
    260263                                conf->ping_interval = i;
     
    265268                                {
    266269                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    267                                         return( 0 );
     270                                        return 0;
    268271                                }
    269272                                conf->ping_timeout = i;
     
    277280                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    278281                                        g_free( url );
    279                                         return( 0 );
     282                                        return 0;
    280283                                }
    281284                               
     
    301304                        {
    302305                                fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key );
    303                                 return( 0 );
     306                                return 0;
    304307                                /* For now just ignore unknown keys... */
    305308                        }
     
    309312                        fprintf( stderr, "Error: Unknown section [%s] in configuration file. "
    310313                                         "BitlBee configuration must be put in a [settings] section!\n", ini->section );
    311                         return( 0 );
     314                        return 0;
    312315                }
    313316        }
    314317        ini_close( ini );
    315318       
    316         return( 1 );
     319        return 1;
    317320}
    318321
     
    321324        ini_t *ini;
    322325       
    323         ini = ini_open( CONF_FILE );
     326        ini = ini_open( global.conf_file );
    324327        if( ini == NULL ) return;
    325328        while( ini_read( ini ) )
  • configure

    rfc5cf88 rca60550  
    189189
    190190if [ "$events" = "libevent" ]; then
    191         if ! [ -e "${libevent}include/event.h" ]; then
     191        if ! [ -f "${libevent}include/event.h" ]; then
    192192                echo
    193193                echo 'Warning: Could not find event.h, you might have to install it and/or specify'
     
    324324
    325325for i in /lib /usr/lib /usr/local/lib; do
    326         if [ -e $i/libresolv.a ]; then
     326        if [ -f $i/libresolv.a ]; then
    327327                echo '#define HAVE_RESOLV_A' >> config.h
    328328                echo 'EFLAGS+='$i'/libresolv.a' >> Makefile.settings
  • crypting.c

    rfc5cf88 rca60550  
    2929   the programs will be built. */
    3030
    31 #include <string.h>
    32 #include <stdio.h>
    33 #include <stdlib.h>
    34 #include <glib.h>
     31#include <bitlbee.h>
    3532#include "md5.h"
    3633#include "crypting.h"
  • doc/user-guide/quickstart.xml

    rfc5cf88 rca60550  
    3434
    3535<para>
    36 For instance, suppose you have an ICQ account with UIN <emphasis>72696705</emphasis> with password <emphasis>QuickStart</emphasis>, you would:
     36For instance, suppose you have a Jabber account at jabber.org with handle <emphasis>bitlbee@jabber.org</emphasis> with password <emphasis>QuickStart</emphasis>, you would:
    3737</para>
    3838
     
    4343
    4444<para>
    45 Other available IM protocols are msn, oscar, and yahoo. Oscar is the protocol used by ICQ and AOL.
     45Other available IM protocols are msn, oscar, and yahoo. OSCAR is the protocol used by ICQ and AOL. For more information about the <emphasis>account add</emphasis> command, see <emphasis>help account add</emphasis>.
    4646</para>
    4747
  • help.c

    rfc5cf88 rca60550  
    7171                {
    7272                        /* FIXME: Clean up */
    73 //                      help_close( *help );
    74                         *help = NULL;
     73                        help_free( help );
    7574                        g_free( s );
    76                         return( NULL );
     75                        return NULL;
    7776                }
    7877                i = strchr( s, '\n' ) - s;
    7978               
    80                 if( h->string )
     79                if( h->title )
    8180                {
    8281                        h = h->next = g_new0( help_t, 1 );
    8382                }
    84                 h->string = g_new ( char, i );
     83                h->title = g_new ( char, i );
    8584               
    86                 strncpy( h->string, s + 1, i - 1 );
    87                 h->string[i-1] = 0;
     85                strncpy( h->title, s + 1, i - 1 );
     86                h->title[i-1] = 0;
    8887                h->fd = (*help)->fd;
    8988                h->offset.file_offset = lseek( h->fd, 0, SEEK_CUR ) - buflen + i + 1;
     
    103102}
    104103
    105 char *help_get( help_t **help, char *string )
     104void help_free( help_t **help )
     105{
     106        help_t *h, *oh;
     107        int last_fd = -1; /* Weak de-dupe */
     108       
     109        if( help == NULL || *help == NULL )
     110                return;
     111       
     112        h = *help;
     113        while( h )
     114        {
     115                if( h->fd != last_fd )
     116                {
     117                        close( h->fd );
     118                        last_fd = h->fd;
     119                }
     120                g_free( h->title );
     121                h = (oh=h)->next;
     122                g_free( oh );
     123        }
     124       
     125        *help = NULL;
     126}
     127
     128char *help_get( help_t **help, char *title )
    106129{
    107130        time_t mtime;
     
    111134        for( h = *help; h; h = h->next )
    112135        {
    113                 if( h->string != NULL &&
    114                         g_strcasecmp( h->string, string ) == 0 )
     136                if( h->title != NULL && g_strcasecmp( h->title, title ) == 0 )
    115137                        break;
    116138        }
     
    119141                char *s = g_new( char, h->length + 1 );
    120142               
    121                 if( fstat( h->fd, stat ) != 0 )
    122                 {
    123                         g_free( h );
    124                         *help = NULL;
    125                         return NULL;
    126                 }
    127                 mtime = stat->st_mtime;
    128                
    129                 if( mtime > h->mtime )
    130                         return NULL;
    131                
    132143                s[h->length] = 0;
    133144                if( h->fd >= 0 )
    134145                {
     146                        if( fstat( h->fd, stat ) != 0 )
     147                        {
     148                                g_free( s );
     149                                return NULL;
     150                        }
     151                        mtime = stat->st_mtime;
     152               
     153                        if( mtime > h->mtime )
     154                        {
     155                                g_free( s );
     156                                return NULL;
     157                        }
     158                       
    135159                        lseek( h->fd, h->offset.file_offset, SEEK_SET );
    136160                        read( h->fd, s, h->length );
  • help.h

    rfc5cf88 rca60550  
    3737        int fd;
    3838        time_t mtime;
    39         char *string;
     39        char *title;
    4040        help_off_t offset;
    4141        int length;
     
    4444
    4545G_GNUC_MALLOC help_t *help_init( help_t **help, const char *helpfile );
    46 char *help_get( help_t **help, char *string );
     46void help_free( help_t **help );
     47char *help_get( help_t **help, char *title );
    4748
    4849#endif
  • ipc.c

    rfc5cf88 rca60550  
    5252        if( g_strcasecmp( cmd[0], "CLIENT" ) == 0 )
    5353                ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n",
    54                                      child ? child->pid : -1, cmd[2], cmd[1], cmd[3] );
     54                                     (int) ( child ? child->pid : -1 ), cmd[2], cmd[1], cmd[3] );
    5555}
    5656
     
    446446       
    447447        for( l = child_list; l; l = l->next )
    448                 fprintf( fp, "%d %d\n", ((struct bitlbee_child*)l->data)->pid,
     448                fprintf( fp, "%d %d\n", (int) ((struct bitlbee_child*)l->data)->pid,
    449449                                        ((struct bitlbee_child*)l->data)->ipc_fd );
    450450       
     
    551551                child = g_new0( struct bitlbee_child, 1 );
    552552               
    553                 if( fscanf( fp, "%d %d", &child->pid, &child->ipc_fd ) != 2 )
     553                if( fscanf( fp, "%d %d", (int *) &child->pid, &child->ipc_fd ) != 2 )
    554554                {
    555555                        log_message( LOGLVL_WARNING, "Unexpected end of file: Only processed %d clients.", i );
  • irc.c

    rfc5cf88 rca60550  
    7474
    7575                if( getnameinfo( (struct sockaddr *) &sock, socklen, buf,
    76                                  NI_MAXHOST, NULL, -1, 0 ) == 0 )
     76                                 NI_MAXHOST, NULL, 0, 0 ) == 0 )
    7777                {
    7878                        irc->myhost = g_strdup( ipv6_unwrap( buf ) );
     
    8585
    8686                if( getnameinfo( (struct sockaddr *)&sock, socklen, buf,
    87                                  NI_MAXHOST, NULL, -1, 0 ) == 0 )
     87                                 NI_MAXHOST, NULL, 0, 0 ) == 0 )
    8888                {
    8989                        irc->host = g_strdup( ipv6_unwrap( buf ) );
     
    189189        account_t *account;
    190190        user_t *user, *usertmp;
    191         help_t *helpnode, *helpnodetmp;
    192191       
    193192        log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
     
    266265        g_hash_table_destroy(irc->watches);
    267266       
    268         if (irc->help != NULL) {
    269                 helpnode = irc->help;
    270                 while (helpnode != NULL) {
    271                         g_free(helpnode->string);
    272                        
    273                         helpnodetmp = helpnode;
    274                         helpnode = helpnode->next;
    275                         g_free(helpnodetmp);
    276                 }
    277         }
    278267        g_free(irc);
    279268       
     
    325314                                if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 )
    326315                                {
     316                                        /* GLib can do strange things if things are not in the expected charset,
     317                                           so let's be a little bit paranoid here: */
    327318                                        if( irc->status & USTATUS_LOGGED_IN )
     319                                        {
    328320                                                irc_usermsg( irc, "Error: Charset mismatch detected. The charset "
    329321                                                                  "setting is currently set to %s, so please make "
     
    333325                                                                  "`help set charset' for more information. Your "
    334326                                                                  "message was ignored.", cs );
    335                                         *conv = 0;
     327                                                *conv = 0;
     328                                        }
     329                                        else
     330                                        {
     331                                                irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost,
     332                                                           "Warning: invalid (non-UTF8) characters received at login time." );
     333                                               
     334                                                strncpy( conv, lines[i], IRC_MAX_LINE );
     335                                                for( temp = conv; *temp; temp ++ )
     336                                                        if( *temp & 0x80 )
     337                                                                *temp = '?';
     338                                        }
    336339                                }
    337340                                lines[i] = conv;
  • irc.h

    rfc5cf88 rca60550  
    8989        GHashTable *watches;
    9090        struct __NICK *nicks;
    91         struct help *help;
    9291        struct set *set;
    9392
  • irc_commands.c

    rfc5cf88 rca60550  
    556556       
    557557        for( h = global.help; h; h = h->next )
    558                 irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->string );
     558                irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->title );
    559559       
    560560        for( s = irc->set; s; s = s->next )
     
    571571                ipc_to_master( cmd );
    572572       
    573         irc_reply( irc, 382, "%s :Rehashing", CONF_FILE );
     573        irc_reply( irc, 382, "%s :Rehashing", global.conf_file );
    574574}
    575575
  • lib/md5.c

    rfc5cf88 rca60550  
    2626#include "md5.h"
    2727
    28 static void md5_transform(u_int32_t buf[4], u_int32_t const in[16]);
     28static void md5_transform(uint32_t buf[4], uint32_t const in[16]);
    2929
    3030/*
     
    3434 * 20021120
    3535 */
     36
     37/* Turns out MD5 was designed for little-endian machines. If we're running
     38   on a big-endian machines, we have to swap some bytes. Since detecting
     39   endianness at compile time reliably seems pretty hard, let's do it at
     40   run-time. It's not like we're going to checksum megabytes of data... */
     41static uint32_t cvt32(uint32_t val)
     42{
     43        static int little_endian = -1;
     44       
     45        if (little_endian == -1)
     46        {
     47                little_endian = 1;
     48                little_endian = *((char*) &little_endian);
     49        }
     50       
     51        if (little_endian)
     52                return val;
     53        else
     54                return (val >> 24) |
     55                       ((val >> 8) & 0xff00) |
     56                       ((val << 8) & 0xff0000) |
     57                       (val << 24);
     58}
    3659
    3760void md5_init(struct MD5Context *ctx)
     
    5376                unsigned int len)
    5477{
    55         u_int32_t t;
     78        uint32_t t;
    5679
    5780        /* Update bitcount */
    5881
    5982        t = ctx->bits[0];
    60         if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t)
     83        if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
    6184                ctx->bits[1]++; /* Carry from low to high */
    6285        ctx->bits[1] += len >> 29;
     
    7598                }
    7699                memcpy(p, buf, t);
    77                 md5_transform(ctx->buf, (u_int32_t *) ctx->in);
     100                md5_transform(ctx->buf, (uint32_t *) ctx->in);
    78101                buf += t;
    79102                len -= t;
     
    83106        while (len >= 64) {
    84107                memcpy(ctx->in, buf, 64);
    85                 md5_transform(ctx->buf, (u_int32_t *) ctx->in);
     108                md5_transform(ctx->buf, (uint32_t *) ctx->in);
    86109                buf += 64;
    87110                len -= 64;
     
    117140                /* Two lots of padding:  Pad the first block to 64 bytes */
    118141                memset(p, 0, count);
    119                 md5_transform(ctx->buf, (u_int32_t *) ctx->in);
     142                md5_transform(ctx->buf, (uint32_t *) ctx->in);
    120143
    121144                /* Now fill the next block with 56 bytes */
     
    127150
    128151        /* Append length in bits and transform */
    129         ((u_int32_t *) ctx->in)[14] = ctx->bits[0];
    130         ((u_int32_t *) ctx->in)[15] = ctx->bits[1];
    131 
    132         md5_transform(ctx->buf, (u_int32_t *) ctx->in);
     152        ((uint32_t *) ctx->in)[14] = cvt32(ctx->bits[0]);
     153        ((uint32_t *) ctx->in)[15] = cvt32(ctx->bits[1]);
     154
     155        md5_transform(ctx->buf, (uint32_t *) ctx->in);
     156        ctx->buf[0] = cvt32(ctx->buf[0]);
     157        ctx->buf[1] = cvt32(ctx->buf[1]);
     158        ctx->buf[2] = cvt32(ctx->buf[2]);
     159        ctx->buf[3] = cvt32(ctx->buf[3]);
    133160        memcpy(digest, ctx->buf, 16);
    134161        memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */
     
    152179 * the data and converts bytes into longwords for this routine.
    153180 */
    154 static void md5_transform(u_int32_t buf[4], u_int32_t const in[16])
    155 {
    156         register u_int32_t a, b, c, d;
     181static void md5_transform(uint32_t buf[4], uint32_t const in[16])
     182{
     183        register uint32_t a, b, c, d;
    157184
    158185        a = buf[0];
     
    161188        d = buf[3];
    162189
    163         MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
    164         MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
    165         MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
    166         MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
    167         MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
    168         MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
    169         MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
    170         MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
    171         MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
    172         MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
    173         MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
    174         MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
    175         MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
    176         MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
    177         MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
    178         MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
    179 
    180         MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
    181         MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
    182         MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
    183         MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
    184         MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
    185         MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
    186         MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
    187         MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
    188         MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
    189         MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
    190         MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
    191         MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
    192         MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
    193         MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
    194         MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
    195         MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
    196 
    197         MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
    198         MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
    199         MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
    200         MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
    201         MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
    202         MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
    203         MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
    204         MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
    205         MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
    206         MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
    207         MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
    208         MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
    209         MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
    210         MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
    211         MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
    212         MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
    213 
    214         MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
    215         MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
    216         MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
    217         MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
    218         MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
    219         MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
    220         MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
    221         MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
    222         MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
    223         MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
    224         MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
    225         MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
    226         MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
    227         MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
    228         MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
    229         MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
     190        MD5STEP(F1, a, b, c, d, cvt32(in[0]) + 0xd76aa478, 7);
     191        MD5STEP(F1, d, a, b, c, cvt32(in[1]) + 0xe8c7b756, 12);
     192        MD5STEP(F1, c, d, a, b, cvt32(in[2]) + 0x242070db, 17);
     193        MD5STEP(F1, b, c, d, a, cvt32(in[3]) + 0xc1bdceee, 22);
     194        MD5STEP(F1, a, b, c, d, cvt32(in[4]) + 0xf57c0faf, 7);
     195        MD5STEP(F1, d, a, b, c, cvt32(in[5]) + 0x4787c62a, 12);
     196        MD5STEP(F1, c, d, a, b, cvt32(in[6]) + 0xa8304613, 17);
     197        MD5STEP(F1, b, c, d, a, cvt32(in[7]) + 0xfd469501, 22);
     198        MD5STEP(F1, a, b, c, d, cvt32(in[8]) + 0x698098d8, 7);
     199        MD5STEP(F1, d, a, b, c, cvt32(in[9]) + 0x8b44f7af, 12);
     200        MD5STEP(F1, c, d, a, b, cvt32(in[10]) + 0xffff5bb1, 17);
     201        MD5STEP(F1, b, c, d, a, cvt32(in[11]) + 0x895cd7be, 22);
     202        MD5STEP(F1, a, b, c, d, cvt32(in[12]) + 0x6b901122, 7);
     203        MD5STEP(F1, d, a, b, c, cvt32(in[13]) + 0xfd987193, 12);
     204        MD5STEP(F1, c, d, a, b, cvt32(in[14]) + 0xa679438e, 17);
     205        MD5STEP(F1, b, c, d, a, cvt32(in[15]) + 0x49b40821, 22);
     206
     207        MD5STEP(F2, a, b, c, d, cvt32(in[1]) + 0xf61e2562, 5);
     208        MD5STEP(F2, d, a, b, c, cvt32(in[6]) + 0xc040b340, 9);
     209        MD5STEP(F2, c, d, a, b, cvt32(in[11]) + 0x265e5a51, 14);
     210        MD5STEP(F2, b, c, d, a, cvt32(in[0]) + 0xe9b6c7aa, 20);
     211        MD5STEP(F2, a, b, c, d, cvt32(in[5]) + 0xd62f105d, 5);
     212        MD5STEP(F2, d, a, b, c, cvt32(in[10]) + 0x02441453, 9);
     213        MD5STEP(F2, c, d, a, b, cvt32(in[15]) + 0xd8a1e681, 14);
     214        MD5STEP(F2, b, c, d, a, cvt32(in[4]) + 0xe7d3fbc8, 20);
     215        MD5STEP(F2, a, b, c, d, cvt32(in[9]) + 0x21e1cde6, 5);
     216        MD5STEP(F2, d, a, b, c, cvt32(in[14]) + 0xc33707d6, 9);
     217        MD5STEP(F2, c, d, a, b, cvt32(in[3]) + 0xf4d50d87, 14);
     218        MD5STEP(F2, b, c, d, a, cvt32(in[8]) + 0x455a14ed, 20);
     219        MD5STEP(F2, a, b, c, d, cvt32(in[13]) + 0xa9e3e905, 5);
     220        MD5STEP(F2, d, a, b, c, cvt32(in[2]) + 0xfcefa3f8, 9);
     221        MD5STEP(F2, c, d, a, b, cvt32(in[7]) + 0x676f02d9, 14);
     222        MD5STEP(F2, b, c, d, a, cvt32(in[12]) + 0x8d2a4c8a, 20);
     223
     224        MD5STEP(F3, a, b, c, d, cvt32(in[5]) + 0xfffa3942, 4);
     225        MD5STEP(F3, d, a, b, c, cvt32(in[8]) + 0x8771f681, 11);
     226        MD5STEP(F3, c, d, a, b, cvt32(in[11]) + 0x6d9d6122, 16);
     227        MD5STEP(F3, b, c, d, a, cvt32(in[14]) + 0xfde5380c, 23);
     228        MD5STEP(F3, a, b, c, d, cvt32(in[1]) + 0xa4beea44, 4);
     229        MD5STEP(F3, d, a, b, c, cvt32(in[4]) + 0x4bdecfa9, 11);
     230        MD5STEP(F3, c, d, a, b, cvt32(in[7]) + 0xf6bb4b60, 16);
     231        MD5STEP(F3, b, c, d, a, cvt32(in[10]) + 0xbebfbc70, 23);
     232        MD5STEP(F3, a, b, c, d, cvt32(in[13]) + 0x289b7ec6, 4);
     233        MD5STEP(F3, d, a, b, c, cvt32(in[0]) + 0xeaa127fa, 11);
     234        MD5STEP(F3, c, d, a, b, cvt32(in[3]) + 0xd4ef3085, 16);
     235        MD5STEP(F3, b, c, d, a, cvt32(in[6]) + 0x04881d05, 23);
     236        MD5STEP(F3, a, b, c, d, cvt32(in[9]) + 0xd9d4d039, 4);
     237        MD5STEP(F3, d, a, b, c, cvt32(in[12]) + 0xe6db99e5, 11);
     238        MD5STEP(F3, c, d, a, b, cvt32(in[15]) + 0x1fa27cf8, 16);
     239        MD5STEP(F3, b, c, d, a, cvt32(in[2]) + 0xc4ac5665, 23);
     240
     241        MD5STEP(F4, a, b, c, d, cvt32(in[0]) + 0xf4292244, 6);
     242        MD5STEP(F4, d, a, b, c, cvt32(in[7]) + 0x432aff97, 10);
     243        MD5STEP(F4, c, d, a, b, cvt32(in[14]) + 0xab9423a7, 15);
     244        MD5STEP(F4, b, c, d, a, cvt32(in[5]) + 0xfc93a039, 21);
     245        MD5STEP(F4, a, b, c, d, cvt32(in[12]) + 0x655b59c3, 6);
     246        MD5STEP(F4, d, a, b, c, cvt32(in[3]) + 0x8f0ccc92, 10);
     247        MD5STEP(F4, c, d, a, b, cvt32(in[10]) + 0xffeff47d, 15);
     248        MD5STEP(F4, b, c, d, a, cvt32(in[1]) + 0x85845dd1, 21);
     249        MD5STEP(F4, a, b, c, d, cvt32(in[8]) + 0x6fa87e4f, 6);
     250        MD5STEP(F4, d, a, b, c, cvt32(in[15]) + 0xfe2ce6e0, 10);
     251        MD5STEP(F4, c, d, a, b, cvt32(in[6]) + 0xa3014314, 15);
     252        MD5STEP(F4, b, c, d, a, cvt32(in[13]) + 0x4e0811a1, 21);
     253        MD5STEP(F4, a, b, c, d, cvt32(in[4]) + 0xf7537e82, 6);
     254        MD5STEP(F4, d, a, b, c, cvt32(in[11]) + 0xbd3af235, 10);
     255        MD5STEP(F4, c, d, a, b, cvt32(in[2]) + 0x2ad7d2bb, 15);
     256        MD5STEP(F4, b, c, d, a, cvt32(in[9]) + 0xeb86d391, 21);
    230257
    231258        buf[0] += a;
  • lib/md5.h

    rfc5cf88 rca60550  
    2727#include <sys/types.h>
    2828#include <gmodule.h>
     29#include <stdint.h>
    2930
    30 typedef u_int8_t md5_byte_t;
     31typedef uint8_t md5_byte_t;
    3132typedef struct MD5Context {
    32         u_int32_t buf[4];
    33         u_int32_t bits[2];
     33        uint32_t buf[4];
     34        uint32_t bits[2];
    3435        unsigned char in[64];
    3536} md5_state_t;
  • lib/misc.c

    rfc5cf88 rca60550  
    9090        struct tm tm;
    9191
     92        memset(&tm, 0, sizeof(struct tm));
    9293        tm.tm_year = year - 1900;
    9394        tm.tm_mon = month - 1;
     
    9697        tm.tm_min = min;
    9798        tm.tm_sec = sec >= 0 ? sec : time(NULL) % 60;
     99       
    98100        return mktime(&tm);
    99101}
     
    245247}
    246248
    247 void info_string_append(GString *str, char *newline, char *name, char *value)
    248 {
    249         if( value && value[0] )
    250                 g_string_sprintfa( str, "%s%s: %s", newline, name, value );
    251 }
    252 
    253249/* Decode%20a%20file%20name                                             */
    254250void http_decode( char *s )
  • lib/misc.h

    rfc5cf88 rca60550  
    4242G_MODULE_EXPORT char *strip_newlines(char *source);
    4343G_MODULE_EXPORT char *normalize( const char *s );
    44 G_MODULE_EXPORT void info_string_append( GString *str, char *newline, char *name, char *value );
    4544
    4645G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );
  • protocols/jabber/conference.c

    rfc5cf88 rca60550  
    3737        xt_add_attr( node, "xmlns", XMLNS_MUC );
    3838        node = jabber_make_packet( "presence", NULL, roomjid, node );
     39        if( password )
     40                xt_add_child( node, xt_new_node( "password", password, NULL ) );
    3941        jabber_cache_add( ic, node, jabber_chat_join_failed );
    4042       
     
    7375       
    7476        room = xt_find_attr( orig, "to" );
    75         if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) )
    76                 jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
    77        
     77        bud = jabber_buddy_by_jid( ic, room, 0 );
    7878        err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR );
    7979        if( err )
    8080        {
    81                 imcb_error( ic, "Error joining groupchat %s: %s%s%s",
    82                             bud->bare_jid, err->code, err->text ? ": " : "",
    83                             err->text ? err->text : "" );
     81                imcb_error( ic, "Error joining groupchat %s: %s%s%s", room, err->code,
     82                            err->text ? ": " : "", err->text ? err->text : "" );
    8483                jabber_error_free( err );
    8584        }
     85        if( bud )
     86                jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) );
    8687       
    8788        return XT_HANDLED;
     
    123124        struct jabber_chat *jc = c->data;
    124125        struct xt_node *node;
     126       
     127        jc->flags |= JCFLAG_MESSAGE_SENT;
    125128       
    126129        node = xt_new_node( "body", message, NULL );
     
    296299        struct xt_node *subject = xt_find_node( node->children, "subject" );
    297300        struct xt_node *body = xt_find_node( node->children, "body" );
    298         struct groupchat *chat;
     301        struct groupchat *chat = bud ? jabber_chat_by_jid( ic, bud->bare_jid ) : NULL;
     302        struct jabber_chat *jc = chat ? chat->data : NULL;
    299303        char *s;
    300304       
    301         if( bud == NULL )
    302         {
     305        if( bud == NULL || ( jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) )
     306        {
     307                char *nick;
     308               
     309                if( body == NULL || body->text_len == 0 )
     310                        /* Meh. Empty messages aren't very interesting, no matter
     311                           how much some servers love to send them. */
     312                        return;
     313               
    303314                s = xt_find_attr( node, "from" ); /* pkt_message() already NULL-checked this one. */
    304                 if( strchr( s, '/' ) == NULL )
     315                nick = strchr( s, '/' );
     316                if( nick )
     317                {
     318                        /* If this message included a resource/nick we don't know,
     319                           we might still know the groupchat itself. */
     320                        *nick = 0;
     321                        chat = jabber_chat_by_jid( ic, s );
     322                        *nick = '/';
     323                       
     324                        nick ++;
     325                }
     326                else
     327                {
     328                        /* message.c uses the EXACT_JID option, so bud should
     329                           always be NULL here for bare JIDs. */
     330                        chat = jabber_chat_by_jid( ic, s );
     331                }
     332               
     333                if( nick == NULL )
     334                {
    305335                        /* This is fine, the groupchat itself isn't in jd->buddies. */
    306                         imcb_log( ic, "System message from groupchat %s: %s", s, body? body->text : "NULL" );
     336                        if( chat )
     337                                imcb_chat_log( chat, "From conference server: %s", body->text );
     338                        else
     339                                imcb_log( ic, "System message from unknown groupchat %s: %s", s, body->text );
     340                }
    307341                else
    308                         /* This, however, isn't fine! */
    309                         imcb_log( ic, "Groupchat message from unknown participant %s: %s", s, body ? body->text : "NULL" );
     342                {
     343                        /* This can happen too, at least when receiving a backlog when
     344                           just joining a channel. */
     345                        if( chat )
     346                                imcb_chat_log( chat, "Message from unknown participant %s: %s", nick, body->text );
     347                        else
     348                                imcb_log( ic, "Groupchat message from unknown JID %s: %s", s, body->text );
     349                }
    310350               
    311351                return;
    312352        }
    313         else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) ) == NULL )
     353        else if( chat == NULL )
    314354        {
    315355                /* How could this happen?? We could do kill( self, 11 )
  • protocols/jabber/io.c

    rfc5cf88 rca60550  
    249249        struct im_connection *ic = data;
    250250       
     251        if( g_slist_find( jabber_connections, ic ) == NULL )
     252                return FALSE;
     253       
    251254        if( source == -1 )
    252255        {
     
    264267{
    265268        struct im_connection *ic = data;
    266         struct jabber_data *jd = ic->proto_data;
     269        struct jabber_data *jd;
     270       
     271        if( g_slist_find( jabber_connections, ic ) == NULL )
     272                return FALSE;
     273       
     274        jd = ic->proto_data;
    267275       
    268276        if( source == NULL )
  • protocols/jabber/iq.c

    rfc5cf88 rca60550  
    9292                else if( strcmp( s, XMLNS_DISCOVER ) == 0 )
    9393                {
    94                         const char *features[] = { XMLNS_VERSION,
     94                        const char *features[] = { XMLNS_DISCOVER,
     95                                                   XMLNS_VERSION,
    9596                                                   XMLNS_TIME,
    9697                                                   XMLNS_CHATSTATES,
  • protocols/jabber/jabber.c

    rfc5cf88 rca60550  
    3535#include "base64.h"
    3636
     37GSList *jabber_connections;
     38
    3739static void jabber_init( account_t *acc )
    3840{
     
    7072        struct ns_srv_reply *srv = NULL;
    7173        char *connect_to, *s;
     74       
     75        /* For now this is needed in the _connected() handlers if using
     76           GLib event handling, to make sure we're not handling events
     77           on dead connections. */
     78        jabber_connections = g_slist_prepend( jabber_connections, ic );
    7279       
    7380        jd->ic = ic;
     
    263270        g_free( jd->username );
    264271        g_free( jd );
     272       
     273        jabber_connections = g_slist_remove( jabber_connections, ic );
    265274}
    266275
  • protocols/jabber/jabber.h

    rfc5cf88 rca60550  
    2929#include "xmltree.h"
    3030#include "bitlbee.h"
     31
     32extern GSList *jabber_connections;
    3133
    3234typedef enum
     
    4749typedef enum
    4850{
    49         JBFLAG_PROBED_XEP85 = 1,        /* Set this when we sent our probe packet to make
     51        JBFLAG_PROBED_XEP85 = 1,        /* Set this when we sent our probe packet to make
    5052                                           sure it gets sent only once. */
    51         JBFLAG_DOES_XEP85 = 2,          /* Set this when the resource seems to support
     53        JBFLAG_DOES_XEP85 = 2,          /* Set this when the resource seems to support
    5254                                           XEP85 (typing notification shite). */
    53         JBFLAG_IS_CHATROOM = 4,         /* It's convenient to use this JID thingy for
     55        JBFLAG_IS_CHATROOM = 4,         /* It's convenient to use this JID thingy for
    5456                                           groupchat state info too. */
    55         JBFLAG_IS_ANONYMOUS = 8,        /* For anonymous chatrooms, when we don't have
     57        JBFLAG_IS_ANONYMOUS = 8,        /* For anonymous chatrooms, when we don't have
    5658                                           have a real JID. */
    5759} jabber_buddy_flags_t;
     60
     61typedef enum
     62{
     63        JCFLAG_MESSAGE_SENT = 1,        /* Set this after sending the first message, so
     64                                           we can detect echoes/backlogs. */
     65} jabber_chat_flags_t;
    5866
    5967struct jabber_data
     
    93101struct jabber_cache_entry
    94102{
     103        time_t saved_at;
    95104        struct xt_node *node;
    96105        jabber_cache_event func;
     
    138147#define JABBER_PACKET_ID "BeeP"
    139148#define JABBER_CACHED_ID "BeeC"
     149
     150/* The number of seconds to keep cached packets before garbage collecting
     151   them. This gc is done on every keepalive (every minute). */
     152#define JABBER_CACHE_MAX_AGE 600
    140153
    141154/* RFC 392[01] stuff */
     
    159172#define XMLNS_MUC          "http://jabber.org/protocol/muc"     /* XEP-0045 */
    160173#define XMLNS_MUC_USER     "http://jabber.org/protocol/muc#user"/* XEP-0045 */
     174#define XMLNS_CAPS         "http://jabber.org/protocol/caps"    /* XEP-0115 */
    161175
    162176/* iq.c */
  • protocols/jabber/jabber_util.c

    rfc5cf88 rca60550  
    142142        entry->node = node;
    143143        entry->func = func;
     144        entry->saved_at = time( NULL );
    144145        g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry );
    145146}
     
    163164{
    164165        struct jabber_data *jd = ic->proto_data;
    165        
    166         g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL );
    167 }
    168 
    169 gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullpointer )
     166        time_t threshold = time( NULL ) - JABBER_CACHE_MAX_AGE;
     167       
     168        g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, &threshold );
     169}
     170
     171gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer threshold_ )
    170172{
    171173        struct jabber_cache_entry *entry = entry_;
    172         struct xt_node *node = entry->node;
    173        
    174         if( node->flags & XT_SEEN )
    175                 return TRUE;
    176         else
    177         {
    178                 node->flags |= XT_SEEN;
    179                 return FALSE;
    180         }
     174        time_t *threshold = threshold_;
     175       
     176        return entry->saved_at < *threshold;
    181177}
    182178
     
    392388                if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) )
    393389                {
     390                        /* Just return the first one for this bare JID. */
     391                        if( flags & GET_BUDDY_FIRST )
     392                        {
     393                                *s = '/';
     394                                g_free( jid );
     395                                return bud;
     396                        }
     397                       
    394398                        /* Is this one of those no-resource buddies? */
    395399                        if( bud->resource == NULL )
    396400                        {
     401                                *s = '/';
    397402                                g_free( jid );
    398403                                return NULL;
    399404                        }
    400                         else
    401                         {
    402                                 /* See if there's an exact match. */
    403                                 for( ; bud; bud = bud->next )
    404                                         if( g_strcasecmp( bud->resource, s + 1 ) == 0 )
    405                                                 break;
    406                         }
     405                       
     406                        /* See if there's an exact match. */
     407                        for( ; bud; bud = bud->next )
     408                                if( g_strcasecmp( bud->resource, s + 1 ) == 0 )
     409                                        break;
    407410                }
    408411                else
     
    413416                           is done to handle conferences properly. */
    414417                        none_found = 1;
     418                        /* TODO(wilmer): Find out what I was thinking when I
     419                           wrote this??? And then fix it. This makes me sad... */
    415420                }
    416421               
     
    442447                else if( ( bud->resource == NULL || bud->next == NULL ) )
    443448                        /* No need for selection if there's only one option. */
     449                        return bud;
     450                else if( flags & GET_BUDDY_FIRST )
     451                        /* Looks like the caller doesn't care about details. */
    444452                        return bud;
    445453               
  • protocols/jabber/presence.c

    rfc5cf88 rca60550  
    2929        char *from = xt_find_attr( node, "from" );
    3030        char *type = xt_find_attr( node, "type" );      /* NULL should mean the person is online. */
    31         struct xt_node *c;
    32         struct jabber_buddy *bud;
    33         int is_chat = 0, is_away = 0;
     31        struct xt_node *c, *cap;
     32        struct jabber_buddy *bud, *send_presence = NULL;
     33        int is_chat = 0;
    3434        char *s;
    3535       
     
    6363                {
    6464                        bud->away_state = (void*) jabber_away_state_by_code( c->text );
    65                         if( strcmp( c->text, "chat" ) != 0 )
    66                                 is_away = OPT_AWAY;
    6765                }
    6866                else
     
    7977                        bud->priority = 0;
    8078               
     79                if( bud && ( cap = xt_find_node( node->children, "c" ) ) &&
     80                    ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 )
     81                {
     82                        /* This <presence> stanza includes an XEP-0115
     83                           capabilities part. Not too interesting, but we can
     84                           see if it has an ext= attribute. */
     85                        s = xt_find_attr( cap, "ext" );
     86                        if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) )
     87                                bud->flags |= JBFLAG_DOES_XEP85;
     88                       
     89                        /* This field can contain more information like xhtml
     90                           support, but we don't support that ourselves.
     91                           Officially the ext= tag was deprecated, but enough
     92                           clients do send it.
     93                           
     94                           (I'm aware that this is not the right way to use
     95                           this field.) See for an explanation of ext=:
     96                           http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/
     97                }
     98               
    8199                if( is_chat )
    82100                        jabber_chat_pkt_presence( ic, bud, node );
    83                 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
    84                         imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    85                                            ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
    86                                            bud->away_message );
     101                else
     102                        send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 );
    87103        }
    88104        else if( strcmp( type, "unavailable" ) == 0 )
     
    119135                        /* If another resource is still available, send its presence
    120136                           information. */
    121                         if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
    122                         {
    123                                 if( bud->away_state && ( *bud->away_state->code == 0 ||
    124                                     strcmp( bud->away_state->code, "chat" ) == 0 ) )
    125                                         is_away = OPT_AWAY;
    126                                
    127                                 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
    128                                                    ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
    129                                                    bud->away_message );
    130                         }
    131                         else
     137                        if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
    132138                        {
    133139                                /* Otherwise, count him/her as offline now. */
     
    177183                } */
    178184        }
     185
     186        if( send_presence )
     187        {
     188                int is_away = 0;
     189
     190                if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
     191                    strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
     192                        is_away = OPT_AWAY;
     193
     194                imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
     195                                   ( is_away && send_presence->away_state ) ?
     196                                   send_presence->away_state->full_name : NULL,
     197                                   send_presence->away_message );
     198        }
    179199       
    180200        return XT_HANDLED;
     
    186206{
    187207        struct jabber_data *jd = ic->proto_data;
    188         struct xt_node *node;
     208        struct xt_node *node, *cap;
    189209        char *show = jd->away_state->code;
    190210        char *status = jd->away_message;
     
    199219                xt_add_child( node, xt_new_node( "status", status, NULL ) );
    200220       
     221        /* This makes the packet slightly bigger, but clients interested in
     222           capabilities can now cache the discovery info. This reduces the
     223           usual post-login iq-flood. See XEP-0115. At least libpurple and
     224           Trillian seem to do this right. */
     225        cap = xt_new_node( "c", NULL, NULL );
     226        xt_add_attr( cap, "xmlns", XMLNS_CAPS );
     227        xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" );
     228        xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */
     229        xt_add_child( node, cap );
     230       
    201231        st = jabber_write_packet( ic, node );
    202232       
  • protocols/jabber/sasl.c

    rfc5cf88 rca60550  
    2121*                                                                           *
    2222\***************************************************************************/
     23
     24#include <ctype.h>
    2325
    2426#include "jabber.h"
     
    107109}
    108110
    109 static char *sasl_get_part( char *data, char *field )
     111/* Non-static function, but not mentioned in jabber.h because it's for internal
     112   use, just that the unittest should be able to reach it... */
     113char *sasl_get_part( char *data, char *field )
    110114{
    111115        int i, len;
    112116       
    113117        len = strlen( field );
     118       
     119        while( isspace( *data ) || *data == ',' )
     120                data ++;
    114121       
    115122        if( g_strncasecmp( data, field, len ) == 0 && data[len] == '=' )
     
    129136                        }
    130137                       
    131                         /* If we got a comma, we got a new field. Check it. */
    132                         if( data[i] == ',' &&
    133                             g_strncasecmp( data + i + 1, field, len ) == 0 &&
    134                             data[i+len+1] == '=' )
     138                        /* If we got a comma, we got a new field. Check it,
     139                           find the next key after it. */
     140                        if( data[i] == ',' )
    135141                        {
    136                                 i += len + 2;
    137                                 break;
     142                                while( isspace( data[i] ) || data[i] == ',' )
     143                                        i ++;
     144                               
     145                                if( g_strncasecmp( data + i, field, len ) == 0 &&
     146                                    data[i+len] == '=' )
     147                                {
     148                                        i += len + 1;
     149                                        break;
     150                                }
    138151                        }
    139152                }
  • protocols/msn/msn.h

    rfc5cf88 rca60550  
    2929#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
    3030
    31 #ifdef _WIN32
    32 #define debug 
     31#ifdef DEBUG
     32#define debug( text... ) imcb_log( ic, text );
    3333#else
    34 #define debug( text... ) irc_usermsg( IRC, text );
    35 #undef debug
    3634#define debug( text... )
    3735#endif
     
    6664        GSList *msgq;
    6765        GSList *switchboards;
     66        int sb_failures;
     67        time_t first_sb_failure;
     68       
    6869        const struct msn_away_state *away_state;
    69        
    7070        int buddycount;
    7171        int groupcount;
  • protocols/msn/ns.c

    rfc5cf88 rca60550  
    584584        else
    585585        {
    586                 debug( "Received unknown command from main server: %s", cmd[0] );
     586                /* debug( "Received unknown command from main server: %s", cmd[0] ); */
    587587        }
    588588       
  • protocols/msn/sb.c

    rfc5cf88 rca60550  
    277277{
    278278        struct msn_switchboard *sb = data;
     279        struct im_connection *ic = sb->ic;
     280        struct msn_data *md = ic->proto_data;
    279281       
    280282        if( msn_handler( sb->handler ) == -1 )
    281283        {
     284                time_t now = time( NULL );
     285               
     286                if( now - md->first_sb_failure > 600 )
     287                {
     288                        /* It's not really the first one, but the start of this "series".
     289                           With this, the warning below will be shown only if this happens
     290                           at least three times in ten minutes. This algorithm isn't
     291                           perfect, but for this purpose it will do. */
     292                        md->first_sb_failure = now;
     293                        md->sb_failures = 0;
     294                }
     295               
    282296                debug( "Error: Switchboard died" );
     297                if( ++ md->sb_failures >= 3 )
     298                        imcb_log( ic, "Warning: Many switchboard failures on MSN connection. "
     299                                      "There might be problems delivering your messages." );
     300               
     301                if( sb->msgq != NULL )
     302                {
     303                        char buf[1024];
     304                       
     305                        if( md->msgq == NULL )
     306                        {
     307                                md->msgq = sb->msgq;
     308                        }
     309                        else
     310                        {
     311                                GSList *l;
     312                               
     313                                for( l = md->msgq; l->next; l = l->next );
     314                                l->next = sb->msgq;
     315                        }
     316                        sb->msgq = NULL;
     317                       
     318                        debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." );
     319                        g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
     320                        if( !msn_write( ic, buf, strlen( buf ) ) )
     321                                return FALSE;
     322                }
     323               
    283324                msn_sb_destroy( sb );
    284325               
     
    286327        }
    287328        else
     329        {
    288330                return TRUE;
     331        }
    289332}
    290333
     
    551594        else
    552595        {
    553                 debug( "Received unknown command from switchboard server: %s", cmd[0] );
     596                /* debug( "Received unknown command from switchboard server: %s", cmd[0] ); */
    554597        }
    555598       
  • protocols/nogaim.c

    rfc5cf88 rca60550  
    625625}
    626626
    627 void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at )
     627void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at )
    628628{
    629629        irc_t *irc = ic->irc;
     
    676676}
    677677
    678 void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags )
     678void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags )
    679679{
    680680        user_t *u;
     
    690690                irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
    691691        }
     692}
     693
     694struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
     695{
     696        struct groupchat *c;
     697       
     698        /* This one just creates the conversation structure, user won't see anything yet */
     699       
     700        if( ic->groupchats )
     701        {
     702                for( c = ic->groupchats; c->next; c = c->next );
     703                c = c->next = g_new0( struct groupchat, 1 );
     704        }
     705        else
     706                ic->groupchats = c = g_new0( struct groupchat, 1 );
     707       
     708        c->ic = ic;
     709        c->title = g_strdup( handle );
     710        c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
     711        c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );
     712       
     713        if( set_getbool( &ic->irc->set, "debug" ) )
     714                imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
     715       
     716        return c;
    692717}
    693718
     
    728753                g_free( c->channel );
    729754                g_free( c->title );
     755                g_free( c->topic );
    730756                g_free( c );
    731757        }
    732758}
    733759
    734 void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at )
     760void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at )
    735761{
    736762        struct im_connection *ic = c->ic;
     
    758784        }
    759785        g_free( wrapped );
     786}
     787
     788void imcb_chat_log( struct groupchat *c, char *format, ... )
     789{
     790        irc_t *irc = c->ic->irc;
     791        va_list params;
     792        char *text;
     793        user_t *u;
     794       
     795        va_start( params, format );
     796        text = g_strdup_vprintf( format, params );
     797        va_end( params );
     798       
     799        u = user_find( irc, irc->mynick );
     800       
     801        irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );
     802       
     803        g_free( text );
    760804}
    761805
     
    781825        if( c->joined && u )
    782826                irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
    783 }
    784 
    785 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
    786 {
    787         struct groupchat *c;
    788        
    789         /* This one just creates the conversation structure, user won't see anything yet */
    790        
    791         if( ic->groupchats )
    792         {
    793                 for( c = ic->groupchats; c->next; c = c->next );
    794                 c = c->next = g_new0( struct groupchat, 1 );
    795         }
    796         else
    797                 ic->groupchats = c = g_new0( struct groupchat, 1 );
    798        
    799         c->ic = ic;
    800         c->title = g_strdup( handle );
    801         c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
    802         c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );
    803        
    804         if( set_getbool( &ic->irc->set, "debug" ) )
    805                 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
    806        
    807         return c;
    808827}
    809828
  • protocols/nogaim.h

    rfc5cf88 rca60550  
    6868{
    6969        account_t *acc;
    70         u_int32_t flags;
     70        uint32_t flags;
    7171       
    7272        /* each connection then can have its own protocol-specific data */
     
    282282/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
    283283/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
    284 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at );
    285 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags );
     284G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at );
     285G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags );
    286286G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle );
    287287
     
    299299G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
    300300/* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
    301 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
     301G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at );
     302/* System messages specific to a groupchat, so they can be displayed in the right context. */
     303G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
    302304/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */
    303305G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at );
  • protocols/oscar/oscar.c

    rfc5cf88 rca60550  
    9191        gboolean icq;
    9292        GSList *evilhack;
     93       
     94        GHashTable *ips;
    9395
    9496        struct {
     
    356358        struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1);
    357359
    358         if (!isdigit(acc->user[0])) {
     360        if (isdigit(acc->user[0]))
     361                odata->icq = TRUE;
     362        else
    359363                ic->flags |= OPT_DOES_HTML;
    360         }
    361364
    362365        sess = g_new0(aim_session_t, 1);
     
    411414                g_free(cr);
    412415        }
     416        if (odata->ips)
     417                g_hash_table_destroy(odata->ips);
    413418        if (odata->email)
    414419                g_free(odata->email);
     
    987992                signon = time(NULL) - info->sessionlen;
    988993
     994        if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) {
     995                uint32_t *uin = g_new0(uint32_t, 1);
     996               
     997                if (od->ips == NULL)
     998                        od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
     999               
     1000                if (sscanf(info->sn, "%d", uin) == 1)
     1001                        g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr);
     1002        }
     1003
    9891004        tmp = g_strdup(normalize(ic->acc->user));
    9901005        if (!strcmp(tmp, normalize(info->sn)))
     
    10511066                g_snprintf(tmp, BUF_LONG, "%s", args->msg);
    10521067        } else {
    1053                 int i;
     1068                aim_mpmsg_section_t *part;
    10541069               
    10551070                *tmp = 0;
    1056                 for (i = 0; i < args->mpmsg.numparts; i ++) {
    1057                         g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG);
    1058                         g_strlcat(tmp, "\n", BUF_LONG);
     1071                for (part = args->mpmsg.parts; part; part = part->next) {
     1072                        if (part->data) {
     1073                                g_strlcat(tmp, (char*) part->data, BUF_LONG);
     1074                                g_strlcat(tmp, "\n", BUF_LONG);
     1075                        }
    10591076                }
    10601077        }
     
    22192236static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
    22202237{
    2221         struct im_connection *ic = sess->aux_data;
    2222         gchar who[16];
    2223         GString *str;
    2224         va_list ap;
    2225         struct aim_icq_info *info;
    2226 
    2227         va_start(ap, fr);
    2228         info = va_arg(ap, struct aim_icq_info *);
    2229         va_end(ap);
    2230 
    2231         if (!info->uin)
    2232                 return 0;
    2233 
    2234         str = g_string_sized_new(100);
    2235         g_snprintf(who, sizeof(who), "%u", info->uin);
    2236 
    2237         g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
    2238                                 info->nick ? info->nick : "-");
    2239         info_string_append(str, "\n", _("First Name"), info->first);
    2240         info_string_append(str, "\n", _("Last Name"), info->last);
    2241                 info_string_append(str, "\n", _("Email Address"), info->email);
    2242         if (info->numaddresses && info->email2) {
    2243                 int i;
    2244                 for (i = 0; i < info->numaddresses; i++) {
    2245                                         info_string_append(str, "\n", _("Email Address"), info->email2[i]);
    2246                 }
    2247         }
    2248         info_string_append(str, "\n", _("Mobile Phone"), info->mobile);
    2249         if (info->gender != 0)
    2250                 info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
    2251         if (info->birthyear || info->birthmonth || info->birthday) {
    2252                 char date[30];
    2253                 struct tm tm;
    2254                 tm.tm_mday = (int)info->birthday;
    2255                 tm.tm_mon = (int)info->birthmonth-1;
    2256                 tm.tm_year = (int)info->birthyear%100;
    2257                 strftime(date, sizeof(date), "%Y-%m-%d", &tm);
    2258                 info_string_append(str, "\n", _("Birthday"), date);
    2259         }
    2260         if (info->age) {
    2261                 char age[5];
    2262                 g_snprintf(age, sizeof(age), "%hhd", info->age);
    2263                 info_string_append(str, "\n", _("Age"), age);
    2264         }
    2265                 info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage);
    2266         if (info->info && info->info[0]) {
    2267                 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
    2268                                                 info->info, _("End of Additional Information"));
    2269         }
    2270         g_string_sprintfa(str, "\n");
    2271         if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
    2272                 g_string_sprintfa(str, "%s:", _("Home Address"));
    2273                 info_string_append(str, "\n", _("Address"), info->homeaddr);
    2274                 info_string_append(str, "\n", _("City"), info->homecity);
    2275                 info_string_append(str, "\n", _("State"), info->homestate);
    2276                                 info_string_append(str, "\n", _("Zip Code"), info->homezip);
    2277                 g_string_sprintfa(str, "\n");
    2278         }
    2279         if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
    2280                 g_string_sprintfa(str, "%s:", _("Work Address"));
    2281                 info_string_append(str, "\n", _("Address"), info->workaddr);
    2282                 info_string_append(str, "\n", _("City"), info->workcity);
    2283                 info_string_append(str, "\n", _("State"), info->workstate);
    2284                                 info_string_append(str, "\n", _("Zip Code"), info->workzip);
    2285                 g_string_sprintfa(str, "\n");
    2286         }
    2287         if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
    2288                 g_string_sprintfa(str, "%s:", _("Work Information"));
    2289                 info_string_append(str, "\n", _("Company"), info->workcompany);
    2290                 info_string_append(str, "\n", _("Division"), info->workdivision);
    2291                 info_string_append(str, "\n", _("Position"), info->workposition);
    2292                 if (info->workwebpage && info->workwebpage[0]) {
    2293                         info_string_append(str, "\n", _("Web Page"), info->workwebpage);
    2294                 }
    2295                 g_string_sprintfa(str, "\n");
    2296         }
    2297 
    2298                 imcb_log(ic, "%s\n%s", _("User Info"), str->str);
    2299         g_string_free(str, TRUE);
    2300 
    2301         return 1;
     2238        struct im_connection *ic = sess->aux_data;
     2239        struct oscar_data *od = ic->proto_data;
     2240        gchar who[16];
     2241        GString *str;
     2242        va_list ap;
     2243        struct aim_icq_info *info;
     2244        uint32_t ip;
     2245
     2246        va_start(ap, fr);
     2247        info = va_arg(ap, struct aim_icq_info *);
     2248        va_end(ap);
     2249
     2250        if (!info->uin)
     2251                return 0;
     2252
     2253        str = g_string_sized_new(512);
     2254        g_snprintf(who, sizeof(who), "%u", info->uin);
     2255
     2256        g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"),
     2257        info->nick ? info->nick : "-");
     2258        g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first);
     2259        g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last);
     2260        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email);
     2261        if (info->numaddresses && info->email2) {
     2262                int i;
     2263                for (i = 0; i < info->numaddresses; i++) {
     2264                        g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]);
     2265                }
     2266        }
     2267        if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) {
     2268                g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"),
     2269                                       (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
     2270        }
     2271        g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile);
     2272        if (info->gender != 0)
     2273                g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male"));
     2274        if (info->birthyear || info->birthmonth || info->birthday) {
     2275                char date[30];
     2276                struct tm tm;
     2277                memset(&tm, 0, sizeof(struct tm));
     2278                tm.tm_mday = (int)info->birthday;
     2279                tm.tm_mon = (int)info->birthmonth-1;
     2280                tm.tm_year = (int)info->birthyear%100;
     2281                strftime(date, sizeof(date), "%Y-%m-%d", &tm);
     2282                g_string_append_printf(str, "\n%s: %s", _("Birthday"), date);
     2283        }
     2284        if (info->age) {
     2285                char age[5];
     2286                g_snprintf(age, sizeof(age), "%hhd", info->age);
     2287                g_string_append_printf(str, "\n%s: %s", _("Age"), age);
     2288        }
     2289        g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage);
     2290        if (info->info && info->info[0]) {
     2291                g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"),
     2292                info->info, _("End of Additional Information"));
     2293        }
     2294        g_string_append_c(str, '\n');
     2295        if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
     2296                g_string_append_printf(str, "%s:", _("Home Address"));
     2297                g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr);
     2298                g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity);
     2299                g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate);
     2300                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip);
     2301                g_string_append_c(str, '\n');
     2302        }
     2303        if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
     2304                g_string_append_printf(str, "%s:", _("Work Address"));
     2305                g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr);
     2306                g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity);
     2307                g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate);
     2308                g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip);
     2309                g_string_append_c(str, '\n');
     2310        }
     2311        if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
     2312                g_string_append_printf(str, "%s:", _("Work Information"));
     2313                g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany);
     2314                g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision);
     2315                g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition);
     2316                if (info->workwebpage && info->workwebpage[0]) {
     2317                        g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage);
     2318                }
     2319                g_string_append_c(str, '\n');
     2320        }
     2321
     2322        imcb_log(ic, "%s\n%s", _("User Info"), str->str);
     2323        g_string_free(str, TRUE);
     2324
     2325        return 1;
    23022326
    23032327}
     
    24332457                /* User has stopped typing */
    24342458                imcb_buddy_typing(ic, sn, 0);
    2435         }       
     2459        }
    24362460       
    24372461        return 1;
  • protocols/yahoo/yahoo.c

    rfc5cf88 rca60550  
    624624{
    625625        struct im_connection *ic = byahoo_get_ic_by_id( id );
    626         char *m = byahoo_strip( msg );
    627        
    628         imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
    629         g_free( m );
     626        char *m;
     627       
     628        if( msg )
     629        {
     630                m = byahoo_strip( msg );
     631                imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
     632                g_free( m );
     633        }
    630634}
    631635
  • root_commands.c

    rfc5cf88 rca60550  
    449449        {
    450450                add_on_server = 0;
    451                 cmd ++;         /* So evil... :-D */
     451                cmd ++;
    452452        }
    453453       
     
    481481        }
    482482       
    483         /* By making this optional, you can talk to people without having to
    484            add them to your *real* (server-side) contact list. */
    485483        if( add_on_server )
    486484                a->ic->acc->prpl->add_buddy( a->ic, cmd[2], NULL );
    487        
    488         /* add_buddy( a->ic, NULL, cmd[2], cmd[2] ); */
     485        else
     486                /* Yeah, officially this is a call-*back*... So if we just
     487                   called add_buddy, we'll wait for the IM server to respond
     488                   before we do this. */
     489                imcb_add_buddy( a->ic, cmd[2], NULL );
    489490       
    490491        irc_usermsg( irc, "Adding `%s' to your contact list", cmd[2]  );
     
    821822                if( online == 1 )
    822823                {
    823                         g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name );
     824                        g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    824825                        irc_usermsg( irc, format, u->nick, s, "Online" );
    825826                }
     
    832833                if( away == 1 )
    833834                {
    834                         g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name );
     835                        g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    835836                        irc_usermsg( irc, format, u->nick, s, u->away );
    836837                }
     
    842843                if( offline == 1 )
    843844                {
    844                         g_snprintf( s, sizeof( s ) - 1, "%s@%s (%s)", u->user, u->host, u->ic->acc->prpl->name );
     845                        g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user );
    845846                        irc_usermsg( irc, format, u->nick, s, "Offline" );
    846847                }
  • storage_text.c

    rfc5cf88 rca60550  
    3030static void text_init (void)
    3131{
    32         if( access( global.conf->configdir, F_OK ) != 0 )
    33                 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
    34         else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
    35                 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
     32        /* Don't complain about the configuration directory anymore, leave it
     33           up to the XML storage module, which uses the same directory for it
     34           anyway. Nobody should be using just the text plugin anymore since
     35           it's read only! */
    3636}
    3737
  • storage_xml.c

    rfc5cf88 rca60550  
    263263{
    264264        if( access( global.conf->configdir, F_OK ) != 0 )
    265                 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
     265                log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir );
    266266        else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
    267                 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
     267                log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir );
    268268}
    269269
  • tests/Makefile

    rfc5cf88 rca60550  
    1111distclean: clean
    1212
    13 main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o 
     13main_objs = account.o bitlbee.o conf.o crypting.o help.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_xml.o storage_text.o user.o
    1414
    15 test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o
     15test_objs = check.o check_util.o check_nick.o check_md5.o check_arc.o check_irc.o check_help.o check_user.o check_crypting.o check_set.o check_jabber_sasl.o
    1616
    1717check: $(test_objs) $(addprefix ../, $(main_objs)) ../protocols/protocols.o ../lib/lib.o
  • tests/check.c

    rfc5cf88 rca60550  
    6666Suite *set_suite(void);
    6767
     68/* From check_jabber_sasl.c */
     69Suite *jabber_sasl_suite(void);
     70
    6871int main (int argc, char **argv)
    6972{
     
    111114        srunner_add_suite(sr, crypting_suite());
    112115        srunner_add_suite(sr, set_suite());
     116        srunner_add_suite(sr, jabber_sasl_suite());
    113117        if (no_fork)
    114118                srunner_set_fork_status(sr, CK_NOFORK);
  • tests/check_arc.c

    rfc5cf88 rca60550  
    6262                        0x73, 0x6d, 0xb3, 0x0a, 0x6f, 0x0a, 0x2b, 0x43, 0x57, 0xe9, 0x3e, 0x63
    6363                }, 24, "OSCAR is creepy..."
    64         }
     64        },
     65        { "", 0, NULL }
    6566};
    6667
     
    6970        int i;
    7071       
    71         for( i = 0; clear_tests[i]; i++ )
     72        for( i = 0; decrypt_tests[i].len; i++ )
    7273        {
    7374                tcase_fn_start (decrypt_tests[i].decrypted, __FILE__, __LINE__);
  • unix.c

    rfc5cf88 rca60550  
    4747       
    4848        log_init();
    49         CONF_FILE = g_strdup( CONF_FILE_DEF );
     49        global.conf_file = g_strdup( CONF_FILE_DEF );
    5050        global.conf = conf_load( argc, argv );
    5151        if( global.conf == NULL )
     
    124124        if( !getuid() || !geteuid() )
    125125                log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" );
    126         if( help_init( &(global.help), global.helpfile ) == NULL )
     126        if( help_init( &global.help, global.helpfile ) == NULL )
    127127                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
    128128       
    129129        b_main_run();
     130       
     131        /* Mainly good for restarting, to make sure we close the help.txt fd. */
     132        help_free( &global.help );
    130133       
    131134        if( global.restart )
     
    197200                {
    198201                        if( WIFSIGNALED( st ) )
    199                                 log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) );
     202                                log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", (int) pid, WEXITSTATUS( st ) );
    200203                        else if( WIFEXITED( st ) )
    201                                 log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) );
     204                                log_message( LOGLVL_INFO, "Client %d killed by signal %d.", (int) pid, WTERMSIG( st ) );
    202205                }
    203206        }
Note: See TracChangeset for help on using the changeset viewer.