1 /** @file cmdline.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 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 PACKAGE 25 #endif 26 27 #ifndef CMDLINE_PARSER_PACKAGE_NAME 28 /** @brief the complete program name (used for help and version) */ 29 #ifdef PACKAGE_NAME 30 #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE_NAME 31 #else 32 #define CMDLINE_PARSER_PACKAGE_NAME PACKAGE 33 #endif 34 #endif 35 36 #ifndef CMDLINE_PARSER_VERSION 37 /** @brief the program version */ 38 #define CMDLINE_PARSER_VERSION VERSION 39 #endif 40 41 /** @brief Where the command line options are stored */ 42 struct gengetopt_args_info 43 { 44 const char *help_help; /**< @brief Print help and exit help description. */ 45 const char *version_help; /**< @brief Print version and exit help description. */ 46 char * origin_arg; /**< @brief Origin URL to use during registration. Defaults to pam://hostname. */ 47 char * origin_orig; /**< @brief Origin URL to use during registration. Defaults to pam://hostname original value given at command line. */ 48 const char *origin_help; /**< @brief Origin URL to use during registration. Defaults to pam://hostname help description. */ 49 char * appid_arg; /**< @brief Application ID to use during registration. Defaults to pam://hostname. */ 50 char * appid_orig; /**< @brief Application ID to use during registration. Defaults to pam://hostname original value given at command line. */ 51 const char *appid_help; /**< @brief Application ID to use during registration. Defaults to pam://hostname help description. */ 52 char * type_arg; /**< @brief COSE type to use during registration (ES256 or RS256). Defaults to ES256.. */ 53 char * type_orig; /**< @brief COSE type to use during registration (ES256 or RS256). Defaults to ES256. original value given at command line. */ 54 const char *type_help; /**< @brief COSE type to use during registration (ES256 or RS256). Defaults to ES256. help description. */ 55 int resident_flag; /**< @brief Generate a resident credential (default=off). */ 56 const char *resident_help; /**< @brief Generate a resident credential help description. */ 57 int no_user_presence_flag; /**< @brief Allow the credential to be used without ensuring the user's presence (default=off). */ 58 const char *no_user_presence_help; /**< @brief Allow the credential to be used without ensuring the user's presence help description. */ 59 int pin_verification_flag; /**< @brief Require PIN verification during authentication (default=off). */ 60 const char *pin_verification_help; /**< @brief Require PIN verification during authentication help description. */ 61 int user_verification_flag; /**< @brief Require user verification during authentication (default=off). */ 62 const char *user_verification_help; /**< @brief Require user verification during authentication help description. */ 63 int debug_flag; /**< @brief Print debug information (highly verbose) (default=off). */ 64 const char *debug_help; /**< @brief Print debug information (highly verbose) help description. */ 65 int verbose_flag; /**< @brief Print information about chosen origin and appid (default=off). */ 66 const char *verbose_help; /**< @brief Print information about chosen origin and appid help description. */ 67 char * username_arg; /**< @brief The name of the user registering the device. Defaults to the current user name. */ 68 char * username_orig; /**< @brief The name of the user registering the device. Defaults to the current user name original value given at command line. */ 69 const char *username_help; /**< @brief The name of the user registering the device. Defaults to the current user name help description. */ 70 const char *nouser_help; /**< @brief Print only registration information (keyHandle and public key). Useful for appending help description. */ 71 72 unsigned int help_given ; /**< @brief Whether help was given. */ 73 unsigned int version_given ; /**< @brief Whether version was given. */ 74 unsigned int origin_given ; /**< @brief Whether origin was given. */ 75 unsigned int appid_given ; /**< @brief Whether appid was given. */ 76 unsigned int type_given ; /**< @brief Whether type was given. */ 77 unsigned int resident_given ; /**< @brief Whether resident was given. */ 78 unsigned int no_user_presence_given ; /**< @brief Whether no-user-presence was given. */ 79 unsigned int pin_verification_given ; /**< @brief Whether pin-verification was given. */ 80 unsigned int user_verification_given ; /**< @brief Whether user-verification was given. */ 81 unsigned int debug_given ; /**< @brief Whether debug was given. */ 82 unsigned int verbose_given ; /**< @brief Whether verbose was given. */ 83 unsigned int username_given ; /**< @brief Whether username was given. */ 84 unsigned int nouser_given ; /**< @brief Whether nouser was given. */ 85 86 int user_group_counter; /**< @brief Counter for group user */ 87 } ; 88 89 /** @brief The additional parameters to pass to parser functions */ 90 struct cmdline_parser_params 91 { 92 int override; /**< @brief whether to override possibly already present options (default 0) */ 93 int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */ 94 int check_required; /**< @brief whether to check that all required options were provided (default 1) */ 95 int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */ 96 int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */ 97 } ; 98 99 /** @brief the purpose string of the program */ 100 extern const char *gengetopt_args_info_purpose; 101 /** @brief the usage string of the program */ 102 extern const char *gengetopt_args_info_usage; 103 /** @brief the description string of the program */ 104 extern const char *gengetopt_args_info_description; 105 /** @brief all the lines making the help output */ 106 extern const char *gengetopt_args_info_help[]; 107 108 /** 109 * The command line parser 110 * @param argc the number of command line options 111 * @param argv the command line options 112 * @param args_info the structure where option information will be stored 113 * @return 0 if everything went fine, NON 0 if an error took place 114 */ 115 int cmdline_parser (int argc, char **argv, 116 struct gengetopt_args_info *args_info); 117 118 /** 119 * The command line parser (version with additional parameters - deprecated) 120 * @param argc the number of command line options 121 * @param argv the command line options 122 * @param args_info the structure where option information will be stored 123 * @param override whether to override possibly already present options 124 * @param initialize whether to initialize the option structure my_args_info 125 * @param check_required whether to check that all required options were provided 126 * @return 0 if everything went fine, NON 0 if an error took place 127 * @deprecated use cmdline_parser_ext() instead 128 */ 129 int cmdline_parser2 (int argc, char **argv, 130 struct gengetopt_args_info *args_info, 131 int override, int initialize, int check_required); 132 133 /** 134 * The command line parser (version with additional parameters) 135 * @param argc the number of command line options 136 * @param argv the command line options 137 * @param args_info the structure where option information will be stored 138 * @param params additional parameters for the parser 139 * @return 0 if everything went fine, NON 0 if an error took place 140 */ 141 int cmdline_parser_ext (int argc, char **argv, 142 struct gengetopt_args_info *args_info, 143 struct cmdline_parser_params *params); 144 145 /** 146 * Save the contents of the option struct into an already open FILE stream. 147 * @param outfile the stream where to dump options 148 * @param args_info the option struct to dump 149 * @return 0 if everything went fine, NON 0 if an error took place 150 */ 151 int cmdline_parser_dump(FILE *outfile, 152 struct gengetopt_args_info *args_info); 153 154 /** 155 * Save the contents of the option struct into a (text) file. 156 * This file can be read by the config file parser (if generated by gengetopt) 157 * @param filename the file where to save 158 * @param args_info the option struct to save 159 * @return 0 if everything went fine, NON 0 if an error took place 160 */ 161 int cmdline_parser_file_save(const char *filename, 162 struct gengetopt_args_info *args_info); 163 164 /** 165 * Print the help 166 */ 167 void cmdline_parser_print_help(void); 168 /** 169 * Print the version 170 */ 171 void cmdline_parser_print_version(void); 172 173 /** 174 * Initializes all the fields a cmdline_parser_params structure 175 * to their default values 176 * @param params the structure to initialize 177 */ 178 void cmdline_parser_params_init(struct cmdline_parser_params *params); 179 180 /** 181 * Allocates dynamically a cmdline_parser_params structure and initializes 182 * all its fields to their default values 183 * @return the created and initialized cmdline_parser_params structure 184 */ 185 struct cmdline_parser_params *cmdline_parser_params_create(void); 186 187 /** 188 * Initializes the passed gengetopt_args_info structure's fields 189 * (also set default values for options that have a default) 190 * @param args_info the structure to initialize 191 */ 192 void cmdline_parser_init (struct gengetopt_args_info *args_info); 193 /** 194 * Deallocates the string fields of the gengetopt_args_info structure 195 * (but does not deallocate the structure itself) 196 * @param args_info the structure to deallocate 197 */ 198 void cmdline_parser_free (struct gengetopt_args_info *args_info); 199 200 /** 201 * Checks that all the required options were specified 202 * @param args_info the structure to check 203 * @param prog_name the name of the program that will be used to print 204 * possible errors 205 * @return 206 */ 207 int cmdline_parser_required (struct gengetopt_args_info *args_info, 208 const char *prog_name); 209 210 211 #ifdef __cplusplus 212 } 213 #endif /* __cplusplus */ 214 #endif /* CMDLINE_H */ 215