Changeset 6395


Ignore:
Timestamp:
Jul 24, 2008, 6:53:17 PM (13 years ago)
Author:
charles
Message:

(libT) make unrecognized peer_ids a little more readable for the peers tab.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/clients.c

    r6389 r6395  
    1818#include <string.h>
    1919
     20#include <libevent/event.h> /* evbuffer */
     21
    2022#include "transmission.h"
    2123#include "utils.h"
     
    142144    if( !id )
    143145        return;
    144    
     146
    145147    /* Azureus-style */
    146148    if( id[0] == '-' && id[7] == '-' )
     
    350352    if( !*buf )
    351353    {
    352         if( isprint( id[0] ) && isprint( id[1] ) && isprint( id[2] ) &&
    353             isprint( id[3] ) && isprint( id[4] ) && isprint( id[5] ) &&
    354             isprint( id[6] ) && isprint( id[7] ) )
    355                 tr_snprintf( buf, buflen, "%c%c%c%c%c%c%c%c",
    356                              id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
    357         else
    358                 tr_snprintf( buf, buflen, "0x%02x%02x%02x%02x%02x%02x%02x%02x",
    359                              id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
    360     }
    361 }
     354        struct evbuffer * out = evbuffer_new( );
     355        const char *in, *in_end;
     356        for( in=(const char*)id, in_end=in+8; in!=in_end; ++in ) {
     357            if( isprint( *in ) )
     358                evbuffer_add_printf( out, "%c", *in );
     359            else
     360                evbuffer_add_printf( out, "%%%02X", (unsigned int)*in );
     361        }
     362
     363        tr_strlcpy( buf, (const char*)EVBUFFER_DATA(out), buflen );
     364        evbuffer_free( out );
     365    }
     366}
  • trunk/libtransmission/utils.c

    r6334 r6395  
    980980    va_end( args );
    981981    return len;
    982 
    983982}
    984983
Note: See TracChangeset for help on using the changeset viewer.