Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

my_getopt.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; either version 2 of the License, or
00006    (at your option) any later version.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
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;                     /* Name of the option */
00042   int        id;                        /* unique id or short option */
00043   const char *comment;                  /* option comment, for autom. --help */
00044   gptr       *value;                    /* The variable value */
00045   gptr       *u_max_value;              /* The user def. max variable value */
00046   const char **str_values;              /* Pointer to possible values */
00047   ulong     var_type;
00048   enum get_opt_arg_type arg_type;
00049   longlong   def_value;                 /* Default value */
00050   longlong   min_value;                 /* Min allowed value */
00051   longlong   max_value;                 /* Max allowed value */
00052   longlong   sub_size;                  /* Subtract this from given value */
00053   long       block_size;                /* Value should be a mult. of this */
00054   int        app_type;                  /* To be used by an application */
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 /* _my_getopt_h */
00077 

Generated on Sun May 14 14:51:19 2006 by  doxygen 1.4.2