1 /* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software Foundation,
21    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
22 
23 /* support for Services */
24 #include <service_versions.h>
25 
26 struct st_service_ref {
27   const char *name;
28   uint version;
29   void *service;
30 };
31 
32 static struct my_snprintf_service_st my_snprintf_handler = {
33   my_snprintf,
34   my_vsnprintf
35 };
36 
37 static struct thd_alloc_service_st thd_alloc_handler= {
38   thd_alloc,
39   thd_calloc,
40   thd_strdup,
41   thd_strmake,
42   thd_memdup,
43   thd_make_lex_string
44 };
45 
46 static struct thd_wait_service_st thd_wait_handler= {
47   thd_wait_begin,
48   thd_wait_end
49 };
50 
51 static struct my_thread_scheduler_service my_thread_scheduler_handler= {
52   my_thread_scheduler_set,
53   my_thread_scheduler_reset,
54 };
55 
56 static struct my_plugin_log_service my_plugin_log_handler= {
57   my_plugin_log_message
58 };
59 
60 static struct mysql_string_service_st mysql_string_handler= {
61   mysql_string_convert_to_char_ptr,
62   mysql_string_get_iterator,
63   mysql_string_iterator_next,
64   mysql_string_iterator_isupper,
65   mysql_string_iterator_islower,
66   mysql_string_iterator_isdigit,
67   mysql_string_to_lowercase,
68   mysql_string_free,
69   mysql_string_iterator_free,
70 };
71 
72 static struct st_service_ref list_of_services[]=
73 {
74   { "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
75   { "thd_alloc_service",   VERSION_thd_alloc,   &thd_alloc_handler },
76   { "thd_wait_service",    VERSION_thd_wait,    &thd_wait_handler },
77   { "my_thread_scheduler_service",
78     VERSION_my_thread_scheduler, &my_thread_scheduler_handler },
79   { "my_plugin_log_service", VERSION_my_plugin_log, &my_plugin_log_handler },
80   { "mysql_string_service",
81     VERSION_mysql_string, &mysql_string_handler },
82 };
83 
84