comparison src/protocols/oscar/tlv.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 6519aeb66b31
comparison
equal deleted inserted replaced
13238:1e855032d7bc 13239:f260d319bbbc
62 * in libfaim. 62 * in libfaim.
63 * 63 *
64 * @param bs Input bstream 64 * @param bs Input bstream
65 * @return Return the TLV chain read 65 * @return Return the TLV chain read
66 */ 66 */
67 faim_internal aim_tlvlist_t *aim_tlvlist_read(aim_bstream_t *bs) 67 faim_internal aim_tlvlist_t *aim_tlvlist_read(ByteStream *bs)
68 { 68 {
69 aim_tlvlist_t *list = NULL, *cur; 69 aim_tlvlist_t *list = NULL, *cur;
70 70
71 while (aim_bstream_empty(bs) > 0) { 71 while (aim_bstream_empty(bs) > 0) {
72 guint16 type, length; 72 guint16 type, length;
147 * There are a number of places where you want to read in a tlvchain, 147 * There are a number of places where you want to read in a tlvchain,
148 * but the chain is not at the end of the SNAC, and the chain is 148 * but the chain is not at the end of the SNAC, and the chain is
149 * preceded by the number of TLVs. So you can limit that with this. 149 * preceded by the number of TLVs. So you can limit that with this.
150 * @return Return the TLV chain read 150 * @return Return the TLV chain read
151 */ 151 */
152 faim_internal aim_tlvlist_t *aim_tlvlist_readnum(aim_bstream_t *bs, guint16 num) 152 faim_internal aim_tlvlist_t *aim_tlvlist_readnum(ByteStream *bs, guint16 num)
153 { 153 {
154 aim_tlvlist_t *list = NULL, *cur; 154 aim_tlvlist_t *list = NULL, *cur;
155 155
156 while ((aim_bstream_empty(bs) > 0) && (num != 0)) { 156 while ((aim_bstream_empty(bs) > 0) && (num != 0)) {
157 guint16 type, length; 157 guint16 type, length;
216 * There are a number of places where you want to read in a tlvchain, 216 * There are a number of places where you want to read in a tlvchain,
217 * but the chain is not at the end of the SNAC, and the chain is 217 * but the chain is not at the end of the SNAC, and the chain is
218 * preceded by the length of the TLVs. So you can limit that with this. 218 * preceded by the length of the TLVs. So you can limit that with this.
219 * @return Return the TLV chain read 219 * @return Return the TLV chain read
220 */ 220 */
221 faim_internal aim_tlvlist_t *aim_tlvlist_readlen(aim_bstream_t *bs, guint16 len) 221 faim_internal aim_tlvlist_t *aim_tlvlist_readlen(ByteStream *bs, guint16 len)
222 { 222 {
223 aim_tlvlist_t *list = NULL, *cur; 223 aim_tlvlist_t *list = NULL, *cur;
224 224
225 while ((aim_bstream_empty(bs) > 0) && (len > 0)) { 225 while ((aim_bstream_empty(bs) > 0) && (len > 0)) {
226 guint16 type, length; 226 guint16 type, length;
292 * @param two The other TLV chain to compare. 292 * @param two The other TLV chain to compare.
293 * @return Return 0 if the lists are the same, return 1 if they are different. 293 * @return Return 0 if the lists are the same, return 1 if they are different.
294 */ 294 */
295 faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two) 295 faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two)
296 { 296 {
297 aim_bstream_t bs1, bs2; 297 ByteStream bs1, bs2;
298 298
299 if (aim_tlvlist_size(&one) != aim_tlvlist_size(&two)) 299 if (aim_tlvlist_size(&one) != aim_tlvlist_size(&two))
300 return 1; 300 return 1;
301 301
302 aim_bstream_init(&bs1, ((guint8 *)malloc(aim_tlvlist_size(&one)*sizeof(guint8))), aim_tlvlist_size(&one)); 302 aim_bstream_init(&bs1, ((guint8 *)malloc(aim_tlvlist_size(&one)*sizeof(guint8))), aim_tlvlist_size(&one));
511 * @return The size of the value added. 511 * @return The size of the value added.
512 */ 512 */
513 faim_internal int aim_tlvlist_add_caps(aim_tlvlist_t **list, const guint16 type, const guint32 caps) 513 faim_internal int aim_tlvlist_add_caps(aim_tlvlist_t **list, const guint16 type, const guint32 caps)
514 { 514 {
515 guint8 buf[16*16]; /* XXX icky fixed length buffer */ 515 guint8 buf[16*16]; /* XXX icky fixed length buffer */
516 aim_bstream_t bs; 516 ByteStream bs;
517 517
518 if (!caps) 518 if (!caps)
519 return 0; /* nothing there anyway */ 519 return 0; /* nothing there anyway */
520 520
521 aim_bstream_init(&bs, buf, sizeof(buf)); 521 aim_bstream_init(&bs, buf, sizeof(buf));
533 * @return The size of the value added. 533 * @return The size of the value added.
534 */ 534 */
535 faim_internal int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *userinfo) 535 faim_internal int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, guint16 type, aim_userinfo_t *userinfo)
536 { 536 {
537 guint8 buf[1024]; /* bleh */ 537 guint8 buf[1024]; /* bleh */
538 aim_bstream_t bs; 538 ByteStream bs;
539 539
540 aim_bstream_init(&bs, buf, sizeof(buf)); 540 aim_bstream_init(&bs, buf, sizeof(buf));
541 541
542 aim_putuserinfo(&bs, userinfo); 542 aim_putuserinfo(&bs, userinfo);
543 543
555 */ 555 */
556 faim_internal int aim_tlvlist_add_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance) 556 faim_internal int aim_tlvlist_add_chatroom(aim_tlvlist_t **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance)
557 { 557 {
558 guint8 *buf; 558 guint8 *buf;
559 int len; 559 int len;
560 aim_bstream_t bs; 560 ByteStream bs;
561 561
562 len = 2 + 1 + strlen(roomname) + 2; 562 len = 2 + 1 + strlen(roomname) + 2;
563 563
564 if (!(buf = malloc(len))) 564 if (!(buf = malloc(len)))
565 return 0; 565 return 0;
608 */ 608 */
609 faim_internal int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl) 609 faim_internal int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, guint16 type, aim_tlvlist_t **tl)
610 { 610 {
611 guint8 *buf; 611 guint8 *buf;
612 int buflen; 612 int buflen;
613 aim_bstream_t bs; 613 ByteStream bs;
614 614
615 buflen = aim_tlvlist_size(tl); 615 buflen = aim_tlvlist_size(tl);
616 616
617 if (buflen <= 0) 617 if (buflen <= 0)
618 return 0; 618 return 0;
776 * 776 *
777 * @param bs Input bstream 777 * @param bs Input bstream
778 * @param list Source TLV chain 778 * @param list Source TLV chain
779 * @return Return 0 if the destination bstream is too small. 779 * @return Return 0 if the destination bstream is too small.
780 */ 780 */
781 faim_internal int aim_tlvlist_write(aim_bstream_t *bs, aim_tlvlist_t **list) 781 faim_internal int aim_tlvlist_write(ByteStream *bs, aim_tlvlist_t **list)
782 { 782 {
783 int goodbuflen; 783 int goodbuflen;
784 aim_tlvlist_t *cur; 784 aim_tlvlist_t *cur;
785 785
786 /* do an initial run to test total length */ 786 /* do an initial run to test total length */