zbopt.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /** @file zbopt.h
  2. * @brief The header file for the command line option parser
  3. * generated by GNU Gengetopt version 2.22.6
  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. #ifndef ZBOPT_H
  8. #define ZBOPT_H
  9. /* If we use autoconf. */
  10. #ifdef HAVE_CONFIG_H
  11. #include "config.h"
  12. #endif
  13. #include <stdio.h> /* for FILE */
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif /* __cplusplus */
  17. #ifndef CMDLINE_PARSER_PACKAGE
  18. /** @brief the program name (used for printing errors) */
  19. #define CMDLINE_PARSER_PACKAGE "zblacklist"
  20. #endif
  21. #ifndef CMDLINE_PARSER_PACKAGE_NAME
  22. /** @brief the complete program name (used for help and version) */
  23. #define CMDLINE_PARSER_PACKAGE_NAME "zblacklist"
  24. #endif
  25. #ifndef CMDLINE_PARSER_VERSION
  26. /** @brief the program version */
  27. #define CMDLINE_PARSER_VERSION "2.1.0-RC1"
  28. #endif
  29. /** @brief Where the command line options are stored */
  30. struct gengetopt_args_info
  31. {
  32. char * blacklist_file_arg; /**< @brief File of subnets to exclude, in CIDR notation, one-per line.. */
  33. char * blacklist_file_orig; /**< @brief File of subnets to exclude, in CIDR notation, one-per line. original value given at command line. */
  34. const char *blacklist_file_help; /**< @brief File of subnets to exclude, in CIDR notation, one-per line. help description. */
  35. char * whitelist_file_arg; /**< @brief File of subnets to include, in CIDR notation, one-per line.. */
  36. char * whitelist_file_orig; /**< @brief File of subnets to include, in CIDR notation, one-per line. original value given at command line. */
  37. const char *whitelist_file_help; /**< @brief File of subnets to include, in CIDR notation, one-per line. help description. */
  38. char * log_file_arg; /**< @brief File to log to. */
  39. char * log_file_orig; /**< @brief File to log to original value given at command line. */
  40. const char *log_file_help; /**< @brief File to log to help description. */
  41. int verbosity_arg; /**< @brief Set log level verbosity (0-5, default 3) (default='3'). */
  42. char * verbosity_orig; /**< @brief Set log level verbosity (0-5, default 3) original value given at command line. */
  43. const char *verbosity_help; /**< @brief Set log level verbosity (0-5, default 3) help description. */
  44. const char *no_duplicate_checking_help; /**< @brief Don't deduplicate IP addresses (default false) help description. */
  45. const char *ignore_blacklist_errors_help; /**< @brief Ignore invalid entires in the blacklist/whitelist (default false) help description. */
  46. const char *help_help; /**< @brief Print help and exit help description. */
  47. const char *version_help; /**< @brief Print version and exit help description. */
  48. unsigned int blacklist_file_given ; /**< @brief Whether blacklist-file was given. */
  49. unsigned int whitelist_file_given ; /**< @brief Whether whitelist-file was given. */
  50. unsigned int log_file_given ; /**< @brief Whether log-file was given. */
  51. unsigned int verbosity_given ; /**< @brief Whether verbosity was given. */
  52. unsigned int no_duplicate_checking_given ; /**< @brief Whether no-duplicate-checking was given. */
  53. unsigned int ignore_blacklist_errors_given ; /**< @brief Whether ignore-blacklist-errors was given. */
  54. unsigned int help_given ; /**< @brief Whether help was given. */
  55. unsigned int version_given ; /**< @brief Whether version was given. */
  56. } ;
  57. /** @brief The additional parameters to pass to parser functions */
  58. struct cmdline_parser_params
  59. {
  60. int override; /**< @brief whether to override possibly already present options (default 0) */
  61. int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
  62. int check_required; /**< @brief whether to check that all required options were provided (default 1) */
  63. int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
  64. int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
  65. } ;
  66. /** @brief the purpose string of the program */
  67. extern const char *gengetopt_args_info_purpose;
  68. /** @brief the usage string of the program */
  69. extern const char *gengetopt_args_info_usage;
  70. /** @brief the description string of the program */
  71. extern const char *gengetopt_args_info_description;
  72. /** @brief all the lines making the help output */
  73. extern const char *gengetopt_args_info_help[];
  74. /**
  75. * The command line parser
  76. * @param argc the number of command line options
  77. * @param argv the command line options
  78. * @param args_info the structure where option information will be stored
  79. * @return 0 if everything went fine, NON 0 if an error took place
  80. */
  81. int cmdline_parser (int argc, char **argv,
  82. struct gengetopt_args_info *args_info);
  83. /**
  84. * The command line parser (version with additional parameters - deprecated)
  85. * @param argc the number of command line options
  86. * @param argv the command line options
  87. * @param args_info the structure where option information will be stored
  88. * @param override whether to override possibly already present options
  89. * @param initialize whether to initialize the option structure my_args_info
  90. * @param check_required whether to check that all required options were provided
  91. * @return 0 if everything went fine, NON 0 if an error took place
  92. * @deprecated use cmdline_parser_ext() instead
  93. */
  94. int cmdline_parser2 (int argc, char **argv,
  95. struct gengetopt_args_info *args_info,
  96. int override, int initialize, int check_required);
  97. /**
  98. * The command line parser (version with additional parameters)
  99. * @param argc the number of command line options
  100. * @param argv the command line options
  101. * @param args_info the structure where option information will be stored
  102. * @param params additional parameters for the parser
  103. * @return 0 if everything went fine, NON 0 if an error took place
  104. */
  105. int cmdline_parser_ext (int argc, char **argv,
  106. struct gengetopt_args_info *args_info,
  107. struct cmdline_parser_params *params);
  108. /**
  109. * Save the contents of the option struct into an already open FILE stream.
  110. * @param outfile the stream where to dump options
  111. * @param args_info the option struct to dump
  112. * @return 0 if everything went fine, NON 0 if an error took place
  113. */
  114. int cmdline_parser_dump(FILE *outfile,
  115. struct gengetopt_args_info *args_info);
  116. /**
  117. * Save the contents of the option struct into a (text) file.
  118. * This file can be read by the config file parser (if generated by gengetopt)
  119. * @param filename the file where to save
  120. * @param args_info the option struct to save
  121. * @return 0 if everything went fine, NON 0 if an error took place
  122. */
  123. int cmdline_parser_file_save(const char *filename,
  124. struct gengetopt_args_info *args_info);
  125. /**
  126. * Print the help
  127. */
  128. void cmdline_parser_print_help(void);
  129. /**
  130. * Print the version
  131. */
  132. void cmdline_parser_print_version(void);
  133. /**
  134. * Initializes all the fields a cmdline_parser_params structure
  135. * to their default values
  136. * @param params the structure to initialize
  137. */
  138. void cmdline_parser_params_init(struct cmdline_parser_params *params);
  139. /**
  140. * Allocates dynamically a cmdline_parser_params structure and initializes
  141. * all its fields to their default values
  142. * @return the created and initialized cmdline_parser_params structure
  143. */
  144. struct cmdline_parser_params *cmdline_parser_params_create(void);
  145. /**
  146. * Initializes the passed gengetopt_args_info structure's fields
  147. * (also set default values for options that have a default)
  148. * @param args_info the structure to initialize
  149. */
  150. void cmdline_parser_init (struct gengetopt_args_info *args_info);
  151. /**
  152. * Deallocates the string fields of the gengetopt_args_info structure
  153. * (but does not deallocate the structure itself)
  154. * @param args_info the structure to deallocate
  155. */
  156. void cmdline_parser_free (struct gengetopt_args_info *args_info);
  157. /**
  158. * The config file parser (deprecated version)
  159. * @param filename the name of the config file
  160. * @param args_info the structure where option information will be stored
  161. * @param override whether to override possibly already present options
  162. * @param initialize whether to initialize the option structure my_args_info
  163. * @param check_required whether to check that all required options were provided
  164. * @return 0 if everything went fine, NON 0 if an error took place
  165. * @deprecated use cmdline_parser_config_file() instead
  166. */
  167. int cmdline_parser_configfile (const char *filename,
  168. struct gengetopt_args_info *args_info,
  169. int override, int initialize, int check_required);
  170. /**
  171. * The config file parser
  172. * @param filename the name of the config file
  173. * @param args_info the structure where option information will be stored
  174. * @param params additional parameters for the parser
  175. * @return 0 if everything went fine, NON 0 if an error took place
  176. */
  177. int cmdline_parser_config_file (const char *filename,
  178. struct gengetopt_args_info *args_info,
  179. struct cmdline_parser_params *params);
  180. /**
  181. * Checks that all the required options were specified
  182. * @param args_info the structure to check
  183. * @param prog_name the name of the program that will be used to print
  184. * possible errors
  185. * @return
  186. */
  187. int cmdline_parser_required (struct gengetopt_args_info *args_info,
  188. const char *prog_name);
  189. #ifdef __cplusplus
  190. }
  191. #endif /* __cplusplus */
  192. #endif /* ZBOPT_H */