diff options
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/opentracker.c b/opentracker.c index de98bb3..b992117 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -339,14 +339,40 @@ void graceful( int s ) { | |||
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | int main() | 342 | void usage( char *name ) { |
343 | { | 343 | fprintf( stderr, "Usage: %s [-i serverip] [-p serverport] [-d serverdirectory]" |
344 | #ifdef WANT_CLOSED_TRACKER | ||
345 | " [-o|c]" | ||
346 | #endif | ||
347 | "\n", name ); | ||
348 | exit(1); | ||
349 | } | ||
350 | |||
351 | int main( int argc, char **argv ) { | ||
344 | int s=socket_tcp4(); | 352 | int s=socket_tcp4(); |
345 | unsigned long ip; | 353 | unsigned long ip; |
346 | uint16 port; | 354 | char *serverip = NULL; |
355 | char *serverdir = "."; | ||
356 | uint16 port = 6969; | ||
357 | |||
358 | while( 1 ) { | ||
359 | switch( getopt(argc,argv,":i:p:d:") ) { | ||
360 | case -1: goto allparsed; | ||
361 | case 'i': serverip = optarg; break; | ||
362 | case 'p': port = (uint16)atol( optarg ); break; | ||
363 | case 'd': serverdir = optarg; break; | ||
364 | #ifdef WANT_CLOSED_TRACKER | ||
365 | case 'o': g_closedtracker = 0; | ||
366 | case 'c': g_closedtracker = 1; | ||
367 | #endif | ||
368 | default: | ||
369 | case '?': usage( argv[0] ); | ||
370 | } | ||
371 | } | ||
347 | 372 | ||
373 | allparsed: | ||
348 | ot_start_time = time( NULL ); | 374 | ot_start_time = time( NULL ); |
349 | if (socket_bind4_reuse(s,NULL,6969)==-1) | 375 | if (socket_bind4_reuse(s,serverip,port)==-1) |
350 | panic("socket_bind4_reuse"); | 376 | panic("socket_bind4_reuse"); |
351 | 377 | ||
352 | if (socket_listen(s,16)==-1) | 378 | if (socket_listen(s,16)==-1) |
@@ -356,7 +382,7 @@ int main() | |||
356 | panic("io_fd"); | 382 | panic("io_fd"); |
357 | 383 | ||
358 | signal( SIGINT, graceful ); | 384 | signal( SIGINT, graceful ); |
359 | if( init_logic( ) == -1 ) | 385 | if( init_logic( serverdir ) == -1 ) |
360 | panic("Logic not started"); | 386 | panic("Logic not started"); |
361 | 387 | ||
362 | io_wantread(s); | 388 | io_wantread(s); |