source: trunk/libtransmission/clients.c @ 1306

Last change on this file since 1306 was 1306, checked in by livings124, 16 years ago

add eXeem to clients

  • Property svn:keywords set to Date Rev Author Id
File size: 8.2 KB
Line 
1/******************************************************************************
2 * $Id: clients.c 1306 2007-01-01 20:03:52Z livings124 $
3 *
4 * Copyright (c) 2005 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#include "transmission.h"
26
27static int charToInt( char character );
28
29static int charToInt( char character )
30{
31    int value;
32    if( character >= 'A' && character <= 'Z' )
33        value = 10 + character - 'A';
34    else
35        value = character - '0';
36   
37    return value;
38}
39
40char * tr_clientForId( uint8_t * id )
41{
42    char * ret = NULL;
43   
44    /* Azureus style */
45    if( id[0] == '-' && id[7] == '-' )
46    {
47        if( !memcmp( &id[1], "TR", 2 ) )
48        {
49            asprintf( &ret, "Transmission %d.%d",
50                      charToInt( id[3] ) * 10 + charToInt( id[4] ),
51                      charToInt( id[5] ) * 10 + charToInt( id[6] ) );
52        }
53        else if( !memcmp( &id[1], "AZ", 2 ) )
54        {
55            asprintf( &ret, "Azureus %c.%c.%c.%c",
56                      id[3], id[4], id[5], id[6] );
57        }
58        else if( !memcmp( &id[1], "UT", 2 ) )
59        {
60            asprintf( &ret, "\xc2\xb5Torrent %c.%d", id[3],
61                      charToInt( id[4] ) * 10 + charToInt( id[5] ) );
62        }
63        else if( !memcmp( &id[1], "TS", 2 ) )
64        {
65            asprintf( &ret, "TorrentStorm (%c%c%c%c)",
66                      id[3], id[4], id[5], id[6] );
67        }
68        else if( !memcmp( &id[1], "BC", 2 ) )
69        {
70            asprintf( &ret, "BitComet %d.%c%c",
71                      charToInt( id[3] ) * 10 + charToInt( id[4] ),
72                      id[5], id[6] );
73        }
74        else if( !memcmp( &id[1], "SZ", 2 ) )
75        {
76            asprintf( &ret, "Shareaza %c.%c.%c.%c",
77                      id[3], id[4], id[5], id[6] );
78        }
79        else if( !memcmp( &id[1], "BOW", 3 ) )
80        {
81            asprintf( &ret, "Bits on Wheels (%c%c%c)",
82                      id[4], id[5], id[6] );
83        }
84        else if( !memcmp( &id[1], "BR", 2 ) )
85        {
86            asprintf( &ret, "BitRocket %c.%c (%d)",
87                      id[3], id[4], charToInt( id[5] ) * 10 + charToInt( id[6] ) );
88        }
89        else if( !memcmp( &id[1], "XX", 2 ) )
90        {
91            asprintf( &ret, "Xtorrent (%d)",
92                      charToInt( id[3] ) * 1000 + charToInt( id[4] ) * 100
93                      + charToInt( id[5] ) * 10 + charToInt( id[6] ) );
94        }
95        else if( !memcmp( &id[1], "KT", 2 ) )
96        {
97            asprintf( &ret, "KTorrent %c.%c.%c.%c",
98                      id[3], id[4], id[5], id[6] );
99        }
100        else if( !memcmp( &id[1], "lt", 2 ) )
101        {
102            asprintf( &ret, "libTorrent %d.%d.%d.%d",
103                      charToInt( id[3] ), charToInt( id[4] ),
104                      charToInt( id[5] ), charToInt( id[6] ) );
105        }
106        else if( !memcmp( &id[1], "LT", 2 ) )
107        {
108            asprintf( &ret, "libtorrent %d.%d.%d.%d",
109                      charToInt( id[3] ), charToInt( id[4] ),
110                      charToInt( id[5] ), charToInt( id[6] ) );
111        }
112        else if( !memcmp( &id[1], "ES", 2 ) )
113        {
114            asprintf( &ret, "Electric Sheep %c.%c.%c",
115                      id[3], id[4], id[5] );
116        }
117        else if( !memcmp( &id[1], "CD", 2 ) )
118        {
119            asprintf( &ret, "CTorrent %d.%d",
120                      charToInt( id[3] ) * 10 + charToInt( id[4] ),
121                      charToInt( id[5] ) * 10 + charToInt( id[6] ) );
122        }
123        else if( !memcmp( &id[1], "LP", 2 ) )
124        {
125            asprintf( &ret, "Lphant %d.%c%c",
126                      charToInt( id[3] ) * 10 + charToInt( id[4] ),
127                      id[5], id[6] );
128        }
129        else if( !memcmp( &id[1], "AR", 2 ) )
130        {
131            asprintf( &ret, "Arctic Torrent" );
132        }
133       
134        if( ret )
135        {
136            return ret;
137        }
138    }
139   
140    /* Tornado-style */
141    if( !memcmp( &id[4], "----", 4 ) || !memcmp( &id[4], "--00", 4 ) )
142    {
143        if( id[0] == 'T' )
144        {
145            asprintf( &ret, "BitTornado %d.%d.%d", charToInt( id[1] ),
146                        charToInt( id[2] ), charToInt( id[3] ) );
147        }
148        else if( id[0] == 'A' )
149        {
150            asprintf( &ret, "ABC %d.%d.%d", charToInt( id[1] ),
151                        charToInt( id[2] ), charToInt( id[3] ) );
152        }
153       
154        if( ret )
155        {
156            return ret;
157        }
158    }
159   
160    /* Different formatting per client */
161    if( id[0] == 'M' && id[2] == '-' && id[7] == '-' )
162    {
163        if( id[4] == '-' && id[6] == '-' )
164        {
165            asprintf( &ret, "BitTorrent %c.%c.%c", id[1], id[3], id[5] );
166        }
167        else if( id[5] == '-' )
168        {
169            asprintf( &ret, "BitTorrent %c.%c%c.%c", id[1], id[3], id[4], id[6] );
170        }
171       
172        if( ret )
173        {
174            return ret;
175        }
176    }
177    if( id[0] == 'Q' && id[2] == '-' && id[7] == '-' )
178    {
179        if( id[4] == '-' && id[6] == '-' )
180        {
181            asprintf( &ret, "Queen Bee %c.%c.%c", id[1], id[3], id[5] );
182        }
183        else if( id[5] == '-' )
184        {
185            asprintf( &ret, "Queen Bee %c.%c%c.%c", id[1], id[3], id[4], id[6] );
186        }
187       
188        if( ret )
189        {
190            return ret;
191        }
192    }
193   
194    /* All versions of each client are formatted the same */
195    if( !memcmp( id, "exbc", 4 ) )
196    {
197        asprintf( &ret, "%s %d.%02d",
198                    !memcmp( &id[6], "LORD", 4 ) ? "BitLord" : "BitComet",
199                    id[4], id[5] );
200    }
201    else if( !memcmp( id, "OP", 2 ) )
202    {
203        asprintf( &ret, "Opera (%c%c%c%c)", id[2], id[3], id[4], id[5] );
204    }
205    else if( !memcmp( id, "-ML", 3 ) )
206    {
207        asprintf( &ret, "MLDonkey %c%c%c%c%c",
208                  id[3], id[4], id[5], id[6], id[7] );
209    }
210    else if( !memcmp( id, "-FG", 3 ) )
211    {
212        asprintf( &ret, "FlashGet %d.%c%c",
213                  charToInt( id[3] ) * 10 + charToInt( id[4] ),
214                      id[5], id[6] );
215    }
216    else if( !memcmp( id, "Plus", 4 ) )
217    {
218        asprintf( &ret, "Plus! v2 %c.%c%c", id[4], id[5], id[6] );
219    }
220    else if( !memcmp( id, "XBT", 3 ) )
221    {
222        asprintf( &ret, "XBT Client %c%c%c%s", id[3], id[4], id[5],
223                  id[6] == 'd' ? " (debug)" : "" );
224    }
225    else if( !memcmp( id, "Mbrst", 5 ) )
226    {
227        asprintf( &ret, "burst! %c.%c.%c", id[5], id[7], id[9] );
228    }
229    else if( !memcmp( id, "LIME", 4 ) )
230    {
231        asprintf( &ret, "Limewire (%c%c%c%c)", id[4], id[5], id[6], id[7] );
232    }
233    else if( !memcmp( id, "-G3", 3 ) )
234    {
235        asprintf( &ret, "G3 Torrent" );
236    }
237    else if( !memcmp( id, "10-------", 9 ) )
238    {
239        asprintf( &ret, "JVtorrent" );
240    }
241    else if( !memcmp( id, "346-", 4 ) )
242    {
243        asprintf( &ret, "TorrentTopia" );
244    }
245    else if( !memcmp( id, "eX", 2 ) )
246    {
247        asprintf( &ret, "eXeem" );
248    }
249
250    /* No match */
251    if( !ret )
252    {
253        if( id[0] != 0 )
254        {
255            asprintf( &ret, "unknown client (%c%c%c%c%c%c%c%c)",
256                  id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7] );
257        }
258        else
259        {
260            asprintf( &ret, "unknown client" );
261        }
262    }
263
264    return ret;
265}
Note: See TracBrowser for help on using the repository browser.