fix help return and detail err
This commit is contained in:
parent
b8106683b9
commit
940bf1a32c
8
server.c
8
server.c
@ -210,17 +210,21 @@ int parse_args(int argc,const char * argv[] , in_port_t * port){
|
|||||||
if (strcmp(opt,"-h") == 0 || strcmp(opt,"--help") == 0)
|
if (strcmp(opt,"-h") == 0 || strcmp(opt,"--help") == 0)
|
||||||
{
|
{
|
||||||
help(argv[0]);
|
help(argv[0]);
|
||||||
return 2;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(strcmp(opt,"-p") == 0 || strcmp(opt,"--port") == 0){
|
else if(strcmp(opt,"-p") == 0 || strcmp(opt,"--port") == 0){
|
||||||
if (pos < argc){
|
if (pos < argc){
|
||||||
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,"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