~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/violite.h

  • Committer: Brian Aker
  • Date: 2008-07-07 14:25:25 UTC
  • mto: (77.1.25 codestyle)
  • mto: This revision was merged to the branch mainline in revision 82.
  • Revision ID: brian@tangent.org-20080707142525-xzy2nl3ie2ebwfln
LL() cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef vio_violite_h_
22
22
#define vio_violite_h_
23
23
 
24
 
#include <sys/socket.h>
25
 
#include <errno.h>
 
24
#include "my_net.h"                     /* needed because of struct in_addr */
 
25
 
26
26
 
27
27
/* Simple vio interface in C;  The functions are implemented in violite.c */
28
28
 
41
41
#define VIO_BUFFERED_READ 2                     /* use buffered read */
42
42
#define VIO_READ_BUFFER_SIZE 16384              /* size of read buffer */
43
43
 
44
 
Vio*    vio_new(int sd, enum enum_vio_type type, unsigned int flags);
 
44
Vio*    vio_new(my_socket sd, enum enum_vio_type type, uint flags);
 
45
#define HANDLE void *
45
46
 
46
47
void    vio_delete(Vio* vio);
47
48
int     vio_close(Vio* vio);
48
 
void    vio_reset(Vio* vio, enum enum_vio_type type, int sd, uint32_t flags);
49
 
size_t  vio_read(Vio *vio, unsigned char *      buf, size_t size);
50
 
size_t  vio_read_buff(Vio *vio, unsigned char * buf, size_t size);
51
 
size_t  vio_write(Vio *vio, const unsigned char * buf, size_t size);
52
 
int     vio_blocking(Vio *vio, bool onoff, bool *old_mode);
53
 
bool    vio_is_blocking(Vio *vio);
 
49
void    vio_reset(Vio* vio, enum enum_vio_type type,
 
50
                  my_socket sd, HANDLE hPipe, uint flags);
 
51
size_t  vio_read(Vio *vio, uchar *      buf, size_t size);
 
52
size_t  vio_read_buff(Vio *vio, uchar * buf, size_t size);
 
53
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);
54
56
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
55
57
int     vio_fastsend(Vio *vio);
56
58
/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */
57
 
int32_t vio_keepalive(Vio *vio, bool    onoff);
 
59
int     vio_keepalive(Vio *vio, my_bool onoff);
58
60
/* Whenever we should retry the last read/write operation. */
59
 
bool    vio_should_retry(Vio *vio);
 
61
my_bool vio_should_retry(Vio *vio);
60
62
/* Check that operation was timed out */
61
 
bool    vio_was_interrupted(Vio *vio);
 
63
my_bool vio_was_interrupted(Vio *vio);
62
64
/* Short text description of the socket for those, who are curious.. */
63
65
const char* vio_description(Vio *vio);
64
66
/* Return the type of the connection */
66
68
/* Return last error number */
67
69
int     vio_errno(Vio*vio);
68
70
/* Get socket number */
69
 
int vio_fd(Vio*vio);
 
71
my_socket vio_fd(Vio*vio);
70
72
/* Remote peer's address and name in text form */
71
 
bool vio_peer_addr(Vio *vio, char *buf, uint16_t *port, size_t buflen);
72
 
bool vio_poll_read(Vio *vio, int timeout);
73
 
bool vio_peek_read(Vio *vio, unsigned int *bytes);
 
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
74
82
 
75
83
void vio_end(void);
76
84
 
110
118
/* This structure is for every connection on both sides */
111
119
struct st_vio
112
120
{
113
 
  int           sd;             /* int - real or imaginary */
 
121
  my_socket             sd;             /* my_socket - real or imaginary */
 
122
  HANDLE hPipe;
 
123
  my_bool               localhost;      /* Are we from localhost? */
114
124
  int                   fcntl_mode;     /* Buffered fcntl(sd,F_GETFL) */
115
125
  struct sockaddr_storage       local;          /* Local internet address */
116
126
  struct sockaddr_storage       remote;         /* Remote internet address */
117
127
  int addrLen;                          /* Length of remote address */
118
128
  enum enum_vio_type    type;           /* Type of connection */
119
129
  char                  desc[30];       /* String description */
 
130
  char                  *read_buffer;   /* buffer for vio_read_buff */
120
131
  char                  *read_pos;      /* start of unfetched data in the
121
132
                                           read buffer */
122
133
  char                  *read_end;      /* end of unfetched data */
123
 
 
124
134
  /* function pointers. They are similar for socket/SSL/whatever */
125
135
  void    (*viodelete)(Vio*);
126
 
  int32_t     (*vioerrno)(Vio*);
127
 
  size_t  (*read)(Vio*, unsigned char *, size_t);
128
 
  size_t  (*write)(Vio*, const unsigned char *, 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);
 
136
  int     (*vioerrno)(Vio*);
 
137
  size_t  (*read)(Vio*, uchar *, size_t);
 
138
  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);
134
144
  void    (*in_addr)(Vio*, struct sockaddr_storage*);
135
 
  bool (*should_retry)(Vio*);
136
 
  bool (*was_interrupted)(Vio*);
137
 
  int32_t     (*vioclose)(Vio*);
138
 
  void    (*timeout)(Vio*, bool is_sndtimeo, int32_t timeout);
139
 
  char                  *read_buffer;   /* buffer for vio_read_buff */
 
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 */
140
161
};
141
162
#endif /* vio_violite_h_ */