1 /* 2 * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 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 * 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 23 * 02110-1301 USA 24 */ 25 26 #ifndef _MYSQLX_H_ 27 #define _MYSQLX_H_ 28 29 typedef char my_bool; 30 #if !defined(_WIN32) 31 #define STDCALL 32 #else 33 #define STDCALL __stdcall 34 #endif 35 36 #if defined (_WIN32) 37 typedef unsigned __int64 my_ulonglong; 38 #else 39 typedef unsigned long long my_ulonglong; 40 #endif 41 42 43 typedef struct st_mysql_field { 44 char *name; /* Name of column */ 45 char *org_name; /* Original column name, if an alias */ 46 char *table; /* Table of column if column was a field */ 47 char *org_table; /* Org table name, if table was an alias */ 48 char *db; /* Database for table */ 49 char *catalog; /* Catalog for table */ 50 char *def; /* Default value (set by mysql_list_fields) */ 51 unsigned long length; /* Width of column (create length) */ 52 unsigned long max_length; /* Max width for selected set */ 53 unsigned int name_length; 54 unsigned int org_name_length; 55 unsigned int table_length; 56 unsigned int org_table_length; 57 unsigned int db_length; 58 unsigned int catalog_length; 59 unsigned int def_length; 60 unsigned int flags; /* Div flags */ 61 unsigned int decimals; /* Number of decimals in field */ 62 unsigned int charsetnr; /* Character set */ 63 enum enum_field_types type; /* Type of field. See mysql_com.h for types */ 64 void *extension; 65 } MYSQL_FIELD; 66 67 typedef char **MYSQL_ROW; /* return data as array of strings */ 68 typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ 69 70 71 enum mysql_option 72 { 73 MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, 74 MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, 75 MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE, 76 MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT, 77 MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT, 78 MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 79 MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH, 80 MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT, 81 MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH, 82 MYSQL_OPT_BIND, 83 MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT, 84 MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER, 85 MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH, 86 MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD, 87 MYSQL_OPT_CONNECT_ATTR_DELETE, 88 MYSQL_SERVER_PUBLIC_KEY, 89 MYSQL_ENABLE_CLEARTEXT_PLUGIN, 90 MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 91 MYSQL_OPT_SSL_ENFORCE 92 }; 93 94 95 96 97 typedef struct st_mysql_res { 98 my_ulonglong row_count; 99 MYSQL_FIELD *fields; 100 // MYSQL_DATA *data; 101 MYSQL_ROWS *data_cursor; 102 unsigned long *lengths; 103 MYSQL *handle; 104 MYSQL_ROW row; 105 MYSQL_ROW current_row; 106 unsigned int field_count, current_field; 107 my_bool eof; 108 my_bool unbuffered_fetch_cancelled; 109 } MYSQL_RES; 110 111 112 113 114 115 116 unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); 117 my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res); 118 unsigned int STDCALL mysql_num_fields(MYSQL_RES *res); 119 my_bool STDCALL mysql_eof(MYSQL_RES *res); 120 MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res, 121 unsigned int fieldnr); 122 MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res); 123 MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res); 124 MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res); 125 126 unsigned int STDCALL mysql_field_count(MYSQL *mysql); 127 my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql); 128 my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql); 129 unsigned int STDCALL mysql_errno(MYSQL *mysql); 130 const char * STDCALL mysql_error(MYSQL *mysql); 131 132 const char *STDCALL mysql_sqlstate(MYSQL *mysql); 133 unsigned int STDCALL mysql_warning_count(MYSQL *mysql); 134 const char * STDCALL mysql_info(MYSQL *mysql); 135 unsigned long STDCALL mysql_thread_id(MYSQL *mysql); 136 137 const char * STDCALL mysql_character_set_name(MYSQL *mysql); 138 int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname); 139 140 141 142 MYSQL * STDCALL mysql_init(MYSQL *mysql); 143 my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, 144 const char *cert, const char *ca, 145 const char *capath, const char *cipher); 146 const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql); 147 my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, 148 const char *passwd, const char *db); 149 MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, 150 const char *user, 151 const char *passwd, 152 const char *db, 153 unsigned int port, 154 const char *unix_socket, 155 unsigned long clientflag); 156 157 158 int STDCALL mysql_select_db(MYSQL *mysql, const char *db); 159 int STDCALL mysql_query(MYSQL *mysql, const char *q); 160 int STDCALL mysql_send_query(MYSQL *mysql, const char *q, 161 unsigned long length); 162 int STDCALL mysql_real_query(MYSQL *mysql, const char *q, 163 unsigned long length); 164 165 MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql); 166 MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql); 167 168 void STDCALL mysql_get_character_set_info(MYSQL *mysql, 169 MY_CHARSET_INFO *charset); 170 171 172 unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql, 173 char *to,const char *from, 174 unsigned long length); 175 unsigned long STDCALL mysql_real_escape_string_quote(MYSQL *mysql, 176 char *to, const char *from, 177 unsigned long length, char quote); 178 179 180 #endif 181