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 #include <drizzled/common_fwd.h>
00019 
00020 namespace drizzled {
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_UINT32     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_SIZE      15
00033 #define GET_UINT64    16
00034 #define GET_ULONG_IS_FAIL 17
00035 
00036 #define GET_TYPE_MASK  127
00037 
00038 enum loglevel {
00039    ERROR_LEVEL,
00040    WARNING_LEVEL,
00041    INFORMATION_LEVEL
00042 };
00043 
00044 enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
00045 
00046 struct option
00047 {
00048   const char *name;                     /* Name of the option */
00049   int        id;                        /* unique id or short option */
00050   const char *comment;                  /* option comment, for autom. --help */
00051   char      **value;                   /* The variable value */
00052   void      **u_max_value_unused;             /* The user def. max variable value */
00053   TYPELIB *typelib;           /* Pointer to possible values */
00054   uint32_t     var_type;
00055   get_opt_arg_type arg_type;
00056   int64_t   def_value;                 /* Default value */
00057   int64_t   min_value;                 /* Min allowed value */
00058   int64_t   max_value;                 /* Max allowed value */
00059   int64_t   sub_size;                  /* Subtract this from given value */
00060   int       block_size;                /* Value should be a mult. of this */
00061   void*     app_type_unused;
00062 };
00063 
00064 
00065 typedef int (* my_get_one_option) (int, const struct option *, char * );
00066 typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
00067 typedef char ** (*getopt_get_addr_func)(const char *, uint32_t, const struct option *);
00068 
00069 extern int handle_options (int *argc, char ***argv, const option*, my_get_one_option);
00070 extern void my_cleanup_options(const struct option *options);
00071 extern void my_print_help(const struct option *options);
00072 extern void my_print_variables(const struct option *options);
00073 
00074 uint64_t getopt_ull_limit_value(uint64_t num, const option&, bool* fix);
00075 int64_t getopt_ll_limit_value(int64_t, const option&, bool* fix);
00076 bool getopt_compare_strings(const char *s, const char *t, uint32_t length);
00077 
00078 } /* namespace drizzled */
00079 
00080