Ignore:
Timestamp:
2010-09-02T09:15:44Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
bae0617
Parents:
02bb9db
Message:

Replace msn*write functions with saner versions that accept format strings.
Also preparing for additional temporary NS connections (auth token renewal).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r02bb9db r64768d4  
    3030#include <ctype.h>
    3131
    32 int msn_write( struct im_connection *ic, char *s, int len )
    33 {
    34         struct msn_data *md = ic->proto_data;
    35         int st;
    36        
    37         if( getenv( "BITLBEE_DEBUG" ) )
    38         {
    39                 write( 2, "->NS:", 5 );
    40                 write( 2, s, len );
    41         }
    42        
    43         st = write( md->fd, s, len );
    44         if( st != len )
    45         {
    46                 imcb_error( ic, "Short write() to main server" );
    47                 imc_logout( ic, TRUE );
    48                 return 0;
    49         }
    50        
    51         return 1;
    52 }
    53 
    5432int msn_logged_in( struct im_connection *ic )
    5533{
     
    7654{
    7755        struct msn_data *md = ic->proto_data;
    78         char buf[1024], groupid[8];
     56        char groupid[8];
    7957        bee_user_t *bu;
    8058        struct msn_buddy_data *bd;
     
    144122        if( ( adl = adlrml_entry( who, list ) ) )
    145123        {
    146                 g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n%s",
    147                             ++md->trId, strlen( adl ), adl );
     124                int st = msn_ns_write( ic, -1, "ADL %d %zd\r\n%s",
     125                                       ++md->trId, strlen( adl ), adl );
    148126                g_free( adl );
    149127               
    150                 return msn_write( ic, buf, strlen( buf ) );
     128                return st;
    151129        }
    152130       
     
    157135{
    158136        struct msn_data *md = ic->proto_data;
    159         char buf[1024], groupid[8];
     137        char groupid[8];
    160138        bee_user_t *bu;
    161139        struct msn_buddy_data *bd;
     
    189167        if( ( adl = adlrml_entry( who, list ) ) )
    190168        {
    191                 g_snprintf( buf, sizeof( buf ), "RML %d %zd\r\n%s",
    192                             ++md->trId, strlen( adl ), adl );
     169                int st = msn_ns_write( ic, -1, "RML %d %zd\r\n%s",
     170                                       ++md->trId, strlen( adl ), adl );
    193171                g_free( adl );
    194172               
    195                 return msn_write( ic, buf, strlen( buf ) );
     173                return st;
    196174        }
    197175       
     
    603581        struct msn_data *md = ic->proto_data;
    604582        char fn[strlen(value)*3+1];
    605         char buf[512];
    606583       
    607584        strcpy( fn, value );
    608585        http_encode( fn );
    609         g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n",
    610                     ++md->trId, fn );
    611586       
    612587        /* Note: We don't actually know if the server accepted the new name,
    613588           and won't give proper feedback yet if it doesn't. */
    614         return msn_write( ic, buf, strlen( buf ) );
    615 }
     589        return msn_ns_write( ic, -1, "PRP %d MFN %s\r\n", ++md->trId, fn );
     590}
Note: See TracChangeset for help on using the changeset viewer.