Mercurial > pidgin.yaz
comparison src/protocols/oscar/tlv.c @ 4230:9f729d6d88a6
[gaim-migrate @ 4475]
This is 128KB of raw kickassyness. AKA ICQ SSI.
I've rewritten all the important parts of ssi.c. Things should be better.
One thing I like a lot is that gaim will store the alias you assign to
buddies in your server list for both AIM and ICQ. WinICQ supports this,
but WinAIM doesn't. However, it doesn't seem to interfere with WinAIM,
and Gaim can still use it. I dunno, I just think it's neat.
Anyway, go nuts. Let me know if something doesn't work, because that's bad.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 07 Jan 2003 21:19:05 +0000 |
parents | 07283934dedd |
children | 7c9f3d0fe8b2 |
comparison
equal
deleted
inserted
replaced
4229:c1857c9c912d | 4230:9f729d6d88a6 |
---|---|
111 * aim_readtlvchain_num - Read a TLV chain from a buffer. | 111 * aim_readtlvchain_num - Read a TLV chain from a buffer. |
112 * @param bs Input bstream | 112 * @param bs Input bstream |
113 * @param num The max number of TLVs that will be read, or -1 if unlimited. | 113 * @param num The max number of TLVs that will be read, or -1 if unlimited. |
114 * There are a number of places where you want to read in a tlvchain, | 114 * There are a number of places where you want to read in a tlvchain, |
115 * but the chain is not at the end of the SNAC, and the chain is | 115 * but the chain is not at the end of the SNAC, and the chain is |
116 * preceeded by the number of TLVs. So you can limit that. | 116 * preceeded by the number of TLVs. So you can limit that with this. |
117 * | |
118 * AAA - Change this. It would never need to read in unlimited, right? | |
119 * That's what aim_readtlvchain() is for. Dumb ass. | |
117 * | 120 * |
118 * Reads and parses a series of TLV patterns from a data buffer; the | 121 * Reads and parses a series of TLV patterns from a data buffer; the |
119 * returned structure is manipulatable with the rest of the TLV | 122 * returned structure is manipulatable with the rest of the TLV |
120 * routines. When done with a TLV chain, aim_freetlvchain() should | 123 * routines. When done with a TLV chain, aim_freetlvchain() should |
121 * be called to free the dynamic substructures. | 124 * be called to free the dynamic substructures. |
174 | 177 |
175 return list; | 178 return list; |
176 } | 179 } |
177 | 180 |
178 /** | 181 /** |
182 * aim_readtlvchain_num - Read a TLV chain from a buffer. | |
183 * @param bs Input bstream | |
184 * @param len The max length in bytes that will be read. | |
185 * There are a number of places where you want to read in a tlvchain, | |
186 * but the chain is not at the end of the SNAC, and the chain is | |
187 * preceeded by the length of the TLVs. So you can limit that with this. | |
188 * | |
189 * Reads and parses a series of TLV patterns from a data buffer; the | |
190 * returned structure is manipulatable with the rest of the TLV | |
191 * routines. When done with a TLV chain, aim_freetlvchain() should | |
192 * be called to free the dynamic substructures. | |
193 * | |
194 * XXX There should be a flag setable here to have the tlvlist contain | |
195 * bstream references, so that at least the ->value portion of each | |
196 * element doesn't need to be malloc/memcpy'd. This could prove to be | |
197 * just as effecient as the in-place TLV parsing used in a couple places | |
198 * in libfaim. | |
199 * | |
200 */ | |
201 faim_internal aim_tlvlist_t *aim_readtlvchain_len(aim_bstream_t *bs, fu16_t len) | |
202 { | |
203 aim_tlvlist_t *list = NULL, *cur; | |
204 | |
205 while ((aim_bstream_empty(bs) > 0) && (len > 0)) { | |
206 fu16_t type, length; | |
207 | |
208 type = aimbs_get16(bs); | |
209 length = aimbs_get16(bs); | |
210 | |
211 if (length > aim_bstream_empty(bs)) { | |
212 aim_freetlvchain(&list); | |
213 return NULL; | |
214 } | |
215 | |
216 cur = (aim_tlvlist_t *)malloc(sizeof(aim_tlvlist_t)); | |
217 if (!cur) { | |
218 aim_freetlvchain(&list); | |
219 return NULL; | |
220 } | |
221 | |
222 memset(cur, 0, sizeof(aim_tlvlist_t)); | |
223 | |
224 cur->tlv = createtlv(); | |
225 if (!cur->tlv) { | |
226 free(cur); | |
227 aim_freetlvchain(&list); | |
228 return NULL; | |
229 } | |
230 cur->tlv->type = type; | |
231 if ((cur->tlv->length = length)) { | |
232 cur->tlv->value = aimbs_getraw(bs, length); | |
233 if (!cur->tlv->value) { | |
234 freetlv(&cur->tlv); | |
235 free(cur); | |
236 aim_freetlvchain(&list); | |
237 return NULL; | |
238 } | |
239 } | |
240 | |
241 len -= aim_sizetlvchain(&cur); | |
242 cur->next = list; | |
243 list = cur; | |
244 } | |
245 | |
246 return list; | |
247 } | |
248 | |
249 /** | |
250 * aim_tlvlist_copy - Duplicate a TLV chain. | |
251 * @param orig | |
252 * | |
253 * This is pretty pelf exslanatory. | |
254 * | |
255 */ | |
256 faim_internal aim_tlvlist_t *aim_tlvlist_copy(aim_tlvlist_t *orig) | |
257 { | |
258 aim_tlvlist_t *new = NULL; | |
259 | |
260 while (orig) { | |
261 aim_addtlvtochain_raw(&new, orig->tlv->type, orig->tlv->length, orig->tlv->value); | |
262 orig = orig->next; | |
263 } | |
264 | |
265 return new; | |
266 } | |
267 | |
268 /** | |
179 * aim_freetlvchain - Free a TLV chain structure | 269 * aim_freetlvchain - Free a TLV chain structure |
180 * @list: Chain to be freed | 270 * @list: Chain to be freed |
181 * | 271 * |
182 * Walks the list of TLVs in the passed TLV chain and | 272 * Walks the list of TLVs in the passed TLV chain and |
183 * frees each one. Note that any references to this data | 273 * frees each one. Note that any references to this data |