# HG changeset patch # User Mark Doliner # Date 1065397840 0 # Node ID 6d3d8f11e76534db5b3b2a8e83d49e39763434be # Parent e6b01bd8d6cda35ee0b0fb80bf3cddd954025dc5 [gaim-migrate @ 7734] I, uh, renamed some functions in libfaim. Functions that every file uses. A lot. So it looks like I did a lot of work, but I didn't. Yeah, in a typical work I actually only do about 15 minutes of real work. committer: Tailor Script diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/gtkprefs.c --- a/src/gtkprefs.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/gtkprefs.c Sun Oct 05 23:50:40 2003 +0000 @@ -847,7 +847,6 @@ "/gaim/gtk/blist/raise_on_events", vbox); vbox = gaim_gtk_make_frame (ret, _("Group Display")); - /* prefs_checkbox(_("Show _groups with no online buddies"), "/gaim/gtk/blist/show_empty_groups", vbox); */ prefs_checkbox(_("Show _numbers in groups"), "/gaim/gtk/blist/show_group_count", vbox); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/admin.c --- a/src/protocols/oscar/admin.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/admin.c Sun Oct 05 23:50:40 2003 +0000 @@ -110,10 +110,10 @@ snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); - aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), newnick); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(newnick), newnick); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -138,13 +138,13 @@ aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); /* new password TLV t(0002) */ - aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw); + aim_tlvlist_add_raw(&tl, 0x0002, strlen(newpw), newpw); /* current password TLV t(0012) */ - aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw); + aim_tlvlist_add_raw(&tl, 0x0012, strlen(curpw), curpw); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -167,10 +167,10 @@ snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); - aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail); + aim_tlvlist_add_raw(&tl, 0x0011, strlen(newemail), newemail); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -204,7 +204,7 @@ status = aimbs_get16(bs); /* This is 0x0013 if unable to confirm at this time */ - tl = aim_readtlvchain(bs); + tl = aim_tlvlist_read(bs); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, status); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/aim.h --- a/src/protocols/oscar/aim.h Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/aim.h Sun Oct 05 23:50:40 2003 +0000 @@ -1344,56 +1344,49 @@ +#if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV) /* tlv.c - TLV handling */ -#if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV) -/* Generic TLV structure. */ + +/* TLV structure */ typedef struct aim_tlv_s { fu16_t type; fu16_t length; fu8_t *value; } aim_tlv_t; -/* List of above. */ +/* TLV List structure */ typedef struct aim_tlvlist_s { aim_tlv_t *tlv; struct aim_tlvlist_s *next; } aim_tlvlist_t; -/* TLV-handling functions */ +/* TLV handling functions */ +faim_internal aim_tlv_t *aim_tlv_gettlv(aim_tlvlist_t *list, fu16_t type, const int nth); +faim_internal char *aim_tlv_getstr(aim_tlvlist_t *list, const fu16_t type, const int nth); +faim_internal fu8_t aim_tlv_get8(aim_tlvlist_t *list, const fu16_t type, const int nth); +faim_internal fu16_t aim_tlv_get16(aim_tlvlist_t *list, const fu16_t type, const int nth); +faim_internal fu32_t aim_tlv_get32(aim_tlvlist_t *list, const fu16_t type, const int nth); -#if 0 -/* Very, very raw TLV handling. */ -faim_internal int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v); -faim_internal int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v); -faim_internal int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v); -faim_internal int aim_puttlv_raw(fu8_t *buf, const fu16_t t, const fu16_t l, const fu8_t *v); -#endif +/* TLV list handling functions */ +faim_internal aim_tlvlist_t *aim_tlvlist_read(aim_bstream_t *bs); +faim_internal aim_tlvlist_t *aim_tlvlist_readnum(aim_bstream_t *bs, fu16_t num); +faim_internal aim_tlvlist_t *aim_tlvlist_readlen(aim_bstream_t *bs, fu16_t len); +faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig); -/* TLV list handling. */ -faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs); -faim_internal aim_tlvlist_t *aim_readtlvchain_num(aim_bstream_t *bs, fu16_t num); -faim_internal aim_tlvlist_t *aim_readtlvchain_len(aim_bstream_t *bs, fu16_t len); -faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig); -faim_internal int aim_counttlvchain(aim_tlvlist_t **list); -faim_internal int aim_sizetlvchain(aim_tlvlist_t **list); +faim_internal int aim_tlvlist_count(aim_tlvlist_t **list); +faim_internal int aim_tlvlist_size(aim_tlvlist_t **list); faim_internal int aim_tlvlist_cmp(aim_tlvlist_t *one, aim_tlvlist_t *two); -faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list); -faim_internal void aim_freetlvchain(aim_tlvlist_t **list); - -faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, fu16_t type, const int nth); -faim_internal char *aim_gettlv_str(aim_tlvlist_t *list, const fu16_t type, const int nth); -faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t type, const int nth); -faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t type, const int nth); -faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t type, const int nth); +faim_internal int aim_tlvlist_write(aim_bstream_t *bs, aim_tlvlist_t **list); +faim_internal void aim_tlvlist_free(aim_tlvlist_t **list); -faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t length, const fu8_t *value); -faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t type); -faim_internal int aim_addtlvtochain8(aim_tlvlist_t **list, const fu16_t type, const fu8_t value); -faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t type, const fu16_t value); -faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t type, const fu32_t value); -faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t type, const fu32_t caps); -faim_internal int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *ui); -faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl); +faim_internal int aim_tlvlist_add_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t length, const fu8_t *value); +faim_internal int aim_tlvlist_add_noval(aim_tlvlist_t **list, const fu16_t type); +faim_internal int aim_tlvlist_add_8(aim_tlvlist_t **list, const fu16_t type, const fu8_t value); +faim_internal int aim_tlvlist_add_16(aim_tlvlist_t **list, const fu16_t type, const fu16_t value); +faim_internal int aim_tlvlist_add_32(aim_tlvlist_t **list, const fu16_t type, const fu32_t value); +faim_internal int aim_tlvlist_add_caps(aim_tlvlist_t **list, const fu16_t type, const fu32_t caps); +faim_internal int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *userinfo); +faim_internal int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl); faim_internal int aim_tlvlist_replace_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t lenth, const fu8_t *value); faim_internal int aim_tlvlist_replace_noval(aim_tlvlist_t **list, const fu16_t type); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/auth.c --- a/src/protocols/oscar/auth.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/auth.c Sun Oct 05 23:50:40 2003 +0000 @@ -30,9 +30,9 @@ return -ENOMEM; aimbs_put32(&fr->data, 0x00000001); - aim_addtlvtochain_raw(&tl, 0x0006, length, chipsahoy); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_add_raw(&tl, 0x0006, length, chipsahoy); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -140,9 +140,9 @@ snacid = aim_cachesnac(sess, 0x0017, 0x0006, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0017, 0x0006, 0x0000, snacid); - aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), sn); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -173,24 +173,24 @@ aim_encode_password(password, password_encoded); aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */ - aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), sn); - aim_addtlvtochain_raw(&tl, 0x0002, passwdlen, password_encoded); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); + aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); if (ci->clientstring) - aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); - aim_addtlvtochain16(&tl, 0x0016, (fu16_t)ci->clientid); - aim_addtlvtochain16(&tl, 0x0017, (fu16_t)ci->major); - aim_addtlvtochain16(&tl, 0x0018, (fu16_t)ci->minor); - aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point); - aim_addtlvtochain16(&tl, 0x001a, (fu16_t)ci->build); - aim_addtlvtochain32(&tl, 0x0014, (fu32_t)ci->distrib); /* distribution chan */ - aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); - aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country); + aim_tlvlist_add_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); + aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); + aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); + aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); + aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); + aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); + aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); /* distribution chan */ + aim_tlvlist_add_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); + aim_tlvlist_add_raw(&tl, 0x000e, strlen(ci->country), ci->country); - aim_writetlvchain(&fr->data, &tl); + aim_tlvlist_write(&fr->data, &tl); free(password_encoded); - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -251,37 +251,37 @@ snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid); - aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), sn); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(sn), sn); aim_encode_password_md5(password, key, digest); - aim_addtlvtochain_raw(&tl, 0x0025, 16, digest); + aim_tlvlist_add_raw(&tl, 0x0025, 16, digest); /* * Newer versions of winaim have an empty type x004c TLV here. */ if (ci->clientstring) - aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); - aim_addtlvtochain16(&tl, 0x0016, (fu16_t)ci->clientid); - aim_addtlvtochain16(&tl, 0x0017, (fu16_t)ci->major); - aim_addtlvtochain16(&tl, 0x0018, (fu16_t)ci->minor); - aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point); - aim_addtlvtochain16(&tl, 0x001a, (fu16_t)ci->build); - aim_addtlvtochain32(&tl, 0x0014, (fu32_t)ci->distrib); - aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country); - aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); + aim_tlvlist_add_raw(&tl, 0x0003, strlen(ci->clientstring), ci->clientstring); + aim_tlvlist_add_16(&tl, 0x0016, (fu16_t)ci->clientid); + aim_tlvlist_add_16(&tl, 0x0017, (fu16_t)ci->major); + aim_tlvlist_add_16(&tl, 0x0018, (fu16_t)ci->minor); + aim_tlvlist_add_16(&tl, 0x0019, (fu16_t)ci->point); + aim_tlvlist_add_16(&tl, 0x001a, (fu16_t)ci->build); + aim_tlvlist_add_32(&tl, 0x0014, (fu32_t)ci->distrib); + aim_tlvlist_add_raw(&tl, 0x000e, strlen(ci->country), ci->country); + aim_tlvlist_add_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); #ifndef NOSSI /* * If set, old-fashioned buddy lists will not work. You will need * to use SSI. */ - aim_addtlvtochain8(&tl, 0x004a, 0x01); + aim_tlvlist_add_8(&tl, 0x004a, 0x01); #endif - aim_writetlvchain(&fr->data, &tl); + aim_tlvlist_write(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -364,14 +364,14 @@ * Read block of TLVs. All further data is derived * from what is parsed here. */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* * No matter what, we should have a screen name. */ memset(sess->sn, 0, sizeof(sess->sn)); - if (aim_gettlv(tlvlist, 0x0001, 1)) { - info->sn = aim_gettlv_str(tlvlist, 0x0001, 1); + if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { + info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); strncpy(sess->sn, info->sn, sizeof(sess->sn)); } @@ -379,24 +379,24 @@ * Check for an error code. If so, we should also * have an error url. */ - if (aim_gettlv(tlvlist, 0x0008, 1)) - info->errorcode = aim_gettlv16(tlvlist, 0x0008, 1); - if (aim_gettlv(tlvlist, 0x0004, 1)) - info->errorurl = aim_gettlv_str(tlvlist, 0x0004, 1); + if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) + info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); + if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) + info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); /* * BOS server address. */ - if (aim_gettlv(tlvlist, 0x0005, 1)) - info->bosip = aim_gettlv_str(tlvlist, 0x0005, 1); + if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) + info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); /* * Authorization cookie. */ - if (aim_gettlv(tlvlist, 0x0006, 1)) { + if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { aim_tlv_t *tmptlv; - tmptlv = aim_gettlv(tlvlist, 0x0006, 1); + tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); info->cookielen = tmptlv->length; info->cookie = tmptlv->value; @@ -409,8 +409,8 @@ * family 0x0018 to check the status of your email. * XXX - Not really true! */ - if (aim_gettlv(tlvlist, 0x0011, 1)) - info->email = aim_gettlv_str(tlvlist, 0x0011, 1); + if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) + info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); /* * The registration status. (Not real sure what it means.) @@ -426,41 +426,41 @@ * Means you can use the admin family? (0x0007) * */ - if (aim_gettlv(tlvlist, 0x0013, 1)) - info->regstatus = aim_gettlv16(tlvlist, 0x0013, 1); + if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) + info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); - if (aim_gettlv(tlvlist, 0x0040, 1)) - info->latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1); - if (aim_gettlv(tlvlist, 0x0041, 1)) - info->latestbeta.url = aim_gettlv_str(tlvlist, 0x0041, 1); - if (aim_gettlv(tlvlist, 0x0042, 1)) - info->latestbeta.info = aim_gettlv_str(tlvlist, 0x0042, 1); - if (aim_gettlv(tlvlist, 0x0043, 1)) - info->latestbeta.name = aim_gettlv_str(tlvlist, 0x0043, 1); - if (aim_gettlv(tlvlist, 0x0048, 1)) + if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) + info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); + if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) + info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); + if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) + info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); + if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) + info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); + if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) ; /* no idea what this is */ - if (aim_gettlv(tlvlist, 0x0044, 1)) - info->latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1); - if (aim_gettlv(tlvlist, 0x0045, 1)) - info->latestrelease.url = aim_gettlv_str(tlvlist, 0x0045, 1); - if (aim_gettlv(tlvlist, 0x0046, 1)) - info->latestrelease.info = aim_gettlv_str(tlvlist, 0x0046, 1); - if (aim_gettlv(tlvlist, 0x0047, 1)) - info->latestrelease.name = aim_gettlv_str(tlvlist, 0x0047, 1); - if (aim_gettlv(tlvlist, 0x0049, 1)) + if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) + info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); + if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) + info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); + if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) + info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); + if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) + info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); + if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) ; /* no idea what this is */ /* * URL to change password. */ - if (aim_gettlv(tlvlist, 0x0054, 1)) - info->chpassurl = aim_gettlv_str(tlvlist, 0x0054, 1); + if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) + info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); /* * Unknown. Seen on an @mac.com screen name with value of 0x003f */ - if (aim_gettlv(tlvlist, 0x0055, 1)) + if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) ; sess->authinfo = info; @@ -468,7 +468,7 @@ if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) ret = userfunc(sess, rx, info); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/bos.c --- a/src/protocols/oscar/bos.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/bos.c Sun Oct 05 23:50:40 2003 +0000 @@ -26,24 +26,24 @@ /* * TLVs follow */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* * TLV type 0x0001: Maximum number of buddies on permit list. */ - if (aim_gettlv(tlvlist, 0x0001, 1)) - maxpermits = aim_gettlv16(tlvlist, 0x0001, 1); + if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) + maxpermits = aim_tlv_get16(tlvlist, 0x0001, 1); /* * TLV type 0x0002: Maximum number of buddies on deny list. */ - if (aim_gettlv(tlvlist, 0x0002, 1)) - maxdenies = aim_gettlv16(tlvlist, 0x0002, 1); + if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) + maxdenies = aim_tlv_get16(tlvlist, 0x0002, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, maxpermits, maxdenies); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/buddylist.c --- a/src/protocols/oscar/buddylist.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/buddylist.c Sun Oct 05 23:50:40 2003 +0000 @@ -33,13 +33,13 @@ /* * TLVs follow */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* * TLV type 0x0001: Maximum number of buddies. */ - if (aim_gettlv(tlvlist, 0x0001, 1)) - maxbuddies = aim_gettlv16(tlvlist, 0x0001, 1); + if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) + maxbuddies = aim_tlv_get16(tlvlist, 0x0001, 1); /* * TLV type 0x0002: Maximum number of watchers. @@ -49,8 +49,8 @@ * other IM protocol.) * */ - if (aim_gettlv(tlvlist, 0x0002, 1)) - maxwatchers = aim_gettlv16(tlvlist, 0x0002, 1); + if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) + maxwatchers = aim_tlv_get16(tlvlist, 0x0002, 1); /* * TLV type 0x0003: Unknown. @@ -61,7 +61,7 @@ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, maxbuddies, maxwatchers); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/chat.c --- a/src/protocols/oscar/chat.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/chat.c Sun Oct 05 23:50:40 2003 +0000 @@ -103,7 +103,7 @@ aimbs_putraw(&bs, roomname, strlen(roomname)); aimbs_put16(&bs, instance); - aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); + aim_tlvlist_add_raw(list, type, aim_bstream_curpos(&bs), buf); free(buf); @@ -143,8 +143,8 @@ aimbs_put16(&fr->data, 0x000e); aim_addtlvtochain_chatroom(&tl, 0x0001, exchange, roomname, instance); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -249,19 +249,19 @@ aimbs_putraw(&hdrbs, ckstr, sizeof(ckstr)); /* I think... */ aim_putcap(&hdrbs, AIM_CAPS_CHAT); - aim_addtlvtochain16(&itl, 0x000a, 0x0001); - aim_addtlvtochain_noval(&itl, 0x000f); - aim_addtlvtochain_raw(&itl, 0x000c, strlen(msg), msg); + aim_tlvlist_add_16(&itl, 0x000a, 0x0001); + aim_tlvlist_add_noval(&itl, 0x000f); + aim_tlvlist_add_raw(&itl, 0x000c, strlen(msg), msg); aim_addtlvtochain_chatroom(&itl, 0x2711, exchange, roomname, instance); - aim_writetlvchain(&hdrbs, &itl); + aim_tlvlist_write(&hdrbs, &itl); - aim_addtlvtochain_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); - aim_writetlvchain(&fr->data, &otl); + aim_tlvlist_write(&fr->data, &otl); free(hdr); - aim_freetlvchain(&itl); - aim_freetlvchain(&otl); + aim_tlvlist_free(&itl); + aim_tlvlist_free(&otl); aim_tx_enqueue(sess, fr); @@ -307,29 +307,29 @@ /* * Everything else are TLVs. */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* * TLV type 0x006a is the room name in Human Readable Form. */ - if (aim_gettlv(tlvlist, 0x006a, 1)) - roomname = aim_gettlv_str(tlvlist, 0x006a, 1); + if (aim_tlv_gettlv(tlvlist, 0x006a, 1)) + roomname = aim_tlv_getstr(tlvlist, 0x006a, 1); /* * Type 0x006f: Number of occupants. */ - if (aim_gettlv(tlvlist, 0x006f, 1)) - usercount = aim_gettlv16(tlvlist, 0x006f, 1); + if (aim_tlv_gettlv(tlvlist, 0x006f, 1)) + usercount = aim_tlv_get16(tlvlist, 0x006f, 1); /* * Type 0x0073: Occupant list. */ - if (aim_gettlv(tlvlist, 0x0073, 1)) { + if (aim_tlv_gettlv(tlvlist, 0x0073, 1)) { int curoccupant = 0; aim_tlv_t *tmptlv; aim_bstream_t occbs; - tmptlv = aim_gettlv(tlvlist, 0x0073, 1); + tmptlv = aim_tlv_gettlv(tlvlist, 0x0073, 1); /* Allocate enough userinfo structs for all occupants */ userinfo = calloc(usercount, sizeof(aim_userinfo_t)); @@ -343,75 +343,75 @@ /* * Type 0x00c9: Flags. (AIM_CHATROOM_FLAG) */ - if (aim_gettlv(tlvlist, 0x00c9, 1)) - flags = aim_gettlv16(tlvlist, 0x00c9, 1); + if (aim_tlv_gettlv(tlvlist, 0x00c9, 1)) + flags = aim_tlv_get16(tlvlist, 0x00c9, 1); /* * Type 0x00ca: Creation time (4 bytes) */ - if (aim_gettlv(tlvlist, 0x00ca, 1)) - creationtime = aim_gettlv32(tlvlist, 0x00ca, 1); + if (aim_tlv_gettlv(tlvlist, 0x00ca, 1)) + creationtime = aim_tlv_get32(tlvlist, 0x00ca, 1); /* * Type 0x00d1: Maximum Message Length */ - if (aim_gettlv(tlvlist, 0x00d1, 1)) - maxmsglen = aim_gettlv16(tlvlist, 0x00d1, 1); + if (aim_tlv_gettlv(tlvlist, 0x00d1, 1)) + maxmsglen = aim_tlv_get16(tlvlist, 0x00d1, 1); /* * Type 0x00d2: Unknown. (2 bytes) */ - if (aim_gettlv(tlvlist, 0x00d2, 1)) - unknown_d2 = aim_gettlv16(tlvlist, 0x00d2, 1); + if (aim_tlv_gettlv(tlvlist, 0x00d2, 1)) + unknown_d2 = aim_tlv_get16(tlvlist, 0x00d2, 1); /* * Type 0x00d3: Room Description */ - if (aim_gettlv(tlvlist, 0x00d3, 1)) - roomdesc = aim_gettlv_str(tlvlist, 0x00d3, 1); + if (aim_tlv_gettlv(tlvlist, 0x00d3, 1)) + roomdesc = aim_tlv_getstr(tlvlist, 0x00d3, 1); /* * Type 0x000d4: Unknown (flag only) */ - if (aim_gettlv(tlvlist, 0x000d4, 1)) + if (aim_tlv_gettlv(tlvlist, 0x000d4, 1)) ; /* * Type 0x00d5: Unknown. (1 byte) */ - if (aim_gettlv(tlvlist, 0x00d5, 1)) - unknown_d5 = aim_gettlv8(tlvlist, 0x00d5, 1); + if (aim_tlv_gettlv(tlvlist, 0x00d5, 1)) + unknown_d5 = aim_tlv_get8(tlvlist, 0x00d5, 1); /* * Type 0x00d6: Encoding 1 ("us-ascii") */ - if (aim_gettlv(tlvlist, 0x000d6, 1)) + if (aim_tlv_gettlv(tlvlist, 0x000d6, 1)) ; /* * Type 0x00d7: Language 1 ("en") */ - if (aim_gettlv(tlvlist, 0x000d7, 1)) + if (aim_tlv_gettlv(tlvlist, 0x000d7, 1)) ; /* * Type 0x00d8: Encoding 2 ("us-ascii") */ - if (aim_gettlv(tlvlist, 0x000d8, 1)) + if (aim_tlv_gettlv(tlvlist, 0x000d8, 1)) ; /* * Type 0x00d9: Language 2 ("en") */ - if (aim_gettlv(tlvlist, 0x000d9, 1)) + if (aim_tlv_gettlv(tlvlist, 0x000d9, 1)) ; /* * Type 0x00da: Maximum visible message length */ - if (aim_gettlv(tlvlist, 0x000da, 1)) - maxvisiblemsglen = aim_gettlv16(tlvlist, 0x00da, 1); + if (aim_tlv_gettlv(tlvlist, 0x000da, 1)) + maxvisiblemsglen = aim_tlv_get16(tlvlist, 0x00da, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { ret = userfunc(sess, @@ -437,7 +437,7 @@ free(userinfo); free(roomname); free(roomdesc); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -515,24 +515,24 @@ /* * Type 1: Flag meaning this message is destined to the room. */ - aim_addtlvtochain_noval(&otl, 0x0001); + aim_tlvlist_add_noval(&otl, 0x0001); /* * Type 6: Reflect */ if (!(flags & AIM_CHATFLAGS_NOREFLECT)) - aim_addtlvtochain_noval(&otl, 0x0006); + aim_tlvlist_add_noval(&otl, 0x0006); /* * Type 7: Autoresponse */ if (flags & AIM_CHATFLAGS_AWAY) - aim_addtlvtochain_noval(&otl, 0x0007); + aim_tlvlist_add_noval(&otl, 0x0007); /* * SubTLV: Type 1: Message */ - aim_addtlvtochain_raw(&itl, 0x0001, msglen, msg); + aim_tlvlist_add_raw(&itl, 0x0001, msglen, msg); /* * Type 5: Message block. Contains more TLVs. @@ -541,12 +541,12 @@ * put in a message TLV however. * */ - aim_addtlvtochain_frozentlvlist(&otl, 0x0005, &itl); + aim_tlvlist_add_frozentlvlist(&otl, 0x0005, &itl); - aim_writetlvchain(&fr->data, &otl); + aim_tlvlist_write(&fr->data, &otl); - aim_freetlvchain(&itl); - aim_freetlvchain(&otl); + aim_tlvlist_free(&itl); + aim_tlvlist_free(&otl); aim_tx_enqueue(sess, fr); @@ -620,16 +620,16 @@ /* * Start parsing TLVs right away. */ - otl = aim_readtlvchain(bs); + otl = aim_tlvlist_read(bs); /* * Type 0x0003: Source User Information */ - if (aim_gettlv(otl, 0x0003, 1)) { + if (aim_tlv_gettlv(otl, 0x0003, 1)) { aim_tlv_t *userinfotlv; aim_bstream_t tbs; - userinfotlv = aim_gettlv(otl, 0x0003, 1); + userinfotlv = aim_tlv_gettlv(otl, 0x0003, 1); aim_bstream_init(&tbs, userinfotlv->value, userinfotlv->length); aim_info_extract(sess, &tbs, &userinfo); @@ -639,28 +639,28 @@ * Type 0x0001: If present, it means it was a message to the * room (as opposed to a whisper). */ - if (aim_gettlv(otl, 0x0001, 1)) + if (aim_tlv_gettlv(otl, 0x0001, 1)) ; /* * Type 0x0005: Message Block. Conains more TLVs. */ - if (aim_gettlv(otl, 0x0005, 1)) { + if (aim_tlv_gettlv(otl, 0x0005, 1)) { aim_tlvlist_t *itl; aim_tlv_t *msgblock; aim_bstream_t tbs; - msgblock = aim_gettlv(otl, 0x0005, 1); + msgblock = aim_tlv_gettlv(otl, 0x0005, 1); aim_bstream_init(&tbs, msgblock->value, msgblock->length); - itl = aim_readtlvchain(&tbs); + itl = aim_tlvlist_read(&tbs); /* * Type 0x0001: Message. */ - if (aim_gettlv(itl, 0x0001, 1)) - msg = aim_gettlv_str(itl, 0x0001, 1); + if (aim_tlv_gettlv(itl, 0x0001, 1)) + msg = aim_tlv_getstr(itl, 0x0001, 1); - aim_freetlvchain(&itl); + aim_tlvlist_free(&itl); } if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) @@ -669,7 +669,7 @@ aim_info_free(&userinfo); free(cookie); free(msg); - aim_freetlvchain(&otl); + aim_tlvlist_free(&otl); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/chatnav.c --- a/src/protocols/oscar/chatnav.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/chatnav.c Sun Oct 05 23:50:40 2003 +0000 @@ -67,15 +67,15 @@ /* detail level */ aimbs_put8(&fr->data, 0x01); - aim_addtlvtochain_raw(&tl, 0x00d3, strlen(name), name); - aim_addtlvtochain_raw(&tl, 0x00d6, strlen(charset), charset); - aim_addtlvtochain_raw(&tl, 0x00d7, strlen(lang), lang); + aim_tlvlist_add_raw(&tl, 0x00d3, strlen(name), name); + aim_tlvlist_add_raw(&tl, 0x00d6, strlen(charset), charset); + aim_tlvlist_add_raw(&tl, 0x00d7, strlen(lang), lang); /* tlvcount */ - aimbs_put16(&fr->data, aim_counttlvchain(&tl)); - aim_writetlvchain(&fr->data, &tl); + aimbs_put16(&fr->data, aim_tlvlist_count(&tl)); + aim_tlvlist_write(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -92,13 +92,13 @@ fu8_t maxrooms = 0; aim_tlvlist_t *tlvlist, *innerlist; - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* * Type 0x0002: Maximum concurrent rooms. */ - if (aim_gettlv(tlvlist, 0x0002, 1)) - maxrooms = aim_gettlv8(tlvlist, 0x0002, 1); + if (aim_tlv_gettlv(tlvlist, 0x0002, 1)) + maxrooms = aim_tlv_get8(tlvlist, 0x0002, 1); /* * Type 0x0003: Exchange information @@ -107,7 +107,7 @@ * representing another exchange. * */ - for (curexchange = 0; ((exchangetlv = aim_gettlv(tlvlist, 0x0003, curexchange+1))); ) { + for (curexchange = 0; ((exchangetlv = aim_tlv_gettlv(tlvlist, 0x0003, curexchange+1))); ) { aim_bstream_t tbs; aim_bstream_init(&tbs, exchangetlv->value, exchangetlv->length); @@ -118,7 +118,7 @@ /* exchange number */ exchanges[curexchange-1].number = aimbs_get16(&tbs); - innerlist = aim_readtlvchain(&tbs); + innerlist = aim_tlvlist_read(&tbs); /* * Type 0x000a: Unknown. @@ -126,28 +126,28 @@ * Usually three bytes: 0x0114 (exchange 1) or 0x010f (others). * */ - if (aim_gettlv(innerlist, 0x000a, 1)) + if (aim_tlv_gettlv(innerlist, 0x000a, 1)) ; /* * Type 0x000d: Unknown. */ - if (aim_gettlv(innerlist, 0x000d, 1)) + if (aim_tlv_gettlv(innerlist, 0x000d, 1)) ; /* * Type 0x0004: Unknown */ - if (aim_gettlv(innerlist, 0x0004, 1)) + if (aim_tlv_gettlv(innerlist, 0x0004, 1)) ; /* * Type 0x0002: Unknown */ - if (aim_gettlv(innerlist, 0x0002, 1)) { + if (aim_tlv_gettlv(innerlist, 0x0002, 1)) { fu16_t classperms; - classperms = aim_gettlv16(innerlist, 0x0002, 1); + classperms = aim_tlv_get16(innerlist, 0x0002, 1); faimdprintf(sess, 1, "faim: class permissions %x\n", classperms); } @@ -161,45 +161,45 @@ * 8 Occupant Peek Allowed * */ - if (aim_gettlv(innerlist, 0x00c9, 1)) - exchanges[curexchange-1].flags = aim_gettlv16(innerlist, 0x00c9, 1); + if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) + exchanges[curexchange-1].flags = aim_tlv_get16(innerlist, 0x00c9, 1); /* * Type 0x00ca: Creation Date */ - if (aim_gettlv(innerlist, 0x00ca, 1)) + if (aim_tlv_gettlv(innerlist, 0x00ca, 1)) ; /* * Type 0x00d0: Mandatory Channels? */ - if (aim_gettlv(innerlist, 0x00d0, 1)) + if (aim_tlv_gettlv(innerlist, 0x00d0, 1)) ; /* * Type 0x00d1: Maximum Message length */ - if (aim_gettlv(innerlist, 0x00d1, 1)) + if (aim_tlv_gettlv(innerlist, 0x00d1, 1)) ; /* * Type 0x00d2: Maximum Occupancy? */ - if (aim_gettlv(innerlist, 0x00d2, 1)) + if (aim_tlv_gettlv(innerlist, 0x00d2, 1)) ; /* * Type 0x00d3: Exchange Description */ - if (aim_gettlv(innerlist, 0x00d3, 1)) - exchanges[curexchange-1].name = aim_gettlv_str(innerlist, 0x00d3, 1); + if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) + exchanges[curexchange-1].name = aim_tlv_getstr(innerlist, 0x00d3, 1); else exchanges[curexchange-1].name = NULL; /* * Type 0x00d4: Exchange Description URL */ - if (aim_gettlv(innerlist, 0x00d4, 1)) + if (aim_tlv_gettlv(innerlist, 0x00d4, 1)) ; /* @@ -210,51 +210,51 @@ * 2 Exchange creation allowed * */ - if (aim_gettlv(innerlist, 0x00d5, 1)) { + if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) { fu8_t createperms; - createperms = aim_gettlv8(innerlist, 0x00d5, 1); + createperms = aim_tlv_get8(innerlist, 0x00d5, 1); } /* * Type 0x00d6: Character Set (First Time) */ - if (aim_gettlv(innerlist, 0x00d6, 1)) - exchanges[curexchange-1].charset1 = aim_gettlv_str(innerlist, 0x00d6, 1); + if (aim_tlv_gettlv(innerlist, 0x00d6, 1)) + exchanges[curexchange-1].charset1 = aim_tlv_getstr(innerlist, 0x00d6, 1); else exchanges[curexchange-1].charset1 = NULL; /* * Type 0x00d7: Language (First Time) */ - if (aim_gettlv(innerlist, 0x00d7, 1)) - exchanges[curexchange-1].lang1 = aim_gettlv_str(innerlist, 0x00d7, 1); + if (aim_tlv_gettlv(innerlist, 0x00d7, 1)) + exchanges[curexchange-1].lang1 = aim_tlv_getstr(innerlist, 0x00d7, 1); else exchanges[curexchange-1].lang1 = NULL; /* * Type 0x00d8: Character Set (Second Time) */ - if (aim_gettlv(innerlist, 0x00d8, 1)) - exchanges[curexchange-1].charset2 = aim_gettlv_str(innerlist, 0x00d8, 1); + if (aim_tlv_gettlv(innerlist, 0x00d8, 1)) + exchanges[curexchange-1].charset2 = aim_tlv_getstr(innerlist, 0x00d8, 1); else exchanges[curexchange-1].charset2 = NULL; /* * Type 0x00d9: Language (Second Time) */ - if (aim_gettlv(innerlist, 0x00d9, 1)) - exchanges[curexchange-1].lang2 = aim_gettlv_str(innerlist, 0x00d9, 1); + if (aim_tlv_gettlv(innerlist, 0x00d9, 1)) + exchanges[curexchange-1].lang2 = aim_tlv_getstr(innerlist, 0x00d9, 1); else exchanges[curexchange-1].lang2 = NULL; /* * Type 0x00da: Unknown */ - if (aim_gettlv(innerlist, 0x00da, 1)) + if (aim_tlv_gettlv(innerlist, 0x00da, 1)) ; - aim_freetlvchain(&innerlist); + aim_tlvlist_free(&innerlist); } /* @@ -271,7 +271,7 @@ free(exchanges[curexchange].lang2); } free(exchanges); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -289,11 +289,11 @@ int ret = 0; aim_bstream_t bbbs; - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); - if (!(bigblock = aim_gettlv(tlvlist, 0x0004, 1))) { + if (!(bigblock = aim_tlv_gettlv(tlvlist, 0x0004, 1))) { faimdprintf(sess, 0, "no bigblock in top tlv in create room response\n"); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return 0; } @@ -307,35 +307,35 @@ if (detaillevel != 0x02) { faimdprintf(sess, 0, "unknown detaillevel in create room response (0x%02x)\n", detaillevel); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); free(ck); return 0; } unknown = aimbs_get16(&bbbs); - innerlist = aim_readtlvchain(&bbbs); + innerlist = aim_tlvlist_read(&bbbs); - if (aim_gettlv(innerlist, 0x006a, 1)) - fqcn = aim_gettlv_str(innerlist, 0x006a, 1); + if (aim_tlv_gettlv(innerlist, 0x006a, 1)) + fqcn = aim_tlv_getstr(innerlist, 0x006a, 1); - if (aim_gettlv(innerlist, 0x00c9, 1)) - flags = aim_gettlv16(innerlist, 0x00c9, 1); + if (aim_tlv_gettlv(innerlist, 0x00c9, 1)) + flags = aim_tlv_get16(innerlist, 0x00c9, 1); - if (aim_gettlv(innerlist, 0x00ca, 1)) - createtime = aim_gettlv32(innerlist, 0x00ca, 1); + if (aim_tlv_gettlv(innerlist, 0x00ca, 1)) + createtime = aim_tlv_get32(innerlist, 0x00ca, 1); - if (aim_gettlv(innerlist, 0x00d1, 1)) - maxmsglen = aim_gettlv16(innerlist, 0x00d1, 1); + if (aim_tlv_gettlv(innerlist, 0x00d1, 1)) + maxmsglen = aim_tlv_get16(innerlist, 0x00d1, 1); - if (aim_gettlv(innerlist, 0x00d2, 1)) - maxoccupancy = aim_gettlv16(innerlist, 0x00d2, 1); + if (aim_tlv_gettlv(innerlist, 0x00d2, 1)) + maxoccupancy = aim_tlv_get16(innerlist, 0x00d2, 1); - if (aim_gettlv(innerlist, 0x00d3, 1)) - name = aim_gettlv_str(innerlist, 0x00d3, 1); + if (aim_tlv_gettlv(innerlist, 0x00d3, 1)) + name = aim_tlv_getstr(innerlist, 0x00d3, 1); - if (aim_gettlv(innerlist, 0x00d5, 1)) - createperms = aim_gettlv8(innerlist, 0x00d5, 1); + if (aim_tlv_gettlv(innerlist, 0x00d5, 1)) + createperms = aim_tlv_get8(innerlist, 0x00d5, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) { ret = userfunc(sess, rx, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); @@ -344,8 +344,8 @@ free(ck); free(name); free(fqcn); - aim_freetlvchain(&innerlist); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&innerlist); + aim_tlvlist_free(&tlvlist); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/email.c --- a/src/protocols/oscar/email.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/email.c Sun Oct 05 23:50:40 2003 +0000 @@ -104,9 +104,9 @@ new->cookie8 = cookie8; new->cookie16 = cookie16; - tlvlist = aim_readtlvchain_num(bs, aimbs_get16(bs)); + tlvlist = aim_tlvlist_readnum(bs, aimbs_get16(bs)); - tmp = aim_gettlv16(tlvlist, 0x0080, 1); + tmp = aim_tlv_get16(tlvlist, 0x0080, 1); if (tmp) { if (new->nummsgs < tmp) havenewmail = 1; @@ -117,18 +117,18 @@ havenewmail = 1; new->nummsgs++; /* We know we have at least 1 new email */ } - new->url = aim_gettlv_str(tlvlist, 0x0007, 1); - if (!(new->unread = aim_gettlv8(tlvlist, 0x0081, 1))) { + new->url = aim_tlv_getstr(tlvlist, 0x0007, 1); + if (!(new->unread = aim_tlv_get8(tlvlist, 0x0081, 1))) { havenewmail = 0; new->nummsgs = 0; } - new->domain = aim_gettlv_str(tlvlist, 0x0082, 1); - new->flag = aim_gettlv16(tlvlist, 0x0084, 1); + new->domain = aim_tlv_getstr(tlvlist, 0x0082, 1); + new->flag = aim_tlv_get16(tlvlist, 0x0084, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, new, havenewmail); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/icq.c --- a/src/protocols/oscar/icq.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/icq.c Sun Oct 05 23:50:40 2003 +0000 @@ -367,8 +367,8 @@ fu32_t ouruin; fu16_t cmdlen, cmd, reqid; - if (!(tl = aim_readtlvchain(bs)) || !(datatlv = aim_gettlv(tl, 0x0001, 1))) { - aim_freetlvchain(&tl); + if (!(tl = aim_tlvlist_read(bs)) || !(datatlv = aim_tlv_gettlv(tl, 0x0001, 1))) { + aim_tlvlist_free(&tl); faimdprintf(sess, 0, "corrupt ICQ response\n"); return 0; } @@ -548,7 +548,7 @@ } } - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/im.c --- a/src/protocols/oscar/im.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/im.c Sun Oct 05 23:50:40 2003 +0000 @@ -632,7 +632,7 @@ /* ICBM header */ aim_im_puticbm(&fr->data, ck, 0x0002, sn); - aim_addtlvtochain_noval(&tl, 0x0003); + aim_tlvlist_add_noval(&tl, 0x0003); hdrlen = 2+8+16+6+8+6+4; hdr = malloc(hdrlen); @@ -642,20 +642,20 @@ aimbs_putraw(&hdrbs, ck, 8); aim_putcap(&hdrbs, AIM_CAPS_DIRECTIM); - aim_addtlvtochain16(&itl, 0x000a, 0x0001); - aim_addtlvtochain_raw(&itl, 0x0003, 4, ip); - aim_addtlvtochain16(&itl, 0x0005, port); - aim_addtlvtochain_noval(&itl, 0x000f); + aim_tlvlist_add_16(&itl, 0x000a, 0x0001); + aim_tlvlist_add_raw(&itl, 0x0003, 4, ip); + aim_tlvlist_add_16(&itl, 0x0005, port); + aim_tlvlist_add_noval(&itl, 0x000f); - aim_writetlvchain(&hdrbs, &itl); + aim_tlvlist_write(&hdrbs, &itl); - aim_addtlvtochain_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); + aim_tlvlist_add_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); - aim_writetlvchain(&fr->data, &tl); + aim_tlvlist_write(&fr->data, &tl); free(hdr); - aim_freetlvchain(&itl); - aim_freetlvchain(&tl); + aim_tlvlist_free(&itl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -687,11 +687,11 @@ int buflen; aim_bstream_t bs; - aim_addtlvtochain16(&subtl, 0x000a, 0x0001); - aim_addtlvtochain_noval(&subtl, 0x000f); -/* aim_addtlvtochain_raw(&subtl, 0x000e, 2, "en"); - aim_addtlvtochain_raw(&subtl, 0x000d, 8, "us-ascii"); - aim_addtlvtochain_raw(&subtl, 0x000c, 24, "Please accept this file."); */ + aim_tlvlist_add_16(&subtl, 0x000a, 0x0001); + aim_tlvlist_add_noval(&subtl, 0x000f); +/* aim_tlvlist_add_raw(&subtl, 0x000e, 2, "en"); + aim_tlvlist_add_raw(&subtl, 0x000d, 8, "us-ascii"); + aim_tlvlist_add_raw(&subtl, 0x000c, 24, "Please accept this file."); */ if (oft_info->clientip) { fu8_t ip[4]; char *nexttoken; @@ -702,9 +702,9 @@ nexttoken = strtok(NULL, "."); i++; } - aim_addtlvtochain_raw(&subtl, 0x0003, 4, ip); + aim_tlvlist_add_raw(&subtl, 0x0003, 4, ip); } - aim_addtlvtochain16(&subtl, 0x0005, oft_info->port); + aim_tlvlist_add_16(&subtl, 0x0005, oft_info->port); /* TLV t(2711) */ buflen = 2+2+4+strlen(oft_info->fh.name)+1; @@ -718,7 +718,7 @@ aimbs_putraw(&bs, oft_info->fh.name, strlen(oft_info->fh.name)); aimbs_put8(&bs, 0x00); - aim_addtlvtochain_raw(&subtl, 0x2711, bs.len, bs.data); + aim_tlvlist_add_raw(&subtl, 0x2711, bs.len, bs.data); free(buf); } @@ -728,22 +728,22 @@ aim_bstream_t bs; /* TLV t(0005) - Encompasses everything from above. Gee. */ - buflen = 2+8+16+aim_sizetlvchain(&subtl); + buflen = 2+8+16+aim_tlvlist_size(&subtl); buf = malloc(buflen); aim_bstream_init(&bs, buf, buflen); aimbs_put16(&bs, AIM_RENDEZVOUS_PROPOSE); aimbs_putraw(&bs, oft_info->cookie, 8); aim_putcap(&bs, AIM_CAPS_SENDFILE); - aim_writetlvchain(&bs, &subtl); - aim_freetlvchain(&subtl); - aim_addtlvtochain_raw(&tl, 0x0005, bs.len, bs.data); + aim_tlvlist_write(&bs, &subtl); + aim_tlvlist_free(&subtl); + aim_tlvlist_add_raw(&tl, 0x0005, bs.len, bs.data); free(buf); /* TLV t(0003) - Request an ack */ - aim_addtlvtochain_noval(&tl, 0x0003); + aim_tlvlist_add_noval(&tl, 0x0003); } - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0004, 0x0006, AIM_SNACFLAGS_DESTRUCTOR, oft_info->cookie, sizeof(oft_info->cookie)); @@ -753,8 +753,8 @@ aim_im_puticbm(&fr->data, oft_info->cookie, 0x0002, oft_info->sn); /* All that crap from above (the 0x0005 TLV and the 0x0003 TLV) */ - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -1032,14 +1032,14 @@ snlen = aimbs_get8(bs); sn = aimbs_getstr(bs, snlen); - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); - if (aim_gettlv(tlvlist, 0x0003, 1)) + if (aim_tlv_gettlv(tlvlist, 0x0003, 1)) icbmflags |= AIM_IMFLAGS_ACK; - if (aim_gettlv(tlvlist, 0x0004, 1)) + if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) icbmflags |= AIM_IMFLAGS_AWAY; - if ((msgblock = aim_gettlv(tlvlist, 0x0002, 1))) { + if ((msgblock = aim_tlv_gettlv(tlvlist, 0x0002, 1))) { aim_bstream_t mbs; int featurelen, msglen; @@ -1064,7 +1064,7 @@ ret = userfunc(sess, rx, channel, sn, msg, icbmflags, flag1, flag2); free(sn); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -1654,7 +1654,7 @@ /* * There's another block of TLVs embedded in the type 5 here. */ - block1 = aim_gettlv(tlvlist, 0x0005, 1); + block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1); aim_bstream_init(&bbs, block1->value, block1->length); /* @@ -1685,17 +1685,17 @@ * * Ack packets for instance have nothing more to them. */ - list2 = aim_readtlvchain(&bbs); + list2 = aim_tlvlist_read(&bbs); /* * IP address to proxy the file transfer through. * * XXX - I don't like this. Maybe just read in an int? Or inet_ntoa... */ - if (aim_gettlv(list2, 0x0002, 1)) { + if (aim_tlv_gettlv(list2, 0x0002, 1)) { aim_tlv_t *iptlv; - iptlv = aim_gettlv(list2, 0x0002, 1); + iptlv = aim_tlv_gettlv(list2, 0x0002, 1); if (iptlv->length == 4) snprintf(proxyip, sizeof(proxyip), "%hhd.%hhd.%hhd.%hhd", iptlv->value[0], iptlv->value[1], @@ -1705,10 +1705,10 @@ /* * IP address from the perspective of the client. */ - if (aim_gettlv(list2, 0x0003, 1)) { + if (aim_tlv_gettlv(list2, 0x0003, 1)) { aim_tlv_t *iptlv; - iptlv = aim_gettlv(list2, 0x0003, 1); + iptlv = aim_tlv_gettlv(list2, 0x0003, 1); if (iptlv->length == 4) snprintf(clientip, sizeof(clientip), "%hhd.%hhd.%hhd.%hhd", iptlv->value[0], iptlv->value[1], @@ -1720,10 +1720,10 @@ * * This is added by the server. */ - if (aim_gettlv(list2, 0x0004, 1)) { + if (aim_tlv_gettlv(list2, 0x0004, 1)) { aim_tlv_t *iptlv; - iptlv = aim_gettlv(list2, 0x0004, 1); + iptlv = aim_tlv_gettlv(list2, 0x0004, 1); if (iptlv->length == 4) snprintf(verifiedip, sizeof(verifiedip), "%hhd.%hhd.%hhd.%hhd", iptlv->value[0], iptlv->value[1], @@ -1733,47 +1733,47 @@ /* * Port number for something. */ - if (aim_gettlv(list2, 0x0005, 1)) - args.port = aim_gettlv16(list2, 0x0005, 1); + if (aim_tlv_gettlv(list2, 0x0005, 1)) + args.port = aim_tlv_get16(list2, 0x0005, 1); /* * Something to do with ft -- two bytes * 0x0001 - "I want to send you this file" * 0x0002 - "I will accept this file from you" */ - if (aim_gettlv(list2, 0x000a, 1)) + if (aim_tlv_gettlv(list2, 0x000a, 1)) ; /* * Error code. */ - if (aim_gettlv(list2, 0x000b, 1)) - args.errorcode = aim_gettlv16(list2, 0x000b, 1); + if (aim_tlv_gettlv(list2, 0x000b, 1)) + args.errorcode = aim_tlv_get16(list2, 0x000b, 1); /* * Invitation message / chat description. */ - if (aim_gettlv(list2, 0x000c, 1)) - args.msg = aim_gettlv_str(list2, 0x000c, 1); + if (aim_tlv_gettlv(list2, 0x000c, 1)) + args.msg = aim_tlv_getstr(list2, 0x000c, 1); /* * Character set. */ - if (aim_gettlv(list2, 0x000d, 1)) - args.encoding = aim_gettlv_str(list2, 0x000d, 1); + if (aim_tlv_gettlv(list2, 0x000d, 1)) + args.encoding = aim_tlv_getstr(list2, 0x000d, 1); /* * Language. */ - if (aim_gettlv(list2, 0x000e, 1)) - args.language = aim_gettlv_str(list2, 0x000e, 1); + if (aim_tlv_gettlv(list2, 0x000e, 1)) + args.language = aim_tlv_getstr(list2, 0x000e, 1); /* * Unknown -- no value * * Maybe means we should connect directly to transfer the file? */ - if (aim_gettlv(list2, 0x000f, 1)) + if (aim_tlv_gettlv(list2, 0x000f, 1)) ; /* @@ -1781,7 +1781,7 @@ * * Maybe means we should proxy the file transfer through an AIM server? */ - if (aim_gettlv(list2, 0x0010, 1)) + if (aim_tlv_gettlv(list2, 0x0010, 1)) ; if (strlen(proxyip)) @@ -1797,7 +1797,7 @@ * * Service Data blocks are module-specific in format. */ - if ((servdatatlv = aim_gettlv(list2, 0x2711 /* 10001 */, 1))) { + if ((servdatatlv = aim_tlv_gettlv(list2, 0x2711 /* 10001 */, 1))) { aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length); sdbsptr = &sdbs; @@ -1831,7 +1831,7 @@ free((char *)args.encoding); free((char *)args.language); - aim_freetlvchain(&list2); + aim_tlvlist_free(&list2); return ret; } @@ -1847,7 +1847,7 @@ /* * Make a bstream for the meaty part. Yum. Meat. */ - if (!(block = aim_gettlv(tlvlist, 0x0005, 1))) + if (!(block = aim_tlv_gettlv(tlvlist, 0x0005, 1))) return -1; aim_bstream_init(&meat, block->value, block->length); @@ -1946,18 +1946,18 @@ * Read block of TLVs (not including the userinfo data). All * further data is derived from what is parsed here. */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); } else if (channel == 4) { aim_tlvlist_t *tlvlist; - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); ret = incomingim_ch4(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); } else { faimdprintf(sess, 0, "icbm: ICBM received on an unsupported channel. Ignoring. (chan = %04x)\n", channel); @@ -2055,9 +2055,9 @@ aimbs_put8(&fr->data, strlen(sender)); aimbs_putraw(&fr->data, sender, strlen(sender)); - aim_addtlvtochain16(&tl, 0x0003, code); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_add_16(&tl, 0x0003, code); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/locate.c --- a/src/protocols/oscar/locate.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/locate.c Sun Oct 05 23:50:40 2003 +0000 @@ -697,33 +697,33 @@ aimbs_put16(bs, info->warnlevel); if (info->present & AIM_USERINFO_PRESENT_FLAGS) - aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); + aim_tlvlist_add_16(&tlvlist, 0x0001, info->flags); if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) - aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); + aim_tlvlist_add_32(&tlvlist, 0x0002, info->membersince); if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) - aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); + aim_tlvlist_add_32(&tlvlist, 0x0003, info->onlinesince); if (info->present & AIM_USERINFO_PRESENT_IDLE) - aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); + aim_tlvlist_add_16(&tlvlist, 0x0004, info->idletime); /* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */ #if ICQ_OSCAR_SUPPORT if (atoi(info->sn) != 0) { if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) - aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status); + aim_tlvlist_add_16(&tlvlist, 0x0006, info->icqinfo.status); if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) - aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr); + aim_tlvlist_add_32(&tlvlist, 0x000a, info->icqinfo.ipaddr); } #endif if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) - aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities); + aim_tlvlist_add_caps(&tlvlist, 0x000d, info->capabilities); if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) - aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); + aim_tlvlist_add_32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen); - aimbs_put16(bs, aim_counttlvchain(&tlvlist)); - aim_writetlvchain(bs, &tlvlist); - aim_freetlvchain(&tlvlist); + aimbs_put16(bs, aim_tlvlist_count(&tlvlist)); + aim_tlvlist_write(bs, &tlvlist); + aim_tlvlist_free(&tlvlist); return 0; } @@ -760,15 +760,15 @@ int ret = 0; fu16_t maxsiglen = 0; - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); - if (aim_gettlv(tlvlist, 0x0001, 1)) - maxsiglen = aim_gettlv16(tlvlist, 0x0001, 1); + if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) + maxsiglen = aim_tlv_get16(tlvlist, 0x0001, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, maxsiglen); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -820,8 +820,8 @@ return -ENOMEM; } snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding); - aim_addtlvtochain_raw(&tl, 0x0001, strlen(encoding), encoding); - aim_addtlvtochain_raw(&tl, 0x0002, profile_len, profile); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(encoding), encoding); + aim_tlvlist_add_raw(&tl, 0x0002, profile_len, profile); free(encoding); } @@ -840,23 +840,23 @@ return -ENOMEM; } snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding); - aim_addtlvtochain_raw(&tl, 0x0003, strlen(encoding), encoding); - aim_addtlvtochain_raw(&tl, 0x0004, awaymsg_len, awaymsg); + aim_tlvlist_add_raw(&tl, 0x0003, strlen(encoding), encoding); + aim_tlvlist_add_raw(&tl, 0x0004, awaymsg_len, awaymsg); free(encoding); } else - aim_addtlvtochain_noval(&tl, 0x0004); + aim_tlvlist_add_noval(&tl, 0x0004); } - aim_addtlvtochain_caps(&tl, 0x0005, caps); + aim_tlvlist_add_caps(&tl, 0x0005, caps); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -909,32 +909,32 @@ userinfo = (aim_userinfo_t *)malloc(sizeof(aim_userinfo_t)); aim_info_extract(sess, bs, userinfo); - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* Profile will be 1 and 2 */ - userinfo->info_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); - if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) { + userinfo->info_encoding = aim_tlv_getstr(tlvlist, 0x0001, 1); + if ((tlv = aim_tlv_gettlv(tlvlist, 0x0002, 1))) { userinfo->info = (char *)malloc(tlv->length); memcpy(userinfo->info, tlv->value, tlv->length); userinfo->info_len = tlv->length; } /* Away message will be 3 and 4 */ - userinfo->away_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); - if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) { + userinfo->away_encoding = aim_tlv_getstr(tlvlist, 0x0003, 1); + if ((tlv = aim_tlv_gettlv(tlvlist, 0x0004, 1))) { userinfo->away = (char *)malloc(tlv->length); memcpy(userinfo->away, tlv->value, tlv->length); userinfo->away_len = tlv->length; } /* Caps will be 5 */ - if ((tlv = aim_gettlv(tlvlist, 0x0005, 1))) { + if ((tlv = aim_tlv_gettlv(tlvlist, 0x0005, 1))) { aim_bstream_t cbs; aim_bstream_init(&cbs, tlv->value, tlv->length); userinfo->capabilities = aim_getcap(sess, &cbs, tlv->length); userinfo->present = AIM_USERINFO_PRESENT_CAPABILITIES; } - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); aim_locate_adduserinfo(sess, userinfo); userinfo2 = aim_locate_finduserinfo(sess, userinfo->sn); @@ -994,38 +994,38 @@ if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC))) return -EINVAL; - aim_addtlvtochain16(&tl, 0x000a, privacy); + aim_tlvlist_add_16(&tl, 0x000a, privacy); if (first) - aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(first), first); if (last) - aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last); + aim_tlvlist_add_raw(&tl, 0x0002, strlen(last), last); if (middle) - aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle); + aim_tlvlist_add_raw(&tl, 0x0003, strlen(middle), middle); if (maiden) - aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden); + aim_tlvlist_add_raw(&tl, 0x0004, strlen(maiden), maiden); if (state) - aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state); + aim_tlvlist_add_raw(&tl, 0x0007, strlen(state), state); if (city) - aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city); + aim_tlvlist_add_raw(&tl, 0x0008, strlen(city), city); if (nickname) - aim_addtlvtochain_raw(&tl, 0x000c, strlen(nickname), nickname); + aim_tlvlist_add_raw(&tl, 0x000c, strlen(nickname), nickname); if (zip) - aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip); + aim_tlvlist_add_raw(&tl, 0x000d, strlen(zip), zip); if (street) - aim_addtlvtochain_raw(&tl, 0x0021, strlen(street), street); + aim_tlvlist_add_raw(&tl, 0x0021, strlen(street), street); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0002, 0x0009, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0002, 0x0009, 0x0000, snacid); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -1077,27 +1077,27 @@ return -EINVAL; /* ?? privacy ?? */ - aim_addtlvtochain16(&tl, 0x000a, privacy); + aim_tlvlist_add_16(&tl, 0x000a, privacy); if (interest1) - aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest1), interest1); + aim_tlvlist_add_raw(&tl, 0x0000b, strlen(interest1), interest1); if (interest2) - aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest2), interest2); + aim_tlvlist_add_raw(&tl, 0x0000b, strlen(interest2), interest2); if (interest3) - aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest3), interest3); + aim_tlvlist_add_raw(&tl, 0x0000b, strlen(interest3), interest3); if (interest4) - aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest4), interest4); + aim_tlvlist_add_raw(&tl, 0x0000b, strlen(interest4), interest4); if (interest5) - aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest5), interest5); + aim_tlvlist_add_raw(&tl, 0x0000b, strlen(interest5), interest5); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0002, 0x000f, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0002, 0x000f, 0x0000, 0); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/odir.c --- a/src/protocols/oscar/odir.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/odir.c Sun Oct 05 23:50:40 2003 +0000 @@ -30,17 +30,17 @@ return -EINVAL; /* Create a TLV chain, write it to the outgoing frame, then free the chain */ - aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region); - aim_addtlvtochain16(&tl, 0x000a, 0x0001); /* Type of search */ - aim_addtlvtochain_raw(&tl, 0x0005, strlen(email), email); + aim_tlvlist_add_raw(&tl, 0x001c, strlen(region), region); + aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ + aim_tlvlist_add_raw(&tl, 0x0005, strlen(email), email); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -79,36 +79,36 @@ return -EINVAL; /* Create a TLV chain, write it to the outgoing frame, then free the chain */ - aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region); - aim_addtlvtochain16(&tl, 0x000a, 0x0000); /* Type of search */ + aim_tlvlist_add_raw(&tl, 0x001c, strlen(region), region); + aim_tlvlist_add_16(&tl, 0x000a, 0x0000); /* Type of search */ if (first) - aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(first), first); if (last) - aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last); + aim_tlvlist_add_raw(&tl, 0x0002, strlen(last), last); if (middle) - aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle); + aim_tlvlist_add_raw(&tl, 0x0003, strlen(middle), middle); if (maiden) - aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden); + aim_tlvlist_add_raw(&tl, 0x0004, strlen(maiden), maiden); if (country) - aim_addtlvtochain_raw(&tl, 0x0006, strlen(country), country); + aim_tlvlist_add_raw(&tl, 0x0006, strlen(country), country); if (state) - aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state); + aim_tlvlist_add_raw(&tl, 0x0007, strlen(state), state); if (city) - aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city); + aim_tlvlist_add_raw(&tl, 0x0008, strlen(city), city); if (nick) - aim_addtlvtochain_raw(&tl, 0x000c, strlen(nick), nick); + aim_tlvlist_add_raw(&tl, 0x000c, strlen(nick), nick); if (zip) - aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip); + aim_tlvlist_add_raw(&tl, 0x000d, strlen(zip), zip); if (address) - aim_addtlvtochain_raw(&tl, 0x0021, strlen(address), address); + aim_tlvlist_add_raw(&tl, 0x0021, strlen(address), address); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -134,18 +134,18 @@ return -EINVAL; /* Create a TLV chain, write it to the outgoing frame, then free the chain */ - aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region); - aim_addtlvtochain16(&tl, 0x000a, 0x0001); /* Type of search */ + aim_tlvlist_add_raw(&tl, 0x001c, strlen(region), region); + aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ if (interest) - aim_addtlvtochain_raw(&tl, 0x0001, strlen(interest), interest); + aim_tlvlist_add_raw(&tl, 0x0001, strlen(interest), interest); - if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl)))) + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -173,22 +173,22 @@ /* Allocate a linked list, 1 node per result */ while (numresults) { struct aim_odir *new; - aim_tlvlist_t *tl = aim_readtlvchain_num(bs, aimbs_get16(bs)); + aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, aimbs_get16(bs)); new = (struct aim_odir *)malloc(sizeof(struct aim_odir)); - new->first = aim_gettlv_str(tl, 0x0001, 1); - new->last = aim_gettlv_str(tl, 0x0002, 1); - new->middle = aim_gettlv_str(tl, 0x0003, 1); - new->maiden = aim_gettlv_str(tl, 0x0004, 1); - new->email = aim_gettlv_str(tl, 0x0005, 1); - new->country = aim_gettlv_str(tl, 0x0006, 1); - new->state = aim_gettlv_str(tl, 0x0007, 1); - new->city = aim_gettlv_str(tl, 0x0008, 1); - new->sn = aim_gettlv_str(tl, 0x0009, 1); - new->interest = aim_gettlv_str(tl, 0x000b, 1); - new->nick = aim_gettlv_str(tl, 0x000c, 1); - new->zip = aim_gettlv_str(tl, 0x000d, 1); - new->region = aim_gettlv_str(tl, 0x001c, 1); - new->address = aim_gettlv_str(tl, 0x0021, 1); + new->first = aim_tlv_getstr(tl, 0x0001, 1); + new->last = aim_tlv_getstr(tl, 0x0002, 1); + new->middle = aim_tlv_getstr(tl, 0x0003, 1); + new->maiden = aim_tlv_getstr(tl, 0x0004, 1); + new->email = aim_tlv_getstr(tl, 0x0005, 1); + new->country = aim_tlv_getstr(tl, 0x0006, 1); + new->state = aim_tlv_getstr(tl, 0x0007, 1); + new->city = aim_tlv_getstr(tl, 0x0008, 1); + new->sn = aim_tlv_getstr(tl, 0x0009, 1); + new->interest = aim_tlv_getstr(tl, 0x000b, 1); + new->nick = aim_tlv_getstr(tl, 0x000c, 1); + new->zip = aim_tlv_getstr(tl, 0x000d, 1); + new->region = aim_tlv_getstr(tl, 0x001c, 1); + new->address = aim_tlv_getstr(tl, 0x0021, 1); new->next = results; results = new; numresults--; diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/popups.c --- a/src/protocols/oscar/popups.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/popups.c Sun Oct 05 23:50:40 2003 +0000 @@ -22,18 +22,18 @@ char *msg, *url; fu16_t width, height, delay; - tl = aim_readtlvchain(bs); + tl = aim_tlvlist_read(bs); - msg = aim_gettlv_str(tl, 0x0001, 1); - url = aim_gettlv_str(tl, 0x0002, 1); - width = aim_gettlv16(tl, 0x0003, 1); - height = aim_gettlv16(tl, 0x0004, 1); - delay = aim_gettlv16(tl, 0x0005, 1); + msg = aim_tlv_getstr(tl, 0x0001, 1); + url = aim_tlv_getstr(tl, 0x0002, 1); + width = aim_tlv_get16(tl, 0x0003, 1); + height = aim_tlv_get16(tl, 0x0004, 1); + delay = aim_tlv_get16(tl, 0x0005, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, msg, url, width, height, delay); - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); free(msg); free(url); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/rxhandlers.c --- a/src/protocols/oscar/rxhandlers.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/rxhandlers.c Sun Oct 05 23:50:40 2003 +0000 @@ -184,18 +184,18 @@ if (fr->conn->type == AIM_CONN_TYPE_AUTH) return consumenonsnac(sess, fr, 0x0017, 0x0003); - tlvlist = aim_readtlvchain(&fr->data); + tlvlist = aim_tlvlist_read(&fr->data); - if (aim_gettlv(tlvlist, 0x0009, 1)) - code = aim_gettlv16(tlvlist, 0x0009, 1); + if (aim_tlv_gettlv(tlvlist, 0x0009, 1)) + code = aim_tlv_get16(tlvlist, 0x0009, 1); - if (aim_gettlv(tlvlist, 0x000b, 1)) - msg = aim_gettlv_str(tlvlist, 0x000b, 1); + if (aim_tlv_gettlv(tlvlist, 0x000b, 1)) + msg = aim_tlv_getstr(tlvlist, 0x000b, 1); if ((userfunc = aim_callhandler(sess, fr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR))) ret = userfunc(sess, fr, code, msg); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); free(msg); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/search.c --- a/src/protocols/oscar/search.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/search.c Sun Oct 05 23:50:40 2003 +0000 @@ -77,14 +77,14 @@ if ((snac2 = aim_remsnac(sess, snac->id))) searchaddr = (char *)snac2->data; - tlvlist = aim_readtlvchain(bs); - m = aim_counttlvchain(&tlvlist); + tlvlist = aim_tlvlist_read(bs); + m = aim_tlvlist_count(&tlvlist); /* XXX uhm. * This is the only place that uses something other than 1 for the 3rd - * parameter to aim_gettlv_whatever(). + * parameter to aim_tlv_gettlv_whatever(). */ - while ((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) { + while ((cur = aim_tlv_getstr(tlvlist, 0x0001, j+1)) && j < m) { buf = realloc(buf, (j+1) * (MAXSNLEN+1)); strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN); @@ -93,7 +93,7 @@ j++; } - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, searchaddr, j, buf); diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/service.c --- a/src/protocols/oscar/service.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/service.c Sun Oct 05 23:50:40 2003 +0000 @@ -108,19 +108,19 @@ memset(&redir, 0, sizeof(redir)); - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); - if (!aim_gettlv(tlvlist, 0x000d, 1) || - !aim_gettlv(tlvlist, 0x0005, 1) || - !aim_gettlv(tlvlist, 0x0006, 1)) { - aim_freetlvchain(&tlvlist); + if (!aim_tlv_gettlv(tlvlist, 0x000d, 1) || + !aim_tlv_gettlv(tlvlist, 0x0005, 1) || + !aim_tlv_gettlv(tlvlist, 0x0006, 1)) { + aim_tlvlist_free(&tlvlist); return 0; } - redir.group = aim_gettlv16(tlvlist, 0x000d, 1); - redir.ip = aim_gettlv_str(tlvlist, 0x0005, 1); - redir.cookielen = aim_gettlv(tlvlist, 0x0006, 1)->length; - redir.cookie = aim_gettlv_str(tlvlist, 0x0006, 1); + redir.group = aim_tlv_get16(tlvlist, 0x000d, 1); + redir.ip = aim_tlv_getstr(tlvlist, 0x0005, 1); + redir.cookielen = aim_tlv_gettlv(tlvlist, 0x0006, 1)->length; + redir.cookie = aim_tlv_getstr(tlvlist, 0x0006, 1); /* Fetch original SNAC so we can get csi if needed */ origsnac = aim_remsnac(sess, snac->id); @@ -143,7 +143,7 @@ free(origsnac->data); free(origsnac); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -585,17 +585,17 @@ faimdprintf(sess, 0, "bifurcated migration unsupported -- group 0x%04x\n", group); } - tl = aim_readtlvchain(bs); + tl = aim_tlvlist_read(bs); - if (aim_gettlv(tl, 0x0005, 1)) - ip = aim_gettlv_str(tl, 0x0005, 1); + if (aim_tlv_gettlv(tl, 0x0005, 1)) + ip = aim_tlv_getstr(tl, 0x0005, 1); - cktlv = aim_gettlv(tl, 0x0006, 1); + cktlv = aim_tlv_gettlv(tl, 0x0006, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, ip, cktlv ? cktlv->value : NULL); - aim_freetlvchain(&tl); + aim_tlvlist_free(&tl); free(ip); return ret; @@ -626,16 +626,16 @@ /* * TLVs follow */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); - msg = aim_gettlv_str(tlvlist, 0x000b, 1); + msg = aim_tlv_getstr(tlvlist, 0x000b, 1); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, id, msg); free(msg); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return ret; } @@ -760,9 +760,9 @@ snacid = aim_cachesnac(sess, 0x0001, 0x001e, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0001, 0x001e, 0x0000, snacid); - aim_addtlvtochain32(&tl, 0x0006, data); - aim_writetlvchain(&fr->data, &tl); - aim_freetlvchain(&tl); + aim_tlvlist_add_32(&tl, 0x0006, data); + aim_tlvlist_write(&fr->data, &tl); + aim_tlvlist_free(&tl); aim_tx_enqueue(sess, fr); @@ -870,9 +870,9 @@ offset = aimbs_get32(bs); len = aimbs_get32(bs); - list = aim_readtlvchain(bs); + list = aim_tlvlist_read(bs); - modname = aim_gettlv_str(list, 0x0001, 1); + modname = aim_tlv_getstr(list, 0x0001, 1); faimdprintf(sess, 1, "data at 0x%08lx (%d bytes) of requested\n", offset, len, modname ? modname : "aim.exe"); @@ -880,7 +880,7 @@ ret = userfunc(sess, rx, offset, len, modname); free(modname); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return ret; } diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/ssi.c --- a/src/protocols/oscar/ssi.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/ssi.c Sun Oct 05 23:50:40 2003 +0000 @@ -184,7 +184,7 @@ /* Free the removed item */ free(del->name); - aim_freetlvchain(&del->data); + aim_tlvlist_free(&del->data); free(del); return 0; @@ -353,7 +353,7 @@ { struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, NULL, NULL, AIM_SSI_TYPE_PDINFO); if (cur) { - aim_tlv_t *tlv = aim_gettlv(cur->data, 0x00ca, 1); + aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00ca, 1); if (tlv && tlv->value) return aimutil_get8(tlv->value); } @@ -372,7 +372,7 @@ { struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS); if (cur) { - aim_tlv_t *tlv = aim_gettlv(cur->data, 0x00c9, 1); + aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00c9, 1); if (tlv && tlv->length) return aimutil_get32(tlv->value); } @@ -393,7 +393,7 @@ { struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY); if (cur) { - aim_tlv_t *tlv = aim_gettlv(cur->data, 0x0131, 1); + aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1); if (tlv && tlv->length) { char *alias = (char *)malloc((tlv->length+1)*sizeof(char)); strncpy(alias, tlv->value, tlv->length); @@ -418,7 +418,7 @@ { struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY); if (cur) { - if (aim_gettlv(cur->data, 0x0066, 1)) + if (aim_tlv_gettlv(cur->data, 0x0066, 1)) return 1; } return 0; @@ -544,7 +544,7 @@ del = cur; cur = cur->next; free(del->name); - aim_freetlvchain(&del->data); + aim_tlvlist_free(&del->data); free(del); } @@ -553,7 +553,7 @@ del = cur; cur = cur->next; free(del->name); - aim_freetlvchain(&del->data); + aim_tlvlist_free(&del->data); free(del); } @@ -592,7 +592,7 @@ del = cur; cur = cur->next; free(del->name); - aim_freetlvchain(&del->data); + aim_tlvlist_free(&del->data); free(del); } sess->ssi.local = NULL; @@ -646,7 +646,7 @@ while (cur) { next = cur->next; if (cur->type == AIM_SSI_TYPE_GROUP) { - aim_tlv_t *tlv = aim_gettlv(cur->data, 0x00c8, 1); + aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00c8, 1); if (!tlv || !tlv->length) aim_ssi_itemlist_del(&sess->ssi.local, cur); } @@ -695,17 +695,17 @@ /* Create a TLV list for the new buddy */ if (needauth) - aim_addtlvtochain_noval(&data, 0x0066); + aim_tlvlist_add_noval(&data, 0x0066); if (alias) - aim_addtlvtochain_raw(&data, 0x0131, strlen(alias), alias); + aim_tlvlist_add_raw(&data, 0x0131, strlen(alias), alias); if (smsnum) - aim_addtlvtochain_raw(&data, 0x013a, strlen(smsnum), smsnum); + aim_tlvlist_add_raw(&data, 0x013a, strlen(smsnum), smsnum); if (comment) - aim_addtlvtochain_raw(&data, 0x013c, strlen(comment), comment); + aim_tlvlist_add_raw(&data, 0x013c, strlen(comment), comment); /* Add that bad boy */ aim_ssi_itemlist_add(&sess->ssi.local, name, parent->gid, 0xFFFF, AIM_SSI_TYPE_BUDDY, data); - aim_freetlvchain(&data); + aim_tlvlist_free(&data); /* Modify the parent group */ aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group); @@ -1063,18 +1063,18 @@ fu16_t *maxitems; /* This SNAC is made up of a bunch of TLVs */ - tlvlist = aim_readtlvchain(bs); + tlvlist = aim_tlvlist_read(bs); /* TLV 0x0004 contains the maximum number of each item */ - if (!(tlv = aim_gettlv(tlvlist, 0x0004, 1))) { - aim_freetlvchain(&tlvlist); + if (!(tlv = aim_tlv_gettlv(tlvlist, 0x0004, 1))) { + aim_tlvlist_free(&tlvlist); return 0; } aim_bstream_init(&bstream, tlv->value, tlv->length); if (!(maxitems = (fu16_t *)malloc((tlv->length/2)*sizeof(fu16_t)))) { - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); return 0; } @@ -1084,7 +1084,7 @@ if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx, tlv->length/2, maxitems); - aim_freetlvchain(&tlvlist); + aim_tlvlist_free(&tlvlist); free(maxitems); return ret; @@ -1168,10 +1168,10 @@ gid = aimbs_get16(bs); bid = aimbs_get16(bs); type = aimbs_get16(bs); - data = aim_readtlvchain_len(bs, aimbs_get16(bs)); + data = aim_tlvlist_readlen(bs, aimbs_get16(bs)); aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data); free(name); - aim_freetlvchain(&data); + aim_tlvlist_free(&data); } /* Read in the timestamp */ @@ -1237,7 +1237,7 @@ if (cur->item->name) snaclen += strlen(cur->item->name); if (cur->item->data) - snaclen += aim_sizetlvchain(&cur->item->data); + snaclen += aim_tlvlist_size(&cur->item->data); } if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen))) @@ -1253,9 +1253,9 @@ aimbs_put16(&fr->data, cur->item->gid); aimbs_put16(&fr->data, cur->item->bid); aimbs_put16(&fr->data, cur->item->type); - aimbs_put16(&fr->data, cur->item->data ? aim_sizetlvchain(&cur->item->data) : 0); + aimbs_put16(&fr->data, cur->item->data ? aim_tlvlist_size(&cur->item->data) : 0); if (cur->item->data) - aim_writetlvchain(&fr->data, &cur->item->data); + aim_tlvlist_write(&fr->data, &cur->item->data); } aim_tx_enqueue(sess, fr); @@ -1285,14 +1285,14 @@ bid = aimbs_get16(bs); type = aimbs_get16(bs); if ((len = aimbs_get16(bs))) - data = aim_readtlvchain_len(bs, len); + data = aim_tlvlist_readlen(bs, len); else data = NULL; aim_ssi_itemlist_add(&sess->ssi.local, name, gid, bid, type, data); aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data); free(name); - aim_freetlvchain(&data); + aim_tlvlist_free(&data); if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) ret = userfunc(sess, rx); @@ -1326,7 +1326,7 @@ bid = aimbs_get16(bs); type = aimbs_get16(bs); if ((len = aimbs_get16(bs))) - data = aim_readtlvchain_len(bs, len); + data = aim_tlvlist_readlen(bs, len); else data = NULL; @@ -1339,7 +1339,7 @@ strcpy(item->name, name); } else item->name = NULL; - aim_freetlvchain(&item->data); + aim_tlvlist_free(&item->data); item->data = aim_tlvlist_copy(data); } @@ -1351,7 +1351,7 @@ strcpy(item->name, name); } else item->name = NULL; - aim_freetlvchain(&item->data); + aim_tlvlist_free(&item->data); item->data = aim_tlvlist_copy(data); } @@ -1359,7 +1359,7 @@ ret = userfunc(sess, rx); free(name); - aim_freetlvchain(&data); + aim_tlvlist_free(&data); } return ret; @@ -1447,7 +1447,7 @@ strcpy(cur->item->name, cur1->name); } else cur->item->name = NULL; - aim_freetlvchain(&cur->item->data); + aim_tlvlist_free(&cur->item->data); cur->item->data = aim_tlvlist_copy(cur1->data); } } else @@ -1481,7 +1481,7 @@ strcpy(cur1->name, cur->item->name); } else cur1->name = NULL; - aim_freetlvchain(&cur1->data); + aim_tlvlist_free(&cur1->data); cur1->data = aim_tlvlist_copy(cur->item->data); } } else diff -r e6b01bd8d6cd -r 6d3d8f11e765 src/protocols/oscar/tlv.c --- a/src/protocols/oscar/tlv.c Sun Oct 05 22:41:29 2003 +0000 +++ b/src/protocols/oscar/tlv.c Sun Oct 05 23:50:40 2003 +0000 @@ -29,11 +29,11 @@ } /** - * aim_readtlvchain - Read a TLV chain from a buffer. + * Read a TLV chain from a buffer. * * Reads and parses a series of TLV patterns from a data buffer; the * returned structure is manipulatable with the rest of the TLV - * routines. When done with a TLV chain, aim_freetlvchain() should + * routines. When done with a TLV chain, aim_tlvlist_free() should * be called to free the dynamic substructures. * * XXX There should be a flag setable here to have the tlvlist contain @@ -44,7 +44,7 @@ * * @param bs Input bstream */ -faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs) +faim_internal aim_tlvlist_t *aim_tlvlist_read(aim_bstream_t *bs) { aim_tlvlist_t *list = NULL, *cur; @@ -72,13 +72,13 @@ else { if (length > aim_bstream_empty(bs)) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } cur = (aim_tlvlist_t *)malloc(sizeof(aim_tlvlist_t)); if (!cur) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } @@ -87,7 +87,7 @@ cur->tlv = createtlv(type, length, NULL); if (!cur->tlv) { free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } if (cur->tlv->length > 0) { @@ -95,7 +95,7 @@ if (!cur->tlv->value) { freetlv(&cur->tlv); free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } } @@ -109,11 +109,11 @@ } /** - * aim_readtlvchain_num - Read a TLV chain from a buffer. + * Read a TLV chain from a buffer. * * Reads and parses a series of TLV patterns from a data buffer; the * returned structure is manipulatable with the rest of the TLV - * routines. When done with a TLV chain, aim_freetlvchain() should + * routines. When done with a TLV chain, aim_tlvlist_free() should * be called to free the dynamic substructures. * * XXX There should be a flag setable here to have the tlvlist contain @@ -128,7 +128,7 @@ * but the chain is not at the end of the SNAC, and the chain is * preceeded by the number of TLVs. So you can limit that with this. */ -faim_internal aim_tlvlist_t *aim_readtlvchain_num(aim_bstream_t *bs, fu16_t num) +faim_internal aim_tlvlist_t *aim_tlvlist_readnum(aim_bstream_t *bs, fu16_t num) { aim_tlvlist_t *list = NULL, *cur; @@ -139,13 +139,13 @@ length = aimbs_get16(bs); if (length > aim_bstream_empty(bs)) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } cur = (aim_tlvlist_t *)malloc(sizeof(aim_tlvlist_t)); if (!cur) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } @@ -154,7 +154,7 @@ cur->tlv = createtlv(type, length, NULL); if (!cur->tlv) { free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } if (cur->tlv->length > 0) { @@ -162,7 +162,7 @@ if (!cur->tlv->value) { freetlv(&cur->tlv); free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } } @@ -177,11 +177,11 @@ } /** - * aim_readtlvchain_len - Read a TLV chain from a buffer. + * Read a TLV chain from a buffer. * * Reads and parses a series of TLV patterns from a data buffer; the * returned structure is manipulatable with the rest of the TLV - * routines. When done with a TLV chain, aim_freetlvchain() should + * routines. When done with a TLV chain, aim_tlvlist_free() should * be called to free the dynamic substructures. * * XXX There should be a flag setable here to have the tlvlist contain @@ -196,7 +196,7 @@ * but the chain is not at the end of the SNAC, and the chain is * preceeded by the length of the TLVs. So you can limit that with this. */ -faim_internal aim_tlvlist_t *aim_readtlvchain_len(aim_bstream_t *bs, fu16_t len) +faim_internal aim_tlvlist_t *aim_tlvlist_readlen(aim_bstream_t *bs, fu16_t len) { aim_tlvlist_t *list = NULL, *cur; @@ -207,13 +207,13 @@ length = aimbs_get16(bs); if (length > aim_bstream_empty(bs)) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } cur = (aim_tlvlist_t *)malloc(sizeof(aim_tlvlist_t)); if (!cur) { - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } @@ -222,7 +222,7 @@ cur->tlv = createtlv(type, length, NULL); if (!cur->tlv) { free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } if (cur->tlv->length > 0) { @@ -230,12 +230,12 @@ if (!cur->tlv->value) { freetlv(&cur->tlv); free(cur); - aim_freetlvchain(&list); + aim_tlvlist_free(&list); return NULL; } } - len -= aim_sizetlvchain(&cur); + len -= aim_tlvlist_size(&cur); cur->next = list; list = cur; } @@ -244,7 +244,7 @@ } /** - * aim_tlvlist_copy - Duplicate a TLV chain. + * Duplicate a TLV chain. * This is pretty pelf exslanatory. * * @param orig The TLV chain you want to make a copy of. @@ -255,7 +255,7 @@ aim_tlvlist_t *new = NULL; while (orig) { - aim_addtlvtochain_raw(&new, orig->tlv->type, orig->tlv->length, orig->tlv->value); + aim_tlvlist_add_raw(&new, orig->tlv->type, orig->tlv->length, orig->tlv->value); orig = orig->next; } @@ -274,14 +274,14 @@ { aim_bstream_t bs1, bs2; - if (aim_sizetlvchain(&one) != aim_sizetlvchain(&two)) + if (aim_tlvlist_size(&one) != aim_tlvlist_size(&two)) return 1; - aim_bstream_init(&bs1, ((fu8_t *)malloc(aim_sizetlvchain(&one)*sizeof(fu8_t))), aim_sizetlvchain(&one)); - aim_bstream_init(&bs2, ((fu8_t *)malloc(aim_sizetlvchain(&two)*sizeof(fu8_t))), aim_sizetlvchain(&two)); + aim_bstream_init(&bs1, ((fu8_t *)malloc(aim_tlvlist_size(&one)*sizeof(fu8_t))), aim_tlvlist_size(&one)); + aim_bstream_init(&bs2, ((fu8_t *)malloc(aim_tlvlist_size(&two)*sizeof(fu8_t))), aim_tlvlist_size(&two)); - aim_writetlvchain(&bs1, &one); - aim_writetlvchain(&bs2, &two); + aim_tlvlist_write(&bs1, &one); + aim_tlvlist_write(&bs2, &two); if (memcmp(bs1.data, bs2.data, bs1.len)) { free(bs1.data); @@ -296,7 +296,7 @@ } /** - * aim_freetlvchain - Free a TLV chain structure + * Free a TLV chain structure * @list: Chain to be freed * * Walks the list of TLVs in the passed TLV chain and @@ -304,7 +304,7 @@ * should be removed before calling this. * */ -faim_internal void aim_freetlvchain(aim_tlvlist_t **list) +faim_internal void aim_tlvlist_free(aim_tlvlist_t **list) { aim_tlvlist_t *cur; @@ -327,13 +327,12 @@ } /** - * aim_counttlvchain - Count the number of TLVs in a chain - * @list: Chain to be counted + * Count the number of TLVs in a chain. * - * Returns the number of TLVs stored in the passed chain. - * + * @param list Chain to be counted. + * @return The number of TLVs stored in the passed chain. */ -faim_internal int aim_counttlvchain(aim_tlvlist_t **list) +faim_internal int aim_tlvlist_count(aim_tlvlist_t **list) { aim_tlvlist_t *cur; int count; @@ -348,14 +347,13 @@ } /** - * aim_sizetlvchain - Count the number of bytes in a TLV chain - * @list: Chain to be sized + * Count the number of bytes in a TLV chain. * - * Returns the number of bytes that would be needed to - * write the passed TLV chain to a data buffer. - * + * @param list Chain to be sized + * @return The number of bytes that would be needed to + * write the passed TLV chain to a data buffer. */ -faim_internal int aim_sizetlvchain(aim_tlvlist_t **list) +faim_internal int aim_tlvlist_size(aim_tlvlist_t **list) { aim_tlvlist_t *cur; int size; @@ -370,17 +368,16 @@ } /** - * aim_addtlvtochain_raw - Add a string to a TLV chain - * * Adds the passed string as a TLV element of the passed type * to the TLV chain. * - * @param list Desination chain (%NULL pointer if empty) - * @param type TLV type - * @length Length of string to add (not including %NULL) - * @value String to add + * @param list Desination chain (%NULL pointer if empty). + * @param type TLV type. + * @length Length of string to add (not including %NULL). + * @value String to add. + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t length, const fu8_t *value) +faim_internal int aim_tlvlist_add_raw(aim_tlvlist_t **list, const fu16_t type, const fu16_t length, const fu8_t *value) { aim_tlvlist_t *newtlv, *cur; @@ -412,62 +409,57 @@ } /** - * aim_addtlvtochain8 - Add a 8bit integer to a TLV chain - * @list: Destination chain - * @type: TLV type to add - * @val: Value to add + * Add a one byte integer to a TLV chain. * - * Adds a one-byte unsigned integer to a TLV chain. - * + * @param list Destination chain. + * @param type TLV type to add. + * @param value Value to add. + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain8(aim_tlvlist_t **list, const fu16_t t, const fu8_t v) +faim_internal int aim_tlvlist_add_8(aim_tlvlist_t **list, const fu16_t type, const fu8_t value) { fu8_t v8[1]; - aimutil_put8(v8, v); + aimutil_put8(v8, value); - return aim_addtlvtochain_raw(list, t, 1, v8); + return aim_tlvlist_add_raw(list, type, 1, v8); } /** - * aim_addtlvtochain16 - Add a 16bit integer to a TLV chain - * @list: Destination chain - * @t: TLV type to add - * @v: Value to add + * Add a two byte integer to a TLV chain. * - * Adds a two-byte unsigned integer to a TLV chain. - * + * @param list Destination chain. + * @param type TLV type to add. + * @param value Value to add. + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t t, const fu16_t v) +faim_internal int aim_tlvlist_add_16(aim_tlvlist_t **list, const fu16_t type, const fu16_t value) { fu8_t v16[2]; - aimutil_put16(v16, v); + aimutil_put16(v16, value); - return aim_addtlvtochain_raw(list, t, 2, v16); + return aim_tlvlist_add_raw(list, type, 2, v16); } /** - * aim_addtlvtochain32 - Add a 32bit integer to a TLV chain - * @list: Destination chain - * @type: TLV type to add - * @val: Value to add + * Add a four byte integer to a TLV chain. * - * Adds a four-byte unsigned integer to a TLV chain. - * + * @param list Destination chain. + * @param type TLV type to add. + * @param value Value to add. + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t t, const fu32_t v) +faim_internal int aim_tlvlist_add_32(aim_tlvlist_t **list, const fu16_t type, const fu32_t value) { fu8_t v32[4]; - aimutil_put32(v32, v); + aimutil_put32(v32, value); - return aim_addtlvtochain_raw(list, t, 4, v32); + return aim_tlvlist_add_raw(list, type, 4, v32); } /** - * aim_addtlvtochain_caps - Add a capability block to a TLV chain - * * Adds a block of capability blocks to a TLV chain. The bitfield * passed in should be a bitwise %OR of any of the %AIM_CAPS constants: * @@ -481,8 +473,9 @@ * @param list Destination chain * @param type TLV type to add * @param caps Bitfield of capability flags to send + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t t, const fu32_t caps) +faim_internal int aim_tlvlist_add_caps(aim_tlvlist_t **list, const fu16_t type, const fu32_t caps) { fu8_t buf[16*16]; /* XXX icky fixed length buffer */ aim_bstream_t bs; @@ -494,32 +487,38 @@ aim_putcap(&bs, caps); - return aim_addtlvtochain_raw(list, t, aim_bstream_curpos(&bs), buf); + return aim_tlvlist_add_raw(list, type, aim_bstream_curpos(&bs), buf); } -faim_internal int aim_addtlvtochain_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *ui) +/** + * Adds the given userinfo struct to a TLV chain. + * + * @param list Destination chain. + * @param type TLV type to add. + * @retun The size of the value added. + */ +faim_internal int aim_tlvlist_add_userinfo(aim_tlvlist_t **list, fu16_t type, aim_userinfo_t *userinfo) { fu8_t buf[1024]; /* bleh */ aim_bstream_t bs; aim_bstream_init(&bs, buf, sizeof(buf)); - aim_putuserinfo(&bs, ui); + aim_putuserinfo(&bs, userinfo); - return aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); + return aim_tlvlist_add_raw(list, type, aim_bstream_curpos(&bs), buf); } /** - * aim_addtlvtochain_noval - Add a blank TLV to a TLV chain - * @list: Destination chain - * @type: TLV type to add - * * Adds a TLV with a zero length to a TLV chain. * + * @param list Destination chain. + * @param type TLV type to add. + * @retun The size of the value added. */ -faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t t) +faim_internal int aim_tlvlist_add_noval(aim_tlvlist_t **list, const fu16_t type) { - return aim_addtlvtochain_raw(list, t, 0, NULL); + return aim_tlvlist_add_raw(list, type, 0, NULL); } /* @@ -532,13 +531,13 @@ * This is so neat. * */ -faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl) +faim_internal int aim_tlvlist_add_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl) { fu8_t *buf; int buflen; aim_bstream_t bs; - buflen = aim_sizetlvchain(tl); + buflen = aim_tlvlist_size(tl); if (buflen <= 0) return 0; @@ -548,9 +547,9 @@ aim_bstream_init(&bs, buf, buflen); - aim_writetlvchain(&bs, tl); + aim_tlvlist_write(&bs, tl); - aim_addtlvtochain_raw(list, type, aim_bstream_curpos(&bs), buf); + aim_tlvlist_add_raw(list, type, aim_bstream_curpos(&bs), buf); free(buf); @@ -560,7 +559,7 @@ /** * Substitute a TLV of a given type with a new TLV of the same type. If * you attempt to replace a TLV that does not exist, this function will - * just add a new TLV as if you called aim_addtlvtochain_raw(). + * just add a new TLV as if you called aim_tlvlist_add_raw(). * * @param list Desination chain (%NULL pointer if empty). * @param type TLV type. @@ -577,7 +576,7 @@ for (cur = *list; ((cur != NULL) && (cur->tlv->type != type)); cur = cur->next); if (cur == NULL) - return aim_addtlvtochain_raw(list, type, length, value); + return aim_tlvlist_add_raw(list, type, length, value); free(cur->tlv->value); cur->tlv->length = length; @@ -593,7 +592,7 @@ /** * Substitute a TLV of a given type with a new TLV of the same type. If * you attempt to replace a TLV that does not exist, this function will - * just add a new TLV as if you called aim_addtlvtochain_raw(). + * just add a new TLV as if you called aim_tlvlist_add_raw(). * * @param list Desination chain (%NULL pointer if empty). * @param type TLV type. @@ -607,7 +606,7 @@ /** * Substitute a TLV of a given type with a new TLV of the same type. If * you attempt to replace a TLV that does not exist, this function will - * just add a new TLV as if you called aim_addtlvtochain_raw(). + * just add a new TLV as if you called aim_tlvlist_add_raw(). * * @param list Desination chain (%NULL pointer if empty). * @param type TLV type. @@ -626,7 +625,7 @@ /** * Substitute a TLV of a given type with a new TLV of the same type. If * you attempt to replace a TLV that does not exist, this function will - * just add a new TLV as if you called aim_addtlvtochain_raw(). + * just add a new TLV as if you called aim_tlvlist_add_raw(). * * @param list Desination chain (%NULL pointer if empty). * @param type TLV type. @@ -676,25 +675,25 @@ } /** - * aim_writetlvchain - Write a TLV chain into a data buffer. + * aim_tlvlist_write - Write a TLV chain into a data buffer. * @buf: Destination buffer * @buflen: Maximum number of bytes that will be written to buffer * @list: Source TLV chain * * Copies a TLV chain into a raw data buffer, writing only the number * of bytes specified. This operation does not free the chain; - * aim_freetlvchain() must still be called to free up the memory used + * aim_tlvlist_free() must still be called to free up the memory used * by the chain structures. * * XXX clean this up, make better use of bstreams */ -faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list) +faim_internal int aim_tlvlist_write(aim_bstream_t *bs, aim_tlvlist_t **list) { int goodbuflen; aim_tlvlist_t *cur; /* do an initial run to test total length */ - goodbuflen = aim_sizetlvchain(list); + goodbuflen = aim_tlvlist_size(list); if (goodbuflen > aim_bstream_empty(bs)) return 0; /* not enough buffer */ @@ -719,21 +718,21 @@ * In most cases, there will be no more than one TLV of any type * in a chain. * - * @param list Source chain - * @param type Requested TLV type - * @param nth Index of TLV of type to get + * @param list Source chain. + * @param type Requested TLV type. + * @param nth Index of TLV of type to get. * @return The TLV you were looking for, or NULL if one could not be found. */ -faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *list, const fu16_t t, const int n) +faim_internal aim_tlv_t *aim_tlv_gettlv(aim_tlvlist_t *list, const fu16_t type, const int nth) { aim_tlvlist_t *cur; int i; for (cur = list, i = 0; cur; cur = cur->next) { if (cur && cur->tlv) { - if (cur->tlv->type == t) + if (cur->tlv->type == type) i++; - if (i >= n) + if (i >= nth) return cur->tlv; } } @@ -742,22 +741,21 @@ } /** - * aim_gettlv_str - Retrieve the Nth TLV in chain as a string. - * @list: Source TLV chain - * @type: TLV type to search for - * @nth: Index of TLV to return + * Retrieve the data from the nth TLV in the given TLV chain as a string. * - * Same as aim_gettlv(), except that the return value is a %NULL- - * terminated string instead of an aim_tlv_t. This is a - * dynamic buffer and must be freed by the caller. - * + * @param list Source TLV chain. + * @param type TLV type to search for. + * @param nth Index of TLV to return. + * @return The value of the TLV you were looking for, or NULL if one could + * not be found. This is a dynamic buffer and must be freed by the + * caller. */ -faim_internal char *aim_gettlv_str(aim_tlvlist_t *list, const fu16_t t, const int n) +faim_internal char *aim_tlv_getstr(aim_tlvlist_t *list, const fu16_t type, const int nth) { aim_tlv_t *tlv; char *newstr; - if (!(tlv = aim_gettlv(list, t, n))) + if (!(tlv = aim_tlv_gettlv(list, type, nth))) return NULL; newstr = (char *) malloc(tlv->length + 1); @@ -768,140 +766,58 @@ } /** - * aim_gettlv8 - Retrieve the Nth TLV in chain as a 8bit integer. - * @list: Source TLV chain - * @type: TLV type to search for - * @nth: Index of TLV to return + * Retrieve the data from the nth TLV in the given TLV chain as an 8bit + * integer. * - * Same as aim_gettlv(), except that the return value is a - * 8bit integer instead of an aim_tlv_t. - * + * @param list Source TLV chain. + * @param type TLV type to search for. + * @param nth Index of TLV to return. + * @return The value the TLV you were looking for, or 0 if one could + * not be found. */ -faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t t, const int n) +faim_internal fu8_t aim_tlv_get8(aim_tlvlist_t *list, const fu16_t type, const int nth) { aim_tlv_t *tlv; - if (!(tlv = aim_gettlv(list, t, n))) + if (!(tlv = aim_tlv_gettlv(list, type, nth))) return 0; /* erm */ return aimutil_get8(tlv->value); } /** - * aim_gettlv16 - Retrieve the Nth TLV in chain as a 16bit integer. - * @list: Source TLV chain - * @type: TLV type to search for - * @nth: Index of TLV to return + * Retrieve the data from the nth TLV in the given TLV chain as a 16bit + * integer. * - * Same as aim_gettlv(), except that the return value is a - * 16bit integer instead of an aim_tlv_t. - * + * @param list Source TLV chain. + * @param type TLV type to search for. + * @param nth Index of TLV to return. + * @return The value the TLV you were looking for, or 0 if one could + * not be found. */ -faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t t, const int n) +faim_internal fu16_t aim_tlv_get16(aim_tlvlist_t *list, const fu16_t type, const int nth) { aim_tlv_t *tlv; - if (!(tlv = aim_gettlv(list, t, n))) + if (!(tlv = aim_tlv_gettlv(list, type, nth))) return 0; /* erm */ return aimutil_get16(tlv->value); } /** - * aim_gettlv32 - Retrieve the Nth TLV in chain as a 32bit integer. - * @list: Source TLV chain - * @type: TLV type to search for - * @nth: Index of TLV to return + * Retrieve the data from the nth TLV in the given TLV chain as a 32bit + * integer. * - * Same as aim_gettlv(), except that the return value is a - * 32bit integer instead of an aim_tlv_t. - * + * @param list Source TLV chain. + * @param type TLV type to search for. + * @param nth Index of TLV to return. + * @return The value the TLV you were looking for, or 0 if one could + * not be found. */ -faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t t, const int n) +faim_internal fu32_t aim_tlv_get32(aim_tlvlist_t *list, const fu16_t type, const int nth) { aim_tlv_t *tlv; - if (!(tlv = aim_gettlv(list, t, n))) + if (!(tlv = aim_tlv_gettlv(list, type, nth))) return 0; /* erm */ return aimutil_get32(tlv->value); } - -#if 0 -/** - * aim_puttlv_8 - Write a one-byte TLV. - * @buf: Destination buffer - * @t: TLV type - * @v: Value - * - * Writes a TLV with a one-byte integer value portion. - * - */ -faim_export int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v) -{ - fu8_t v8[1]; - - aimutil_put8(v8, v); - - return aim_puttlv_raw(buf, t, 1, v8); -} - -/** - * aim_puttlv_16 - Write a two-byte TLV. - * @buf: Destination buffer - * @t: TLV type - * @v: Value - * - * Writes a TLV with a two-byte integer value portion. - * - */ -faim_export int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v) -{ - fu8_t v16[2]; - - aimutil_put16(v16, v); - - return aim_puttlv_raw(buf, t, 2, v16); -} - - -/** - * aim_puttlv_32 - Write a four-byte TLV. - * @buf: Destination buffer - * @t: TLV type - * @v: Value - * - * Writes a TLV with a four-byte integer value portion. - * - */ -faim_export int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v) -{ - fu8_t v32[4]; - - aimutil_put32(v32, v); - - return aim_puttlv_raw(buf, t, 4, v32); -} - -/** - * aim_puttlv_raw - Write a raw TLV. - * @buf: Destination buffer - * @t: TLV type - * @l: Length of string - * @v: String to write - * - * Writes a TLV with a raw value portion. (Only the first @l - * bytes of the passed buffer will be written, which should not - * include a terminating NULL.) - * - */ -faim_export int aim_puttlv_raw(fu8_t *buf, const fu16_t t, const fu16_t l, const fu8_t *v) -{ - int i; - - i = aimutil_put16(buf, t); - i += aimutil_put16(buf+i, l); - if (l) - memcpy(buf+i, v, l); - i += l; - - return i; -} -#endif