Browse Source

Added option --prealloc and a directory argument to btpd. Synced the command

line help with the available options.
master
Richard Nyberg 18 years ago
parent
commit
476765a7a7
3 changed files with 15 additions and 13 deletions
  1. +13
    -13
      btpd/main.c
  2. +1
    -0
      btpd/opts.c
  3. +1
    -0
      btpd/opts.h

+ 13
- 13
btpd/main.c View File

@@ -81,14 +81,10 @@ setup_daemon(const char *dir)
static void static void
usage(void) usage(void)
{ {
printf("Usage: btpd [options]\n"
printf("Usage: btpd [options] [dir]\n"
"\n" "\n"
"Options:\n" "Options:\n"
"\n" "\n"
"--bw-hz n\n"
"\tRun the bandwidth limiter at n hz.\n"
"\tDefault is 8 hz.\n"
"\n"
"--bw-in n\n" "--bw-in n\n"
"\tLimit incoming BitTorrent traffic to n kB/s.\n" "\tLimit incoming BitTorrent traffic to n kB/s.\n"
"\tDefault is 0 which means unlimited.\n" "\tDefault is 0 which means unlimited.\n"
@@ -101,16 +97,14 @@ usage(void)
"\tKeep the btpd process in the foregorund and log to std{out,err}.\n" "\tKeep the btpd process in the foregorund and log to std{out,err}.\n"
"\tThis option is intended for debugging purposes.\n" "\tThis option is intended for debugging purposes.\n"
"\n" "\n"
"--ipc key\n"
"\tThe same key must be used by the cli to talk to this\n"
"\tbtpd instance. You shouldn't need to use this option.\n"
"\n"
"--logfile file\n"
"\tLog to the given file. By default btpd logs to ./btpd.log.\n"
"\n"
"-p n, --port n\n" "-p n, --port n\n"
"\tListen at port n. Default is 6881.\n" "\tListen at port n. Default is 6881.\n"
"\n" "\n"
"--prealloc n\n"
"\tPreallocate disk space in chunks n kB. Default is 1.\n"
"\tNote that n will be rounded up to the closest multiple of the\n"
"\ttorrent piece size. If n is zero no preallocation will be done.\n"
"\n"
"--help\n" "--help\n"
"\tShow this help.\n" "\tShow this help.\n"
"\n"); "\n");
@@ -123,6 +117,7 @@ static struct option longopts[] = {
{ "port", required_argument, NULL, 'p' }, { "port", required_argument, NULL, 'p' },
{ "bw-in", required_argument, &longval, 1 }, { "bw-in", required_argument, &longval, 1 },
{ "bw-out", required_argument, &longval, 2 }, { "bw-out", required_argument, &longval, 2 },
{ "prealloc", required_argument, &longval, 3 },
{ "help", no_argument, &longval, 5 }, { "help", no_argument, &longval, 5 },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@@ -152,6 +147,9 @@ main(int argc, char **argv)
case 2: case 2:
net_bw_limit_out = atoi(optarg) * 1024; net_bw_limit_out = atoi(optarg) * 1024;
break; break;
case 3:
cm_alloc_size = atoi(optarg) * 1024;
break;
default: default:
usage(); usage();
} }
@@ -165,8 +163,10 @@ args_done:
argc -= optind; argc -= optind;
argv += optind; argv += optind;


if (argc != 0)
if (argc > 1)
usage(); usage();
if (argc > 0)
dir = argv[0];


setup_daemon(dir); setup_daemon(dir);




+ 1
- 0
btpd/opts.c View File

@@ -11,3 +11,4 @@ unsigned net_max_peers;
unsigned net_bw_limit_in; unsigned net_bw_limit_in;
unsigned net_bw_limit_out; unsigned net_bw_limit_out;
int net_port = 6881; int net_port = 6881;
off_t cm_alloc_size = 1;

+ 1
- 0
btpd/opts.h View File

@@ -8,5 +8,6 @@ extern unsigned net_max_peers;
extern unsigned net_bw_limit_in; extern unsigned net_bw_limit_in;
extern unsigned net_bw_limit_out; extern unsigned net_bw_limit_out;
extern int net_port; extern int net_port;
extern off_t cm_alloc_size;


#endif #endif

Loading…
Cancel
Save