From fe55a21ddcea9e5e685987bea3e265ba2b3d0bf5 Mon Sep 17 00:00:00 2001 From: Filippos Giannakos Date: Mon, 3 Dec 2012 19:13:08 +0200 Subject: [PATCH] make peers expect portno --- xseg/peers/user/peer.c | 71 ++++-------------------------------------------- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/xseg/peers/user/peer.c b/xseg/peers/user/peer.c index 2d2647e..53ef192 100644 --- a/xseg/peers/user/peer.c +++ b/xseg/peers/user/peer.c @@ -699,71 +699,6 @@ int main(int argc, char *argv[]) // -dp xseg_portno to defer blocking requests // -l log file ? //TODO print messages on arg parsing error - //TODO string checking - - /* - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-g") && i + 1 < argc) { - spec = argv[i+1]; - i += 1; - continue; - } - - if (!strcmp(argv[i], "-sp") && i + 1 < argc) { - portno_start = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - - if (!strcmp(argv[i], "-ep") && i + 1 < argc) { - portno_end = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - - if (!strcmp(argv[i], "-p") && i + 1 < argc) { - portno = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - - if (!strcmp(argv[i], "-n") && i + 1 < argc) { - nr_ops = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - if (!strcmp(argv[i], "-v") && i + 1 < argc ) { - debug_level = atoi(argv[i+1]); - i += 1; - continue; - } - if (!strcmp(argv[i], "-t") && i + 1 < argc ) { - nr_threads = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - if (!strcmp(argv[i], "-dp") && i + 1 < argc ) { - defer_portno = strtoul(argv[i+1], NULL, 10); - i += 1; - continue; - } - if (!strcmp(argv[i], "-l") && i + 1 < argc ) { - logfile = argv[i+1]; - i += 1; - continue; - } - if (!strcmp(argv[i], "-d")) { - daemonize = 1; - continue; - } - if (!strcmp(argv[i], "--pidfile") && i + 1 < argc ) { - pidfile = argv[i+1]; - i += 1; - continue; - } - - } - */ BEGIN_READ_ARGS(argc, argv); READ_ARG_STRING("-g", spec, MAX_SPEC_LEN); READ_ARG_ULONG("-sp", portno_start); @@ -823,6 +758,12 @@ int main(int argc, char *argv[]) portno_start = portno; portno_end = portno; } + if (portno_start == -1 || portno_end == -1){ + XSEGLOG2(&lc, E, "Portno or {portno_start, portno_end} must be supplied"); + usage(argv[0]); + r = -1; + goto out; + } peer = peerd_init(nr_ops, spec, portno_start, portno_end, nr_threads, defer_portno); if (!peer){ -- 1.7.10.4