Changeset 64768d4 for protocols/msn/sb.c
- Timestamp:
- 2010-09-02T09:15:44Z (14 years ago)
- Branches:
- master
- Children:
- bae0617
- Parents:
- 02bb9db
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/sb.c
r02bb9db r64768d4 35 35 static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ); 36 36 37 int msn_sb_write( struct msn_switchboard *sb, char *s, int len ) 38 { 37 int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) 38 { 39 va_list params; 40 char *out; 41 size_t len; 39 42 int st; 40 43 44 va_start( params, fmt ); 45 out = g_strdup_vprintf( fmt, params ); 46 va_end( params ); 47 41 48 if( getenv( "BITLBEE_DEBUG" ) ) 42 { 43 write( 2, "->SB:", 5 ); 44 write( 2, s, len ); 45 } 46 47 st = write( sb->fd, s, len ); 49 fprintf( stderr, "->SB%d:%s", sb->fd, out ); 50 51 len = strlen( out ); 52 st = write( sb->fd, out, len ); 53 g_free( out ); 48 54 if( st != len ) 49 55 { 50 56 msn_sb_destroy( sb ); 51 return ( 0 );52 } 53 54 return ( 1 );57 return 0; 58 } 59 60 return 1; 55 61 } 56 62 … … 59 65 struct msn_data *md = ic->proto_data; 60 66 struct msn_switchboard *sb; 61 char buf[1024];62 67 63 68 /* FIXME: *CHECK* the reliability of using spare sb's! */ … … 67 72 68 73 sb->who = g_strdup( m->who ); 69 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, m->who ); 70 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 74 if( msn_sb_write( sb, "CAL %d %s\r\n", ++sb->trId, m->who ) ) 71 75 { 72 76 /* He/She should join the switchboard soon, let's queue the message. */ … … 79 83 80 84 /* If we reach this line, there was no spare switchboard, so let's make one. */ 81 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 82 if( !msn_write( ic, buf, strlen( buf ) ) ) 85 if( !msn_ns_write( ic, -1, "XFR %d SB\r\n", ++md->trId ) ) 83 86 { 84 87 g_free( m->who ); … … 171 174 if( sb->ready ) 172 175 { 173 char * packet, *buf;176 char *buf; 174 177 int i, j; 175 178 … … 207 210 208 211 /* Build the final packet (MSG command + the message). */ 209 packet = g_strdup_printf( "MSG %d N %d\r\n%s", ++sb->trId, i, buf ); 210 g_free( buf ); 211 if( msn_sb_write( sb, packet, strlen( packet ) ) ) 212 { 213 g_free( packet ); 214 return( 1 ); 212 if( msn_sb_write( sb, "MSG %d N %d\r\n%s", ++sb->trId, i, buf ) ) 213 { 214 g_free( buf ); 215 return 1; 215 216 } 216 217 else 217 218 { 218 g_free( packet);219 return ( 0 );219 g_free( buf ); 220 return 0; 220 221 } 221 222 } … … 332 333 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->acc->user, sb->key, sb->session ); 333 334 334 if( msn_sb_write( sb, buf, strlen( buf )) )335 if( msn_sb_write( sb, "%s", buf ) ) 335 336 sb->inp = b_input_add( sb->fd, B_EV_IO_READ, msn_sb_callback, sb ); 336 337 else … … 352 353 { 353 354 time_t now = time( NULL ); 354 char buf[1024];355 355 356 356 if( now - md->first_sb_failure > 600 ) … … 384 384 debug( "Moved queued messages back to the main queue, " 385 385 "creating a new switchboard to retry." ); 386 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 387 if( !msn_write( ic, buf, strlen( buf ) ) ) 386 if( !msn_ns_write( ic, -1, "XFR %d SB\r\n", ++md->trId ) ) 388 387 return FALSE; 389 388 } … … 397 396 struct msn_switchboard *sb = data; 398 397 struct im_connection *ic = sb->ic; 399 char buf[1024];400 398 401 399 if( !num_parts ) … … 426 424 427 425 if( sb->who ) 428 { 429 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, sb->who ); 430 return( msn_sb_write( sb, buf, strlen( buf ) ) ); 431 } 426 return msn_sb_write( sb, "CAL %d %s\r\n", ++sb->trId, sb->who ); 432 427 else 433 {434 428 debug( "Just created a switchboard, but I don't know what to do with it." ); 435 }436 429 } 437 430 else if( strcmp( cmd[0], "IRO" ) == 0 )
Note: See TracChangeset
for help on using the changeset viewer.