Mercurial > pidgin
comparison src/gaim_buffer.h @ 13200:33bef17125c2
[gaim-migrate @ 15563]
This is the soon-to-be-infamous nonblocking network activity patch that I've been working on. Feel free to yell at me if this makes you unhappy.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 09 Feb 2006 04:17:56 +0000 |
parents | |
children | 64bae3cbec8d |
comparison
equal
deleted
inserted
replaced
13199:d8f238864c88 | 13200:33bef17125c2 |
---|---|
1 /* | |
2 * @file gaim_buffer.h Buffer Utility Functions | |
3 * @ingroup core | |
4 * | |
5 * Gaim is the legal property of its developers, whose names are too numerous | |
6 * to list here. Please refer to the COPYRIGHT file distributed with this | |
7 * source distribution. | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #ifndef _GAIM_BUFFER_H | |
24 #define _GAIM_BUFFER_H | |
25 | |
26 #ifdef __cplusplus | |
27 extern "C" { | |
28 #endif | |
29 | |
30 typedef struct _GaimCircBuffer { | |
31 gchar *buffer; | |
32 gsize growsize; | |
33 gsize buflen; | |
34 gsize bufused; | |
35 gchar *inptr; | |
36 gchar *outptr; | |
37 } GaimCircBuffer; | |
38 | |
39 /** | |
40 * Creates a new circular buffer. This will not allocate any memory for the | |
41 * actual buffer until data is appended to it. | |
42 * | |
43 * @param growsize The size that the buffer should grow by the first time data | |
44 * is appended and every time more space is needed. | |
45 * | |
46 * @return The new GaimCircBuffer. This should be freed with | |
47 * gaim_circ_buffer_destroy when you are done with it | |
48 */ | |
49 GaimCircBuffer *gaim_circ_buffer_new(gsize growsize); | |
50 | |
51 /** | |
52 * Dispose of the GaimCircBuffer and free any memory used by it (including any | |
53 * memory used by the internal buffer). | |
54 * | |
55 * @param buf The GaimCircBuffer to free | |
56 */ | |
57 void gaim_circ_buffer_destroy(GaimCircBuffer *buf); | |
58 | |
59 /** | |
60 * Append data to the GaimCircBuffer. This will automatically grow the internal | |
61 * buffer to fit the added data. | |
62 * | |
63 * @param buf The GaimCircBuffer to which to append the data | |
64 * @param src pointer to the data to copy into the buffer | |
65 * @param len number of bytes to copy into the buffer | |
66 */ | |
67 void gaim_circ_buffer_append(GaimCircBuffer *buf, gconstpointer src, gsize len); | |
68 | |
69 /** | |
70 * Determine the maximum number of contiguous bytes that can be read from the | |
71 * GaimCircBuffer. | |
72 * Note: This may not be the total number of bytes that are buffered - a | |
73 * subsequent call after calling gaim_circ_buffer_mark_read() may indicate more | |
74 * data is available to read. | |
75 * | |
76 * @param buf the GaimCircBuffer for which to determine the maximum contiguous | |
77 * bytes that can be read. | |
78 * | |
79 * @return the number of bytes that can be read from the GaimCircBuffer | |
80 */ | |
81 gsize gaim_circ_buffer_get_max_read(GaimCircBuffer *buf); | |
82 | |
83 /** | |
84 * Mark the number of bytes that have been read from the buffer. | |
85 * | |
86 * @param buf The GaimCircBuffer to mark bytes read from | |
87 * @param len The number of bytes to mark as read | |
88 * | |
89 * @return TRUE if we successfully marked the bytes as having been read, FALSE | |
90 * otherwise. | |
91 */ | |
92 gboolean gaim_circ_buffer_mark_read(GaimCircBuffer *buf, gsize len); | |
93 | |
94 #ifdef __cplusplus | |
95 } | |
96 #endif | |
97 | |
98 #endif /* _GAIM_BUFFER_H */ |