Changes in / [52b3a99:8a9afe4]


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • configure

    r52b3a99 r8a9afe4  
    252252        if [ "$ret" = "0" ]; then
    253253                echo
    254                 echo 'ERROR: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
    255                 echo '       This is necessary for MSN and full Jabber support. To continue,'
    256                 echo '       install a suitable SSL library or disable MSN support (--msn=0).'
    257                 echo '       If you want Jabber without SSL support you can try --ssl=bogus.'
     254                echo 'WARNING: Could not find a suitable SSL library (GnuTLS, libnss or OpenSSL).'
     255                echo '         This is necessary for MSN and full Jabber support. To continue,'
     256                echo '         install a suitable SSL library or disable MSN support (--msn=0).'
     257                echo '         If you want Jabber without SSL support you can try --ssl=bogus.'
    258258               
    259259                exit 1;
     
    308308        echo '#define WITH_MSN' >> config.h
    309309        protocols=$protocols'msn '
    310         protoobjs=$protoobjs'msn_mod.o '
     310        protoobjs=$protoobjs'msnn.o '
    311311fi
    312312
     
    316316        echo '#define WITH_JABBER' >> config.h
    317317        protocols=$protocols'jabber '
    318         protoobjs=$protoobjs'jabber_mod.o '
     318        protoobjs=$protoobjs'jabberr.o '
    319319fi
    320320
     
    324324        echo '#define WITH_OSCAR' >> config.h
    325325        protocols=$protocols'oscar '
    326         protoobjs=$protoobjs'oscar_mod.o '
     326        protoobjs=$protoobjs'oscarr.o '
    327327fi
    328328
     
    332332        echo '#define WITH_YAHOO' >> config.h
    333333        protocols=$protocols'yahoo '
    334         protoobjs=$protoobjs'yahoo_mod.o '
     334        protoobjs=$protoobjs'yahooo.o '
    335335fi
    336336
  • protocols/http_client.c

    r52b3a99 r8a9afe4  
    55  \********************************************************************/
    66
    7 /* HTTP(S) module                                                       */
     7/* HTTP(S) module (actually, it only does HTTPS right now)              */
    88
    99/*
     
    2525
    2626#include <string.h>
    27 #include <stdio.h>
    2827
    2928#include "sock.h"
    3029#include "http_client.h"
    31 #include "url.h"
    3230
    3331
     
    6361        }
    6462       
    65         req->func = func;
    66         req->data = data;
    6763        req->request = g_strdup( request );
    6864        req->request_length = strlen( request );
     
    107103                        if( !sockerr_again() )
    108104                        {
    109                                 closesocket( req->fd );
     105                                close( req->fd );
    110106                                goto error;
    111107                        }
     
    192188                req->reply_headers = g_realloc( req->reply_headers, req->bytes_read + st + 1 );
    193189                memcpy( req->reply_headers + req->bytes_read, buffer, st );
    194                 req->bytes_read += st;
    195190        }
    196191       
     
    213208        if( end2 && end2 < end1 )
    214209        {
    215                 end1 = end2 + 1;
     210                end1 = end2;
    216211                evil_server = 1;
    217         }
    218         else
    219         {
    220                 end1 += 2;
    221212        }
    222213       
     
    226217               
    227218                if( evil_server )
    228                         req->reply_body = end1 + 1;
     219                        req->reply_body = end1 + 2;
    229220                else
    230                         req->reply_body = end1 + 2;
    231         }
    232        
    233         if( ( end1 = strchr( req->reply_headers, ' ' ) ) != NULL )
    234         {
    235                 if( sscanf( end1 + 1, "%d", &req->status_code ) != 1 )
    236                         req->status_code = -1;
    237         }
    238         else
    239         {
    240                 req->status_code = -1;
    241         }
    242        
    243         if( req->status_code == 301 || req->status_code == 302 )
    244         {
    245                 char *loc, *new_request, *new_host;
    246                 int error = 0, new_port, new_proto;
    247                
    248                 loc = strstr( req->reply_headers, "\nLocation: " );
    249                 if( loc == NULL ) /* We can't handle this redirect... */
    250                         goto cleanup;
    251                
    252                 loc += 11;
    253                 while( *loc == ' ' )
    254                         loc ++;
    255                
    256                 /* TODO/FIXME: Possibly have to handle relative redirections,
    257                    and rewrite Host: headers. Not necessary for now, it's
    258                    enough for passport authentication like this. */
    259                
    260                 if( *loc == '/' )
    261                 {
    262                         /* Just a different pathname... */
    263                        
    264                         /* Since we don't cache the servername, and since we
    265                            don't need this yet anyway, I won't implement it. */
    266                        
    267                         goto cleanup;
    268                 }
    269                 else
    270                 {
    271                         /* A whole URL */
    272                         url_t *url;
    273                         char *s;
    274                        
    275                         s = strstr( loc, "\r\n" );
    276                         if( s == NULL )
    277                                 goto cleanup;
    278                        
    279                         url = g_new0( url_t, 1 );
    280                         *s = 0;
    281                        
    282                         if( !url_set( url, loc ) )
    283                         {
    284                                 g_free( url );
    285                                 goto cleanup;
    286                         }
    287                        
    288                         /* Okay, this isn't fun! We have to rebuild the request... :-( */
    289                         new_request = g_malloc( req->request_length + strlen( url->file ) );
    290                        
    291                         /* So, now I just allocated enough memory, so I'm
    292                            going to use strcat(), whether you like it or not. :-) */
    293                        
    294                         /* First, find the GET/POST/whatever from the original request. */
    295                         s = strchr( req->request, ' ' );
    296                         if( s == NULL )
    297                         {
    298                                 g_free( new_request );
    299                                 g_free( url );
    300                                 goto cleanup;
    301                         }
    302                        
    303                         *s = 0;
    304                         sprintf( new_request, "%s %s HTTP/1.0\r\n", req->request, url->file );
    305                         *s = ' ';
    306                        
    307                         s = strstr( req->request, "\r\n" );
    308                         if( s == NULL )
    309                         {
    310                                 g_free( new_request );
    311                                 g_free( url );
    312                                 goto cleanup;
    313                         }
    314                        
    315                         strcat( new_request, s + 2 );
    316                         new_host = g_strdup( url->host );
    317                         new_port = url->port;
    318                         new_proto = url->proto;
    319                        
    320                         g_free( url );
    321                 }
    322                
    323                 if( req->ssl )
    324                         ssl_disconnect( req->ssl );
    325                 else
    326                         closesocket( req->fd );
    327                
    328                 req->fd = -1;
    329                 req->ssl = 0;
    330                
    331                 if( new_proto == PROTO_HTTPS )
    332                 {
    333                         req->ssl = ssl_connect( new_host, new_port, http_ssl_connected, req );
    334                         if( req->ssl == NULL )
    335                                 error = 1;
    336                 }
    337                 else
    338                 {
    339                         req->fd = proxy_connect( new_host, new_port, http_connected, req );
    340                         if( req->fd < 0 )
    341                                 error = 1;
    342                 }
    343                
    344                 if( error )
    345                 {
    346                         g_free( new_request );
    347                         goto cleanup;
    348                 }
    349                
    350                 g_free( req->request );
    351                 g_free( req->reply_headers );
    352                 req->request = new_request;
    353                 req->request_length = strlen( new_request );
    354                 req->bytes_read = req->bytes_written = req->inpa = 0;
    355                 req->reply_headers = req->reply_body = NULL;
    356                
    357                 return;
     221                        req->reply_body = end1 + 4;
    358222        }
    359223       
     
    366230                ssl_disconnect( req->ssl );
    367231        else
    368                 closesocket( req->fd );
     232                close( req->fd );
    369233       
    370234        req->func( req );
  • protocols/jabber/Makefile

    r52b3a99 r8a9afe4  
    1616
    1717# [SH] Phony targets
    18 all: jabber_mod.o
     18all: jabberr.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 jabber_mod.o: $(objects)
    36         @echo '*' Linking jabber_mod.o
    37         @$(LD) $(LFLAGS) $(objects) -o jabber_mod.o
     35jabberr.o: $(objects)
     36        @echo '*' Linking jabberr.o
     37        @$(LD) $(LFLAGS) $(objects) -o jabberr.o
  • protocols/msn/Makefile

    r52b3a99 r8a9afe4  
    1616
    1717# [SH] Phony targets
    18 all: msn_mod.o
     18all: msnn.o
    1919       
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 msn_mod.o: $(objects)
    36         @echo '*' Linking msn_mod.o
    37         @$(LD) $(LFLAGS) $(objects) -o msn_mod.o
     35msnn.o: $(objects)
     36        @echo '*' Linking msnn.o
     37        @$(LD) $(LFLAGS) $(objects) -o msnn.o
    3838       
    3939
  • protocols/oscar/Makefile

    r52b3a99 r8a9afe4  
    1616
    1717# [SH] Phony targets
    18 all: oscar_mod.o
     18all: oscarr.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 oscar_mod.o: $(objects)
    36         @echo '*' Linking oscar_mod.o
    37         @$(LD) $(LFLAGS) $(objects) -o oscar_mod.o
     35oscarr.o: $(objects)
     36        @echo '*' Linking oscarr.o
     37        @$(LD) $(LFLAGS) $(objects) -o oscarr.o
  • protocols/yahoo/Makefile

    r52b3a99 r8a9afe4  
    1616
    1717# [SH] Phony targets
    18 all: yahoo_mod.o
     18all: yahooo.o
    1919
    2020.PHONY: all clean distclean
     
    3333        @$(CC) -c $(CFLAGS) $< -o $@
    3434
    35 yahoo_mod.o: $(objects)
    36         @echo '*' Linking yahoo_mod.o
    37         @$(LD) $(LFLAGS) $(objects) -o yahoo_mod.o
     35yahooo.o: $(objects)
     36        @echo '*' Linking yahooo.o
     37        @$(LD) $(LFLAGS) $(objects) -o yahooo.o
  • url.c

    r52b3a99 r8a9afe4  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2001-2005 Wilmer van der Gaast and others                *
     4  * Copyright 2001-2004 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    3030{
    3131        char s[MAX_STRING];
    32         char *i;
     32        char *i, *j;
    3333       
    3434        /* protocol://                                                  */
     
    4040        else
    4141        {
    42                 if( g_strncasecmp( set_url, "https", i - set_url ) == 0 )
    43                         url->proto = PROTO_HTTPS;
    44                 else if( g_strncasecmp( set_url, "http", i - set_url ) == 0 )
     42                if( g_strncasecmp( set_url, "http", i - set_url ) == 0 )
    4543                        url->proto = PROTO_HTTP;
    4644                else if( g_strncasecmp( set_url, "socks4", i - set_url ) == 0 )
     
    5856        if( ( i = strchr( s, '/' ) ) == NULL )
    5957        {
    60                 strcpy( url->file, "/" );
     58                strcpy( url->dir, "/" );
    6159        }
    6260        else
    6361        {
    64                 strncpy( url->file, i, MAX_STRING );
    6562                *i = 0;
     63                g_snprintf( url->dir, MAX_STRING, "/%s", i + 1 );
     64                if( url->proto == PROTO_HTTP )
     65                        http_encode( url->dir );
    6666        }
    6767        strncpy( url->host, s, MAX_STRING );
     68        j = strchr( url->dir, '?' );
     69        if( j != NULL )
     70                *j = 0;
     71        i = strrchr( url->dir, '/' );
     72        *i = 0;
     73        if( j != NULL )
     74                *j = '?';
     75        if( i == NULL )
     76        {
     77                strcpy( url->file, url->dir );
     78                strcpy( url->dir, "/" );
     79        }
     80        else
     81        {
     82                strcpy( url->file, i + 1 );
     83                strcat( url->dir, "/" );
     84        }
    6885       
    6986        /* Check for username in host field                             */
     
    7996        else
    8097        {
    81                 *url->user = *url->pass = 0;
     98                if( url->proto == PROTO_FTP )
     99                {
     100                        strcpy( url->user, "anonymous" );
     101                        strcpy( url->pass, "-p.artmaps@lintux.cx" );
     102                }
     103                else
     104                {
     105                        *url->user = *url->pass = 0;
     106                }
    82107        }
    83108       
     
    92117        {
    93118                *i = 0;
    94                 sscanf( i + 1, "%d", &url->port );
     119                sscanf( i + 1, "%i", &url->port );
    95120        }
     121        /* Take default port numbers from /etc/services                 */
    96122        else
    97123        {
    98124                if( url->proto == PROTO_HTTP )
    99                         url->port = 80;
    100                 else if( url->proto == PROTO_HTTPS )
    101                         url->port = 443;
     125                        url->port = 8080;
    102126                else if( url->proto == PROTO_SOCKS4 || url->proto == PROTO_SOCKS4 )
    103127                        url->port = 1080;
  • url.h

    r52b3a99 r8a9afe4  
    2626#include "bitlbee.h"
    2727
     28#define PROTO_FTP               1
    2829#define PROTO_HTTP              2
    29 #define PROTO_HTTPS             5
    3030#define PROTO_SOCKS4    3
    3131#define PROTO_SOCKS5    4
     
    3737        int port;
    3838        char host[MAX_STRING];
     39        char dir[MAX_STRING];
    3940        char file[MAX_STRING];
    4041        char user[MAX_STRING];
Note: See TracChangeset for help on using the changeset viewer.