/[cvs]/eggdrop1.9/testcode/sockbuf.h
ViewVC logotype

Contents of /eggdrop1.9/testcode/sockbuf.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jan 8 00:09:09 2002 UTC (18 years, 2 months ago) by stdarg
Branch: MAIN
File MIME type: text/x-csrc
Err, I don't know if I already added these files or not, so I'll add them again.

1 #ifndef _SOCKBUF_H_
2 #define _SOCKBUF_H_
3
4 /* Flags for sockbuf_t structure. */
5 #define SOCKBUF_BLOCK 1
6 #define SOCKBUF_SERVER 2
7 #define SOCKBUF_CLIENT 4
8 #define SOCKBUF_DELETE 8
9 #define SOCKBUF_NOREAD 16
10
11 /* Event types. */
12 enum {
13 SOCKBUF_READ, SOCKBUF_EMPTY, SOCKBUF_EOF, SOCKBUF_ERR,
14 SOCKBUF_WRITE,
15 SOCKBUF_NEVENTS /* Marker for how many events are defined. */
16 };
17
18 typedef struct sockbuf_iobuf_b {
19 unsigned char *data;
20 int len;
21 int max;
22 } sockbuf_iobuf_t;
23
24 typedef int (*Function)();
25 typedef Function sockbuf_event_t[];
26 typedef Function *sockbuf_event_b;
27
28 typedef struct sockbuf_b {
29 int sock; /* Underlying socket descriptor */
30 int flags; /* Keep track of blocked status, client/server */
31
32 int idx; /* Self-referencing idx */
33
34 sockbuf_iobuf_t outbuf; /* Output buffer. */
35
36 sockbuf_event_b *filters; /* Line-mode, gzip, ssl... */
37 void **filter_client_data; /* Client data for filters */
38 int nfilters; /* Number of filters */
39
40 sockbuf_event_b on; /* User's event handlers */
41 void *client_data; /* User's client data */
42 } sockbuf_t;
43
44 int sockbuf_filter(int idx, int event, int level, void *arg);
45 int sockbuf_write(int idx, unsigned char *data, int len);
46 int sockbuf_new(int sock, int flags);
47 int sockbuf_delete(int idx);
48 int sockbuf_set_handler(int idx, sockbuf_event_t handler, void *client_data);
49 int sockbuf_attach_listener(int fd);
50 int sockbuf_detach_listener(int fd);
51 int sockbuf_attach_filter(int idx, sockbuf_event_t filter, void *client_data);
52 int sockbuf_detach_filter(int idx, sockbuf_event_t filter, void *client_data);
53 int sockbuf_update_all(int timeout);
54
55 #endif /* _SOCKBUF_H_ */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23