PK!b³Õ Õ client_plugin.hnu„[µü¤#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED /* Copyright (c) 2010, 2024, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have either included with the program or referenced in the documentation. Without limiting anything contained in the foregoing, this file, which is part of C Driver for MySQL (Connector/C), is also subject to the Universal FOSS Exception, version 1.0, a copy of which can be found at http://oss.oracle.com/licenses/universal-foss-exception. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file include/mysql/client_plugin.h MySQL Client Plugin API. This file defines the API for plugins that work on the client side */ #define MYSQL_CLIENT_PLUGIN_INCLUDED #ifndef MYSQL_ABI_CHECK #include #include #endif /* On Windows, exports from DLL need to be declared. Also, plugin needs to be declared as extern "C" because MSVC unlike other compilers, uses C++ mangling for variables not only for functions. */ #if defined(_MSC_VER) #if defined(MYSQL_DYNAMIC_CLIENT_PLUGIN) #ifdef __cplusplus #define MYSQL_CLIENT_PLUGIN_EXPORT extern "C" __declspec(dllexport) #else #define MYSQL_CLIENT_PLUGIN_EXPORT __declspec(dllexport) #endif #else /* MYSQL_DYNAMIC_CLIENT_PLUGIN */ #ifdef __cplusplus #define MYSQL_CLIENT_PLUGIN_EXPORT extern "C" #else #define MYSQL_CLIENT_PLUGIN_EXPORT #endif #endif /*MYSQL_DYNAMIC_CLIENT_PLUGIN */ #else /*_MSC_VER */ #if defined(MYSQL_DYNAMIC_CLIENT_PLUGIN) #define MYSQL_CLIENT_PLUGIN_EXPORT MY_ATTRIBUTE((visibility("default"))) #else #define MYSQL_CLIENT_PLUGIN_EXPORT #endif #endif #ifdef __cplusplus extern "C" { #endif /* known plugin types */ #define MYSQL_CLIENT_reserved1 0 #define MYSQL_CLIENT_reserved2 1 #define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2 #define MYSQL_CLIENT_TRACE_PLUGIN 3 #define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0200 #define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0200 #define MYSQL_CLIENT_MAX_PLUGINS 4 #define MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE "Oracle Corporation" #define mysql_declare_client_plugin(X) \ MYSQL_CLIENT_PLUGIN_EXPORT st_mysql_client_plugin_##X \ _mysql_client_plugin_declaration_ = { \ MYSQL_CLIENT_##X##_PLUGIN, \ MYSQL_CLIENT_##X##_PLUGIN_INTERFACE_VERSION, #define mysql_end_client_plugin } /* generic plugin header structure */ #define MYSQL_CLIENT_PLUGIN_HEADER \ int type; \ unsigned int interface_version; \ const char *name; \ const char *author; \ const char *desc; \ unsigned int version[3]; \ const char *license; \ void *mysql_api; \ int (*init)(char *, size_t, int, va_list); \ int (*deinit)(void); \ int (*options)(const char *option, const void *); \ int (*get_options)(const char *option, void *); struct st_mysql_client_plugin { MYSQL_CLIENT_PLUGIN_HEADER }; struct MYSQL; /******** authentication plugin specific declarations *********/ #include "plugin_auth_common.h" struct auth_plugin_t { MYSQL_CLIENT_PLUGIN_HEADER int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql); enum net_async_status (*authenticate_user_nonblocking)(MYSQL_PLUGIN_VIO *vio, struct MYSQL *mysql, int *result); }; // Needed for the mysql_declare_client_plugin() macro. Do not use elsewhere. typedef struct auth_plugin_t st_mysql_client_plugin_AUTHENTICATION; /******** using plugins ************/ /** loads a plugin and initializes it @param mysql MYSQL structure. @param name a name of the plugin to load @param type type of plugin that should be loaded, -1 to disable type check @param argc number of arguments to pass to the plugin initialization function @param ... arguments for the plugin initialization function @retval a pointer to the loaded plugin, or NULL in case of a failure */ struct st_mysql_client_plugin *mysql_load_plugin(struct MYSQL *mysql, const char *name, int type, int argc, ...); /** loads a plugin and initializes it, taking va_list as an argument This is the same as mysql_load_plugin, but take va_list instead of a list of arguments. @param mysql MYSQL structure. @param name a name of the plugin to load @param type type of plugin that should be loaded, -1 to disable type check @param argc number of arguments to pass to the plugin initialization function @param args arguments for the plugin initialization function @retval a pointer to the loaded plugin, or NULL in case of a failure */ struct st_mysql_client_plugin *mysql_load_plugin_v(struct MYSQL *mysql, const char *name, int type, int argc, va_list args); /** finds an already loaded plugin by name, or loads it, if necessary @param mysql MYSQL structure. @param name a name of the plugin to load @param type type of plugin that should be loaded @retval a pointer to the plugin, or NULL in case of a failure */ struct st_mysql_client_plugin *mysql_client_find_plugin(struct MYSQL *mysql, const char *name, int type); /** adds a plugin structure to the list of loaded plugins This is useful if an application has the necessary functionality (for example, a special load data handler) statically linked into the application binary. It can use this function to register the plugin directly, avoiding the need to factor it out into a shared object. @param mysql MYSQL structure. It is only used for error reporting @param plugin an st_mysql_client_plugin structure to register @retval a pointer to the plugin, or NULL in case of a failure */ struct st_mysql_client_plugin *mysql_client_register_plugin( struct MYSQL *mysql, struct st_mysql_client_plugin *plugin); /** set plugin options Can be used to set extra options and affect behavior for a plugin. This function may be called multiple times to set several options @param plugin an st_mysql_client_plugin structure @param option a string which specifies the option to set @param value value for the option. @retval 0 on success, 1 in case of failure **/ int mysql_plugin_options(struct st_mysql_client_plugin *plugin, const char *option, const void *value); /** get plugin options Can be used to get options from a plugin. This function may be called multiple times to get several options @param plugin an st_mysql_client_plugin structure @param option a string which specifies the option to get @param[out] value value for the option. @retval 0 on success, 1 in case of failure **/ int mysql_plugin_get_option(struct st_mysql_client_plugin *plugin, const char *option, void *value); #ifdef __cplusplus } #endif #endif PK!çùplugin_auth_common.hnu„[µü¤#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED /* Copyright (c) 2010, 2024, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have either included with the program or referenced in the documentation. Without limiting anything contained in the foregoing, this file, which is part of C Driver for MySQL (Connector/C), is also subject to the Universal FOSS Exception, version 1.0, a copy of which can be found at http://oss.oracle.com/licenses/universal-foss-exception. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @file include/mysql/plugin_auth_common.h This file defines constants and data structures that are the same for both client- and server-side authentication plugins. */ #define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED /** the max allowed length for a user name */ #define MYSQL_USERNAME_LENGTH 96 /** return values of the plugin authenticate_user() method. */ /** Authentication failed, plugin internal error. An error occurred in the authentication plugin itself. These errors are reported in table performance_schema.host_cache, column COUNT_AUTH_PLUGIN_ERRORS. */ #define CR_AUTH_PLUGIN_ERROR 3 /** Authentication failed, client server handshake. An error occurred during the client server handshake. These errors are reported in table performance_schema.host_cache, column COUNT_HANDSHAKE_ERRORS. */ #define CR_AUTH_HANDSHAKE 2 /** Authentication failed, user credentials. For example, wrong passwords. These errors are reported in table performance_schema.host_cache, column COUNT_AUTHENTICATION_ERRORS. */ #define CR_AUTH_USER_CREDENTIALS 1 /** Authentication failed. Additionally, all other CR_xxx values (libmysql error code) can be used too. The client plugin may set the error code and the error message directly in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error code was returned, an error message in the MYSQL structure will be overwritten. If CR_ERROR is returned without setting the error in MYSQL, CR_UNKNOWN_ERROR will be user. */ #define CR_ERROR 0 /** Authentication (client part) was successful. It does not mean that the authentication as a whole was successful, usually it only means that the client was able to send the user name and the password to the server. If CR_OK is returned, the libmysql reads the next packet expecting it to be one of OK, ERROR, or CHANGE_PLUGIN packets. */ #define CR_OK -1 /** Authentication was successful. It means that the client has done its part successfully and also that a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN). In this case, libmysql will not read a packet from the server, but it will use the data at mysql->net.read_pos. A plugin may return this value if the number of roundtrips in the authentication protocol is not known in advance, and the client plugin needs to read one packet more to determine if the authentication is finished or not. */ #define CR_OK_HANDSHAKE_COMPLETE -2 /** Authentication was successful with limited operations. It means that the both client and server side plugins decided to allow authentication with very limited operations ALTER USER to do registration. */ #define CR_OK_AUTH_IN_SANDBOX_MODE -3 /** Flag to be passed back to server from authentication plugins via authenticated_as when proxy mapping should be done by the server. */ #define PROXY_FLAG 0 /* We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if not already done) to minimize amount of imported declarations. */ #if defined(_WIN32) && !defined(MYSQL_ABI_CHECK) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #endif struct MYSQL_PLUGIN_VIO_INFO { enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET, MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol; int socket; /**< it's set, if the protocol is SOCKET or TCP */ #if defined(_WIN32) && !defined(MYSQL_ABI_CHECK) HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */ #endif }; /* state of an asynchronous operation */ enum net_async_status { NET_ASYNC_COMPLETE = 0, NET_ASYNC_NOT_READY, NET_ASYNC_ERROR, NET_ASYNC_COMPLETE_NO_MORE_RESULTS }; /** Provides plugin access to communication channel */ typedef struct MYSQL_PLUGIN_VIO { /** Plugin provides a pointer reference and this function sets it to the contents of any incoming packet. Returns the packet length, or -1 if the plugin should terminate. */ int (*read_packet)(struct MYSQL_PLUGIN_VIO *vio, unsigned char **buf); /** Plugin provides a buffer with data and the length and this function sends it as a packet. Returns 0 on success, 1 on failure. */ int (*write_packet)(struct MYSQL_PLUGIN_VIO *vio, const unsigned char *packet, int packet_len); /** Fills in a MYSQL_PLUGIN_VIO_INFO structure, providing the information about the connection. */ void (*info)(struct MYSQL_PLUGIN_VIO *vio, struct MYSQL_PLUGIN_VIO_INFO *info); /** Non blocking version of read_packet. This function points buf to starting position of incoming packet. When this function returns NET_ASYNC_NOT_READY plugin should call this function again until all incoming packets are read. If return code is NET_ASYNC_COMPLETE, plugin can do further processing of read packets. */ enum net_async_status (*read_packet_nonblocking)(struct MYSQL_PLUGIN_VIO *vio, unsigned char **buf, int *result); /** Non blocking version of write_packet. Sends data available in pkt of length pkt_len to server in asynchronous way. */ enum net_async_status (*write_packet_nonblocking)( struct MYSQL_PLUGIN_VIO *vio, const unsigned char *pkt, int pkt_len, int *result); } MYSQL_PLUGIN_VIO; #endif PK!ãÇ¿[##udf_registration_types.hnu„[µü¤/* Copyright (c) 2017, 2024, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have either included with the program or referenced in the documentation. Without limiting anything contained in the foregoing, this file, which is part of C Driver for MySQL (Connector/C), is also subject to the Universal FOSS Exception, version 1.0, a copy of which can be found at http://oss.oracle.com/licenses/universal-foss-exception. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef UDF_REGISTRATION_TYPES_H #define UDF_REGISTRATION_TYPES_H #ifndef MYSQL_ABI_CHECK #include #endif /** Type of the user defined function return slot and arguments */ enum Item_result { INVALID_RESULT = -1, /** not valid for UDFs */ STRING_RESULT = 0, /** char * */ REAL_RESULT, /** double */ INT_RESULT, /** long long */ ROW_RESULT, /** not valid for UDFs */ DECIMAL_RESULT /** char *, to be converted to/from a decimal */ }; typedef struct UDF_ARGS { unsigned int arg_count; /**< Number of arguments */ enum Item_result *arg_type; /**< Pointer to item_results */ char **args; /**< Pointer to argument */ unsigned long *lengths; /**< Length of string arguments */ char *maybe_null; /**< Set to 1 for all maybe_null args */ char **attributes; /**< Pointer to attribute name */ unsigned long *attribute_lengths; /**< Length of attribute arguments */ void *extension; } UDF_ARGS; /** Information about the result of a user defined function @todo add a notion for determinism of the UDF. @sa Item_udf_func::update_used_tables() */ typedef struct UDF_INIT { bool maybe_null; /** 1 if function can return NULL */ unsigned int decimals; /** for real functions */ unsigned long max_length; /** For string functions */ char *ptr; /** free pointer for function data */ bool const_item; /** 1 if function always returns the same value */ void *extension; } UDF_INIT; enum Item_udftype { UDFTYPE_FUNCTION = 1, UDFTYPE_AGGREGATE }; typedef void (*Udf_func_clear)(UDF_INIT *, unsigned char *, unsigned char *); typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *); typedef void (*Udf_func_deinit)(UDF_INIT *); typedef bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *); typedef void (*Udf_func_any)(void); typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *); typedef long long (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, unsigned char *, unsigned char *); typedef char *(*Udf_func_string)(UDF_INIT *, UDF_ARGS *, char *, unsigned long *, unsigned char *, unsigned char *); #endif /* UDF_REGISTRATION_TYPES_H */ PK!b³Õ Õ client_plugin.hnu„[µü¤PK!çù!plugin_auth_common.hnu„[µü¤PK!ãÇ¿[##]<udf_registration_types.hnu„[µü¤PKûÈK