Drizzled Public API Documentation

option.h
00001 /* Copyright (C) 2002-2004 MySQL 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; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 #pragma once
00017 
00018 namespace drizzled
00019 {
00020 
00021 #define GET_NO_ARG     1
00022 #define GET_BOOL       2
00023 #define GET_INT        3
00024 #define GET_UINT       4
00025 #define GET_LONG       5
00026 #define GET_UINT32     6
00027 #define GET_LL         7
00028 #define GET_ULL        8
00029 #define GET_STR        9
00030 #define GET_STR_ALLOC 10
00031 #define GET_DISABLED  11
00032 #define GET_ENUM      12
00033 #define GET_SET       13
00034 #define GET_DOUBLE    14
00035 #define GET_SIZE      15
00036 #define GET_UINT64    16
00037 #define GET_ULONG_IS_FAIL 17
00038 
00039 #define GET_ASK_ADDR   128
00040 #define GET_TYPE_MASK  127
00041 
00042 enum loglevel {
00043    ERROR_LEVEL,
00044    WARNING_LEVEL,
00045    INFORMATION_LEVEL
00046 };
00047 
00048 enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
00049 
00050 struct st_typelib;
00051 
00052 struct option
00053 {
00054   const char *name;                     /* Name of the option */
00055   int        id;                        /* unique id or short option */
00056   const char *comment;                  /* option comment, for autom. --help */
00057   char      **value;                   /* The variable value */
00058   char      **u_max_value;             /* The user def. max variable value */
00059   struct st_typelib *typelib;           /* Pointer to possible values */
00060   uint32_t     var_type;
00061   enum get_opt_arg_type arg_type;
00062   int64_t   def_value;                 /* Default value */
00063   int64_t   min_value;                 /* Min allowed value */
00064   int64_t   max_value;                 /* Max allowed value */
00065   int64_t   sub_size;                  /* Subtract this from given value */
00066   long       block_size;                /* Value should be a mult. of this */
00067   void       *app_type;                 /* To be used by an application */
00068 };
00069 
00070 
00071 typedef int (* my_get_one_option) (int, const struct option *, char * );
00072 typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
00073 typedef char ** (*getopt_get_addr_func)(const char *, uint32_t, const struct option *);
00074 
00075 extern char *disabled_my_option;
00076 extern bool my_getopt_skip_unknown;
00077 extern my_error_reporter my_getopt_error_reporter;
00078 
00079 extern int handle_options (int *argc, char ***argv,
00080          const struct option *longopts, my_get_one_option);
00081 extern void my_cleanup_options(const struct option *options);
00082 extern void my_print_help(const struct option *options);
00083 extern void my_print_variables(const struct option *options);
00084 
00085 uint64_t getopt_ull_limit_value(uint64_t num, const struct option *optp,
00086                                  bool *fix);
00087 int64_t getopt_ll_limit_value(int64_t, const struct option *,
00088                                bool *fix);
00089 bool getopt_compare_strings(const char *s, const char *t, uint32_t length);
00090 
00091 } /* namespace drizzled */
00092 
00093