Ignore:
Timestamp:
2006-10-15T09:31:13Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
69cb623, 93b7bd4
Parents:
3ef6410 (diff), 695e392 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging from devel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r3ef6410 re97827b  
    5454{
    5555        struct msn_data *md = gc->proto_data;
    56         GSList *l, **lp = NULL;
    5756        char buf[1024], *realname;
    5857       
    59         if( strcmp( list, "AL" ) == 0 )
    60                 lp = &gc->permit;
    61         else if( strcmp( list, "BL" ) == 0 )
    62                 lp = &gc->deny;
    63        
    64         if( lp )
    65                 for( l = *lp; l; l = l->next )
    66                         if( g_strcasecmp( l->data, who ) == 0 )
    67                                 return( 1 );
    68        
    69         realname = g_new0( char, strlen( realname_ ) * 3 + 1 );
    70         strcpy( realname, realname_ );
    71         http_encode( realname );
     58        realname = msn_http_encode( realname_ );
    7259       
    7360        g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname );
     
    7663                g_free( realname );
    7764               
    78                 if( lp )
    79                         *lp = g_slist_append( *lp, g_strdup( who ) );
    80                
    8165                return( 1 );
    8266        }
     
    9074{
    9175        struct msn_data *md = gc->proto_data;
    92         GSList *l = NULL, **lp = NULL;
    9376        char buf[1024];
    94        
    95         if( strcmp( list, "AL" ) == 0 )
    96                 lp = &gc->permit;
    97         else if( strcmp( list, "BL" ) == 0 )
    98                 lp = &gc->deny;
    99        
    100         if( lp )
    101         {
    102                 for( l = *lp; l; l = l->next )
    103                         if( g_strcasecmp( l->data, who ) == 0 )
    104                                 break;
    105                
    106                 if( !l )
    107                         return( 1 );
    108         }
    10977       
    11078        g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who );
    11179        if( msn_write( gc, buf, strlen( buf ) ) )
    112         {
    113                 if( lp )
    114                         *lp = g_slist_remove( *lp, l->data );
    115                
    11680                return( 1 );
    117         }
    11881       
    11982        return( 0 );
     
    350313        return( 1 );
    351314}
     315
     316/* The difference between this function and the normal http_encode() function
     317   is that this one escapes every 7-bit ASCII character because this is said
     318   to avoid some lame server-side checks when setting a real-name. Also,
     319   non-ASCII characters are not escaped because MSN servers don't seem to
     320   appreciate that! */
     321char *msn_http_encode( const char *input )
     322{
     323        char *ret, *s;
     324        int i;
     325       
     326        ret = s = g_new0( char, strlen( input ) * 3 + 1 );
     327        for( i = 0; input[i]; i ++ )
     328                if( input[i] & 128 )
     329                {
     330                        *s = input[i];
     331                        s ++;
     332                }
     333                else
     334                {
     335                        g_snprintf( s, 4, "%%%02X", input[i] );
     336                        s += 3;
     337                }
     338       
     339        return ret;
     340}
Note: See TracChangeset for help on using the changeset viewer.