From 53f8f003d7605cc690b5bc4862613bacb2182d69 Mon Sep 17 00:00:00 2001 From: ubuntu201711081 <201711081@jbnu.ac.kr> Date: Mon, 14 Dec 2020 11:33:56 +0000 Subject: [PATCH] add comment --- p-server.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/p-server.c b/p-server.c index 5173c92..4e5d28d 100644 --- a/p-server.c +++ b/p-server.c @@ -211,6 +211,9 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){ #endif return 0; } +/** print help message + * arg `n`: executable name + */ const char * help(const char * n){ const char * msg = "USASE : %s [Option] ...\n" "Options and arguments: \n" @@ -219,7 +222,8 @@ const char * help(const char * n){ printf(msg,n); return msg; } -/** return 0 ok. otherwise invalid format*/ +/** parse arguments. + * if return 0, success. otherwise arguments are invalid format.*/ int parse_args(int argc,const char * argv[] , in_port_t * port){ int pos = 1; const char * opt; @@ -236,10 +240,14 @@ int parse_args(int argc,const char * argv[] , in_port_t * port){ const char * value = argv[pos++]; *port = atoi(value); if (port == 0){ // either not number or zero + fprintf(stderr,"port argument is either not number or zero\n"); return 2; } } - else return 2; //failed to find argument. + else{ + fprintf(stderr,"need argument\n"); + return 2; //failed to find argument. + } } } return 0;