| 1 |
/* Copyright (c) 2021, 2026, Oracle and/or its affiliates. |
| 2 |
|
| 3 |
This program is free software; you can redistribute it and/or modify |
| 4 |
it under the terms of the GNU General Public License, version 2.0, |
| 5 |
as published by the Free Software Foundation. |
| 6 |
|
| 7 |
This program is designed to work with certain software (including |
| 8 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 9 |
as designated in a particular file or component or in included license |
| 10 |
documentation. The authors of MySQL hereby grant you an additional |
| 11 |
permission to link the program and your derivative works with the |
| 12 |
separately licensed software that they have either included with |
| 13 |
the program or referenced in the documentation. |
| 14 |
|
| 15 |
This program is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
GNU General Public License, version 2.0, for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU General Public License |
| 21 |
along with this program; if not, write to the Free Software |
| 22 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 23 |
|
| 24 |
#ifndef KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED |
| 25 |
#define KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED |
| 26 |
|
| 27 |
#include <mysql/components/component_implementation.h> |
| 28 |
#include <mysql/components/service_implementation.h> |
| 29 |
|
| 30 |
#include <mysql/components/services/log_builtins.h> |
| 31 |
|
| 32 |
namespace keyring_common { |
| 33 |
namespace service_definition { |
| 34 |
|
| 35 |
class Log_builtins_keyring { |
| 36 |
public: |
| 37 |
/* ================ DUMMY ================ */ |
| 38 |
/* log_builtins */ |
| 39 |
static DEFINE_METHOD(int, wellknown_by_type, (log_item_type)) { |
| 40 |
return LOG_ITEM_TYPE_NOT_FOUND; |
| 41 |
} |
| 42 |
static DEFINE_METHOD(int, wellknown_by_name, (const char *, size_t)) { |
| 43 |
return LOG_ITEM_TYPE_NOT_FOUND; |
| 44 |
} |
| 45 |
static DEFINE_METHOD(log_item_type, wellknown_get_type, (uint)) { |
| 46 |
return LOG_ITEM_END; |
| 47 |
} |
| 48 |
static DEFINE_METHOD(const char *, wellknown_get_name, (uint)) { |
| 49 |
return "--ERROR--"; |
| 50 |
} |
| 51 |
static DEFINE_METHOD(int, item_inconsistent, (log_item *)) { return -2; } |
| 52 |
static DEFINE_METHOD(bool, item_generic_type, (log_item_type)) { |
| 53 |
return true; |
| 54 |
} |
| 55 |
static DEFINE_METHOD(bool, item_string_class, (log_item_class)) { |
| 56 |
return false; |
| 57 |
} |
| 58 |
static DEFINE_METHOD(bool, item_numeric_class, (log_item_class)) { |
| 59 |
return false; |
| 60 |
} |
| 61 |
|
| 62 |
static DEFINE_METHOD(log_item_data *, item_set_with_key, |
| 63 |
(log_item *, log_item_type, const char *, uint32)) { |
| 64 |
return nullptr; |
| 65 |
} |
| 66 |
static DEFINE_METHOD(log_item_data *, item_set, (log_item *, log_item_type)) { |
| 67 |
return nullptr; |
| 68 |
} |
| 69 |
static DEFINE_METHOD(bool, item_set_float, (log_item_data *, double)) { |
| 70 |
return false; |
| 71 |
} |
| 72 |
|
| 73 |
static DEFINE_METHOD(int, line_item_count, (log_line *)) { return 0; } |
| 74 |
static DEFINE_METHOD(log_item *, line_get_output_buffer, (log_line *)) { |
| 75 |
return nullptr; |
| 76 |
} |
| 77 |
static DEFINE_METHOD(log_item_iter *, line_item_iter_acquire, (log_line *)) { |
| 78 |
return nullptr; |
| 79 |
} |
| 80 |
static DEFINE_METHOD(void, line_item_iter_release, (log_item_iter *)) { |
| 81 |
return; |
| 82 |
} |
| 83 |
static DEFINE_METHOD(log_item *, line_item_iter_first, (log_item_iter *)) { |
| 84 |
return nullptr; |
| 85 |
} |
| 86 |
static DEFINE_METHOD(log_item *, line_item_iter_next, (log_item_iter *)) { |
| 87 |
return nullptr; |
| 88 |
} |
| 89 |
static DEFINE_METHOD(log_item *, line_item_iter_current, (log_item_iter *)) { |
| 90 |
return nullptr; |
| 91 |
} |
| 92 |
static DEFINE_METHOD(int, sanitize, (log_item *)) { return -1; } |
| 93 |
static DEFINE_METHOD(ulonglong, parse_iso8601_timestamp, |
| 94 |
(const char *, size_t)) { |
| 95 |
return 0; |
| 96 |
} |
| 97 |
static DEFINE_METHOD(const char *, label_from_prio, (int)) { return "Error"; } |
| 98 |
static DEFINE_METHOD(log_service_error, open_errstream, |
| 99 |
(const char *, void **)) { |
| 100 |
return LOG_SERVICE_COULD_NOT_MAKE_LOG_NAME; |
| 101 |
} |
| 102 |
static DEFINE_METHOD(log_service_error, write_errstream, |
| 103 |
(void *, const char *, size_t)) { |
| 104 |
return LOG_SERVICE_NOTHING_DONE; |
| 105 |
} |
| 106 |
static DEFINE_METHOD(int, dedicated_errstream, (void *)) { return -1; } |
| 107 |
static DEFINE_METHOD(log_service_error, close_errstream, (void **)) { |
| 108 |
return LOG_SERVICE_NOTHING_DONE; |
| 109 |
} |
| 110 |
static DEFINE_METHOD(log_service_error, reopen_errstream, |
| 111 |
(const char *, void **)) { |
| 112 |
return LOG_SERVICE_NOTHING_DONE; |
| 113 |
} |
| 114 |
static DEFINE_METHOD(int, message, (int, ...)) { return 0; } |
| 115 |
|
| 116 |
/* log_builtins_string */ |
| 117 |
static DEFINE_METHOD(char *, find_first, (const char *, int)) { |
| 118 |
return nullptr; |
| 119 |
} |
| 120 |
static DEFINE_METHOD(char *, find_last, (const char *, int)) { |
| 121 |
return nullptr; |
| 122 |
} |
| 123 |
static DEFINE_METHOD(int, compare, |
| 124 |
(const char *, const char *, size_t, bool)) { |
| 125 |
return 0; |
| 126 |
} |
| 127 |
static DEFINE_METHOD(size_t, substitute, |
| 128 |
(char *, size_t, const char *, ...)) { |
| 129 |
return -1; |
| 130 |
} |
| 131 |
static DEFINE_METHOD(longlong, errcode_by_errsymbol, (const char *)) { |
| 132 |
return 0; |
| 133 |
} |
| 134 |
|
| 135 |
/* ================ REQUIRED ================ */ |
| 136 |
/* log_builtins */ |
| 137 |
static DEFINE_METHOD(log_item_data *, line_item_set_with_key, |
| 138 |
(log_line * ll, log_item_type t, const char *key, |
| 139 |
uint32 alloc)); |
| 140 |
static DEFINE_METHOD(log_item_data *, line_item_set, |
| 141 |
(log_line * ll, log_item_type t)); |
| 142 |
static DEFINE_METHOD(log_line *, line_init, ()); |
| 143 |
static DEFINE_METHOD(void, line_exit, (log_line * ll)); |
| 144 |
static DEFINE_METHOD(log_item_type_mask, line_item_types_seen, |
| 145 |
(log_line * ll, log_item_type_mask m)); |
| 146 |
static DEFINE_METHOD(bool, item_set_int, (log_item_data * lid, longlong i)); |
| 147 |
static DEFINE_METHOD(bool, item_set_lexstring, |
| 148 |
(log_item_data * lid, const char *s, size_t s_len)); |
| 149 |
static DEFINE_METHOD(bool, item_set_cstring, |
| 150 |
(log_item_data * lid, const char *s)); |
| 151 |
static DEFINE_METHOD(int, line_submit, (log_line * ll)); |
| 152 |
static DEFINE_METHOD(const char *, errmsg_by_errcode, (int mysql_errcode)); |
| 153 |
|
| 154 |
/* log_builtins_string */ |
| 155 |
static DEFINE_METHOD(void *, malloc, (size_t len)); |
| 156 |
static DEFINE_METHOD(char *, strndup, (const char *fm, size_t len)); |
| 157 |
static DEFINE_METHOD(void, free, (void *ptr)); |
| 158 |
static DEFINE_METHOD(size_t, length, (const char *s)); |
| 159 |
static DEFINE_METHOD(size_t, substitutev, |
| 160 |
(char *to, size_t n, const char *fmt, va_list ap)) |
| 161 |
MY_ATTRIBUTE((format(printf, 3, 0))); |
| 162 |
}; |
| 163 |
|
| 164 |
} // namespace service_definition |
| 165 |
} // namespace keyring_common |
| 166 |
|
| 167 |
#define KEYRING_LOG_BUILTINS_IMPLEMENTOR(component_name) \ |
| 168 |
BEGIN_SERVICE_IMPLEMENTATION(component_name, log_builtins) \ |
| 169 |
keyring_common::service_definition::Log_builtins_keyring::wellknown_by_type, \ |
| 170 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 171 |
wellknown_by_name, \ |
| 172 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 173 |
wellknown_get_type, \ |
| 174 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 175 |
wellknown_get_name, \ |
| 176 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 177 |
item_inconsistent, \ |
| 178 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 179 |
item_generic_type, \ |
| 180 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 181 |
item_string_class, \ |
| 182 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 183 |
item_numeric_class, \ |
| 184 |
keyring_common::service_definition::Log_builtins_keyring::item_set_int, \ |
| 185 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 186 |
item_set_float, \ |
| 187 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 188 |
item_set_lexstring, \ |
| 189 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 190 |
item_set_cstring, \ |
| 191 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 192 |
item_set_with_key, \ |
| 193 |
keyring_common::service_definition::Log_builtins_keyring::item_set, \ |
| 194 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 195 |
line_item_set_with_key, \ |
| 196 |
keyring_common::service_definition::Log_builtins_keyring::line_item_set, \ |
| 197 |
keyring_common::service_definition::Log_builtins_keyring::line_init, \ |
| 198 |
keyring_common::service_definition::Log_builtins_keyring::line_exit, \ |
| 199 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 200 |
line_item_count, \ |
| 201 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 202 |
line_item_types_seen, \ |
| 203 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 204 |
line_get_output_buffer, \ |
| 205 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 206 |
line_item_iter_acquire, \ |
| 207 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 208 |
line_item_iter_release, \ |
| 209 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 210 |
line_item_iter_first, \ |
| 211 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 212 |
line_item_iter_next, \ |
| 213 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 214 |
line_item_iter_current, \ |
| 215 |
keyring_common::service_definition::Log_builtins_keyring::line_submit, \ |
| 216 |
keyring_common::service_definition::Log_builtins_keyring::message, \ |
| 217 |
keyring_common::service_definition::Log_builtins_keyring::sanitize, \ |
| 218 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 219 |
errmsg_by_errcode, \ |
| 220 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 221 |
errcode_by_errsymbol, \ |
| 222 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 223 |
label_from_prio, \ |
| 224 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 225 |
parse_iso8601_timestamp, \ |
| 226 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 227 |
open_errstream, \ |
| 228 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 229 |
write_errstream, \ |
| 230 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 231 |
dedicated_errstream, \ |
| 232 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 233 |
close_errstream, \ |
| 234 |
keyring_common::service_definition::Log_builtins_keyring:: \ |
| 235 |
reopen_errstream \ |
| 236 |
END_SERVICE_IMPLEMENTATION() |
| 237 |
|
| 238 |
#define KEYRING_LOG_BUILTINS_STRING_IMPLEMENTOR(component_name) \ |
| 239 |
BEGIN_SERVICE_IMPLEMENTATION(component_name, log_builtins_string) \ |
| 240 |
keyring_common::service_definition::Log_builtins_keyring::malloc, \ |
| 241 |
keyring_common::service_definition::Log_builtins_keyring::strndup, \ |
| 242 |
keyring_common::service_definition::Log_builtins_keyring::free, \ |
| 243 |
keyring_common::service_definition::Log_builtins_keyring::length, \ |
| 244 |
keyring_common::service_definition::Log_builtins_keyring::find_first, \ |
| 245 |
keyring_common::service_definition::Log_builtins_keyring::find_last, \ |
| 246 |
keyring_common::service_definition::Log_builtins_keyring::compare, \ |
| 247 |
keyring_common::service_definition::Log_builtins_keyring::substitutev, \ |
| 248 |
keyring_common::service_definition::Log_builtins_keyring::substitute \ |
| 249 |
END_SERVICE_IMPLEMENTATION() |
| 250 |
|
| 251 |
#endif /* KEYRING_LOG_BUILTINS_DEFINITION_INCLUDED */ |