nmxptool_getoptlong.h 3.57 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.94 2008-03-19 12:55:46 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

Matteo Quintiliani's avatar
Matteo Quintiliani committed
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
61
62
63
/* Empiric constant values TODO */
#define DEFAULT_N_CHANNEL	9
#define DEFAULT_N_USEC		250000

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

101
102
103
104
105
106
/*! \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
107
108
109
/*! \brief Print supports of tool i.e. libmseed, earthworm, ...*/
void nmxptool_supports();

110
111
112
113
/*! \brief Print the usage of paramters */
void nmxptool_usage(struct option long_options[]);


114
115
116
117
118
119
120
121
/*! \brief Read channel states from file
 *
 * \param filename File name of state file
 *
 * \retval Argument string for -C
 * */
char *get_channel_list_argument_from_state_file(const char *filename);

122
/*! \brief Calls getopt_long and set struct NMXPTOOL_PARAMS
123
124
125
126
127
128
129
130
131
 *
 * \param argc
 * \param argv
 * \param params
 *
 * \retval 0 on success.
 * \retval >0 Number of errors.
 *
 */
132
int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params);
133
134


135
136
137
138
139
140
141
/*! \brief Print value of NMXPTOOL_PARAMS
 *
 * \param params Struct to validate.
 *
 */
void nmxptool_log_params(NMXPTOOL_PARAMS *params);

142
/*! \brief Check semantyc of values in struct NMXPTOOL_PARAMS
143
144
145
146
147
148
 *
 * \param params Struct to validate.
 *
 * \retval 0 on success.
 * \retval -1 on error.
 */
149
int nmxptool_check_params(NMXPTOOL_PARAMS *params);
150
151
152

#endif