add comment
This commit is contained in:
parent
ad881333e0
commit
53f8f003d7
12
p-server.c
12
p-server.c
@ -211,6 +211,9 @@ int send_response(int sock,int fd, uint8_t * buf, size_t bufsize){
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/** print help message
|
||||||
|
* arg `n`: executable name
|
||||||
|
*/
|
||||||
const char * help(const char * n){
|
const char * help(const char * n){
|
||||||
const char * msg = "USASE : %s [Option] ...\n"
|
const char * msg = "USASE : %s [Option] ...\n"
|
||||||
"Options and arguments: \n"
|
"Options and arguments: \n"
|
||||||
@ -219,7 +222,8 @@ const char * help(const char * n){
|
|||||||
printf(msg,n);
|
printf(msg,n);
|
||||||
return msg;
|
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 parse_args(int argc,const char * argv[] , in_port_t * port){
|
||||||
int pos = 1;
|
int pos = 1;
|
||||||
const char * opt;
|
const char * opt;
|
||||||
@ -236,10 +240,14 @@ int parse_args(int argc,const char * argv[] , in_port_t * port){
|
|||||||
const char * value = argv[pos++];
|
const char * value = argv[pos++];
|
||||||
*port = atoi(value);
|
*port = atoi(value);
|
||||||
if (port == 0){ // either not number or zero
|
if (port == 0){ // either not number or zero
|
||||||
|
fprintf(stderr,"port argument is either not number or zero\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return 2; //failed to find argument.
|
else{
|
||||||
|
fprintf(stderr,"need argument\n");
|
||||||
|
return 2; //failed to find argument.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user