diff options
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 52 |
1 files changed, 4 insertions, 48 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 083161d..84330df 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -1,3 +1,6 @@ | |||
1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ | ||
3 | |||
1 | #include "trackerlogic.h" | 4 | #include "trackerlogic.h" |
2 | 5 | ||
3 | #include <stdlib.h> | 6 | #include <stdlib.h> |
@@ -269,63 +272,16 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) { | |||
269 | } | 272 | } |
270 | } | 273 | } |
271 | 274 | ||
272 | #if 0 | ||
273 | void dump_knowledge( void ) { | ||
274 | int ati, tli, pli; | ||
275 | for( ati = 0; ati<256; ++ati ) { | ||
276 | ot_vector *torrent_list = &all_torrents[ati]; | ||
277 | for( tli = 0; tli<torrent_list->size; ++tli ) { | ||
278 | ot_torrent *torrent = &torrent_list->data[tli]; | ||
279 | for( pool = 0; pool<OT_POOLS_COUNT; ++pool ) { | ||
280 | for( pli=0; pli<torrent->peer_list->peers[pool].size; ++pli ) { | ||
281 | |||
282 | |||
283 | } | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | #endif | ||
289 | |||
290 | void cleanup_torrents( void ) { | 275 | void cleanup_torrents( void ) { |
291 | 276 | ||
292 | } | 277 | } |
293 | 278 | ||
294 | int init_logic( char *directory ) { | 279 | int init_logic( ) { |
295 | glob_t globber; | ||
296 | int i; | ||
297 | |||
298 | if( directory ) { | ||
299 | if( chdir( directory )) | ||
300 | return -1; | ||
301 | } | ||
302 | |||
303 | srandom( time(NULL)); | 280 | srandom( time(NULL)); |
304 | 281 | ||
305 | // Initialize control structures | 282 | // Initialize control structures |
306 | byte_zero( all_torrents, sizeof (all_torrents)); | 283 | byte_zero( all_torrents, sizeof (all_torrents)); |
307 | 284 | ||
308 | // Scan directory for filenames in the form [0-9A-F]{20} | ||
309 | // * I know this looks ugly, but I've seen A-F to match umlauts as well in strange locales | ||
310 | // * lower case for .. better being safe than sorry, this is not expensive here :) | ||
311 | if( !glob( | ||
312 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
313 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
314 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
315 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
316 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
317 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
318 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
319 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
320 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
321 | "[0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef][0-9ABCDEFabcdef]" | ||
322 | , GLOB_NOCHECK, 0, &globber) ) | ||
323 | { | ||
324 | for( i=0; i<globber.gl_matchc; ++i ) | ||
325 | printf( "Found: %s\n", globber.gl_pathv[i] ); | ||
326 | } | ||
327 | |||
328 | globfree( &globber ); | ||
329 | return 0; | 285 | return 0; |
330 | } | 286 | } |
331 | 287 | ||