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.9 by root, Mon Mar 4 05:34:52 2019 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
30#endif /* __cplusplus */ 30#endif /* __cplusplus */
31 31
32#if MYSQL_VERSION_ID < 50100 32#if MYSQL_VERSION_ID < 50100
33typedef I8 *xgptr; 33typedef I8 *xgptr;
34typedef I8 *const cxgptr; 34typedef I8 *const cxgptr;
35typedef int xlen; 35typedef int xsize_t;
36typedef int xssize_t;
36#else 37#else
37typedef U8 *xgptr; 38typedef U8 *xgptr;
38typedef const U8 *cxgptr; 39typedef const U8 *cxgptr;
39typedef size_t xlen; 40typedef size_t xsize_t;
41typedef size_t xssize_t;
40#endif 42#endif
41 43
42enum enum_vio_type 44enum enum_vio_type
43{ 45{
44 VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, 46 VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE,
130 SSL_TYPE_ANY, 132 SSL_TYPE_ANY,
131 SSL_TYPE_X509, 133 SSL_TYPE_X509,
132 SSL_TYPE_SPECIFIED 134 SSL_TYPE_SPECIFIED
133}; 135};
134 136
137typedef unsigned char uchar;
135 138
136/* HFTODO - hide this if we don't want client in embedded server */ 139/* HFTODO - hide this if we don't want client in embedded server */
137/* This structure is for every connection on both sides */ 140/* This structure is for every connection on both sides */
141#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100010
142
143#define DESC_IS_PTR 1
144struct st_vio
145{
146 my_socket sd; /* my_socket - real or imaginary */
147 void *m_psi;
148 my_bool localhost; /* Are we from localhost? */
149 int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
150 struct sockaddr_storage local; /* Local internet address */
151 struct sockaddr_storage remote; /* Remote internet address */
152 int addrLen; /* Length of remote address */
153 enum enum_vio_type type; /* Type of connection */
154 const char *desc; /* String description */
155 char *read_buffer; /* buffer for vio_read_buff */
156 char *read_pos; /* start of unfetched data in the
157 read buffer */
158 char *read_end; /* end of unfetched data */
159 struct mysql_async_context *async_context; /* For non-blocking API */
160 int read_timeout; /* Timeout value (ms) for read ops. */
161 int write_timeout; /* Timeout value (ms) for write ops. */
162 /* function pointers. They are similar for socket/SSL/whatever */
163 void (*viodelete)(Vio*);
164 int (*vioerrno)(Vio*);
165 size_t (*read)(Vio*, uchar *, size_t);
166 size_t (*write)(Vio*, const uchar *, size_t);
167 int (*timeout)(Vio*, uint, my_bool);
168 int (*vioblocking)(Vio*, my_bool, my_bool *);
169 my_bool (*is_blocking)(Vio*);
170 int (*viokeepalive)(Vio*, my_bool);
171 int (*fastsend)(Vio*);
172 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
173 void (*in_addr)(Vio*, struct sockaddr_storage*);
174 my_bool (*should_retry)(Vio*);
175 my_bool (*was_timeout)(Vio*);
176 int (*vioclose)(Vio*);
177 my_bool (*is_connected)(Vio*);
178 int (*shutdown)(Vio *, int);
179 my_bool (*has_data) (Vio*);
180};
181
138#if MYSQL_VERSION_ID < 50500 182#elif MYSQL_VERSION_ID < 50500
139 183
140struct st_vio 184struct st_vio
141{ 185{
142 my_socket sd; /* my_socket - real or imaginary */ 186 my_socket sd; /* my_socket - real or imaginary */
143 HANDLE hPipe; 187 HANDLE hPipe;
166 my_bool (*was_interrupted)(Vio*); 210 my_bool (*was_interrupted)(Vio*);
167 int (*vioclose)(Vio*); 211 int (*vioclose)(Vio*);
168 void (*timeout)(Vio*, unsigned int which, unsigned int timeout); 212 void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
169}; 213};
170 214
171#else 215#elif MYSQL_VERSION_ID < 50600
172 216
173struct st_vio 217struct st_vio
174{ 218{
175 my_socket sd; /* my_socket - real or imaginary */ 219 my_socket sd; /* my_socket - real or imaginary */
176 HANDLE hPipe; 220 HANDLE hPipe;
183 char desc[30]; /* String description */ 227 char desc[30]; /* String description */
184 char *read_buffer; /* buffer for vio_read_buff */ 228 char *read_buffer; /* buffer for vio_read_buff */
185 char *read_pos; /* start of unfetched data in the 229 char *read_pos; /* start of unfetched data in the
186 read buffer */ 230 read buffer */
187 char *read_end; /* end of unfetched data */ 231 char *read_end; /* end of unfetched data */
232#if defined(MARIADB_BASE_VERSION)
233 struct mysql_async_context *async_context; /* For non-blocking API */
234 uint read_timeout, write_timeout;
235#endif
188 /* function pointers. They are similar for socket/SSL/whatever */ 236 /* function pointers. They are similar for socket/SSL/whatever */
189 void (*viodelete)(Vio*); 237 void (*viodelete)(Vio*);
190 int (*vioerrno)(Vio*); 238 int (*vioerrno)(Vio*);
191 size_t (*read)(Vio*, unsigned char *, size_t); 239 size_t (*read)(Vio*, unsigned char *, size_t);
192 size_t (*write)(Vio*, const unsigned char *, size_t); 240 size_t (*write)(Vio*, const unsigned char *, size_t);
203 my_bool (*poll_read)(Vio *vio, uint timeout); 251 my_bool (*poll_read)(Vio *vio, uint timeout);
204 my_bool (*is_connected)(Vio*); 252 my_bool (*is_connected)(Vio*);
205 my_bool (*has_data) (Vio*); 253 my_bool (*has_data) (Vio*);
206}; 254};
207 255
256#else
257
258/* this is not supposed to work, but it's a start
259 * one needs to look into MYSQL_SOCKET, missing
260 * vioblocking and this io_wait stuff, at the least. */
261
262/**
263 VIO I/O events.
264*/
265enum enum_vio_io_event
266{
267 VIO_IO_EVENT_READ,
268 VIO_IO_EVENT_WRITE,
269 VIO_IO_EVENT_CONNECT
270};
271
272struct st_vio
273{
274 MYSQL_SOCKET mysql_socket; /* Instrumented socket */
275 my_bool localhost; /* Are we from localhost? */
276 struct sockaddr_storage local; /* Local internet address */
277 struct sockaddr_storage remote; /* Remote internet address */
278 int addrLen; /* Length of remote address */
279 enum enum_vio_type type; /* Type of connection */
280 my_bool inactive; /* Connection inactive (has been shutdown) */
281 char desc[30]; /* Description string. This
282 member MUST NOT be
283 used directly, but only
284 via function
285 "vio_description" */
286 char *read_buffer; /* buffer for vio_read_buff */
287 char *read_pos; /* start of unfetched data in the
288 read buffer */
289 char *read_end; /* end of unfetched data */
290 int read_timeout; /* Timeout value (ms) for read ops. */
291 int write_timeout; /* Timeout value (ms) for write ops. */
292
293 /*
294 VIO vtable interface to be implemented by VIO's like SSL, Socket,
295 Named Pipe, etc.
296 */
297
298 /*
299 viodelete is responsible for cleaning up the VIO object by freeing
300 internal buffers, closing descriptors, handles.
301 */
302 void (*viodelete)(Vio*);
303 int (*vioerrno)(Vio*);
304 size_t (*read)(Vio*, uchar *, size_t);
305 size_t (*write)(Vio*, const uchar *, size_t);
306 int (*timeout)(Vio*, uint, my_bool);
307 int (*viokeepalive)(Vio*, my_bool);
308 int (*fastsend)(Vio*);
309 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
310 void (*in_addr)(Vio*, struct sockaddr_storage*);
311 my_bool (*should_retry)(Vio*);
312 my_bool (*was_timeout)(Vio*);
313 /*
314 vioshutdown is resposnible to shutdown/close the channel, so that no
315 further communications can take place, however any related buffers,
316 descriptors, handles can remain valid after a shutdown.
317 */
318 int (*vioshutdown)(Vio*);
319 my_bool (*is_connected)(Vio*);
320 my_bool (*has_data) (Vio*);
321 int (*io_wait)(Vio*, enum enum_vio_io_event, int);
322 my_bool (*connect)(Vio*, struct sockaddr *, socklen_t, int);
323};
324
208#endif 325#endif
209 326
210#endif /* vio_violite_h_ */ 327#endif /* vio_violite_h_ */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines