From 5aa4e9a6640c71e53cc398316b07fb8164fafb08 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 9 May 2007 03:05:38 +0000 Subject: [PATCH] differentiate old-style and new-style Transmission peer id (so version 1.01, etc is identified correctly) --- libtransmission/clients.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libtransmission/clients.c b/libtransmission/clients.c index db8af196a..8ca0b086c 100644 --- a/libtransmission/clients.c +++ b/libtransmission/clients.c @@ -46,9 +46,18 @@ char * tr_clientForId( uint8_t * id ) { if( !memcmp( &id[1], "TR", 2 ) ) { - asprintf( &ret, "Transmission %d.%d", - charToInt( id[3] ) * 10 + charToInt( id[4] ), - charToInt( id[5] ) * 10 + charToInt( id[6] ) ); + /* support old-style Transmission id without maintenance number */ + if ( !memcmp( &id[3], "00", 2 ) ) + { + asprintf( &ret, "Transmission 0.%d", + charToInt( id[5] ) * 10 + charToInt( id[6] ) ); + } + else + { + asprintf( &ret, "Transmission %d.%c%c", + charToInt( id[3] ) * 10 + charToInt( id[4] ), + id[5], id[6] ); + } } else if( !memcmp( &id[1], "AZ", 2 ) ) {