Mercurial > pidgin
comparison libpurple/circbuffer.h @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Mon, 19 Mar 2007 07:01:17 +0000 |
| parents | c2d75b47198d |
| children | 44b4e8bd759b |
comparison
equal
deleted
inserted
replaced
| 15821:84b0f9b23ede | 15822:32c366eeeb99 |
|---|---|
| 1 /* | 1 /* |
| 2 * @file circbuffer.h Buffer Utility Functions | 2 * @file circbuffer.h Buffer Utility Functions |
| 3 * @ingroup core | 3 * @ingroup core |
| 4 * | 4 * |
| 5 * Gaim is the legal property of its developers, whose names are too numerous | 5 * Purple 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 | 6 * to list here. Please refer to the COPYRIGHT file distributed with this |
| 7 * source distribution. | 7 * source distribution. |
| 8 * | 8 * |
| 9 * This program is free software; you can redistribute it and/or modify | 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 | 10 * it under the terms of the GNU General Public License as published by |
| 27 | 27 |
| 28 #ifdef __cplusplus | 28 #ifdef __cplusplus |
| 29 extern "C" { | 29 extern "C" { |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 typedef struct _GaimCircBuffer { | 32 typedef struct _PurpleCircBuffer { |
| 33 | 33 |
| 34 /** A pointer to the starting address of our chunk of memory. */ | 34 /** A pointer to the starting address of our chunk of memory. */ |
| 35 gchar *buffer; | 35 gchar *buffer; |
| 36 | 36 |
| 37 /** The incremental amount to increase this buffer by when | 37 /** The incremental amount to increase this buffer by when |
| 50 | 50 |
| 51 /** A pointer to the next byte of buffered data that should be | 51 /** A pointer to the next byte of buffered data that should be |
| 52 * read by the consumer. */ | 52 * read by the consumer. */ |
| 53 gchar *outptr; | 53 gchar *outptr; |
| 54 | 54 |
| 55 } GaimCircBuffer; | 55 } PurpleCircBuffer; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Creates a new circular buffer. This will not allocate any memory for the | 58 * Creates a new circular buffer. This will not allocate any memory for the |
| 59 * actual buffer until data is appended to it. | 59 * actual buffer until data is appended to it. |
| 60 * | 60 * |
| 61 * @param growsize The amount that the buffer should grow the first time data | 61 * @param growsize The amount that the buffer should grow the first time data |
| 62 * is appended and every time more space is needed. Pass in | 62 * is appended and every time more space is needed. Pass in |
| 63 * "0" to use the default of 256 bytes. | 63 * "0" to use the default of 256 bytes. |
| 64 * | 64 * |
| 65 * @return The new GaimCircBuffer. This should be freed with | 65 * @return The new PurpleCircBuffer. This should be freed with |
| 66 * gaim_circ_buffer_destroy when you are done with it | 66 * purple_circ_buffer_destroy when you are done with it |
| 67 */ | 67 */ |
| 68 GaimCircBuffer *gaim_circ_buffer_new(gsize growsize); | 68 PurpleCircBuffer *purple_circ_buffer_new(gsize growsize); |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Dispose of the GaimCircBuffer and free any memory used by it (including any | 71 * Dispose of the PurpleCircBuffer and free any memory used by it (including any |
| 72 * memory used by the internal buffer). | 72 * memory used by the internal buffer). |
| 73 * | 73 * |
| 74 * @param buf The GaimCircBuffer to free | 74 * @param buf The PurpleCircBuffer to free |
| 75 */ | 75 */ |
| 76 void gaim_circ_buffer_destroy(GaimCircBuffer *buf); | 76 void purple_circ_buffer_destroy(PurpleCircBuffer *buf); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Append data to the GaimCircBuffer. This will grow the internal | 79 * Append data to the PurpleCircBuffer. This will grow the internal |
| 80 * buffer to fit the added data, if needed. | 80 * buffer to fit the added data, if needed. |
| 81 * | 81 * |
| 82 * @param buf The GaimCircBuffer to which to append the data | 82 * @param buf The PurpleCircBuffer to which to append the data |
| 83 * @param src pointer to the data to copy into the buffer | 83 * @param src pointer to the data to copy into the buffer |
| 84 * @param len number of bytes to copy into the buffer | 84 * @param len number of bytes to copy into the buffer |
| 85 */ | 85 */ |
| 86 void gaim_circ_buffer_append(GaimCircBuffer *buf, gconstpointer src, gsize len); | 86 void purple_circ_buffer_append(PurpleCircBuffer *buf, gconstpointer src, gsize len); |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Determine the maximum number of contiguous bytes that can be read from the | 89 * Determine the maximum number of contiguous bytes that can be read from the |
| 90 * GaimCircBuffer. | 90 * PurpleCircBuffer. |
| 91 * Note: This may not be the total number of bytes that are buffered - a | 91 * Note: This may not be the total number of bytes that are buffered - a |
| 92 * subsequent call after calling gaim_circ_buffer_mark_read() may indicate more | 92 * subsequent call after calling purple_circ_buffer_mark_read() may indicate more |
| 93 * data is available to read. | 93 * data is available to read. |
| 94 * | 94 * |
| 95 * @param buf the GaimCircBuffer for which to determine the maximum contiguous | 95 * @param buf the PurpleCircBuffer for which to determine the maximum contiguous |
| 96 * bytes that can be read. | 96 * bytes that can be read. |
| 97 * | 97 * |
| 98 * @return the number of bytes that can be read from the GaimCircBuffer | 98 * @return the number of bytes that can be read from the PurpleCircBuffer |
| 99 */ | 99 */ |
| 100 gsize gaim_circ_buffer_get_max_read(const GaimCircBuffer *buf); | 100 gsize purple_circ_buffer_get_max_read(const PurpleCircBuffer *buf); |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * Mark the number of bytes that have been read from the buffer. | 103 * Mark the number of bytes that have been read from the buffer. |
| 104 * | 104 * |
| 105 * @param buf The GaimCircBuffer to mark bytes read from | 105 * @param buf The PurpleCircBuffer to mark bytes read from |
| 106 * @param len The number of bytes to mark as read | 106 * @param len The number of bytes to mark as read |
| 107 * | 107 * |
| 108 * @return TRUE if we successfully marked the bytes as having been read, FALSE | 108 * @return TRUE if we successfully marked the bytes as having been read, FALSE |
| 109 * otherwise. | 109 * otherwise. |
| 110 */ | 110 */ |
| 111 gboolean gaim_circ_buffer_mark_read(GaimCircBuffer *buf, gsize len); | 111 gboolean purple_circ_buffer_mark_read(PurpleCircBuffer *buf, gsize len); |
| 112 | 112 |
| 113 #ifdef __cplusplus | 113 #ifdef __cplusplus |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| 116 | 116 |
