~drizzle-trunk/drizzle/development

971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
15
16
/*
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
17
 * Virtual I/O layer, only used with TCP/IP sockets at the moment.
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
18
 */
19
971.7.11 by Eric Day
Fixed header file guards and fixed test cases.
20
#ifndef PLUGIN_MYSQL_PROTOCOL_VIO_H
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
21
#define PLUGIN_MYSQL_PROTOCOL_VIO_H
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
22
23
#include <sys/socket.h>
24
#include <errno.h>
25
26
typedef struct st_vio Vio;
27
28
struct st_vio
29
{
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
30
  bool closed;
31
  int sd;
32
  int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
33
  struct sockaddr_storage local; /* Local internet address */
34
  struct sockaddr_storage remote; /* Remote internet address */
35
  int addrLen; /* Length of remote address */
36
  char *read_pos; /* start of unfetched data in the read buffer */
37
  char *read_end; /* end of unfetched data */
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
38
39
  /* function pointers. They are similar for socket/SSL/whatever */
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
40
  void (*viodelete)(Vio*);
41
  int32_t (*vioerrno)(Vio*);
42
  size_t (*read)(Vio*, unsigned char *, size_t);
43
  size_t (*write)(Vio*, const unsigned char *, size_t);
44
  int32_t (*vioblocking)(Vio*, bool, bool *);
45
  int32_t (*viokeepalive)(Vio*, bool);
46
  int32_t (*fastsend)(Vio*);
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
47
  bool (*peer_addr)(Vio*, char *, uint16_t *, size_t);
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
48
  void (*in_addr)(Vio*, struct sockaddr_storage*);
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
49
  bool (*should_retry)(Vio*);
50
  bool (*was_interrupted)(Vio*);
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
51
  int32_t (*vioclose)(Vio*);
52
  void (*timeout)(Vio*, bool is_sndtimeo, int32_t timeout);
971.7.10 by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port.
53
};
54
1337.4.1 by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage.
55
Vio* mysql_protocol_vio_new(int sd);
56
57
#define vio_fd(vio) (vio)->sd
58
#define vio_delete(vio) (vio)->viodelete(vio)
59
#define vio_errno(vio) (vio)->vioerrno(vio)
60
#define vio_read(vio, buf, size) ((vio)->read)(vio,buf,size)
61
#define vio_write(vio, buf, size) ((vio)->write)(vio, buf, size)
62
#define vio_blocking(vio, set_blocking_mode, old_mode) (vio)->vioblocking(vio, set_blocking_mode, old_mode)
63
#define vio_fastsend(vio) (vio)->fastsend(vio)
64
#define vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive)
65
#define vio_should_retry(vio) (vio)->should_retry(vio)
66
#define vio_was_interrupted(vio) (vio)->was_interrupted(vio)
67
#define vio_close(vio) ((vio)->vioclose)(vio)
68
#define vio_peer_addr(vio, buf, prt, buflen) (vio)->peer_addr(vio, buf, prt, buflen)
69
#define vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds)
70
971.7.11 by Eric Day
Fixed header file guards and fixed test cases.
71
#endif /* PLUGIN_MYSQL_PROTOCOL_VIO_H */