~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/vio.h

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
/*
17
 
 * Virtual I/O layer, only used with TCP/IP sockets at the moment.
18
 
 */
19
 
 
20
 
#ifndef PLUGIN_MYSQL_PROTOCOL_VIO_H
21
 
#define PLUGIN_MYSQL_PROTOCOL_VIO_H
22
 
 
23
 
#include <sys/socket.h>
24
 
#include <errno.h>
25
 
 
26
 
typedef struct st_vio Vio;
27
 
 
28
 
struct st_vio
29
 
{
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 */
38
 
 
39
 
  /* function pointers. They are similar for socket/SSL/whatever */
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*);
47
 
  bool (*peer_addr)(Vio*, char *, uint16_t *, size_t);
48
 
  void (*in_addr)(Vio*, struct sockaddr_storage*);
49
 
  bool (*should_retry)(Vio*);
50
 
  bool (*was_interrupted)(Vio*);
51
 
  int32_t (*vioclose)(Vio*);
52
 
  void (*timeout)(Vio*, bool is_sndtimeo, int32_t timeout);
53
 
};
54
 
 
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
 
 
71
 
#endif /* PLUGIN_MYSQL_PROTOCOL_VIO_H */