~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/violite.h

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#define VIO_READ_BUFFER_SIZE 16384              /* size of read buffer */
43
43
 
44
44
Vio*    vio_new(my_socket sd, enum enum_vio_type type, uint flags);
45
 
#define HANDLE void *
46
45
 
47
46
void    vio_delete(Vio* vio);
48
47
int     vio_close(Vio* vio);
49
 
void    vio_reset(Vio* vio, enum enum_vio_type type,
50
 
                  my_socket sd, HANDLE hPipe, uint flags);
 
48
void    vio_reset(Vio* vio, enum enum_vio_type type, my_socket sd, uint32_t flags);
51
49
size_t  vio_read(Vio *vio, uchar *      buf, size_t size);
52
50
size_t  vio_read_buff(Vio *vio, uchar * buf, size_t size);
53
51
size_t  vio_write(Vio *vio, const uchar * buf, size_t size);
54
 
int     vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode);
55
 
my_bool vio_is_blocking(Vio *vio);
 
52
int     vio_blocking(Vio *vio, bool onoff, bool *old_mode);
 
53
bool    vio_is_blocking(Vio *vio);
56
54
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
57
55
int     vio_fastsend(Vio *vio);
58
56
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
59
 
int     vio_keepalive(Vio *vio, my_bool onoff);
 
57
int32_t vio_keepalive(Vio *vio, bool    onoff);
60
58
/* Whenever we should retry the last read/write operation. */
61
 
my_bool vio_should_retry(Vio *vio);
 
59
bool    vio_should_retry(Vio *vio);
62
60
/* Check that operation was timed out */
63
 
my_bool vio_was_interrupted(Vio *vio);
 
61
bool    vio_was_interrupted(Vio *vio);
64
62
/* Short text description of the socket for those, who are curious.. */
65
63
const char* vio_description(Vio *vio);
66
64
/* Return the type of the connection */
70
68
/* Get socket number */
71
69
my_socket vio_fd(Vio*vio);
72
70
/* Remote peer's address and name in text form */
73
 
my_bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
74
 
my_bool vio_poll_read(Vio *vio,uint timeout);
75
 
my_bool vio_peek_read(Vio *vio, uint *bytes);
76
 
 
77
 
#ifdef HAVE_SMEM
78
 
size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size);
79
 
size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size);
80
 
int vio_close_shared_memory(Vio * vio);
81
 
#endif
 
71
bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
 
72
bool    vio_poll_read(Vio *vio,uint timeout);
 
73
bool vio_peek_read(Vio *vio, uint *bytes);
82
74
 
83
75
void vio_end(void);
84
76
 
119
111
struct st_vio
120
112
{
121
113
  my_socket             sd;             /* my_socket - real or imaginary */
122
 
  HANDLE hPipe;
123
 
  my_bool               localhost;      /* Are we from localhost? */
124
114
  int                   fcntl_mode;     /* Buffered fcntl(sd,F_GETFL) */
125
115
  struct sockaddr_storage       local;          /* Local internet address */
126
116
  struct sockaddr_storage       remote;         /* Remote internet address */
127
117
  int addrLen;                          /* Length of remote address */
128
118
  enum enum_vio_type    type;           /* Type of connection */
129
119
  char                  desc[30];       /* String description */
130
 
  char                  *read_buffer;   /* buffer for vio_read_buff */
131
120
  char                  *read_pos;      /* start of unfetched data in the
132
121
                                           read buffer */
133
122
  char                  *read_end;      /* end of unfetched data */
 
123
 
134
124
  /* function pointers. They are similar for socket/SSL/whatever */
135
125
  void    (*viodelete)(Vio*);
136
 
  int     (*vioerrno)(Vio*);
 
126
  int32_t     (*vioerrno)(Vio*);
137
127
  size_t  (*read)(Vio*, uchar *, size_t);
138
128
  size_t  (*write)(Vio*, const uchar *, size_t);
139
 
  int     (*vioblocking)(Vio*, my_bool, my_bool *);
140
 
  my_bool (*is_blocking)(Vio*);
141
 
  int     (*viokeepalive)(Vio*, my_bool);
142
 
  int     (*fastsend)(Vio*);
143
 
  my_bool (*peer_addr)(Vio*, char *, uint16*, size_t);
 
129
  int32_t     (*vioblocking)(Vio*, bool, bool *);
 
130
  bool (*is_blocking)(Vio*);
 
131
  int32_t     (*viokeepalive)(Vio*, bool);
 
132
  int32_t     (*fastsend)(Vio*);
 
133
  bool (*peer_addr)(Vio*, char *, uint16_t *, size_t);
144
134
  void    (*in_addr)(Vio*, struct sockaddr_storage*);
145
 
  my_bool (*should_retry)(Vio*);
146
 
  my_bool (*was_interrupted)(Vio*);
147
 
  int     (*vioclose)(Vio*);
148
 
  void    (*timeout)(Vio*, unsigned int which, unsigned int timeout);
149
 
#ifdef HAVE_SMEM
150
 
  HANDLE  handle_file_map;
151
 
  char    *handle_map;
152
 
  HANDLE  event_server_wrote;
153
 
  HANDLE  event_server_read;
154
 
  HANDLE  event_client_wrote;
155
 
  HANDLE  event_client_read;
156
 
  HANDLE  event_conn_closed;
157
 
  size_t  shared_memory_remain;
158
 
  char    *shared_memory_pos;
159
 
  NET     *net;
160
 
#endif /* HAVE_SMEM */
 
135
  bool (*should_retry)(Vio*);
 
136
  bool (*was_interrupted)(Vio*);
 
137
  int32_t     (*vioclose)(Vio*);
 
138
  void    (*timeout)(Vio*, uint32_t which, uint32_t timeout);
 
139
  char                  *read_buffer;   /* buffer for vio_read_buff */
161
140
};
162
141
#endif /* vio_violite_h_ */