X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=blobdiff_plain;f=tr%2Ftrpc_main.c;fp=tr%2Ftrpc_main.c;h=db29417dfb56127ea418723dd60161b8e777e9ee;hp=f04b4dd69738bae5c9a5be9d84a25ccbaee1ae85;hb=6f65c9cce86719147d0b4dcc9823b25443c2d185;hpb=eaa1a8ceed54fbfadc2638cf383aaa12ab446a57 diff --git a/tr/trpc_main.c b/tr/trpc_main.c index f04b4dd..db29417 100644 --- a/tr/trpc_main.c +++ b/tr/trpc_main.c @@ -41,6 +41,7 @@ #include #include #include +#include /* command-line option setup */ @@ -49,7 +50,7 @@ const char *argp_program_bug_address=PACKAGE_BUGREPORT; /* bug reporting address */ /* doc strings */ -static const char doc[]=PACKAGE_NAME " - TRP Client"; +static const char doc[]=PACKAGE_NAME " - Moonshot Trust Router TRP Client"; static const char arg_doc[]=" []"; /* string describing arguments, if any */ /* define the options here. Fields are: @@ -92,7 +93,19 @@ static error_t parse_option(int key, char *arg, struct argp_state *state) break; case 2: - arguments->port=strtol(arg, NULL, 10); /* optional */ + arguments->port=tr_parse_port(arg); /* optional */ + if (arguments->port < 0) { + switch(-(arguments->port)) { + case ERANGE: + printf("\nError parsing port (%s): port must be an integer in the range 1 - 65535\n\n", arg); + break; + + default: + printf("\nError parsing port (%s): %s\n\n", arg, strerror(-arguments->port)); + break; + } + argp_usage(state); + } break; default: