MySQL  8.0.18
Source Code Documentation
client_plugin.h
Go to the documentation of this file.
1 #ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
2 /* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License, version 2.0,
6  as published by the Free Software Foundation.
7 
8  This program is also distributed with certain software (including
9  but not limited to OpenSSL) that is licensed under separate terms,
10  as designated in a particular file or component or in included license
11  documentation. The authors of MySQL hereby grant you an additional
12  permission to link the program and your derivative works with the
13  separately licensed software that they have included with MySQL.
14 
15  Without limiting anything contained in the foregoing, this file,
16  which is part of C Driver for MySQL (Connector/C), is also subject to the
17  Universal FOSS Exception, version 1.0, a copy of which can be found at
18  http://oss.oracle.com/licenses/universal-foss-exception.
19 
20  This program is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License, version 2.0, for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with this program; if not, write to the Free Software
27  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
28 
29 /**
30  @file include/mysql/client_plugin.h
31  MySQL Client Plugin API.
32  This file defines the API for plugins that work on the client side
33 */
34 #define MYSQL_CLIENT_PLUGIN_INCLUDED
35 
36 #ifndef MYSQL_ABI_CHECK
37 #include <stdarg.h>
38 #include <stdlib.h>
39 #endif
40 
41 /*
42  On Windows, exports from DLL need to be declared.
43  Also, plugin needs to be declared as extern "C" because MSVC
44  unlike other compilers, uses C++ mangling for variables not only
45  for functions.
46 */
47 
48 #undef MYSQL_PLUGIN_EXPORT
49 
50 #if defined(_MSC_VER)
51 #if defined(MYSQL_DYNAMIC_PLUGIN)
52 #ifdef __cplusplus
53 #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
54 #else
55 #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
56 #endif
57 #else /* MYSQL_DYNAMIC_PLUGIN */
58 #ifdef __cplusplus
59 #define MYSQL_PLUGIN_EXPORT extern "C"
60 #else
61 #define MYSQL_PLUGIN_EXPORT
62 #endif
63 #endif /*MYSQL_DYNAMIC_PLUGIN */
64 #else /*_MSC_VER */
65 #define MYSQL_PLUGIN_EXPORT
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 /* known plugin types */
73 #define MYSQL_CLIENT_reserved1 0
74 #define MYSQL_CLIENT_reserved2 1
75 #define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
76 #define MYSQL_CLIENT_TRACE_PLUGIN 3
77 
78 #define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0101
79 #define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100
80 
81 #define MYSQL_CLIENT_MAX_PLUGINS 4
82 
83 #define mysql_declare_client_plugin(X) \
84  MYSQL_PLUGIN_EXPORT st_mysql_client_plugin_##X \
85  _mysql_client_plugin_declaration_ = { \
86  MYSQL_CLIENT_##X##_PLUGIN, \
87  MYSQL_CLIENT_##X##_PLUGIN_INTERFACE_VERSION,
88 #define mysql_end_client_plugin }
89 
90 /* generic plugin header structure */
91 #define MYSQL_CLIENT_PLUGIN_HEADER \
92  int type; \
93  unsigned int interface_version; \
94  const char *name; \
95  const char *author; \
96  const char *desc; \
97  unsigned int version[3]; \
98  const char *license; \
99  void *mysql_api; \
100  int (*init)(char *, size_t, int, va_list); \
101  int (*deinit)(void); \
102  int (*options)(const char *option, const void *);
103 
106 };
107 
108 struct MYSQL;
109 
110 /******** authentication plugin specific declarations *********/
111 #include "plugin_auth_common.h"
112 
117  struct MYSQL *mysql,
118  int *result);
119 };
120 
121 // Needed for the mysql_declare_client_plugin() macro. Do not use elsewhere.
123 
124 /******** using plugins ************/
125 
126 /**
127  loads a plugin and initializes it
128 
129  @param mysql MYSQL structure.
130  @param name a name of the plugin to load
131  @param type type of plugin that should be loaded, -1 to disable type check
132  @param argc number of arguments to pass to the plugin initialization
133  function
134  @param ... arguments for the plugin initialization function
135 
136  @retval
137  a pointer to the loaded plugin, or NULL in case of a failure
138 */
140  const char *name, int type,
141  int argc, ...);
142 
143 /**
144  loads a plugin and initializes it, taking va_list as an argument
145 
146  This is the same as mysql_load_plugin, but take va_list instead of
147  a list of arguments.
148 
149  @param mysql MYSQL structure.
150  @param name a name of the plugin to load
151  @param type type of plugin that should be loaded, -1 to disable type check
152  @param argc number of arguments to pass to the plugin initialization
153  function
154  @param args arguments for the plugin initialization function
155 
156  @retval
157  a pointer to the loaded plugin, or NULL in case of a failure
158 */
160  const char *name, int type,
161  int argc, va_list args);
162 
163 /**
164  finds an already loaded plugin by name, or loads it, if necessary
165 
166  @param mysql MYSQL structure.
167  @param name a name of the plugin to load
168  @param type type of plugin that should be loaded
169 
170  @retval
171  a pointer to the plugin, or NULL in case of a failure
172 */
174  const char *name,
175  int type);
176 
177 /**
178  adds a plugin structure to the list of loaded plugins
179 
180  This is useful if an application has the necessary functionality
181  (for example, a special load data handler) statically linked into
182  the application binary. It can use this function to register the plugin
183  directly, avoiding the need to factor it out into a shared object.
184 
185  @param mysql MYSQL structure. It is only used for error reporting
186  @param plugin an st_mysql_client_plugin structure to register
187 
188  @retval
189  a pointer to the plugin, or NULL in case of a failure
190 */
192  struct MYSQL *mysql, struct st_mysql_client_plugin *plugin);
193 
194 /**
195  set plugin options
196 
197  Can be used to set extra options and affect behavior for a plugin.
198  This function may be called multiple times to set several options
199 
200  @param plugin an st_mysql_client_plugin structure
201  @param option a string which specifies the option to set
202  @param value value for the option.
203 
204  @retval 0 on success, 1 in case of failure
205 **/
207  const char *option, const void *value);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif
struct st_mysql_client_plugin * mysql_client_register_plugin(struct MYSQL *mysql, struct st_mysql_client_plugin *plugin)
adds a plugin structure to the list of loaded plugins
Definition: client_plugin.cc:377
get_options & argc
Definition: do_ctype.cc:51
const string name("\ame\)
struct result result
Definition: result.h:37
struct st_mysql_client_plugin * mysql_load_plugin(struct MYSQL *mysql, const char *name, int type, int argc,...)
loads a plugin and initializes it
Definition: client_plugin.cc:503
static struct st_mysql_daemon plugin
Definition: test_services_host_application_signal.cc:130
net_async_status
Definition: plugin_auth_common.h:130
Definition: client_plugin.h:104
int mysql_plugin_options(struct st_mysql_client_plugin *plugin, const char *option, const void *value)
set plugin options
Definition: client_plugin.cc:541
structure to define some default "config_option" option settings
Definition: innodb_config.h:180
enum net_async_status(* authenticate_user_nonblocking)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql, int *result)
Definition: client_plugin.h:116
This file defines constants and data structures that are the same for both client- and server-side au...
int type
Definition: http_common.h:411
Definition: client_plugin.h:113
static MYSQL mysql
Definition: mysql.cc:152
struct st_mysql_client_plugin * mysql_client_find_plugin(struct MYSQL *mysql, const char *name, int type)
finds an already loaded plugin by name, or loads it, if necessary
Definition: client_plugin.cc:514
const string value("\alue\)
Provides plugin access to communication channel.
Definition: plugin_auth_common.h:140
Definition: mysql.h:295
struct st_mysql_client_plugin * mysql_load_plugin_v(struct MYSQL *mysql, const char *name, int type, int argc, va_list args)
loads a plugin and initializes it, taking va_list as an argument
Definition: client_plugin.cc:398
#define MYSQL_CLIENT_PLUGIN_HEADER
Definition: client_plugin.h:91
MYSQL_CLIENT_PLUGIN_HEADER int(* authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql)
Definition: client_plugin.h:115