Commit ecc7ef2d authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added Earthworm parameter check


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@363 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 07604337
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxptool.c,v 1.71 2007-09-28 12:57:21 mtheo Exp $ * $Id: nmxptool.c,v 1.72 2007-09-28 13:24:52 mtheo Exp $
* *
*/ */
...@@ -132,11 +132,25 @@ int main (int argc, char **argv) { ...@@ -132,11 +132,25 @@ int main (int argc, char **argv) {
return 1; return 1;
} }
/* Check consistency of params */ if(params.ew_configuration_file) {
if(nmxptool_check_params(&params) != 0) { nmxp_log(NMXP_LOG_NORM_NO, 0, "\n");
return 1; nmxp_log(NMXP_LOG_WARN, 0, "Earthworm support is still under development!\n");
nmxp_log(NMXP_LOG_NORM_NO, 0, "\n");
exit(0);
} else {
/* Check consistency of params */
if(nmxptool_check_params(&params) != 0) {
return 1;
}
} }
#ifdef HAVE_EARTHWORMOBJS
/* Attach to Output transport ring */
tport_attach (&regionOut, ringKey);
logit ("t", "nmxp2ew version %s\n", VERSION);
#endif
if(params.flag_verbose) { if(params.flag_verbose) {
nmxp_log(-1, 2); nmxp_log(-1, 2);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxptool_getoptlong.c,v 1.24 2007-09-28 10:13:48 mtheo Exp $ * $Id: nmxptool_getoptlong.c,v 1.25 2007-09-28 13:24:52 mtheo Exp $
* *
*/ */
...@@ -38,6 +38,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT = ...@@ -38,6 +38,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
NULL, NULL,
DEFAULT_DELAY, DEFAULT_DELAY,
DEFAULT_MAX_TOLLERABLE_LATENCY, DEFAULT_MAX_TOLLERABLE_LATENCY,
NULL,
0, 0,
0, 0,
0, 0,
...@@ -274,6 +275,20 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -274,6 +275,20 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
strcat(optstr, "k:"); strcat(optstr, "k:");
#endif #endif
/* Check number of command line arguments for earthworm */
if (argc == 2)
{
int l = strlen(argv[1]);
if(l >= 3) {
if(argv[1][0] != '-') {
if(argv[1][l-2] == '.' && argv[1][l-1] == 'd') {
params->ew_configuration_file = argv[1];
return 0;
}
}
}
}
while ( (c = getopt_long (argc, argv, optstr, long_options, &option_index)) != -1) { while ( (c = getopt_long (argc, argv, optstr, long_options, &option_index)) != -1) {
/* BE CAREFUL if use synonym options !!! */ /* BE CAREFUL if use synonym options !!! */
...@@ -439,7 +454,9 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params) ...@@ -439,7 +454,9 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
int nmxptool_check_params(NMXPTOOL_PARAMS *params) { int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
int ret = 0; int ret = 0;
if(params->hostname == NULL) { if(params->ew_configuration_file != NULL) {
/* Do nothing */
} else if(params->hostname == NULL) {
ret = -1; ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<hostname> is required!\n"); nmxp_log(NMXP_LOG_NORM_NO, 0, "<hostname> is required!\n");
} else if(params->flag_listchannels) { } else if(params->flag_listchannels) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxptool_getoptlong.h,v 1.15 2007-09-28 10:13:48 mtheo Exp $ * $Id: nmxptool_getoptlong.h,v 1.16 2007-09-28 13:24:52 mtheo Exp $
* *
*/ */
...@@ -55,6 +55,7 @@ typedef struct { ...@@ -55,6 +55,7 @@ typedef struct {
char *plugin_slink; char *plugin_slink;
int32_t delay; int32_t delay;
int32_t max_tollerable_latency; int32_t max_tollerable_latency;
char *ew_configuration_file;
int flag_writeseed; int flag_writeseed;
int flag_verbose; int flag_verbose;
int flag_listchannels; int flag_listchannels;
......
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