Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / core / net-sendbuffer.h
1 #ifndef __NET_SENDBUFFER_H
2 #define __NET_SENDBUFFER_H
3
4 #define DEFAULT_BUFFER_SIZE 8192
5
6 struct _NET_SENDBUF_REC {
7         GIOChannel *handle;
8
9         int send_tag;
10         int bufsize;
11         int bufpos;
12         char *buffer; /* Buffer is NULL until it's actually needed. */
13 };
14
15 /* Create new buffer - if `bufsize' is zero or less, DEFAULT_BUFFER_SIZE
16    is used */
17 NET_SENDBUF_REC *net_sendbuffer_create(GIOChannel *handle, int bufsize);
18 /* Destroy the buffer. `close' specifies if socket handle should be closed. */
19 void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close);
20
21 /* Send data, if all of it couldn't be sent immediately, it will be resent
22    automatically after a while. Returns -1 if some unrecoverable error
23    occured. */
24 int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size);
25
26 /* Flush the buffer, blocks until finished. */
27 void net_sendbuffer_flush(NET_SENDBUF_REC *rec);
28
29 /* Returns the socket handle */
30 GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec);
31
32 void net_sendbuffer_init(void);
33 void net_sendbuffer_deinit(void);
34
35 #endif