00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _my_getopt_h
00018 #define _my_getopt_h
00019
00020 C_MODE_START
00021
00022 #define GET_NO_ARG 1
00023 #define GET_BOOL 2
00024 #define GET_INT 3
00025 #define GET_UINT 4
00026 #define GET_LONG 5
00027 #define GET_ULONG 6
00028 #define GET_LL 7
00029 #define GET_ULL 8
00030 #define GET_STR 9
00031 #define GET_STR_ALLOC 10
00032 #define GET_DISABLED 11
00033
00034 #define GET_ASK_ADDR 128
00035 #define GET_TYPE_MASK 127
00036
00037 enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
00038
00039 struct my_option
00040 {
00041 const char *name;
00042 int id;
00043 const char *comment;
00044 gptr *value;
00045 gptr *u_max_value;
00046 const char **str_values;
00047 ulong var_type;
00048 enum get_opt_arg_type arg_type;
00049 longlong def_value;
00050 longlong min_value;
00051 longlong max_value;
00052 longlong sub_size;
00053 long block_size;
00054 int app_type;
00055 };
00056
00057 typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
00058 typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
00059
00060 extern char *disabled_my_option;
00061 extern my_bool my_getopt_print_errors;
00062 extern my_error_reporter my_getopt_error_reporter;
00063
00064 extern int handle_options (int *argc, char ***argv,
00065 const struct my_option *longopts, my_get_one_option);
00066 extern void my_print_help(const struct my_option *options);
00067 extern void my_print_variables(const struct my_option *options);
00068 extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
00069 const struct my_option *));
00070
00071 ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
00072 my_bool getopt_compare_strings(const char *s, const char *t, uint length);
00073
00074 C_MODE_END
00075
00076 #endif
00077