/[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.6 - (show annotations) (download) (as text)
Fri Aug 9 23:42:04 2002 UTC (16 years, 7 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +2 -2 lines
File MIME type: text/x-csrc
* Some updates to network code

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 #define SOCKBUF_AVAIL 32
11 #define SOCKBUF_DELETED 64
12 /* The difference between SOCKBUF_AVAIL and SOCKBUF_DELETED is that DELETED
13 means it's invalid but not available for use yet. That happens when you
14 delete a sockbuf from within sockbuf_update_all(). Otherwise, when you
15 create a new sockbuf after you delete one, you could get the same idx,
16 and sockbuf_update_all() might trigger invalid events for it. */
17
18
19 /* Levels for filters. */
20 #define SOCKBUF_LEVEL_INTERNAL -1
21 #define SOCKBUF_LEVEL_WRITE_INTERNAL 1000000
22 #define SOCKBUF_LEVEL_PROXY 1000
23 #define SOCKBUF_LEVEL_ENCRYPTION 2000
24 #define SOCKBUF_LEVEL_COMPRESSION 3000
25 #define SOCKBUF_LEVEL_TEXT_ALTERATION 4000
26 #define SOCKBUF_LEVEL_TEXT_BUFFER 5000
27
28 typedef struct {
29 const char *name;
30 int level;
31
32 /* Connection-level events. */
33 int (*on_connect)(void *client_data, int idx, const char *peer_ip, int peer_port);
34 int (*on_eof)(void *client_data, int idx, int err, const char *errmsg);
35 int (*on_newclient)(void *client_data, int idx, int newidx, const char *peer_ip, int peer_port);
36
37 /* Data-level events. */
38 int (*on_read)(void *client_data, int idx, char *data, int len);
39 int (*on_write)(void *client_data, int idx, const char *data, int len);
40 int (*on_written)(void *client_data, int idx, int len, int remaining);
41
42 /* Command-level events. */
43 int (*on_flush)(void *client_data, int idx);
44 int (*on_delete)(void *client_data, int idx);
45 } sockbuf_filter_t;
46
47 typedef struct {
48 const char *name;
49
50 /* Connection-level events. */
51 int (*on_connect)(void *client_data, int idx, const char *peer_ip, int peer_port);
52 int (*on_eof)(void *client_data, int idx, int err, const char *errmsg);
53 int (*on_newclient)(void *client_data, int idx, int newidx, const char *peer_ip, int peer_port);
54
55 /* Data-level events. */
56 int (*on_read)(void *client_data, int idx, char *data, int len);
57 int (*on_written)(void *client_data, int idx, int len, int remaining);
58 } sockbuf_handler_t;
59
60 int sockbuf_write(int idx, const char *data, int len);
61 int sockbuf_new();
62 int sockbuf_delete(int idx);
63 int sockbuf_close(int idx);
64 int sockbuf_flush(int idx);
65 int sockbuf_set_handler(int idx, sockbuf_handler_t *handler, void *client_data);
66 int sockbuf_set_sock(int idx, int sock, int flags);
67 int sockbuf_attach_listener(int fd);
68 int sockbuf_detach_listener(int fd);
69 int sockbuf_attach_filter(int idx, sockbuf_filter_t *filter, void *client_data);
70 int sockbuf_detach_filter(int idx, sockbuf_filter_t *filter, void *client_data);
71 int sockbuf_update_all(int timeout);
72
73 #endif /* _SOCKBUF_H_ */

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23