Changes in / [4ff0966:cdca30b]


Ignore:
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • configure

    r4ff0966 rcdca30b  
    169169fi
    170170
     171GLIB=0
     172
    171173if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
    172174        cat<<EOF>>Makefile.settings
     
    174176CFLAGS+=`$PKG_CONFIG --cflags glib-2.0 gmodule-2.0`
    175177EOF
    176 else
    177         echo 'Cannot find glib2 development libraries, aborting. (Install libglib2-dev?)'
     178        echo '#define GLIB2' >> config.h
     179        GLIB=2
     180elif type glib-config > /dev/null 2> /dev/null; then
     181        cat<<EOF>>Makefile.settings
     182EFLAGS+=`glib-config --libs`
     183CFLAGS+=`glib-config --cflags`
     184EOF
     185        echo '#define GLIB1' >> config.h
     186        GLIB=1
     187else
     188        echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)'
    178189        exit 1;
    179190fi
     191
     192if [ GLIB = 1 -o -r /usr/include/iconv.h ]; then
     193        :;
     194elif [ -r /usr/local/include/iconv.h ]; then
     195        echo CFLAGS+=-I/usr/local/include >> Makefile.settings
     196else
     197        echo
     198        echo 'Warning: Could not find iconv.h, you might have to install it and/or modify'
     199        echo 'Makefile.settings to tell where this file is.'
     200fi
     201
    180202
    181203if [ "$events" = "libevent" ]; then
     
    201223fi
    202224echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings
     225
    203226
    204227detect_gnutls()
     
    397420;;
    398421*BSD )
    399 ;;
    400 Darwin )
    401 ;;
    402 IRIX )
     422        echo 'EFLAGS+=-liconv' >> Makefile.settings;
    403423;;
    404424SunOS )
    405425        echo 'EFLAGS+=-lresolv -lnsl -lsocket' >> Makefile.settings
    406426        echo 'STRIP=\# skip strip' >> Makefile.settings
     427        echo 'EFLAGS+=-liconv' >> Makefile.settings;
     428;;
     429Darwin )
     430        echo 'EFLAGS+=-liconv' >> Makefile.settings;
     431;;
     432IRIX )
    407433;;
    408434CYGWIN* )
  • doc/README

    r4ff0966 rcdca30b  
    4747
    4848BitlBee's only real dependency is GLib. This is available on virtually every
    49 platform. Any recent version of GLib (2.0 or higher) will work.
     49platform. Any recent version of GLib (including 1.x versions) will work.
    5050
    5151These days, MSN Messenger clients have to connect to the MS Passport servers
  • irc_commands.c

    r4ff0966 rcdca30b  
    321321{
    322322        user_t *u;
    323         char buff[IRC_MAX_LINE], *s;
     323        char buff[IRC_MAX_LINE];
    324324        int lenleft, i;
    325325       
     
    331331        for( i = 1; cmd[i]; i ++ )
    332332        {
    333                 char *this, *next;
    334                
    335                 this = cmd[i];
    336                 while( *this )
    337                 {
    338                         if( ( next = strchr( this, ' ' ) ) )
    339                                 *next = 0;
    340                        
    341                         if( ( u = user_find( irc, this ) ) && u->online )
    342                         {
    343                                 lenleft -= strlen( u->nick ) + 1;
    344                                
    345                                 if( lenleft < 0 )
    346                                         break;
    347                                
    348                                 strcat( buff, u->nick );
    349                                 strcat( buff, " " );
    350                         }
    351                        
    352                         if( next )
    353                         {
    354                                 *next = ' ';
    355                                 this = next + 1;
    356                         }
    357                         else
     333                if( ( u = user_find( irc, cmd[i] ) ) && u->online )
     334                {
     335                        /* [SH] Make sure we don't use too much buffer space. */
     336                        lenleft -= strlen( u->nick ) + 1;
     337                       
     338                        if( lenleft < 0 )
    358339                        {
    359340                                break;
    360                         }   
    361                 }
    362                
    363                 /* *sigh* */
    364                 if( lenleft < 0 )
    365                         break;
    366         }
    367        
     341                        }
     342                       
     343                        /* [SH] Add the nick to the buffer. Note
     344                         * that an extra space is always added. Even
     345                         * if it's the last nick in the list. Who
     346                         * cares?
     347                         */
     348                       
     349                        strcat( buff, u->nick );
     350                        strcat( buff, " " );
     351                }
     352        }
     353       
     354        /* [WvG] Well, maybe someone cares, so why not remove it? */
    368355        if( strlen( buff ) > 0 )
    369356                buff[strlen(buff)-1] = '\0';
  • protocols/http_client.c

    r4ff0966 rcdca30b  
    157157       
    158158error:
    159         req->status_string = g_strdup( "Error while writing HTTP request" );
    160        
    161159        req->func( req );
    162160       
     
    218216                        if( !sockerr_again() )
    219217                        {
    220                                 req->status_string = g_strdup( strerror( errno ) );
    221218                                goto cleanup;
    222219                        }
     
    246243           support... */
    247244        if( req->bytes_read == 0 )
    248         {
    249                 req->status_string = g_strdup( "Empty HTTP reply" );
    250245                goto cleanup;
    251         }
    252246       
    253247        /* Zero termination is very convenient. */
     
    270264        else
    271265        {
    272                 req->status_string = g_strdup( "Malformed HTTP reply" );
    273266                goto cleanup;
    274267        }
     
    286279        {
    287280                if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 )
    288                 {
    289                         req->status_string = g_strdup( "Can't parse status code" );
    290281                        req->status_code = -1;
    291                 }
    292                 else
    293                 {
    294                         char *eol;
    295                        
    296                         if( evil_server )
    297                                 eol = strchr( end1, '\n' );
    298                         else
    299                                 eol = strchr( end1, '\r' );
    300                        
    301                         req->status_string = g_strndup( end1 + 1, eol - end1 - 1 );
    302                        
    303                         /* Just to be sure... */
    304                         if( ( eol = strchr( req->status_string, '\r' ) ) )
    305                                 *eol = 0;
    306                         if( ( eol = strchr( req->status_string, '\n' ) ) )
    307                                 *eol = 0;
    308                 }
    309         }
    310         else
    311         {
    312                 req->status_string = g_strdup( "Can't locate status code" );
     282        }
     283        else
     284        {
    313285                req->status_code = -1;
    314286        }
     
    319291                int error = 0, new_port, new_proto;
    320292               
    321                 /* We might fill it again, so let's not leak any memory. */
    322                 g_free( req->status_string );
    323                 req->status_string = NULL;
    324                
    325293                loc = strstr( req->reply_headers, "\nLocation: " );
    326294                if( loc == NULL ) /* We can't handle this redirect... */
    327                 {
    328                         req->status_string = g_strdup( "Can't locate Location: header" );
    329295                        goto cleanup;
    330                 }
    331296               
    332297                loc += 11;
     
    345310                           don't need this yet anyway, I won't implement it. */
    346311                       
    347                         req->status_string = g_strdup( "Can't handle recursive redirects" );
    348                        
    349312                        goto cleanup;
    350313                }
     
    364327                        if( !url_set( url, loc ) )
    365328                        {
    366                                 req->status_string = g_strdup( "Malformed redirect URL" );
    367329                                g_free( url );
    368330                                goto cleanup;
     
    375337                           going to use strcat(), whether you like it or not. :-) */
    376338                       
    377                         sprintf( new_request, "GET %s HTTP/1.0", url->file );
    378                        
    379                         s = strstr( req->request, "\r\n" );
     339                        /* First, find the GET/POST/whatever from the original request. */
     340                        s = strchr( req->request, ' ' );
    380341                        if( s == NULL )
    381342                        {
    382                                 req->status_string = g_strdup( "Error while rebuilding request string" );
    383343                                g_free( new_request );
    384344                                g_free( url );
     
    386346                        }
    387347                       
    388                         strcat( new_request, s );
     348                        *s = 0;
     349                        sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file );
     350                        *s = ' ';
     351                       
     352                        s = strstr( req->request, "\r\n" );
     353                        if( s == NULL )
     354                        {
     355                                g_free( new_request );
     356                                g_free( url );
     357                                goto cleanup;
     358                        }
     359                       
     360                        strcat( new_request, s + 2 );
    389361                        new_host = g_strdup( url->host );
    390362                        new_port = url->port;
     
    400372               
    401373                req->fd = -1;
    402                 req->ssl = NULL;
     374                req->ssl = 0;
    403375               
    404376                if( new_proto == PROTO_HTTPS )
     
    418390                if( error )
    419391                {
    420                         req->status_string = g_strdup( "Connection problem during redirect" );
    421392                        g_free( new_request );
    422393                        goto cleanup;
     
    447418        g_free( req->request );
    448419        g_free( req->reply_headers );
    449         g_free( req->status_string );
    450420        g_free( req );
    451421       
  • protocols/http_client.h

    r4ff0966 rcdca30b  
    3737        int request_length;
    3838        int status_code;
    39         char *status_string;
    4039        char *reply_headers;
    4140        char *reply_body;
  • protocols/msn/ns.c

    r4ff0966 rcdca30b  
    656656        if( key == NULL )
    657657        {
    658                 char *err;
    659                
    660                 err = g_strdup_printf( "Error during Passport authentication (%s)",
    661                                        rep->error_string ? rep->error_string : "Unknown error" );
    662                
    663                 hide_login_progress( gc, err );
     658                hide_login_progress( gc, "Error during Passport authentication" );
    664659                signoff( gc );
    665                
    666                 g_free( err );
    667660        }
    668661        else
  • protocols/msn/passport.c

    r4ff0966 rcdca30b  
    6969        }
    7070       
    71         reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
     71        reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 );
     72        sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );
    7273       
    7374        *dummy = 0;
     
    8788        struct passport_reply *rep = req->data;
    8889       
    89         if( !g_slist_find( msn_connections, rep->data ) )
     90        if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
    9091        {
    9192                destroy_reply( rep );
     
    9394        }
    9495       
    95         if( req->finished && req->reply_headers && req->status_code == 200 )
     96        if( req->status_code == 200 )
    9697        {
    9798                char *dummy;
     
    108109                        rep->result = g_strdup( dummy );
    109110                }
    110                 else
    111                 {
    112                         rep->error_string = g_strdup( "Could not parse Passport server response" );
    113                 }
    114         }
    115         else
    116         {
    117                 rep->error_string = g_strdup_printf( "HTTP error: %s",
    118                                       req->status_string ? req->status_string : "Unknown error" );
    119111        }
    120112       
     
    153145}
    154146
     147#define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"
    155148static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header )
    156149{
     
    162155        rep->header = header;
    163156       
    164         req = http_dorequest_url( "https://nexus.passport.com/rdr/pprdr.asp", passport_retrieve_dalogin_ready, rep );
     157        req = http_dorequest( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep );
    165158       
    166159        if( !req )
     
    176169        char *urlend;
    177170       
    178         if( !g_slist_find( msn_connections, rep->data ) )
     171        if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers )
    179172        {
    180173                destroy_reply( rep );
     
    182175        }
    183176       
    184         if( !req->finished || !req->reply_headers || req->status_code != 200 )
    185         {
    186                 rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin: %s",
    187                                         req->status_string ? req->status_string : "Unknown error" );
     177        dalogin = strstr( req->reply_headers, "DALogin=" );     
     178       
     179        if( !dalogin )
    188180                goto failure;
    189         }
    190        
    191         dalogin = strstr( req->reply_headers, "DALogin=" );     
    192        
    193         if( !dalogin )
    194         {
    195                 rep->error_string = g_strdup( "Parse error while fetching DALogin" );
    196                 goto failure;
    197         }
    198181       
    199182        dalogin += strlen( "DALogin=" );
     
    225208        g_free( rep->result );
    226209        g_free( rep->header );
    227         g_free( rep->error_string );
    228210        g_free( rep );
    229211}
  • protocols/msn/passport.h

    r4ff0966 rcdca30b  
    3939        char *result;
    4040        char *header;
    41         char *error_string;
    4241};
    4342
  • protocols/msn/sb.c

    r4ff0966 rcdca30b  
    529529                {
    530530                        msn_sb_destroy( sb );
    531                         return 0;
    532                 }
    533                 else if( err->flags & STATUS_FATAL )
     531                        return( 0 );
     532                }
     533                if( err->flags & STATUS_FATAL )
    534534                {
    535535                        signoff( gc );
    536                         return 0;
    537                 }
    538                 else if( err->flags & STATUS_SB_IM_SPARE )
     536                        return( 0 );
     537                }
     538                if( err->flags & STATUS_SB_IM_SPARE )
    539539                {
    540540                        if( sb->who )
     
    559559                                sb->msgq = NULL;
    560560                        }
    561                        
    562                         /* Do NOT return 0 here, we want to keep this sb. */
    563561                }
    564562        }
  • protocols/msn/tables.c

    r4ff0966 rcdca30b  
    127127       
    128128        { 910, "Server is busy",                                        STATUS_FATAL },
    129         { 911, "Authentication failed",                                 STATUS_SB_FATAL | STATUS_FATAL },
     129        { 911, "Authentication failed",                                 STATUS_FATAL },
    130130        { 912, "Server is busy",                                        STATUS_FATAL },
    131131        { 913, "Not allowed when hiding",                               0 },
  • util.c

    r4ff0966 rcdca30b  
    3939#include <glib.h>
    4040#include <time.h>
     41#ifdef GLIB2
     42#define iconv_t GIConv
     43#define iconv_open g_iconv_open
     44#define iconv_close g_iconv_close
     45#define iconv g_iconv
     46#else
     47#include <iconv.h>
     48#endif
    4149
    4250void strip_linefeed(gchar *text)
     
    457465signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf )
    458466{
    459         GIConv cd;
     467        iconv_t cd;
    460468        size_t res;
    461469        size_t inbytesleft, outbytesleft;
     
    463471        char *outbuf = dst;
    464472       
    465         cd = g_iconv_open( to_cs, from_cs );
    466         if( cd == (GIConv) -1 )
     473        cd = iconv_open( to_cs, from_cs );
     474        if( cd == (iconv_t) -1 )
    467475                return( -1 );
    468476       
    469477        inbytesleft = size ? size : strlen( src );
    470478        outbytesleft = maxbuf - 1;
    471         res = g_iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
     479        res = iconv( cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
    472480        *outbuf = '\0';
    473         g_iconv_close( cd );
     481        iconv_close( cd );
    474482       
    475483        if( res == (size_t) -1 )
     
    481489char *set_eval_charset( irc_t *irc, set_t *set, char *value )
    482490{
    483         GIConv cd;
     491        iconv_t cd;
    484492
    485493        if ( g_strncasecmp( value, "none", 4 ) == 0 )
    486494                return( value );
    487495
    488         cd = g_iconv_open( "UTF-8", value );
    489         if( cd == (GIConv) -1 )
     496        cd = iconv_open( "UTF-8", value );
     497        if( cd == (iconv_t) -1 )
    490498                return( NULL );
    491499
    492         g_iconv_close( cd );
     500        iconv_close( cd );
    493501        return( value );
    494502}
Note: See TracChangeset for help on using the changeset viewer.