X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=blobdiff_plain;f=tid%2Fexample%2Ftidc_main.c;h=f1dfce59d7659df706ba9b784612a499154171f8;hp=02cd1db58faf5fbb08c2fbbbd3834b785cbb702e;hb=1ec949998ea6bc2c21e808346052b2e92d50479b;hpb=2bf7cf8d0fe531983cdcb72805d7272630ac1ee1 diff --git a/tid/example/tidc_main.c b/tid/example/tidc_main.c index 02cd1db..f1dfce5 100644 --- a/tid/example/tidc_main.c +++ b/tid/example/tidc_main.c @@ -42,6 +42,7 @@ #include #include #include +#include static void tidc_resp_handler (TIDC_INSTANCE * tidc, TID_REQ *req, @@ -146,7 +147,19 @@ static error_t parse_option(int key, char *arg, struct argp_state *state) break; case 4: - 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: