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

Merge branch 'release/2.1.4'

parents a4aab733 412222ca
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
nmxptool Release History 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) * 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
......
...@@ -9,9 +9,9 @@ m4_define([full_package_name], [nmxptool]) ...@@ -9,9 +9,9 @@ m4_define([full_package_name], [nmxptool])
dnl These three define the plug-in version number dnl These three define the plug-in version number
m4_define([major_version], [2]) m4_define([major_version], [2])
m4_define([minor_version], [1]) m4_define([minor_version], [1])
m4_define([micro_version], [3]) m4_define([micro_version], [4])
# Comment build_version for stable release # Comment build_version for stable release
# m4_define([build_version], [beta1]) # m4_define([build_version], [dev])
m4_ifdef([build_version], [ m4_ifdef([build_version], [
m4_define([version], m4_define([version],
......
...@@ -106,6 +106,9 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void)) ...@@ -106,6 +106,9 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
isock, NMXP_LOG_STR(inet_ntoa(hostaddr)), portNum); isock, NMXP_LOG_STR(inet_ntoa(hostaddr)), portNum);
return isock; return isock;
} else { } 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(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_LOG_STR(inet_ntoa(hostaddr)), portNum, sleepTime);
nmxp_closeSocket(isock); nmxp_closeSocket(isock);
...@@ -120,6 +123,7 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void)) ...@@ -120,6 +123,7 @@ int nmxp_openSocket(char *hostname, int portNum, int (*func_cond)(void))
if (sleepTime > NMXP_SLEEPMAX) { if (sleepTime > NMXP_SLEEPMAX) {
sleepTime = NMXP_SLEEPMAX; sleepTime = NMXP_SLEEPMAX;
} }
*/
} }
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include "config.h" #include "config.h"
#include "nmxp.h" #include "nmxp.h"
...@@ -599,6 +600,42 @@ int nmxptool_read_time(char *str_input, int32_t *pvalue) { ...@@ -599,6 +600,42 @@ int nmxptool_read_time(char *str_input, int32_t *pvalue) {
return ret_errors; 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 nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{ {
int ret_errors = 0; int ret_errors = 0;
...@@ -766,11 +803,17 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -766,11 +803,17 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break; break;
case 'P': 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; break;
case 'D': 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; break;
case 'C': case 'C':
...@@ -792,15 +835,22 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -792,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':
...@@ -842,19 +892,30 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -842,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':
...@@ -868,9 +929,12 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -868,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;
...@@ -910,13 +974,19 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -910,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
...@@ -1038,25 +1108,29 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -1038,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
......
...@@ -198,6 +198,28 @@ int nmxptool_read_time(char *str_input, int32_t *pvalue); ...@@ -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); 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 /*! \brief Print value of NMXPTOOL_PARAMS
* *
* \param params Struct to validate. * \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