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 file in this directory for full text.
40
13
#include <stdlib.h>
72
45
drizzle_verbose_t verbose= DRIZZLE_VERBOSE_NEVER;
73
46
drizzle_return_t ret;
74
47
drizzle_st drizzle;
75
drizzle_con_st *con_listen= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
76
drizzle_con_st *server= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
77
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;
78
51
drizzle_result_st server_result;
79
52
drizzle_result_st client_result;
80
53
drizzle_column_st column;
139
112
drizzle_add_options(&drizzle, DRIZZLE_FREE_OBJECTS);
140
113
drizzle_set_verbose(&drizzle, verbose);
142
if (drizzle_con_create(&drizzle, con_listen) == NULL)
115
if (drizzle_con_create(&drizzle, &con_listen) == NULL)
144
117
printf("drizzle_con_create:NULL\n");
148
drizzle_con_add_options(con_listen, DRIZZLE_CON_LISTEN);
149
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);
151
124
if (server_mysql)
152
drizzle_con_add_options(con_listen, DRIZZLE_CON_MYSQL);
125
drizzle_con_add_options(&con_listen, DRIZZLE_CON_MYSQL);
154
if (drizzle_con_listen(con_listen) != DRIZZLE_RETURN_OK)
127
if (drizzle_con_listen(&con_listen) != DRIZZLE_RETURN_OK)
156
129
printf("drizzle_con_listen:%s\n", drizzle_error(&drizzle));
162
(void)drizzle_con_accept(&drizzle, server, &ret);
135
(void)drizzle_con_accept(&drizzle, &server, &ret);
163
136
if (ret != DRIZZLE_RETURN_OK)
165
138
printf("drizzle_con_accept:%s\n", drizzle_error(&drizzle));
169
if (drizzle_con_create(&drizzle, client) == NULL)
142
if (drizzle_con_create(&drizzle, &client) == NULL)
171
144
printf("drizzle_con_create:NULL\n");
175
drizzle_con_add_options(client,
148
drizzle_con_add_options(&client,
176
149
DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_RAW_SCRAMBLE);
177
150
if (client_mysql)
178
drizzle_con_add_options(client, DRIZZLE_CON_MYSQL);
179
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);
181
ret= drizzle_con_connect(client);
154
ret= drizzle_con_connect(&client);
182
155
if (ret != DRIZZLE_RETURN_OK)
184
157
printf("drizzle_con_connect:%s\n", drizzle_error(&drizzle));
188
proxy(&drizzle, server, client, &server_result, &client_result, &column);
161
proxy(&drizzle, &server, &client, &server_result, &client_result, &column);
190
drizzle_con_free(client);
191
drizzle_con_free(server);
163
drizzle_con_free(&client);
164
drizzle_con_free(&server);