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.8 by root, Tue Jun 3 03:17:37 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) && MYSQL_VERSION_ID >= 100010
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;
183 char desc[30]; /* String description */ 226 char desc[30]; /* String description */
184 char *read_buffer; /* buffer for vio_read_buff */ 227 char *read_buffer; /* buffer for vio_read_buff */
185 char *read_pos; /* start of unfetched data in the 228 char *read_pos; /* start of unfetched data in the
186 read buffer */ 229 read buffer */
187 char *read_end; /* end of unfetched data */ 230 char *read_end; /* end of unfetched data */
231#if defined(MARIADB_BASE_VERSION)
232 struct mysql_async_context *async_context; /* For non-blocking API */
233 uint read_timeout, write_timeout;
234#endif
188 /* function pointers. They are similar for socket/SSL/whatever */ 235 /* function pointers. They are similar for socket/SSL/whatever */
189 void (*viodelete)(Vio*); 236 void (*viodelete)(Vio*);
190 int (*vioerrno)(Vio*); 237 int (*vioerrno)(Vio*);
191 size_t (*read)(Vio*, unsigned char *, size_t); 238 size_t (*read)(Vio*, unsigned char *, size_t);
192 size_t (*write)(Vio*, const unsigned char *, size_t); 239 size_t (*write)(Vio*, const unsigned char *, size_t);
203 my_bool (*poll_read)(Vio *vio, uint timeout); 250 my_bool (*poll_read)(Vio *vio, uint timeout);
204 my_bool (*is_connected)(Vio*); 251 my_bool (*is_connected)(Vio*);
205 my_bool (*has_data) (Vio*); 252 my_bool (*has_data) (Vio*);
206}; 253};
207 254
255#else
256
257/* this is not supposed to work, but it's a start
258 * one needs to look into MYSQL_SOCKET, missing
259 * vioblocking and this io_wait stuff, at the least. */
260
261/**
262 VIO I/O events.
263*/
264enum enum_vio_io_event
265{
266 VIO_IO_EVENT_READ,
267 VIO_IO_EVENT_WRITE,
268 VIO_IO_EVENT_CONNECT
269};
270
271struct st_vio
272{
273 MYSQL_SOCKET mysql_socket; /* Instrumented socket */
274 my_bool localhost; /* Are we from localhost? */
275 struct sockaddr_storage local; /* Local internet address */
276 struct sockaddr_storage remote; /* Remote internet address */
277 int addrLen; /* Length of remote address */
278 enum enum_vio_type type; /* Type of connection */
279 my_bool inactive; /* Connection inactive (has been shutdown) */
280 char desc[30]; /* Description string. This
281 member MUST NOT be
282 used directly, but only
283 via function
284 "vio_description" */
285 char *read_buffer; /* buffer for vio_read_buff */
286 char *read_pos; /* start of unfetched data in the
287 read buffer */
288 char *read_end; /* end of unfetched data */
289 int read_timeout; /* Timeout value (ms) for read ops. */
290 int write_timeout; /* Timeout value (ms) for write ops. */
291
292 /*
293 VIO vtable interface to be implemented by VIO's like SSL, Socket,
294 Named Pipe, etc.
295 */
296
297 /*
298 viodelete is responsible for cleaning up the VIO object by freeing
299 internal buffers, closing descriptors, handles.
300 */
301 void (*viodelete)(Vio*);
302 int (*vioerrno)(Vio*);
303 size_t (*read)(Vio*, uchar *, size_t);
304 size_t (*write)(Vio*, const uchar *, size_t);
305 int (*timeout)(Vio*, uint, my_bool);
306 int (*viokeepalive)(Vio*, my_bool);
307 int (*fastsend)(Vio*);
308 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
309 void (*in_addr)(Vio*, struct sockaddr_storage*);
310 my_bool (*should_retry)(Vio*);
311 my_bool (*was_timeout)(Vio*);
312 /*
313 vioshutdown is resposnible to shutdown/close the channel, so that no
314 further communications can take place, however any related buffers,
315 descriptors, handles can remain valid after a shutdown.
316 */
317 int (*vioshutdown)(Vio*);
318 my_bool (*is_connected)(Vio*);
319 my_bool (*has_data) (Vio*);
320 int (*io_wait)(Vio*, enum enum_vio_io_event, int);
321 my_bool (*connect)(Vio*, struct sockaddr *, socklen_t, int);
322};
323
208#endif 324#endif
209 325
210#endif /* vio_violite_h_ */ 326#endif /* vio_violite_h_ */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines