add client quiet mode

This commit is contained in:
ubuntu201711081 2020-12-07 10:49:29 +00:00
parent 07aa3824a9
commit 80a03a8610
2 changed files with 11 additions and 3 deletions

View File

@ -18,6 +18,7 @@ Client option and arguments:
- `-b` or `--benchmark` :benchmark mode
- `-nv` or `--no-verbose` :no progress bar
- `-t [number]` or `--thread [number]` :set to thread number.
- `-q` or `--quiet` :no stdout
Available macro:

View File

@ -141,7 +141,7 @@ int recvData(int sock,const char * filename){
else perror("recv fail");
return -1;
}
static char error_meesage_buf[80] = "";
char error_meesage_buf[80] = "";
switch(res.res){
case RES_ERR:
fprintf(stderr,"Server Fail: %s\n", strerror(res.err_number));
@ -166,10 +166,12 @@ int recvData(int sock,const char * filename){
return 0;
}
static bool quiet_mode = false;
int SendOpAndReceiveFile(const char * filename, struct sockaddr const * addr){
int sock;
int ret = -1;
fprintf(stdout,"request %s\n",filename);
if(!quiet_mode)
fprintf(stdout,"request %s\n",filename);
sock = socket(AF_INET,SOCK_STREAM,0);
if(sock < 0){
@ -329,6 +331,7 @@ static struct {
in_port_t server_port;
bool stdinisatty;
int thread_number_option;
bool quiet_mode;
} cmd_args = {
.server_name = "",
.server_port = 0
@ -358,6 +361,7 @@ static int parse_arg(int argc,const char *argv[]){
fprintf(stderr,"port invalid\n");
return -1;
}
cmd_args.quiet_mode = false;
cmd_args.thread_number_option = 1;
for(cur = 3;cur < argc; cur++){
if (strcmp("-b",argv[cur])==0||strcmp("--benchmark",argv[cur])==0){
@ -382,6 +386,10 @@ static int parse_arg(int argc,const char *argv[]){
show_help_message(stdout,argv[0]);
return 0;
}
else if(strcmp("-q",argv[cur]) == 0 || strcmp("--quiet",argv[cur]) == 0){
cmd_args.quiet_mode = true;
quiet_mode = true;
}
else break;
}
if (cmd_args.stdinisatty){
@ -390,7 +398,6 @@ static int parse_arg(int argc,const char *argv[]){
else{
init_queue_from_file(&global_state.queue,stdin);
}
return 0;
}