Mercurial > pidgin
diff src/protocols/oscar/tlv.c @ 3952:07283934dedd
[gaim-migrate @ 4133]
Ok, big commit with little functionality change.
Most of it is me shuffling crap around because I'm one of them neat freaks. Lots of general code
cleanup too. I'm trying to move to that whole "one-family-per-file" thing.
The details...
I added libfaim support for aim's new search family, 0x000f. I only tested this briefly, so if
anyone uses it for anything, be aware that it could be buggy. I'll add oscar support sometime.
Advantages of this family are... when you search for someone, you get the directory info for that
person. So like, first name, middle name, last name, maiden name, city, state, country, zip,
address, interests, nickname, and maybe some other stuff. Basically all the info that they've set in
their directory info thing. Info. Oh, and I'm calling it "new search" because seach was already
taken, and cookie monster ate my right brain.
The reason I didn't add support to oscar.c... the new search family requires making a connection to
another server. While moving stuff around I realized that I didn't really like how new connections
are made. It's kind of sloppy. I'm thinking it would be nice to have an outgoing queue for each
type of connection, and then let the client queue messages as much as they want. Then, if libfaim
sees that there is a message for a certain type of connection, and there is no open connection of
that type, it will connect, and then flush the queue when the connection is made. This seems a lot
cleaner, but it also seems like a pain in the ass. I should do ssi for icq first, anyway :-)
Also, I think it would be neat if there was an ICBM file that handled channels 1 through 4. Then
im.c and chat.c could pass the ICBM part to the icbm stuff and it could get parsed there. im.c is
really huge right now.
I applied a patch from Graham Booker that paves the way for unicode in direct IMs. Thanks Graham.
Now we just need Paco-Paco to git a little free time and write a patch for this.
http://sourceforge.net/tracker/index.php?func=detail&aid=633589&group_id=235&atid=300235
I applied 2 patches from Will Mahan dealing with file transfer/oft/rendezous/whatever. Here's some
info on them, from The Man himself:
Patch 1
"Currently the Rendezvous code is rather messy; this
patch attempts to bring it up to speed with the rest of
the Oscar prpl. Its changes include:
* Rewrite several ft.c functions to use bstreams.
Apparently the code in question was written before
bstreams were implemented.
* Handle incoming Rendezvous packets through the
rxqueue like FLAP packets, rather than handling them as
a special case as soon as they are received. This
takes advantage of the bstream cleanup to unify some
code and simplify the aim_frame_t struct.
* Change some names used to try to clarify the
distinction between OFT, which refers specifically to
file transfer, and Rendezvous, which encompasses OFT as
well as other types of client-to-client connections."
Patch 2
"* Add some comments I inadvertently left out of my last patch.
* Fix a double-free that occurs when connections time out.
* Correct a bug causing filenames to be truncated by 4 characters on
some clients.
* Preserve directory structure when sending multiple files.
* Handle (throw away) resource forks sent by Mac clients."
I also changed all indents to tabs in ft.c.
And split all the bstream stuff from rxqueue.c and put it in bstream.c. It really is a separate
thing. Especially since it can be used for outgoing connections.
Also, I was going to look over the whole patch tonight to make sure it's all good, but it's like 6000
lines, so, uh, I'll do it later.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 13 Nov 2002 07:01:37 +0000 |
parents | e73c48cf1645 |
children | 9f729d6d88a6 |
line wrap: on
line diff
--- a/src/protocols/oscar/tlv.c Tue Nov 12 03:40:19 2002 +0000 +++ b/src/protocols/oscar/tlv.c Wed Nov 13 07:01:37 2002 +0000 @@ -28,8 +28,7 @@ /** * aim_readtlvchain - Read a TLV chain from a buffer. - * @buf: Input buffer - * @maxlen: Length of input buffer + * @param bs Input bstream * * Reads and parses a series of TLV patterns from a data buffer; the * returned structure is manipulatable with the rest of the TLV @@ -109,6 +108,74 @@ } /** + * aim_readtlvchain_num - Read a TLV chain from a buffer. + * @param bs Input bstream + * @param num The max number of TLVs that will be read, or -1 if unlimited. + * There are a number of places where you want to read in a tlvchain, + * 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. + * + * 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 + * be called to free the dynamic substructures. + * + * XXX There should be a flag setable here to have the tlvlist contain + * bstream references, so that at least the ->value portion of each + * element doesn't need to be malloc/memcpy'd. This could prove to be + * just as effecient as the in-place TLV parsing used in a couple places + * in libfaim. + * + */ +faim_internal aim_tlvlist_t *aim_readtlvchain_num(aim_bstream_t *bs, fu16_t num) +{ + aim_tlvlist_t *list = NULL, *cur; + + while ((aim_bstream_empty(bs) > 0) && (num != 0)) { + fu16_t type, length; + + type = aimbs_get16(bs); + length = aimbs_get16(bs); + + if (length > aim_bstream_empty(bs)) { + aim_freetlvchain(&list); + return NULL; + } + + cur = (aim_tlvlist_t *)malloc(sizeof(aim_tlvlist_t)); + if (!cur) { + aim_freetlvchain(&list); + return NULL; + } + + memset(cur, 0, sizeof(aim_tlvlist_t)); + + cur->tlv = createtlv(); + if (!cur->tlv) { + free(cur); + aim_freetlvchain(&list); + return NULL; + } + cur->tlv->type = type; + if ((cur->tlv->length = length)) { + cur->tlv->value = aimbs_getraw(bs, length); + if (!cur->tlv->value) { + freetlv(&cur->tlv); + free(cur); + aim_freetlvchain(&list); + return NULL; + } + } + + num--; + cur->next = list; + list = cur; + } + + return list; +} + +/** * aim_freetlvchain - Free a TLV chain structure * @list: Chain to be freed * @@ -246,8 +313,8 @@ /** * aim_addtlvtochain16 - Add a 16bit integer to a TLV chain * @list: Destination chain - * @type: TLV type to add - * @val: Value to add + * @t: TLV type to add + * @v: Value to add * * Adds a two-byte unsigned integer to a TLV chain. * @@ -608,4 +675,3 @@ return i; } #endif -