Mercurial > pidgin
comparison src/protocols/oscar/rxqueue.c @ 13239:f260d319bbbc
[gaim-migrate @ 15605]
Renaming a bunch of structs and typedefs to use the same naming
scheme as the rest of Gaim
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 12 Feb 2006 16:02:05 +0000 |
parents | f2431a7e33aa |
children | e9802db22b06 |
comparison
equal
deleted
inserted
replaced
13238:1e855032d7bc | 13239:f260d319bbbc |
---|---|
55 | 55 |
56 /* | 56 /* |
57 * Read into a byte stream. Will not read more than count, but may read | 57 * Read into a byte stream. Will not read more than count, but may read |
58 * less if there is not enough room in the stream buffer. | 58 * less if there is not enough room in the stream buffer. |
59 */ | 59 */ |
60 faim_internal int aim_bstream_recv(aim_bstream_t *bs, int fd, size_t count) | 60 faim_internal int aim_bstream_recv(ByteStream *bs, int fd, size_t count) |
61 { | 61 { |
62 int red = 0; | 62 int red = 0; |
63 | 63 |
64 if (!bs || (fd < 0)) | 64 if (!bs || (fd < 0)) |
65 return -1; | 65 return -1; |
79 | 79 |
80 return red; | 80 return red; |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * Free an aim_frame_t | 84 * Free an FlapFrame |
85 * | 85 * |
86 * @param frame The frame to free. | 86 * @param frame The frame to free. |
87 * @return -1 on error; 0 on success. | 87 * @return -1 on error; 0 on success. |
88 */ | 88 */ |
89 faim_internal void aim_frame_destroy(aim_frame_t *frame) | 89 faim_internal void aim_frame_destroy(FlapFrame *frame) |
90 { | 90 { |
91 | 91 |
92 free(frame->data.data); /* XXX aim_bstream_free */ | 92 free(frame->data.data); /* XXX aim_bstream_free */ |
93 free(frame); | 93 free(frame); |
94 | 94 |
99 * Read a FLAP header from conn into fr, and return the number of | 99 * Read a FLAP header from conn into fr, and return the number of |
100 * bytes in the payload. | 100 * bytes in the payload. |
101 * | 101 * |
102 * @return -1 on error, otherwise return the length of the payload. | 102 * @return -1 on error, otherwise return the length of the payload. |
103 */ | 103 */ |
104 static int aim_get_command_flap(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) | 104 static int aim_get_command_flap(OscarSession *sess, OscarConnection *conn, FlapFrame *fr) |
105 { | 105 { |
106 guint8 hdr_raw[6]; | 106 guint8 hdr_raw[6]; |
107 aim_bstream_t hdr; | 107 ByteStream hdr; |
108 | 108 |
109 fr->hdrtype = AIM_FRAMETYPE_FLAP; | 109 fr->hdrtype = AIM_FRAMETYPE_FLAP; |
110 | 110 |
111 /* | 111 /* |
112 * Read FLAP header. Six bytes total. | 112 * Read FLAP header. Six bytes total. |
147 * Read a rendezvous header from conn into fr, and return the number of | 147 * Read a rendezvous header from conn into fr, and return the number of |
148 * bytes in the payload. | 148 * bytes in the payload. |
149 * | 149 * |
150 * @return -1 on error, otherwise return the length of the payload. | 150 * @return -1 on error, otherwise return the length of the payload. |
151 */ | 151 */ |
152 static int aim_get_command_rendezvous(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) | 152 static int aim_get_command_rendezvous(OscarSession *sess, OscarConnection *conn, FlapFrame *fr) |
153 { | 153 { |
154 guint8 hdr_raw[8]; | 154 guint8 hdr_raw[8]; |
155 aim_bstream_t hdr; | 155 ByteStream hdr; |
156 | 156 |
157 fr->hdrtype = AIM_FRAMETYPE_OFT; | 157 fr->hdrtype = AIM_FRAMETYPE_OFT; |
158 | 158 |
159 /* | 159 /* |
160 * Read rendezvous header | 160 * Read rendezvous header |
180 * | 180 * |
181 * @return 0 on success, otherwise return the error number. | 181 * @return 0 on success, otherwise return the error number. |
182 * "Success" doesn't mean we have new data, it just means | 182 * "Success" doesn't mean we have new data, it just means |
183 * the connection isn't dead. | 183 * the connection isn't dead. |
184 */ | 184 */ |
185 faim_export int aim_get_command(aim_session_t *sess, aim_conn_t *conn) | 185 faim_export int aim_get_command(OscarSession *sess, OscarConnection *conn) |
186 { | 186 { |
187 aim_frame_t *fr; | 187 FlapFrame *fr; |
188 int payloadlen; | 188 int payloadlen; |
189 | 189 |
190 if (!sess || !conn) | 190 if (!sess || !conn) |
191 return -EINVAL; | 191 return -EINVAL; |
192 | 192 |
199 */ | 199 */ |
200 | 200 |
201 if (conn->status & AIM_CONN_STATUS_INPROGRESS) | 201 if (conn->status & AIM_CONN_STATUS_INPROGRESS) |
202 return aim_conn_completeconnect(sess, conn); | 202 return aim_conn_completeconnect(sess, conn); |
203 | 203 |
204 if (!(fr = (aim_frame_t *)calloc(sizeof(aim_frame_t), 1))) | 204 if (!(fr = (FlapFrame *)calloc(sizeof(FlapFrame), 1))) |
205 return -ENOMEM; | 205 return -ENOMEM; |
206 | 206 |
207 /* | 207 /* |
208 * Rendezvous (client to client) connections do not speak FLAP, so this | 208 * Rendezvous (client to client) connections do not speak FLAP, so this |
209 * function will break on them. | 209 * function will break on them. |
248 /* Enqueue this puppy */ | 248 /* Enqueue this puppy */ |
249 fr->next = NULL; /* this will always be at the bottom */ | 249 fr->next = NULL; /* this will always be at the bottom */ |
250 if (sess->queue_incoming == NULL) | 250 if (sess->queue_incoming == NULL) |
251 sess->queue_incoming = fr; | 251 sess->queue_incoming = fr; |
252 else { | 252 else { |
253 aim_frame_t *cur; | 253 FlapFrame *cur; |
254 for (cur = sess->queue_incoming; cur->next; cur = cur->next); | 254 for (cur = sess->queue_incoming; cur->next; cur = cur->next); |
255 cur->next = fr; | 255 cur->next = fr; |
256 } | 256 } |
257 | 257 |
258 fr->conn->lastactivity = time(NULL); | 258 fr->conn->lastactivity = time(NULL); |
262 | 262 |
263 /* | 263 /* |
264 * Purge receive queue of all handled commands (->handled==1). | 264 * Purge receive queue of all handled commands (->handled==1). |
265 * | 265 * |
266 */ | 266 */ |
267 faim_export void aim_purge_rxqueue(aim_session_t *sess) | 267 faim_export void aim_purge_rxqueue(OscarSession *sess) |
268 { | 268 { |
269 aim_frame_t *cur, **prev; | 269 FlapFrame *cur, **prev; |
270 | 270 |
271 for (prev = &sess->queue_incoming; (cur = *prev); ) { | 271 for (prev = &sess->queue_incoming; (cur = *prev); ) { |
272 if (cur->handled) { | 272 if (cur->handled) { |
273 *prev = cur->next; | 273 *prev = cur->next; |
274 aim_frame_destroy(cur); | 274 aim_frame_destroy(cur); |
284 * to clean up the rxqueue of unprocessed connections on that socket. | 284 * to clean up the rxqueue of unprocessed connections on that socket. |
285 * | 285 * |
286 * XXX: this is something that was handled better in the old connection | 286 * XXX: this is something that was handled better in the old connection |
287 * handling method, but eh. | 287 * handling method, but eh. |
288 */ | 288 */ |
289 faim_internal void aim_rxqueue_cleanbyconn(aim_session_t *sess, aim_conn_t *conn) | 289 faim_internal void aim_rxqueue_cleanbyconn(OscarSession *sess, OscarConnection *conn) |
290 { | 290 { |
291 aim_frame_t *currx; | 291 FlapFrame *currx; |
292 | 292 |
293 for (currx = sess->queue_incoming; currx; currx = currx->next) { | 293 for (currx = sess->queue_incoming; currx; currx = currx->next) { |
294 if ((!currx->handled) && (currx->conn == conn)) | 294 if ((!currx->handled) && (currx->conn == conn)) |
295 currx->handled = 1; | 295 currx->handled = 1; |
296 } | 296 } |