topt.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /** @file topt.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 TOPT_H
  8. #define TOPT_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 "ztee"
  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 "ztee"
  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. const char *success_only_help; /**< @brief Only write to stdout rows where success=1 or success=true help description. */
  33. const char *monitor_help; /**< @brief Print monitor output to stdout help description. */
  34. char * status_updates_file_arg; /**< @brief File to write status updates in CSV format. */
  35. char * status_updates_file_orig; /**< @brief File to write status updates in CSV format original value given at command line. */
  36. const char *status_updates_file_help; /**< @brief File to write status updates in CSV format help description. */
  37. char * log_file_arg; /**< @brief File to log to. */
  38. char * log_file_orig; /**< @brief File to log to original value given at command line. */
  39. const char *log_file_help; /**< @brief File to log to help description. */
  40. const char *raw_help; /**< @brief Ignore input formatting help description. */
  41. const char *help_help; /**< @brief Print help and exit help description. */
  42. const char *version_help; /**< @brief Print version and exit help description. */
  43. unsigned int success_only_given ; /**< @brief Whether success-only was given. */
  44. unsigned int monitor_given ; /**< @brief Whether monitor was given. */
  45. unsigned int status_updates_file_given ; /**< @brief Whether status-updates-file was given. */
  46. unsigned int log_file_given ; /**< @brief Whether log-file was given. */
  47. unsigned int raw_given ; /**< @brief Whether raw was given. */
  48. unsigned int help_given ; /**< @brief Whether help was given. */
  49. unsigned int version_given ; /**< @brief Whether version was given. */
  50. char **inputs ; /**< @brief unamed options (options without names) */
  51. unsigned inputs_num ; /**< @brief unamed options number */
  52. } ;
  53. /** @brief The additional parameters to pass to parser functions */
  54. struct cmdline_parser_params
  55. {
  56. int override; /**< @brief whether to override possibly already present options (default 0) */
  57. int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
  58. int check_required; /**< @brief whether to check that all required options were provided (default 1) */
  59. int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
  60. int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
  61. } ;
  62. /** @brief the purpose string of the program */
  63. extern const char *gengetopt_args_info_purpose;
  64. /** @brief the usage string of the program */
  65. extern const char *gengetopt_args_info_usage;
  66. /** @brief the description string of the program */
  67. extern const char *gengetopt_args_info_description;
  68. /** @brief all the lines making the help output */
  69. extern const char *gengetopt_args_info_help[];
  70. /**
  71. * The command line parser
  72. * @param argc the number of command line options
  73. * @param argv the command line options
  74. * @param args_info the structure where option information will be stored
  75. * @return 0 if everything went fine, NON 0 if an error took place
  76. */
  77. int cmdline_parser (int argc, char **argv,
  78. struct gengetopt_args_info *args_info);
  79. /**
  80. * The command line parser (version with additional parameters - deprecated)
  81. * @param argc the number of command line options
  82. * @param argv the command line options
  83. * @param args_info the structure where option information will be stored
  84. * @param override whether to override possibly already present options
  85. * @param initialize whether to initialize the option structure my_args_info
  86. * @param check_required whether to check that all required options were provided
  87. * @return 0 if everything went fine, NON 0 if an error took place
  88. * @deprecated use cmdline_parser_ext() instead
  89. */
  90. int cmdline_parser2 (int argc, char **argv,
  91. struct gengetopt_args_info *args_info,
  92. int override, int initialize, int check_required);
  93. /**
  94. * The command line parser (version with additional parameters)
  95. * @param argc the number of command line options
  96. * @param argv the command line options
  97. * @param args_info the structure where option information will be stored
  98. * @param params additional parameters for the parser
  99. * @return 0 if everything went fine, NON 0 if an error took place
  100. */
  101. int cmdline_parser_ext (int argc, char **argv,
  102. struct gengetopt_args_info *args_info,
  103. struct cmdline_parser_params *params);
  104. /**
  105. * Save the contents of the option struct into an already open FILE stream.
  106. * @param outfile the stream where to dump options
  107. * @param args_info the option struct to dump
  108. * @return 0 if everything went fine, NON 0 if an error took place
  109. */
  110. int cmdline_parser_dump(FILE *outfile,
  111. struct gengetopt_args_info *args_info);
  112. /**
  113. * Save the contents of the option struct into a (text) file.
  114. * This file can be read by the config file parser (if generated by gengetopt)
  115. * @param filename the file where to save
  116. * @param args_info the option struct to save
  117. * @return 0 if everything went fine, NON 0 if an error took place
  118. */
  119. int cmdline_parser_file_save(const char *filename,
  120. struct gengetopt_args_info *args_info);
  121. /**
  122. * Print the help
  123. */
  124. void cmdline_parser_print_help(void);
  125. /**
  126. * Print the version
  127. */
  128. void cmdline_parser_print_version(void);
  129. /**
  130. * Initializes all the fields a cmdline_parser_params structure
  131. * to their default values
  132. * @param params the structure to initialize
  133. */
  134. void cmdline_parser_params_init(struct cmdline_parser_params *params);
  135. /**
  136. * Allocates dynamically a cmdline_parser_params structure and initializes
  137. * all its fields to their default values
  138. * @return the created and initialized cmdline_parser_params structure
  139. */
  140. struct cmdline_parser_params *cmdline_parser_params_create(void);
  141. /**
  142. * Initializes the passed gengetopt_args_info structure's fields
  143. * (also set default values for options that have a default)
  144. * @param args_info the structure to initialize
  145. */
  146. void cmdline_parser_init (struct gengetopt_args_info *args_info);
  147. /**
  148. * Deallocates the string fields of the gengetopt_args_info structure
  149. * (but does not deallocate the structure itself)
  150. * @param args_info the structure to deallocate
  151. */
  152. void cmdline_parser_free (struct gengetopt_args_info *args_info);
  153. /**
  154. * The string parser (interprets the passed string as a command line)
  155. * @param cmdline the command line stirng
  156. * @param args_info the structure where option information will be stored
  157. * @param prog_name the name of the program that will be used to print
  158. * possible errors
  159. * @return 0 if everything went fine, NON 0 if an error took place
  160. */
  161. int cmdline_parser_string (const char *cmdline, struct gengetopt_args_info *args_info,
  162. const char *prog_name);
  163. /**
  164. * The string parser (version with additional parameters - deprecated)
  165. * @param cmdline the command line stirng
  166. * @param args_info the structure where option information will be stored
  167. * @param prog_name the name of the program that will be used to print
  168. * possible errors
  169. * @param override whether to override possibly already present options
  170. * @param initialize whether to initialize the option structure my_args_info
  171. * @param check_required whether to check that all required options were provided
  172. * @return 0 if everything went fine, NON 0 if an error took place
  173. * @deprecated use cmdline_parser_string_ext() instead
  174. */
  175. int cmdline_parser_string2 (const char *cmdline, struct gengetopt_args_info *args_info,
  176. const char *prog_name,
  177. int override, int initialize, int check_required);
  178. /**
  179. * The string parser (version with additional parameters)
  180. * @param cmdline the command line stirng
  181. * @param args_info the structure where option information will be stored
  182. * @param prog_name the name of the program that will be used to print
  183. * possible errors
  184. * @param params additional parameters for the parser
  185. * @return 0 if everything went fine, NON 0 if an error took place
  186. */
  187. int cmdline_parser_string_ext (const char *cmdline, struct gengetopt_args_info *args_info,
  188. const char *prog_name,
  189. struct cmdline_parser_params *params);
  190. /**
  191. * Checks that all the required options were specified
  192. * @param args_info the structure to check
  193. * @param prog_name the name of the program that will be used to print
  194. * possible errors
  195. * @return
  196. */
  197. int cmdline_parser_required (struct gengetopt_args_info *args_info,
  198. const char *prog_name);
  199. #ifdef __cplusplus
  200. }
  201. #endif /* __cplusplus */
  202. #endif /* TOPT_H */