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.1 by root, Mon May 18 15:19:38 2009 UTC vs.
Revision 1.3 by root, Thu Jul 26 21:38:00 2012 UTC

1/* adapted from violite.h from mysql 5.0.51 *( 1/* adapted from violite.h from mysql 5.0.51 */
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
26/* Simple vio interface in C; The functions are implemented in violite.c */ 26/* Simple vio interface in C; The functions are implemented in violite.c */
27 27
28#ifdef __cplusplus 28#ifdef __cplusplus
29extern "C" { 29extern "C" {
30#endif /* __cplusplus */ 30#endif /* __cplusplus */
31
32#if MYSQL_VERSION_ID < 50100
33typedef I8 *xgptr;
34typedef I8 *const cxgptr;
35typedef int xlen;
36#else
37typedef U8 *xgptr;
38typedef const U8 *cxgptr;
39typedef size_t xlen;
40#endif
31 41
32enum enum_vio_type 42enum enum_vio_type
33{ 43{
34 VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, 44 VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE,
35 VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY 45 VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY
48 HANDLE event_server_wrote, 58 HANDLE event_server_wrote,
49 HANDLE event_server_read, 59 HANDLE event_server_read,
50 HANDLE event_client_wrote, 60 HANDLE event_client_wrote,
51 HANDLE event_client_read, 61 HANDLE event_client_read,
52 HANDLE event_conn_closed); 62 HANDLE event_conn_closed);
53int vio_read_pipe(Vio *vio, gptr buf, int size); 63xlen vio_read_pipe(Vio *vio, xgptr buf, xlen size);
54int vio_write_pipe(Vio *vio, const gptr buf, int size); 64xlen vio_write_pipe(Vio *vio, xcgptr buf, xlen size);
55int vio_close_pipe(Vio * vio); 65xlen vio_close_pipe(Vio * vio);
56#else 66#else
57#define HANDLE void * 67#define HANDLE void *
58#endif /* __WIN__ */ 68#endif /* __WIN__ */
59 69
60void vio_delete(Vio* vio); 70void vio_delete(Vio* vio);
61int vio_close(Vio* vio); 71int vio_close(Vio* vio);
62void vio_reset(Vio* vio, enum enum_vio_type type, 72void vio_reset(Vio* vio, enum enum_vio_type type,
63 my_socket sd, HANDLE hPipe, uint flags); 73 my_socket sd, HANDLE hPipe, uint flags);
64int vio_read(Vio *vio, gptr buf, int size); 74xlen vio_read(Vio *vio, xgptr buf, xlen size);
65int vio_read_buff(Vio *vio, gptr buf, int size); 75xlen vio_read_buff(Vio *vio, xgptr buf, xlen size);
66int vio_write(Vio *vio, const gptr buf, int size); 76xlen vio_write(Vio *vio, cxgptr buf, xlen size);
67int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); 77int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
68my_bool vio_is_blocking(Vio *vio); 78my_bool vio_is_blocking(Vio *vio);
69/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ 79/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
70int vio_fastsend(Vio *vio); 80int vio_fastsend(Vio *vio);
71/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */ 81/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
86my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); 96my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port);
87/* Remotes in_addr */ 97/* Remotes in_addr */
88void vio_in_addr(Vio *vio, struct in_addr *in); 98void vio_in_addr(Vio *vio, struct in_addr *in);
89my_bool vio_poll_read(Vio *vio,uint timeout); 99my_bool vio_poll_read(Vio *vio,uint timeout);
90 100
91#ifdef HAVE_OPENSSL
92#include <openssl/opensslv.h>
93#if OPENSSL_VERSION_NUMBER < 0x0090700f
94#define DES_cblock des_cblock
95#define DES_key_schedule des_key_schedule
96#define DES_set_key_unchecked(k,ks) des_set_key_unchecked((k),*(ks))
97#define DES_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e) des_ede3_cbc_encrypt((i),(o),(l),*(k1),*(k2),*(k3),(iv),(e))
98#endif
99
100#define HEADER_DES_LOCL_H dummy_something
101#define YASSL_MYSQL_COMPATIBLE
102#ifndef YASSL_PREFIX
103#define YASSL_PREFIX
104#endif
105/* Set yaSSL to use same type as MySQL do for socket handles */
106typedef my_socket YASSL_SOCKET_T;
107#define YASSL_SOCKET_T_DEFINED
108#include <openssl/ssl.h>
109#include <openssl/err.h>
110
111struct st_VioSSLFd
112{
113 SSL_CTX *ssl_context;
114};
115
116int sslaccept(struct st_VioSSLFd*, Vio *, long timeout);
117int sslconnect(struct st_VioSSLFd*, Vio *, long timeout);
118
119struct st_VioSSLFd
120*new_VioSSLConnectorFd(const char *key_file, const char *cert_file,
121 const char *ca_file, const char *ca_path,
122 const char *cipher);
123struct st_VioSSLFd
124*new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
125 const char *ca_file,const char *ca_path,
126 const char *cipher);
127#endif /* HAVE_OPENSSL */
128
129#ifdef HAVE_SMEM
130int vio_read_shared_memory(Vio *vio, gptr buf, int size);
131int vio_write_shared_memory(Vio *vio, const gptr buf, int size);
132int vio_close_shared_memory(Vio * vio);
133#endif
134
135void vio_end(void); 101void vio_end(void);
136 102
137#ifdef __cplusplus 103#ifdef __cplusplus
138} 104}
139#endif 105#endif
167}; 133};
168 134
169 135
170/* HFTODO - hide this if we don't want client in embedded server */ 136/* HFTODO - hide this if we don't want client in embedded server */
171/* This structure is for every connection on both sides */ 137/* This structure is for every connection on both sides */
138#if MYSQL_VERSION_ID < 50500
139
172struct st_vio 140struct st_vio
173{ 141{
174 my_socket sd; /* my_socket - real or imaginary */ 142 my_socket sd; /* my_socket - real or imaginary */
175 HANDLE hPipe; 143 HANDLE hPipe;
176 my_bool localhost; /* Are we from localhost? */ 144 my_bool localhost; /* Are we from localhost? */
184 read buffer */ 152 read buffer */
185 char *read_end; /* end of unfetched data */ 153 char *read_end; /* end of unfetched data */
186 /* function pointers. They are similar for socket/SSL/whatever */ 154 /* function pointers. They are similar for socket/SSL/whatever */
187 void (*viodelete)(Vio*); 155 void (*viodelete)(Vio*);
188 int (*vioerrno)(Vio*); 156 int (*vioerrno)(Vio*);
189 int (*read)(Vio*, gptr, int); 157 xlen (*read)(Vio*, xgptr, xlen);
190 int (*write)(Vio*, const gptr, int); 158 xlen (*write)(Vio*, cxgptr, xlen);
191 int (*vioblocking)(Vio*, my_bool, my_bool *); 159 int (*vioblocking)(Vio*, my_bool, my_bool *);
192 my_bool (*is_blocking)(Vio*); 160 my_bool (*is_blocking)(Vio*);
193 int (*viokeepalive)(Vio*, my_bool); 161 int (*viokeepalive)(Vio*, my_bool);
194 int (*fastsend)(Vio*); 162 int (*fastsend)(Vio*);
195 my_bool (*peer_addr)(Vio*, char *, uint16*); 163 my_bool (*peer_addr)(Vio*, char *, uint16*);
196 void (*in_addr)(Vio*, struct in_addr*); 164 void (*in_addr)(Vio*, struct in_addr*);
197 my_bool (*should_retry)(Vio*); 165 my_bool (*should_retry)(Vio*);
198 my_bool (*was_interrupted)(Vio*); 166 my_bool (*was_interrupted)(Vio*);
199 int (*vioclose)(Vio*); 167 int (*vioclose)(Vio*);
200 void (*timeout)(Vio*, unsigned int which, unsigned int timeout); 168 void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
201#ifdef HAVE_OPENSSL 169};
202 void *ssl_arg; 170
171#else
172
173struct st_vio
174{
175 my_socket sd; /* my_socket - real or imaginary */
176 HANDLE hPipe;
177 my_bool localhost; /* Are we from localhost? */
178 int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
179 struct sockaddr_storage local; /* Local internet address */
180 struct sockaddr_storage remote; /* Remote internet address */
181 int addrLen; /* Length of remote address */
182 enum enum_vio_type type; /* Type of connection */
183 char desc[30]; /* String description */
184 char *read_buffer; /* buffer for vio_read_buff */
185 char *read_pos; /* start of unfetched data in the
186 read buffer */
187 char *read_end; /* end of unfetched data */
188 /* function pointers. They are similar for socket/SSL/whatever */
189 void (*viodelete)(Vio*);
190 int (*vioerrno)(Vio*);
191 size_t (*read)(Vio*, unsigned char *, size_t);
192 size_t (*write)(Vio*, const unsigned char *, size_t);
193 int (*vioblocking)(Vio*, my_bool, my_bool *);
194 my_bool (*is_blocking)(Vio*);
195 int (*viokeepalive)(Vio*, my_bool);
196 int (*fastsend)(Vio*);
197 my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
198 void (*in_addr)(Vio*, struct sockaddr_storage*);
199 my_bool (*should_retry)(Vio*);
200 my_bool (*was_interrupted)(Vio*);
201 int (*vioclose)(Vio*);
202 void (*timeout)(Vio*, unsigned int which, unsigned int timeout);
203 my_bool (*poll_read)(Vio *vio, uint timeout);
204 my_bool (*is_connected)(Vio*);
205 my_bool (*has_data) (Vio*);
206};
207
203#endif 208#endif
204#ifdef HAVE_SMEM 209
205 HANDLE handle_file_map;
206 char *handle_map;
207 HANDLE event_server_wrote;
208 HANDLE event_server_read;
209 HANDLE event_client_wrote;
210 HANDLE event_client_read;
211 HANDLE event_conn_closed;
212 long shared_memory_remain;
213 char *shared_memory_pos;
214 NET *net;
215#endif /* HAVE_SMEM */
216};
217#endif /* vio_violite_h_ */ 210#endif /* vio_violite_h_ */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines