nmxptool_getoptlong.h 3.94 KB
Newer Older
Matteo Quintiliani's avatar
Matteo Quintiliani committed
1 2 3 4 5 6 7 8 9
/*! \file
 *
 * \brief Nanometrics Protocol Tool
 *
 * Author:
 * 	Matteo Quintiliani
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *
10
 * $Id: nmxptool_getoptlong.h,v 1.98 2008-03-20 12:43:50 mtheo Exp $
Matteo Quintiliani's avatar
Matteo Quintiliani committed
11 12 13
 *
 */

14 15
#ifndef NMXPTOOL_GETLONG_H
#define NMXPTOOL_GETLONG_H 1
16 17 18 19

#include <getopt.h>
#include <stdint.h>

20 21
#define NMXP_STR_STATE_EXT ".nmxpstate"

Matteo Quintiliani's avatar
Matteo Quintiliani committed
22 23 24 25 26 27 28 29 30 31 32 33 34
#define DEFAULT_NETWORK  	"XX"
#define DEFAULT_PORT_DAP 	28002
#define DEFAULT_PORT_PDS 	28000

#define DEFAULT_STC_MINIMUM	-1
#define DEFAULT_STC_MAXIMUM	300
#define DEFAULT_STC      	-1

#define DEFAULT_RATE_MINIMUM   	-1
#define DEFAULT_RATE_MAXIMUM   	1000
#define DEFAULT_RATE     	-1

#define DEFAULT_DELAY_MINIMUM  	60
35
#define DEFAULT_DELAY_MAXIMUM  	(86400 * 31)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
36 37
#define DEFAULT_DELAY    	0

38 39 40 41 42 43 44
#define DEFAULT_MAX_TOLERABLE_LATENCY_MINIMUM	60
#define DEFAULT_MAX_TOLERABLE_LATENCY_MAXIMUM	600
#define DEFAULT_MAX_TOLERABLE_LATENCY 		600

#define DEFAULT_TIMEOUTRECV 			0
#define DEFAULT_TIMEOUTRECV_MINIMUM 		10
#define DEFAULT_TIMEOUTRECV_MAXIMUM 		300
45

46
#define DEFAULT_VERBOSE_LEVEL 			NMXP_LOG_D_NULL
47 48
#define DEFAULT_VERBOSE_LEVEL_MINIMUM		NMXP_LOG_D_NULL
#define DEFAULT_VERBOSE_LEVEL_MAXIMUM		NMXP_LOG_D_ANY
49

50
#define DEFAULT_BUFFERED_TIME			-1.0
51

52 53
#define DEFAULT_INTERVAL_NO_VALUE		-1
#define DEFAULT_INTERVAL_INFINITE		0
54
#define DEFAULT_INTERVAL_MAXIMUM		(86400 * 31)
Matteo Quintiliani's avatar
Matteo Quintiliani committed
55

56
#define DEFAULT_MAX_TIME_TO_RETRIEVE_MINIMUM	0
57
#define DEFAULT_MAX_TIME_TO_RETRIEVE_MAXIMUM	86400
58
#define DEFAULT_MAX_TIME_TO_RETRIEVE 		0
59

60
/* Empiric constant values TODO */
61 62 63 64
#define DEFAULT_N_CHANNEL		9
#define DEFAULT_N_CHANNEL_MINIMUM	3
#define DEFAULT_N_CHANNEL_MAXIMUM	30

65
#define DEFAULT_USEC		280000
66 67
#define DEFAULT_USEC_MINIMUM	0
#define DEFAULT_USEC_MAXIMUM	1000000
68

69 70 71 72 73 74 75 76
/*! \brief Struct that stores information about parameter of the program */
typedef struct {
    char *hostname;
    int portnumberdap;
    int portnumberpds;
    char *channels;
    char *network;
    char *location;
77 78
    double start_time;
    double end_time;
Matteo Quintiliani's avatar
Matteo Quintiliani committed
79
    int32_t interval;
80 81
    char *datas_username;
    char *datas_password;
82 83
    int32_t stc;
    int32_t rate;
84
    char *plugin_slink;
85
    int32_t delay;
Matteo Quintiliani's avatar
Matteo Quintiliani committed
86
    int32_t max_tolerable_latency;
87
    int32_t timeoutrecv;
88
    int32_t verbose_level;
89
    char *ew_configuration_file;
90
    char *statefile;
91
    double buffered_time;
92
    int n_channel;
93
    int usec;
94
    int32_t max_data_to_retrieve;
95 96
    int flag_writeseed;
    int flag_listchannels;
97
    int flag_listchannelsnaqs;
98
    int flag_request_channelinfo;
99
    int flag_writefile;
100
    int flag_slink;
101
    int flag_buffered;
102
    int flag_logdata;
Matteo Quintiliani's avatar
Matteo Quintiliani committed
103
    int flag_logsample;
104
} NMXPTOOL_PARAMS;
105

106 107 108 109 110 111
/*! \brief Print author and e-mail for support and bugs */
void nmxptool_author_support();

/*! \brief Print version of tool */
void nmxptool_version();

Matteo Quintiliani's avatar
Matteo Quintiliani committed
112 113 114
/*! \brief Print supports of tool i.e. libmseed, earthworm, ...*/
void nmxptool_supports();

115 116 117 118
/*! \brief Print the usage of paramters */
void nmxptool_usage(struct option long_options[]);


119 120 121 122 123
/*! \brief Read channel states from file
 *
 * \param filename File name of state file
 *
 * \retval Argument string for -C
124
 */
125 126
char *get_channel_list_argument_from_state_file(const char *filename);

127 128 129 130 131 132 133 134 135 136
/*! \brief Convert a string TIME (ex. 1, 3m, 2h, 10d) in seconds 
 *
 * \param str_input input string
 * \param[out] pvalue value in seconds
 *
 * \return number of errors
 */
int nmxptool_read_time(char *str_input, int32_t *pvalue);


137
/*! \brief Calls getopt_long and set struct NMXPTOOL_PARAMS
138 139 140 141 142 143 144 145 146
 *
 * \param argc
 * \param argv
 * \param params
 *
 * \retval 0 on success.
 * \retval >0 Number of errors.
 *
 */
147
int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params);
148 149


150 151 152 153 154 155 156
/*! \brief Print value of NMXPTOOL_PARAMS
 *
 * \param params Struct to validate.
 *
 */
void nmxptool_log_params(NMXPTOOL_PARAMS *params);

157
/*! \brief Check semantyc of values in struct NMXPTOOL_PARAMS
158 159 160 161 162 163
 *
 * \param params Struct to validate.
 *
 * \retval 0 on success.
 * \retval -1 on error.
 */
164
int nmxptool_check_params(NMXPTOOL_PARAMS *params);
165 166 167

#endif