2
Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2
Copyright (C) 2008 MySQL AB, 2008 Sun Microsystems, Inc
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; version 2 of the
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
9
8
This program is distributed in the hope that it will be useful,
10
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
11
GNU General Public License for more details.
14
13
You should have received a copy of the GNU General Public License
15
14
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
160
static int lua_proto_get_masterinfo_string (lua_State *L) {
162
const char *packet_str = luaL_checklstring(L, 1, &packet_len);
163
network_mysqld_masterinfo_t *info;
165
network_packet packet;
169
s.str = (char *)packet_str;
175
info = network_mysqld_masterinfo_new();
177
err = err || network_mysqld_masterinfo_get(&packet, info);
180
network_mysqld_masterinfo_free(info);
181
luaL_error(L, "%s: network_mysqld_masterinfo_get() failed", G_STRLOC);
187
LUA_EXPORT_INT(info, master_lines);
188
LUA_EXPORT_STR(info, master_log_file);
189
LUA_EXPORT_INT(info, master_log_pos);
190
LUA_EXPORT_STR(info, master_host);
191
LUA_EXPORT_STR(info, master_user);
192
LUA_EXPORT_STR(info, master_password);
193
LUA_EXPORT_INT(info, master_port);
194
LUA_EXPORT_INT(info, master_connect_retry);
195
LUA_EXPORT_INT(info, master_ssl);
196
LUA_EXPORT_STR(info, master_ssl_ca);
197
LUA_EXPORT_STR(info, master_ssl_capath);
198
LUA_EXPORT_STR(info, master_ssl_cert);
199
LUA_EXPORT_STR(info, master_ssl_cipher);
200
LUA_EXPORT_STR(info, master_ssl_key);
201
if (info->master_lines >= 15) {
202
LUA_EXPORT_INT(info, master_ssl_verify_server_cert);
205
network_mysqld_masterinfo_free(info);
210
static int lua_proto_append_masterinfo_string (lua_State *L) {
212
network_mysqld_masterinfo_t *info;
214
luaL_checktype(L, 1, LUA_TTABLE);
216
info = network_mysqld_masterinfo_new();
218
LUA_IMPORT_INT(info, master_lines);
219
LUA_IMPORT_STR(info, master_log_file);
220
LUA_IMPORT_INT(info, master_log_pos);
221
LUA_IMPORT_STR(info, master_host);
222
LUA_IMPORT_STR(info, master_user);
223
LUA_IMPORT_STR(info, master_password);
224
LUA_IMPORT_INT(info, master_port);
225
LUA_IMPORT_INT(info, master_connect_retry);
226
LUA_IMPORT_INT(info, master_ssl);
227
LUA_IMPORT_STR(info, master_ssl_ca);
228
LUA_IMPORT_STR(info, master_ssl_capath);
229
LUA_IMPORT_STR(info, master_ssl_cert);
230
LUA_IMPORT_STR(info, master_ssl_cipher);
231
LUA_IMPORT_STR(info, master_ssl_key);
232
LUA_IMPORT_INT(info, master_ssl_verify_server_cert);
234
packet = g_string_new(NULL);
235
network_mysqld_masterinfo_append(packet, info);
237
network_mysqld_masterinfo_free(info);
239
lua_pushlstring(L, S(packet));
241
g_string_free(packet, TRUE);
247
157
static int lua_proto_append_ok_packet (lua_State *L) {
249
159
network_mysqld_ok_packet_t *ok_packet;
383
293
if (network_mysqld_proto_append_auth_response(packet, auth_response)) {
384
294
network_mysqld_auth_response_free(auth_response);
385
g_string_free(packet, TRUE);
387
296
luaL_error(L, "to_response_packet() failed");
388
g_string_free(packet, TRUE);
300
lua_pushlstring(L, S(packet));
392
302
network_mysqld_auth_response_free(auth_response);
394
lua_pushlstring(L, S(packet));
396
g_string_free(packet, TRUE);