ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro-Mysql/violite.h
(Generate patch)

Comparing Coro-Mysql/violite.h (file contents):
Revision 1.3 by root, Thu Jul 26 21:38:00 2012 UTC vs.
Revision 1.5 by root, Sun Apr 13 08:01:45 2014 UTC

1/* adapted from violite.h from mysql 5.0.51 */ 1/* adapted from violite.h from mysql 5.0.51 and many others */
2/* all modifications public domain */ 2/* all modifications public domain */
3/* Copyright (C) 2000 MySQL AB 3/* Copyright (C) 2000 MySQL AB
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
130 SSL_TYPE_ANY, 130 SSL_TYPE_ANY,
131 SSL_TYPE_X509, 131 SSL_TYPE_X509,
132 SSL_TYPE_SPECIFIED 132 SSL_TYPE_SPECIFIED
133}; 133};
134 134
135typedef unsigned char uchar;
135 136
136/* HFTODO - hide this if we don't want client in embedded server */ 137/* HFTODO - hide this if we don't want client in embedded server */
137/* This structure is for every connection on both sides */ 138/* This structure is for every connection on both sides */
139#if defined(MARIADB_BASE_VERSION) && 0
140
141#define DESC_IS_PTR 1
142
143struct st_vio
144{
145 my_socket sd; /* my_socket - real or imaginary */
146 void *m_psi;
147 my_bool localhost; /* Are we from localhost? */
148 int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
149 struct sockaddr_storage local; /* Local internet address */
150 struct sockaddr_storage remote; /* Remote internet address */
151 int addrLen; /* Length of remote address */
152 enum enum_vio_type type; /* Type of connection */
153 const char *desc; /* String description */
154 char *read_buffer; /* buffer for vio_read_buff */
155 char *read_pos; /* start of unfetched data in the
156 read buffer */
157 char *read_end; /* end of unfetched data */
158 struct mysql_async_context *async_context; /* For non-blocking API */
159 int read_timeout; /* Timeout value (ms) for read ops. */
160 int write_timeout; /* Timeout value (ms) for write ops. */
161 /* function pointers. They are similar for socket/SSL/whatever */
162 void (*viodelete)(Vio*);
163 int (*vioerrno)(Vio*);
164 size_t (*read)(Vio*, uchar *, size_t);
165 size_t (*write)(Vio*, const uchar *, size_t);
166 int (*timeout)(Vio*, uint, my_bool);
167 int (*vioblocking)(Vio*, my_bool, my_bool *);
168 my_bool (*is_blocking)(Vio*);
169 int (*viokeepalive)(Vio*, my_bool);
170 int (*fastsend)(Vio*);
171 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
172 void (*in_addr)(Vio*, struct sockaddr_storage*);
173 my_bool (*should_retry)(Vio*);
174 my_bool (*was_timeout)(Vio*);
175 int (*vioclose)(Vio*);
176 my_bool (*is_connected)(Vio*);
177 int (*shutdown)(Vio *, int);
178 my_bool (*has_data) (Vio*);
179};
180
138#if MYSQL_VERSION_ID < 50500 181#elif MYSQL_VERSION_ID < 50500
139 182
140struct st_vio 183struct st_vio
141{ 184{
142 my_socket sd; /* my_socket - real or imaginary */ 185 my_socket sd; /* my_socket - real or imaginary */
143 HANDLE hPipe; 186 HANDLE hPipe;
166 my_bool (*was_interrupted)(Vio*); 209 my_bool (*was_interrupted)(Vio*);
167 int (*vioclose)(Vio*); 210 int (*vioclose)(Vio*);
168 void (*timeout)(Vio*, unsigned int which, unsigned int timeout); 211 void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
169}; 212};
170 213
171#else 214#elif MYSQL_VERSION_ID < 50600
172 215
173struct st_vio 216struct st_vio
174{ 217{
175 my_socket sd; /* my_socket - real or imaginary */ 218 my_socket sd; /* my_socket - real or imaginary */
176 HANDLE hPipe; 219 HANDLE hPipe;
203 my_bool (*poll_read)(Vio *vio, uint timeout); 246 my_bool (*poll_read)(Vio *vio, uint timeout);
204 my_bool (*is_connected)(Vio*); 247 my_bool (*is_connected)(Vio*);
205 my_bool (*has_data) (Vio*); 248 my_bool (*has_data) (Vio*);
206}; 249};
207 250
251#else
252
253/* this is not supposed to work, but it's a start
254 * one needs to look into MYSQL_SOCKET, missing
255 * vioblocking and this io_wait stuff, at the least. */
256
257/**
258 VIO I/O events.
259*/
260enum enum_vio_io_event
261{
262 VIO_IO_EVENT_READ,
263 VIO_IO_EVENT_WRITE,
264 VIO_IO_EVENT_CONNECT
265};
266
267struct st_vio
268{
269 MYSQL_SOCKET mysql_socket; /* Instrumented socket */
270 my_bool localhost; /* Are we from localhost? */
271 struct sockaddr_storage local; /* Local internet address */
272 struct sockaddr_storage remote; /* Remote internet address */
273 int addrLen; /* Length of remote address */
274 enum enum_vio_type type; /* Type of connection */
275 my_bool inactive; /* Connection inactive (has been shutdown) */
276 char desc[30]; /* Description string. This
277 member MUST NOT be
278 used directly, but only
279 via function
280 "vio_description" */
281 char *read_buffer; /* buffer for vio_read_buff */
282 char *read_pos; /* start of unfetched data in the
283 read buffer */
284 char *read_end; /* end of unfetched data */
285 int read_timeout; /* Timeout value (ms) for read ops. */
286 int write_timeout; /* Timeout value (ms) for write ops. */
287
288 /*
289 VIO vtable interface to be implemented by VIO's like SSL, Socket,
290 Named Pipe, etc.
291 */
292
293 /*
294 viodelete is responsible for cleaning up the VIO object by freeing
295 internal buffers, closing descriptors, handles.
296 */
297 void (*viodelete)(Vio*);
298 int (*vioerrno)(Vio*);
299 size_t (*read)(Vio*, uchar *, size_t);
300 size_t (*write)(Vio*, const uchar *, size_t);
301 int (*timeout)(Vio*, uint, my_bool);
302 int (*viokeepalive)(Vio*, my_bool);
303 int (*fastsend)(Vio*);
304 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
305 void (*in_addr)(Vio*, struct sockaddr_storage*);
306 my_bool (*should_retry)(Vio*);
307 my_bool (*was_timeout)(Vio*);
308 /*
309 vioshutdown is resposnible to shutdown/close the channel, so that no
310 further communications can take place, however any related buffers,
311 descriptors, handles can remain valid after a shutdown.
312 */
313 int (*vioshutdown)(Vio*);
314 my_bool (*is_connected)(Vio*);
315 my_bool (*has_data) (Vio*);
316 int (*io_wait)(Vio*, enum enum_vio_io_event, int);
317 my_bool (*connect)(Vio*, struct sockaddr *, socklen_t, int);
318};
319
208#endif 320#endif
209 321
210#endif /* vio_violite_h_ */ 322#endif /* vio_violite_h_ */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines