Mercurial > pidgin
comparison libpurple/circbuffer.c @ 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 |
24 | 24 |
25 #include "circbuffer.h" | 25 #include "circbuffer.h" |
26 | 26 |
27 #define DEFAULT_BUF_SIZE 256 | 27 #define DEFAULT_BUF_SIZE 256 |
28 | 28 |
29 GaimCircBuffer * | 29 PurpleCircBuffer * |
30 gaim_circ_buffer_new(gsize growsize) { | 30 purple_circ_buffer_new(gsize growsize) { |
31 GaimCircBuffer *buf = g_new0(GaimCircBuffer, 1); | 31 PurpleCircBuffer *buf = g_new0(PurpleCircBuffer, 1); |
32 buf->growsize = growsize ? growsize : DEFAULT_BUF_SIZE; | 32 buf->growsize = growsize ? growsize : DEFAULT_BUF_SIZE; |
33 return buf; | 33 return buf; |
34 } | 34 } |
35 | 35 |
36 void gaim_circ_buffer_destroy(GaimCircBuffer *buf) { | 36 void purple_circ_buffer_destroy(PurpleCircBuffer *buf) { |
37 g_return_if_fail(buf != NULL); | 37 g_return_if_fail(buf != NULL); |
38 | 38 |
39 g_free(buf->buffer); | 39 g_free(buf->buffer); |
40 g_free(buf); | 40 g_free(buf); |
41 } | 41 } |
42 | 42 |
43 static void grow_circ_buffer(GaimCircBuffer *buf, gsize len) { | 43 static void grow_circ_buffer(PurpleCircBuffer *buf, gsize len) { |
44 int in_offset = 0, out_offset = 0; | 44 int in_offset = 0, out_offset = 0; |
45 int start_buflen; | 45 int start_buflen; |
46 | 46 |
47 g_return_if_fail(buf != NULL); | 47 g_return_if_fail(buf != NULL); |
48 | 48 |
86 start_buflen + in_offset; | 86 start_buflen + in_offset; |
87 } | 87 } |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void gaim_circ_buffer_append(GaimCircBuffer *buf, gconstpointer src, gsize len) { | 91 void purple_circ_buffer_append(PurpleCircBuffer *buf, gconstpointer src, gsize len) { |
92 | 92 |
93 int len_stored; | 93 int len_stored; |
94 | 94 |
95 g_return_if_fail(buf != NULL); | 95 g_return_if_fail(buf != NULL); |
96 | 96 |
120 } | 120 } |
121 | 121 |
122 buf->bufused += len; | 122 buf->bufused += len; |
123 } | 123 } |
124 | 124 |
125 gsize gaim_circ_buffer_get_max_read(const GaimCircBuffer *buf) { | 125 gsize purple_circ_buffer_get_max_read(const PurpleCircBuffer *buf) { |
126 gsize max_read; | 126 gsize max_read; |
127 | 127 |
128 g_return_val_if_fail(buf != NULL, 0); | 128 g_return_val_if_fail(buf != NULL, 0); |
129 | 129 |
130 if (buf->bufused == 0) | 130 if (buf->bufused == 0) |
135 max_read = buf->inptr - buf->outptr; | 135 max_read = buf->inptr - buf->outptr; |
136 | 136 |
137 return max_read; | 137 return max_read; |
138 } | 138 } |
139 | 139 |
140 gboolean gaim_circ_buffer_mark_read(GaimCircBuffer *buf, gsize len) { | 140 gboolean purple_circ_buffer_mark_read(PurpleCircBuffer *buf, gsize len) { |
141 g_return_val_if_fail(buf != NULL, FALSE); | 141 g_return_val_if_fail(buf != NULL, FALSE); |
142 g_return_val_if_fail(gaim_circ_buffer_get_max_read(buf) >= len, FALSE); | 142 g_return_val_if_fail(purple_circ_buffer_get_max_read(buf) >= len, FALSE); |
143 | 143 |
144 buf->outptr += len; | 144 buf->outptr += len; |
145 buf->bufused -= len; | 145 buf->bufused -= len; |
146 /* wrap to the start if we're at the end */ | 146 /* wrap to the start if we're at the end */ |
147 if ((buf->outptr - buf->buffer) == buf->buflen) | 147 if ((buf->outptr - buf->buffer) == buf->buflen) |