1 /** @file cmdline.h
2  *  @brief The header file for the command line option parser
3  *  generated by GNU Gengetopt version 2.22.4
4  *  http://www.gnu.org/software/gengetopt.
5  *  DO NOT modify this file, since it can be overwritten
6  *  @author GNU Gengetopt by Lorenzo Bettini */
7 
8 #ifndef CMDLINE_H
9 #define CMDLINE_H
10 
11 /* If we use autoconf.  */
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #include <stdio.h> /* for FILE */
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21 
22 #ifndef CMDLINE_PARSER_PACKAGE
23 /** @brief the program name (used for printing errors) */
24 #define CMDLINE_PARSER_PACKAGE "gmetad"
25 #endif
26 
27 #ifndef CMDLINE_PARSER_PACKAGE_NAME
28 /** @brief the complete program name (used for help and version) */
29 #define CMDLINE_PARSER_PACKAGE_NAME "gmetad"
30 #endif
31 
32 #ifndef CMDLINE_PARSER_VERSION
33 /** @brief the program version */
34 #define CMDLINE_PARSER_VERSION VERSION
35 #endif
36 
37 /** @brief Where the command line options are stored */
38 struct gengetopt_args_info
39 {
40   const char *help_help; /**< @brief Print help and exit help description.  */
41   const char *version_help; /**< @brief Print version and exit help description.  */
42   char * conf_arg;	/**< @brief Location of gmetad configuration file (default='@sysconfdir@/gmetad.conf').  */
43   char * conf_orig;	/**< @brief Location of gmetad configuration file original value given at command line.  */
44   const char *conf_help; /**< @brief Location of gmetad configuration file help description.  */
45   int debug_arg;	/**< @brief Debug level. If greater than zero, daemon will stay in foreground. (default='0').  */
46   char * debug_orig;	/**< @brief Debug level. If greater than zero, daemon will stay in foreground. original value given at command line.  */
47   const char *debug_help; /**< @brief Debug level. If greater than zero, daemon will stay in foreground. help description.  */
48   char * pid_file_arg;	/**< @brief Write process-id to file.  */
49   char * pid_file_orig;	/**< @brief Write process-id to file original value given at command line.  */
50   const char *pid_file_help; /**< @brief Write process-id to file help description.  */
51 
52   unsigned int help_given ;	/**< @brief Whether help was given.  */
53   unsigned int version_given ;	/**< @brief Whether version was given.  */
54   unsigned int conf_given ;	/**< @brief Whether conf was given.  */
55   unsigned int debug_given ;	/**< @brief Whether debug was given.  */
56   unsigned int pid_file_given ;	/**< @brief Whether pid-file was given.  */
57 
58 } ;
59 
60 /** @brief The additional parameters to pass to parser functions */
61 struct cmdline_parser_params
62 {
63   int override; /**< @brief whether to override possibly already present options (default 0) */
64   int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
65   int check_required; /**< @brief whether to check that all required options were provided (default 1) */
66   int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
67   int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
68 } ;
69 
70 /** @brief the purpose string of the program */
71 extern const char *gengetopt_args_info_purpose;
72 /** @brief the usage string of the program */
73 extern const char *gengetopt_args_info_usage;
74 /** @brief all the lines making the help output */
75 extern const char *gengetopt_args_info_help[];
76 
77 /**
78  * The command line parser
79  * @param argc the number of command line options
80  * @param argv the command line options
81  * @param args_info the structure where option information will be stored
82  * @return 0 if everything went fine, NON 0 if an error took place
83  */
84 int cmdline_parser (int argc, char **argv,
85   struct gengetopt_args_info *args_info);
86 
87 /**
88  * The command line parser (version with additional parameters - deprecated)
89  * @param argc the number of command line options
90  * @param argv the command line options
91  * @param args_info the structure where option information will be stored
92  * @param override whether to override possibly already present options
93  * @param initialize whether to initialize the option structure my_args_info
94  * @param check_required whether to check that all required options were provided
95  * @return 0 if everything went fine, NON 0 if an error took place
96  * @deprecated use cmdline_parser_ext() instead
97  */
98 int cmdline_parser2 (int argc, char **argv,
99   struct gengetopt_args_info *args_info,
100   int override, int initialize, int check_required);
101 
102 /**
103  * The command line parser (version with additional parameters)
104  * @param argc the number of command line options
105  * @param argv the command line options
106  * @param args_info the structure where option information will be stored
107  * @param params additional parameters for the parser
108  * @return 0 if everything went fine, NON 0 if an error took place
109  */
110 int cmdline_parser_ext (int argc, char **argv,
111   struct gengetopt_args_info *args_info,
112   struct cmdline_parser_params *params);
113 
114 /**
115  * Save the contents of the option struct into an already open FILE stream.
116  * @param outfile the stream where to dump options
117  * @param args_info the option struct to dump
118  * @return 0 if everything went fine, NON 0 if an error took place
119  */
120 int cmdline_parser_dump(FILE *outfile,
121   struct gengetopt_args_info *args_info);
122 
123 /**
124  * Save the contents of the option struct into a (text) file.
125  * This file can be read by the config file parser (if generated by gengetopt)
126  * @param filename the file where to save
127  * @param args_info the option struct to save
128  * @return 0 if everything went fine, NON 0 if an error took place
129  */
130 int cmdline_parser_file_save(const char *filename,
131   struct gengetopt_args_info *args_info);
132 
133 /**
134  * Print the help
135  */
136 void cmdline_parser_print_help(void);
137 /**
138  * Print the version
139  */
140 void cmdline_parser_print_version(void);
141 
142 /**
143  * Initializes all the fields a cmdline_parser_params structure
144  * to their default values
145  * @param params the structure to initialize
146  */
147 void cmdline_parser_params_init(struct cmdline_parser_params *params);
148 
149 /**
150  * Allocates dynamically a cmdline_parser_params structure and initializes
151  * all its fields to their default values
152  * @return the created and initialized cmdline_parser_params structure
153  */
154 struct cmdline_parser_params *cmdline_parser_params_create(void);
155 
156 /**
157  * Initializes the passed gengetopt_args_info structure's fields
158  * (also set default values for options that have a default)
159  * @param args_info the structure to initialize
160  */
161 void cmdline_parser_init (struct gengetopt_args_info *args_info);
162 /**
163  * Deallocates the string fields of the gengetopt_args_info structure
164  * (but does not deallocate the structure itself)
165  * @param args_info the structure to deallocate
166  */
167 void cmdline_parser_free (struct gengetopt_args_info *args_info);
168 
169 /**
170  * Checks that all the required options were specified
171  * @param args_info the structure to check
172  * @param prog_name the name of the program that will be used to print
173  *   possible errors
174  * @return
175  */
176 int cmdline_parser_required (struct gengetopt_args_info *args_info,
177   const char *prog_name);
178 
179 
180 #ifdef __cplusplus
181 }
182 #endif /* __cplusplus */
183 #endif /* CMDLINE_H */
184