Commit f1afa3cd authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

Fix checking for option -S, -R, -M, -T, -v, -A, -Q, -E, -r

parent d4da0063
...@@ -4,6 +4,15 @@ nmxptool Release History ...@@ -4,6 +4,15 @@ nmxptool Release History
* Release 2.1.4-dev (2017/01/04) * Release 2.1.4-dev (2017/01/04)
- Fix checking port number for option -P and -D. - Fix checking port number for option -P and -D.
- Fix checking short-term-completion, option -S.
- Fix checking rate, option -R.
- Fix checking Maximum tolerable latency, option -M.
- Fix checking Time-out receving, option -T.
- Fix checking verbose level, option -v.
- Fix checking max data to retrieve, option -A.
- Fix checking timing quality, option -Q.
- Fix checking listen port, option -E.
- Fix checking mini-SEED record length, option -r.
* Release 2.1.3 (2015/10/01) * Release 2.1.3 (2015/10/01)
- Added options to intall binary and template on SeisComP3 - Added options to intall binary and template on SeisComP3
......
...@@ -835,15 +835,22 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -835,15 +835,22 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break; break;
case 'S': case 'S':
params->stc = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->stc)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Short-Term-Completion %d.\n", params->stc); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Short-Term-Completion '%s'.\n", optarg);
if(params->stc >= 0) { ret_errors++;
params->rate = 0; // original sample rate } else {
} nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Short-Term-Completion %d.\n", params->stc);
if(params->stc >= 0) {
params->rate = 0; // original sample rate
}
}
break; break;
case 'R': case 'R':
params->rate = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->rate)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Rate '%s'.\n", optarg);
ret_errors++;
}
break; break;
case 's': case 's':
...@@ -885,19 +892,30 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -885,19 +892,30 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break; break;
case 'M': case 'M':
params->max_tolerable_latency = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->max_tolerable_latency)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_tolerable_latency %d\n", nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Max Tolerable Latency '%s'.\n", optarg);
params->max_tolerable_latency); ret_errors++;
} else {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_tolerable_latency %d\n",
params->max_tolerable_latency);
}
break; break;
case 'T': case 'T':
params->timeoutrecv = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->timeoutrecv)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Time-out receiving %d\n", nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Time-out receving '%s'.\n", optarg);
params->timeoutrecv); ret_errors++;
} else {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Time-out receiving %d\n",
params->timeoutrecv);
}
break; break;
case 'v': case 'v':
params->verbose_level = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->verbose_level)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing verbose level '%s'.\n", optarg);
ret_errors++;
}
break; break;
case 'B': case 'B':
...@@ -911,9 +929,12 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -911,9 +929,12 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break; break;
case 'A': case 'A':
if(optarg) { if(optarg) {
params->max_data_to_retrieve = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->max_data_to_retrieve)) == 0) {
} nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Max amount of data to retrieve '%s'.\n", optarg);
ret_errors++;
}
}
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_time_to_retrieve %d\n", params->max_data_to_retrieve); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_time_to_retrieve %d\n", params->max_data_to_retrieve);
break; break;
...@@ -953,13 +974,19 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -953,13 +974,19 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
#ifdef HAVE_SEEDLINK #ifdef HAVE_SEEDLINK
case 'Q': case 'Q':
params->timing_quality = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->timing_quality)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing timing quality '%s'.\n", optarg);
ret_errors++;
}
break; break;
#endif #endif
#ifndef HAVE_WINDOWS_H #ifndef HAVE_WINDOWS_H
case 'E': case 'E':
params->listen_port = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->listen_port)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing listen port '%s'.\n", optarg);
ret_errors++;
}
break; break;
#endif #endif
...@@ -1081,25 +1108,29 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -1081,25 +1108,29 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break; break;
case 'r': case 'r':
params->reclen = atoi(optarg); if(nmxptool_parse_int(optarg, &(params->reclen)) == 0) {
if(params->reclen >= DEFAULT_RECLEN_MINIMUM && params->reclen <= DEFAULT_RECLEN_MAXIMUM) { nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing mini-SEED record length '%s'.\n", optarg);
flag_reclen_pow = 0; ret_errors++;
while(!flag_reclen_pow && reclen_pow <= DEFAULT_RECLEN_MAXIMUM) { } else {
if(params->reclen == reclen_pow) { if(params->reclen >= DEFAULT_RECLEN_MINIMUM && params->reclen <= DEFAULT_RECLEN_MAXIMUM) {
flag_reclen_pow = 1; flag_reclen_pow = 0;
} while(!flag_reclen_pow && reclen_pow <= DEFAULT_RECLEN_MAXIMUM) {
reclen_pow *= 2; if(params->reclen == reclen_pow) {
} flag_reclen_pow = 1;
if(!flag_reclen_pow) { }
ret_errors++; reclen_pow *= 2;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, }
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n"); if(!flag_reclen_pow) {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n");
}
} else {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n");
}
} }
} else {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY,
"reclen must expressible as 2 raised to the power of X where X is between (and including) 8 to 20.\n");
}
break; break;
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment