4
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
5
5
* All rights reserved.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
14
* * Redistributions in binary form must reproduce the above
15
* copyright notice, this list of conditions and the following disclaimer
16
* in the documentation and/or other materials provided with the
19
* * The names of its contributors may not be used to endorse or
20
* promote products derived from this software without specific prior
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
* Use and distribution licensed under the BSD license. See
8
* the COPYING.BSD file in the root source directory for full text.
42
13
#include <stdlib.h>
74
45
drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
75
46
drizzle_return_t ret;
76
47
drizzle_st drizzle;
77
drizzle_con_st *con_listen= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
78
drizzle_con_st *server= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
79
drizzle_con_st *client= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
48
drizzle_con_st con_listen;
49
drizzle_con_st server;
50
drizzle_con_st client;
80
51
drizzle_result_st server_result;
81
52
drizzle_result_st client_result;
82
53
drizzle_column_st column;
119
case DRIZZLE_VERBOSE_NEVER:
120
verbose= DRIZZLE_VERBOSE_FATAL;
122
case DRIZZLE_VERBOSE_FATAL:
123
verbose= DRIZZLE_VERBOSE_ERROR;
125
case DRIZZLE_VERBOSE_ERROR:
126
verbose= DRIZZLE_VERBOSE_INFO;
128
case DRIZZLE_VERBOSE_INFO:
129
verbose= DRIZZLE_VERBOSE_DEBUG;
131
case DRIZZLE_VERBOSE_DEBUG:
132
verbose= DRIZZLE_VERBOSE_CRAZY;
134
case DRIZZLE_VERBOSE_CRAZY:
135
case DRIZZLE_VERBOSE_MAX:
161
112
drizzle_add_options(&drizzle, DRIZZLE_FREE_OBJECTS);
162
113
drizzle_set_verbose(&drizzle, verbose);
164
if (drizzle_con_create(&drizzle, con_listen) == NULL)
115
if (drizzle_con_create(&drizzle, &con_listen) == NULL)
166
117
printf("drizzle_con_create:NULL\n");
170
drizzle_con_add_options(con_listen, DRIZZLE_CON_LISTEN);
171
drizzle_con_set_tcp(con_listen, server_host, server_port);
121
drizzle_con_add_options(&con_listen, DRIZZLE_CON_LISTEN);
122
drizzle_con_set_tcp(&con_listen, server_host, server_port);
173
124
if (server_mysql)
174
drizzle_con_add_options(con_listen, DRIZZLE_CON_MYSQL);
125
drizzle_con_add_options(&con_listen, DRIZZLE_CON_MYSQL);
176
if (drizzle_con_listen(con_listen) != DRIZZLE_RETURN_OK)
127
if (drizzle_con_listen(&con_listen) != DRIZZLE_RETURN_OK)
178
129
printf("drizzle_con_listen:%s\n", drizzle_error(&drizzle));
184
(void)drizzle_con_accept(&drizzle, server, &ret);
135
(void)drizzle_con_accept(&drizzle, &server, &ret);
185
136
if (ret != DRIZZLE_RETURN_OK)
187
138
printf("drizzle_con_accept:%s\n", drizzle_error(&drizzle));
191
if (drizzle_con_create(&drizzle, client) == NULL)
142
if (drizzle_con_create(&drizzle, &client) == NULL)
193
144
printf("drizzle_con_create:NULL\n");
197
drizzle_con_add_options(client,
148
drizzle_con_add_options(&client,
198
149
DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_RAW_SCRAMBLE);
199
150
if (client_mysql)
200
drizzle_con_add_options(client, DRIZZLE_CON_MYSQL);
201
drizzle_con_set_tcp(client, client_host, client_port);
151
drizzle_con_add_options(&client, DRIZZLE_CON_MYSQL);
152
drizzle_con_set_tcp(&client, client_host, client_port);
203
ret= drizzle_con_connect(client);
154
ret= drizzle_con_connect(&client);
204
155
if (ret != DRIZZLE_RETURN_OK)
206
157
printf("drizzle_con_connect:%s\n", drizzle_error(&drizzle));
210
proxy(&drizzle, server, client, &server_result, &client_result, &column);
161
proxy(&drizzle, &server, &client, &server_result, &client_result, &column);
212
drizzle_con_free(client);
213
drizzle_con_free(server);
163
drizzle_con_free(&client);
164
drizzle_con_free(&server);
293
data= (uint8_t *)drizzle_con_command_read(server, &command, &offset, &size, &total,
240
data= drizzle_con_command_read(server, &command, &offset, &size, &total,
295
242
if (ret == DRIZZLE_RETURN_LOST_CONNECTION)