| 1 | |
| 2 | // vim:sw=2:ai |
| 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2010-2011 DeNA Co.,Ltd.. All rights reserved. |
| 6 | * Copyright (C) 2011 Kentoku SHIBA |
| 7 | * See COPYRIGHT.txt for details. |
| 8 | */ |
| 9 | |
| 10 | #ifndef DENA_CONFIG_HPP |
| 11 | #define DENA_CONFIG_HPP |
| 12 | |
| 13 | #include "mysql_version.h" |
| 14 | #if MYSQL_VERSION_ID < 50500 |
| 15 | #include "mysql_priv.h" |
| 16 | #include <mysql/plugin.h> |
| 17 | #else |
| 18 | #include "sql_priv.h" |
| 19 | #include "probes_mysql.h" |
| 20 | #include "sql_class.h" |
| 21 | #endif |
| 22 | |
| 23 | #define DENA_VERBOSE(lv, x) if (dena::verbose_level >= (lv)) { (x); } |
| 24 | |
| 25 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
| 26 | #define INFO_KIND_HS_RET_FIELDS 1 |
| 27 | #define INFO_KIND_HS_APPEND_STRING_REF 3 |
| 28 | #define INFO_KIND_HS_CLEAR_STRING_REF 4 |
| 29 | #define INFO_KIND_HS_INCREMENT_BEGIN 5 |
| 30 | #define INFO_KIND_HS_INCREMENT_END 6 |
| 31 | #define INFO_KIND_HS_DECREMENT_BEGIN 7 |
| 32 | #define INFO_KIND_HS_DECREMENT_END 8 |
| 33 | #endif |
| 34 | |
| 35 | namespace dena { |
| 36 | |
| 37 | #ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS |
| 38 | struct uint32_info { |
| 39 | size_t info_size; |
| 40 | uint32 *info; |
| 41 | }; |
| 42 | #endif |
| 43 | |
| 44 | struct conf_param { |
| 45 | String key; |
| 46 | String val; |
| 47 | }; |
| 48 | |
| 49 | uchar *conf_get_key( |
| 50 | conf_param *share, |
| 51 | size_t *length, |
| 52 | my_bool not_used __attribute__ ((unused)) |
| 53 | ); |
| 54 | |
| 55 | struct config { |
| 56 | bool init; |
| 57 | HASH conf_hash; |
| 58 | config(); |
| 59 | ~config(); |
| 60 | conf_param *find(const String& key) const; |
| 61 | conf_param *find(const char *key) const; |
| 62 | String get_str(const String& key, const String& def = |
| 63 | String("" , &my_charset_bin)) const; |
| 64 | String get_str(const char *key, const char *def = "" ) const; |
| 65 | long long get_int(const String& key, long long def = 0) const; |
| 66 | long long get_int(const char *key, long long def = 0) const; |
| 67 | bool replace(const char *key, const char *val); |
| 68 | bool replace(const char *key, long long val); |
| 69 | bool compare(const char *key, const char *val); |
| 70 | void list_all_params() const; |
| 71 | config& operator =(const config& x); |
| 72 | }; |
| 73 | |
| 74 | void parse_args(int argc, char **argv, config& conf); |
| 75 | |
| 76 | extern unsigned int verbose_level; |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | #endif |
| 81 | |
| 82 | |