Commit 3b6b5a99 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Merge branch 'release/2.1.4'

parents a4aab733 412222ca
......@@ -2,6 +2,19 @@
nmxptool Release History
#########################
* Release 2.1.4 (2017/01/04)
- Exit if connect() fails first time.
- 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)
- Added options to intall binary and template on SeisComP3
......
......@@ -9,9 +9,9 @@ m4_define([full_package_name], [nmxptool])
dnl These three define the plug-in version number
m4_define([major_version], [2])
m4_define([minor_version], [1])
m4_define([micro_version], [3])
m4_define([micro_version], [4])
# Comment build_version for stable release
# m4_define([build_version], [beta1])
# m4_define([build_version], [dev])
m4_ifdef([build_version], [
m4_define([version],
......
......@@ -106,6 +106,9 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
isock, NMXP_LOG_STR(inet_ntoa(hostaddr)), portNum);
return isock;
} else {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "connect(): (errno=%d) %s \n", errno, NMXP_LOG_STR(nmxp_strerror(errno)));
return -1;
/*
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Connecting to %s port %d. Trying again after %d seconds...\n",
NMXP_LOG_STR(inet_ntoa(hostaddr)), portNum, sleepTime);
nmxp_closeSocket(isock);
......@@ -120,6 +123,7 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
if (sleepTime > NMXP_SLEEPMAX) {
sleepTime = NMXP_SLEEPMAX;
}
*/
}
}
......
......@@ -17,6 +17,7 @@
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include "config.h"
#include "nmxp.h"
......@@ -599,6 +600,42 @@ int nmxptool_read_time(char *str_input, int32_t *pvalue) {
return ret_errors;
}
int nmxptool_parse_long(const char *str, long *val)
{
char *temp;
int rc = 1;
errno = 0;
*val = strtol(str, &temp, 0);
if (temp == str || *temp != '\0' ||
( (*val == LONG_MIN || *val == LONG_MAX) && errno == ERANGE)
) {
rc = 0;
}
return rc;
}
int nmxptool_parse_int(const char *str, int *val)
{
long v = 0;
int rc = 1;
rc = nmxptool_parse_long(str, &v);
if(rc) {
if(v >= INT_MIN && v <= INT_MAX) {
*val = v;
} else {
rc = 0;
}
}
return rc;
}
int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{
int ret_errors = 0;
......@@ -766,11 +803,17 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
case 'P':
params->portnumberpds = atoi(optarg);
if(nmxptool_parse_int(optarg, &(params->portnumberpds)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing NaqsServer port number '%s'.\n", optarg);
ret_errors++;
}
break;
case 'D':
params->portnumberdap = atoi(optarg);
if(nmxptool_parse_int(optarg, &(params->portnumberdap)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing DataServer port number '%s'.\n", optarg);
ret_errors++;
}
break;
case 'C':
......@@ -792,15 +835,22 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
case 'S':
params->stc = atoi(optarg);
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
}
if(nmxptool_parse_int(optarg, &(params->stc)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Short-Term-Completion '%s'.\n", optarg);
ret_errors++;
} 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;
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;
case 's':
......@@ -842,19 +892,30 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
case 'M':
params->max_tolerable_latency = atoi(optarg);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_tolerable_latency %d\n",
params->max_tolerable_latency);
if(nmxptool_parse_int(optarg, &(params->max_tolerable_latency)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Max Tolerable Latency '%s'.\n", optarg);
ret_errors++;
} else {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_tolerable_latency %d\n",
params->max_tolerable_latency);
}
break;
case 'T':
params->timeoutrecv = atoi(optarg);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Time-out receiving %d\n",
params->timeoutrecv);
if(nmxptool_parse_int(optarg, &(params->timeoutrecv)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing Time-out receving '%s'.\n", optarg);
ret_errors++;
} else {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Time-out receiving %d\n",
params->timeoutrecv);
}
break;
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;
case 'B':
......@@ -868,9 +929,12 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
case 'A':
if(optarg) {
params->max_data_to_retrieve = atoi(optarg);
}
if(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);
break;
......@@ -910,13 +974,19 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
#ifdef HAVE_SEEDLINK
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;
#endif
#ifndef HAVE_WINDOWS_H
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;
#endif
......@@ -1038,25 +1108,29 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
case 'r':
params->reclen = atoi(optarg);
if(params->reclen >= DEFAULT_RECLEN_MINIMUM && params->reclen <= DEFAULT_RECLEN_MAXIMUM) {
flag_reclen_pow = 0;
while(!flag_reclen_pow && reclen_pow <= DEFAULT_RECLEN_MAXIMUM) {
if(params->reclen == reclen_pow) {
flag_reclen_pow = 1;
}
reclen_pow *= 2;
}
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");
if(nmxptool_parse_int(optarg, &(params->reclen)) == 0) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Error parsing mini-SEED record length '%s'.\n", optarg);
ret_errors++;
} else {
if(params->reclen >= DEFAULT_RECLEN_MINIMUM && params->reclen <= DEFAULT_RECLEN_MAXIMUM) {
flag_reclen_pow = 0;
while(!flag_reclen_pow && reclen_pow <= DEFAULT_RECLEN_MAXIMUM) {
if(params->reclen == reclen_pow) {
flag_reclen_pow = 1;
}
reclen_pow *= 2;
}
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;
#endif
......
......@@ -198,6 +198,28 @@ int nmxptool_read_time(char *str_input, int32_t *pvalue);
int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params);
/*! \brief Wrapper to strtol()
*
* \param str
* \param[out] val
*
* \retval 1 on success.
* \retval 0 on failure.
*
*/
int nmxptool_parse_long(const char *str, long *val);
/*! \brief Wrapper to nmxptool_parse_long() to parse int value
*
* \param str
* \param[out] val
*
* \retval 1 on success.
* \retval 0 on failure.
*
*/
int nmxptool_parse_int(const char *str, int *val);
/*! \brief Print value of NMXPTOOL_PARAMS
*
* \param params Struct to validate.
......
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