Wed, 13 May 2009 20:29:03 +0000
Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /** |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
2 | * @file circbuffer.h Buffer Utility Functions |
| 13201 | 3 | * @ingroup core |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* Purple is the legal property of its developers, whose names are too numerous |
| 13201 | 7 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 8 | * source distribution. | |
| 9 | * | |
| 10 | * This program is free software; you can redistribute it and/or modify | |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15884
diff
changeset
|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 13201 | 23 | */ |
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
24 | #ifndef _CIRCBUFFER_H |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
25 | #define _CIRCBUFFER_H |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
26 | |
|
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
27 | #include <glib.h> |
| 13201 | 28 | |
| 29 | #ifdef __cplusplus | |
| 30 | extern "C" { | |
| 31 | #endif | |
| 32 | ||
| 15884 | 33 | typedef struct _PurpleCircBuffer { |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
34 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
35 | /** A pointer to the starting address of our chunk of memory. */ |
| 13201 | 36 | gchar *buffer; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
37 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
38 | /** The incremental amount to increase this buffer by when |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
39 | * the buffer is not big enough to hold incoming data, in bytes. */ |
| 13201 | 40 | gsize growsize; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
41 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
42 | /** The length of this buffer, in bytes. */ |
| 13201 | 43 | gsize buflen; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
44 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
45 | /** The number of bytes of this buffer that contain unread data. */ |
| 13201 | 46 | gsize bufused; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
47 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
48 | /** A pointer to the next byte where new incoming data is |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
49 | * buffered to. */ |
| 13201 | 50 | gchar *inptr; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
51 | |
|
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
52 | /** A pointer to the next byte of buffered data that should be |
|
13233
1a55c46f0a24
[gaim-migrate @ 15597]
Mark Doliner <markdoliner@pidgin.im>
parents:
13230
diff
changeset
|
53 | * read by the consumer. */ |
| 13201 | 54 | gchar *outptr; |
|
13230
44b216532ea2
[gaim-migrate @ 15594]
Mark Doliner <markdoliner@pidgin.im>
parents:
13213
diff
changeset
|
55 | |
| 15884 | 56 | } PurpleCircBuffer; |
| 13201 | 57 | |
| 58 | /** | |
| 59 | * Creates a new circular buffer. This will not allocate any memory for the | |
| 60 | * actual buffer until data is appended to it. | |
| 61 | * | |
|
13213
8dcf2385a862
[gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents:
13201
diff
changeset
|
62 | * @param growsize The amount that the buffer should grow the first time data |
|
8dcf2385a862
[gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents:
13201
diff
changeset
|
63 | * is appended and every time more space is needed. Pass in |
|
8dcf2385a862
[gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents:
13201
diff
changeset
|
64 | * "0" to use the default of 256 bytes. |
| 13201 | 65 | * |
| 15884 | 66 | * @return The new PurpleCircBuffer. This should be freed with |
| 67 | * purple_circ_buffer_destroy when you are done with it | |
| 13201 | 68 | */ |
| 15884 | 69 | PurpleCircBuffer *purple_circ_buffer_new(gsize growsize); |
| 13201 | 70 | |
| 71 | /** | |
| 15884 | 72 | * Dispose of the PurpleCircBuffer and free any memory used by it (including any |
| 13201 | 73 | * memory used by the internal buffer). |
| 74 | * | |
| 15884 | 75 | * @param buf The PurpleCircBuffer to free |
| 13201 | 76 | */ |
| 15884 | 77 | void purple_circ_buffer_destroy(PurpleCircBuffer *buf); |
| 13201 | 78 | |
| 79 | /** | |
| 15884 | 80 | * Append data to the PurpleCircBuffer. This will grow the internal |
|
13213
8dcf2385a862
[gaim-migrate @ 15576]
Mark Doliner <markdoliner@pidgin.im>
parents:
13201
diff
changeset
|
81 | * buffer to fit the added data, if needed. |
| 13201 | 82 | * |
| 15884 | 83 | * @param buf The PurpleCircBuffer to which to append the data |
| 13201 | 84 | * @param src pointer to the data to copy into the buffer |
| 85 | * @param len number of bytes to copy into the buffer | |
| 86 | */ | |
| 15884 | 87 | void purple_circ_buffer_append(PurpleCircBuffer *buf, gconstpointer src, gsize len); |
| 13201 | 88 | |
| 89 | /** | |
| 90 | * Determine the maximum number of contiguous bytes that can be read from the | |
| 15884 | 91 | * PurpleCircBuffer. |
| 13201 | 92 | * Note: This may not be the total number of bytes that are buffered - a |
| 15884 | 93 | * subsequent call after calling purple_circ_buffer_mark_read() may indicate more |
| 13201 | 94 | * data is available to read. |
| 95 | * | |
| 15884 | 96 | * @param buf the PurpleCircBuffer for which to determine the maximum contiguous |
| 13201 | 97 | * bytes that can be read. |
| 98 | * | |
| 15884 | 99 | * @return the number of bytes that can be read from the PurpleCircBuffer |
| 13201 | 100 | */ |
| 15884 | 101 | gsize purple_circ_buffer_get_max_read(const PurpleCircBuffer *buf); |
| 13201 | 102 | |
| 103 | /** | |
| 104 | * Mark the number of bytes that have been read from the buffer. | |
| 105 | * | |
| 15884 | 106 | * @param buf The PurpleCircBuffer to mark bytes read from |
| 13201 | 107 | * @param len The number of bytes to mark as read |
| 108 | * | |
| 109 | * @return TRUE if we successfully marked the bytes as having been read, FALSE | |
| 110 | * otherwise. | |
| 111 | */ | |
| 15884 | 112 | gboolean purple_circ_buffer_mark_read(PurpleCircBuffer *buf, gsize len); |
| 13201 | 113 | |
| 114 | #ifdef __cplusplus | |
| 115 | } | |
| 116 | #endif | |
| 117 | ||
|
14013
86dac5633bd9
[gaim-migrate @ 16496]
Mark Doliner <markdoliner@pidgin.im>
parents:
13233
diff
changeset
|
118 | #endif /* _CIRCBUFFER_H */ |