Mercurial > pidgin.yaz
comparison src/protocols/oscar/aim.h @ 2246:933346315b9b
[gaim-migrate @ 2256]
heh.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 09 Sep 2001 10:07:14 +0000 |
parents | 016c5307f26b |
children | d82efea341ef |
comparison
equal
deleted
inserted
replaced
2245:31157c54fe6e | 2246:933346315b9b |
---|---|
37 #include <unistd.h> | 37 #include <unistd.h> |
38 #include <netinet/in.h> | 38 #include <netinet/in.h> |
39 #include <sys/socket.h> | 39 #include <sys/socket.h> |
40 #endif | 40 #endif |
41 | 41 |
42 /* XXX adjust these based on autoconf-detected platform */ | |
43 typedef unsigned char fu8_t; | |
44 typedef unsigned short fu16_t; | |
45 typedef unsigned long fu32_t; | |
46 typedef fu32_t aim_snacid_t; | |
47 typedef fu16_t flap_seqnum_t; | |
48 | |
42 #ifdef FAIM_USEPTHREADS | 49 #ifdef FAIM_USEPTHREADS |
43 #include <pthread.h> | 50 #include <pthread.h> |
44 #define faim_mutex_t pthread_mutex_t | 51 #define faim_mutex_t pthread_mutex_t |
45 #define faim_mutex_init(x) pthread_mutex_init(x, NULL) | 52 #define faim_mutex_init(x) pthread_mutex_init(x, NULL) |
46 #define faim_mutex_lock(x) pthread_mutex_lock(x) | 53 #define faim_mutex_lock(x) pthread_mutex_lock(x) |
51 * For platforms without pthreads, we also assume | 58 * For platforms without pthreads, we also assume |
52 * we're not linking against a threaded app. Which | 59 * we're not linking against a threaded app. Which |
53 * means we don't have to do real locking. The | 60 * means we don't have to do real locking. The |
54 * macros below do nothing really. They're a joke. | 61 * macros below do nothing really. They're a joke. |
55 * But they get it to compile. | 62 * But they get it to compile. |
56 */ | 63 * |
57 #define faim_mutex_t char | 64 * XXX NOTE that locking hasn't really been tested in a long time, |
65 * and most code written after dec2000 --is not thread safe--. You'll | |
66 * want to audit locking use before you use less-than-library level | |
67 * concurrency. | |
68 * | |
69 */ | |
70 #define faim_mutex_t fu8_t | |
58 #define faim_mutex_init(x) *x = 0 | 71 #define faim_mutex_init(x) *x = 0 |
59 #define faim_mutex_lock(x) while(*x != 0) {/* spin */}; *x = 1; | 72 #define faim_mutex_lock(x) while(*x != 0) {/* spin */}; *x = 1; |
60 #define faim_mutex_unlock(x) while(*x != 0) {/* spin spin spin */}; *x = 0; | 73 #define faim_mutex_unlock(x) while(*x != 0) {/* spin spin spin */}; *x = 0; |
61 #define faim_mutex_destroy(x) while(*x != 0) {/* spiiiinnn */}; *x = 0; | 74 #define faim_mutex_destroy(x) while(*x != 0) {/* spiiiinnn */}; *x = 0; |
62 #elif defined(FAIM_USENOPLOCKS) | 75 #elif defined(FAIM_USENOPLOCKS) |
63 #define faim_mutex_t char | 76 #define faim_mutex_t fu8_t |
64 #define faim_mutex_init(x) | 77 #define faim_mutex_init(x) |
65 #define faim_mutex_lock(x) | 78 #define faim_mutex_lock(x) |
66 #define faim_mutex_unlock(x) | 79 #define faim_mutex_unlock(x) |
67 #define faim_mutex_destroy(x) | 80 #define faim_mutex_destroy(x) |
68 #endif | 81 #endif |
162 * | 175 * |
163 * XXX: Should this be per-session? -mid | 176 * XXX: Should this be per-session? -mid |
164 * | 177 * |
165 */ | 178 */ |
166 struct client_info_s { | 179 struct client_info_s { |
167 char clientstring[100]; /* arbitrary size */ | 180 char clientstring[100]; /* arbitrary size */ |
168 int major; | 181 int major; |
169 int minor; | 182 int minor; |
170 int build; | 183 int build; |
171 char country[3]; | 184 char country[3]; |
172 char lang[3]; | 185 char lang[3]; |
173 int major2; | 186 int major2; |
174 int minor2; | 187 int minor2; |
175 long unknown; | 188 long unknown; |
176 }; | 189 }; |
177 | 190 |
178 #define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \ | 191 #define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \ |
179 "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \ | 192 "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \ |
180 0x0003, \ | 193 0x0003, \ |
181 0x0005, \ | 194 0x0005, \ |
182 0x0686, \ | 195 0x0686, \ |
183 "us", \ | 196 "us", \ |
184 "en", \ | 197 "en", \ |
185 0x0004, \ | 198 0x0004, \ |
186 0x0000, \ | 199 0x0000, \ |
187 0x0000002a, \ | 200 0x0000002a, \ |
188 } | 201 } |
189 | 202 |
190 #define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \ | 203 #define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \ |
191 "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \ | 204 "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \ |
192 0x0004, \ | 205 0x0004, \ |
193 0x0001, \ | 206 0x0001, \ |
194 0x07da, \ | 207 0x07da, \ |
195 "us", \ | 208 "us", \ |
196 "en", \ | 209 "en", \ |
197 0x0004, \ | 210 0x0004, \ |
198 0x0000, \ | 211 0x0000, \ |
199 0x0000004b, \ | 212 0x0000004b, \ |
200 } | 213 } |
201 | 214 |
202 /* | 215 /* |
203 * I would make 4.1.2010 the default, but they seem to have found | 216 * I would make 4.1.2010 the default, but they seem to have found |
204 * an alternate way of breaking that one. | 217 * an alternate way of breaking that one. |
222 #define AIM_CONN_TYPE_BOS 0x0002 | 235 #define AIM_CONN_TYPE_BOS 0x0002 |
223 #define AIM_CONN_TYPE_CHAT 0x000e | 236 #define AIM_CONN_TYPE_CHAT 0x000e |
224 #define AIM_CONN_TYPE_CHATNAV 0x000d | 237 #define AIM_CONN_TYPE_CHATNAV 0x000d |
225 | 238 |
226 /* they start getting arbitrary in rendezvous stuff =) */ | 239 /* they start getting arbitrary in rendezvous stuff =) */ |
227 #define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak OSCAR! */ | 240 #define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak FLAP! */ |
228 #define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */ | 241 #define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */ |
229 | 242 |
230 /* | 243 /* |
231 * Subtypes, we need these for OFT stuff. | 244 * Subtypes, we need these for OFT stuff. |
232 */ | 245 */ |
243 #define AIM_CONN_STATUS_INTERNALERR 0x0002 | 256 #define AIM_CONN_STATUS_INTERNALERR 0x0002 |
244 #define AIM_CONN_STATUS_RESOLVERR 0x0040 | 257 #define AIM_CONN_STATUS_RESOLVERR 0x0040 |
245 #define AIM_CONN_STATUS_CONNERR 0x0080 | 258 #define AIM_CONN_STATUS_CONNERR 0x0080 |
246 #define AIM_CONN_STATUS_INPROGRESS 0x0100 | 259 #define AIM_CONN_STATUS_INPROGRESS 0x0100 |
247 | 260 |
248 #define AIM_FRAMETYPE_OSCAR 0x0000 | 261 #define AIM_FRAMETYPE_FLAP 0x0000 |
249 #define AIM_FRAMETYPE_OFT 0x0001 | 262 #define AIM_FRAMETYPE_OFT 0x0001 |
250 | 263 |
251 struct aim_conn_t { | 264 typedef struct aim_conn_s { |
252 int fd; | 265 int fd; |
253 unsigned short type; | 266 fu16_t type; |
254 unsigned short subtype; | 267 fu16_t subtype; |
255 int seqnum; | 268 flap_seqnum_t seqnum; |
256 int status; | 269 fu32_t status; |
257 void *priv; /* misc data the client may want to store */ | 270 void *priv; /* misc data the client may want to store */ |
258 time_t lastactivity; /* time of last transmit */ | 271 void *internal; /* internal conn-specific libfaim data */ |
259 int forcedlatency; | 272 time_t lastactivity; /* time of last transmit */ |
260 struct aim_rxcblist_t *handlerlist; | 273 int forcedlatency; |
261 faim_mutex_t active; /* lock around read/writes */ | 274 void *handlerlist; |
262 faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */ | 275 faim_mutex_t active; /* lock around read/writes */ |
263 void *sessv; | 276 faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */ |
264 struct aim_conn_t *next; | 277 void *sessv; /* pointer to parent session */ |
265 }; | 278 struct aim_conn_s *next; |
266 | 279 } aim_conn_t; |
267 /* struct for incoming commands */ | 280 |
268 struct command_rx_struct { | 281 /* |
269 unsigned char hdrtype; /* defines which piece of the union to use */ | 282 * Byte Stream type. Sort of. |
270 union { | 283 * |
271 struct { | 284 * Use of this type serves a couple purposes: |
272 char type; | 285 * - Buffer/buflen pairs are passed all around everywhere. This turns |
273 unsigned short seqnum; | 286 * that into one value, as well as abstracting it slightly. |
274 } oscar; | 287 * - Through the abstraction, it is possible to enable bounds checking |
275 struct { | 288 * for robustness at the cost of performance. But a clean failure on |
276 unsigned short type; | 289 * weird packets is much better than a segfault. |
277 unsigned char magic[4]; /* ODC2 OFT2 */ | 290 * - I like having variables named "bs". |
278 unsigned short hdr2len; | 291 * |
279 unsigned char *hdr2; /* rest of bloated header */ | 292 * Don't touch the insides of this struct. Or I'll have to kill you. |
280 } oft; | 293 * |
281 } hdr; | 294 */ |
282 unsigned short commandlen; /* total payload length */ | 295 typedef struct aim_bstream_s { |
283 unsigned char *data; /* packet data (from 7 byte on) */ | 296 fu8_t *data; |
284 unsigned char lock; /* 0 = open, !0 = locked */ | 297 fu16_t len; |
285 unsigned char handled; /* 0 = new, !0 = been handled */ | 298 fu16_t offset; |
286 unsigned char nofree; /* 0 = free data on purge, 1 = only unlink */ | 299 } aim_bstream_t; |
287 struct aim_conn_t *conn; /* the connection it came in on... */ | 300 |
288 struct command_rx_struct *next; /* ptr to next struct in list */ | 301 typedef struct aim_frame_s { |
289 }; | 302 fu8_t hdrtype; /* defines which piece of the union to use */ |
290 | 303 union { |
291 /* struct for outgoing commands */ | 304 struct { |
292 struct command_tx_struct { | 305 fu8_t type; |
293 unsigned char hdrtype; /* defines which piece of the union to use */ | 306 flap_seqnum_t seqnum; |
294 union { | 307 } flap; |
295 struct { | 308 struct { |
296 unsigned char type; | 309 fu16_t type; |
297 unsigned short seqnum; | 310 fu8_t magic[4]; /* ODC2 OFT2 */ |
298 } oscar; | 311 fu16_t hdr2len; |
299 struct { | 312 fu8_t *hdr2; /* rest of bloated header */ |
300 unsigned short type; | 313 } oft; |
301 unsigned char magic[4]; /* ODC2 OFT2 */ | 314 } hdr; |
302 unsigned short hdr2len; | 315 aim_bstream_t data; /* payload stream */ |
303 unsigned char *hdr2; | 316 fu8_t handled; /* 0 = new, !0 = been handled */ |
304 } oft; | 317 fu8_t nofree; /* 0 = free data on purge, 1 = only unlink */ |
305 } hdr; | 318 aim_conn_t *conn; /* the connection it came in on... */ |
306 u_int commandlen; | 319 struct aim_frame_s *next; |
307 u_char *data; | 320 } aim_frame_t; |
308 u_int lock; /* 0 = open, !0 = locked */ | 321 |
309 u_int sent; /* 0 = pending, !0 = has been sent */ | 322 typedef struct aim_msgcookie_s { |
310 struct aim_conn_t *conn; | 323 unsigned char cookie[8]; |
311 struct command_tx_struct *next; /* ptr to next struct in list */ | 324 int type; |
312 }; | 325 void *data; |
326 time_t addtime; | |
327 struct aim_msgcookie_s *next; | |
328 } aim_msgcookie_t; | |
313 | 329 |
314 /* | 330 /* |
315 * AIM Session: The main client-data interface. | 331 * AIM Session: The main client-data interface. |
316 * | 332 * |
317 */ | 333 */ |
318 struct aim_session_t { | 334 typedef struct aim_session_s { |
319 | 335 |
320 /* ---- Client Accessible ------------------------ */ | 336 /* ---- Client Accessible ------------------------ */ |
321 /* | 337 |
322 * Our screen name. | 338 /* Our screen name. */ |
323 * | 339 char sn[MAXSNLEN+1]; |
324 */ | 340 |
325 char sn[MAXSNLEN+1]; | 341 /* |
326 | 342 * Pointer to anything the client wants to |
327 /* | 343 * explicitly associate with this session. |
328 * Pointer to anything the client wants to | 344 * |
329 * explicitly associate with this session. | 345 * This is for use in the callbacks mainly. In any |
330 * | 346 * callback, you can access this with sess->aux_data. |
331 * This is for use in the callbacks mainly. In any | 347 * |
332 * callback, you can access this with sess->aux_data. | 348 */ |
333 * | 349 void *aux_data; |
334 */ | 350 |
335 void *aux_data; | 351 /* ---- Internal Use Only ------------------------ */ |
336 | 352 |
337 /* ---- Internal Use Only ------------------------ */ | 353 /* Connection information */ |
338 /* | 354 aim_conn_t *connlist; |
339 * Connection information | 355 faim_mutex_t connlistlock; |
340 */ | 356 |
341 struct aim_conn_t *connlist; | 357 /* |
342 faim_mutex_t connlistlock; | 358 * Transmit/receive queues. |
343 | 359 * |
344 /* | 360 * These are only used when you don't use your own lowlevel |
345 * TX/RX queues | 361 * I/O. I don't suggest that you use libfaim's internal I/O. |
346 */ | 362 * Its really bad and the API/event model is quirky at best. |
347 struct command_tx_struct *queue_outgoing; | 363 * |
348 struct command_rx_struct *queue_incoming; | 364 */ |
349 | 365 aim_frame_t *queue_outgoing; |
350 /* | 366 aim_frame_t *queue_incoming; |
351 * Tx Enqueuing function | 367 |
352 */ | 368 /* |
353 int (*tx_enqueue)(struct aim_session_t *, struct command_tx_struct *); | 369 * Tx Enqueuing function. |
354 | 370 * |
355 /* | 371 * This is how you override the transmit direction of libfaim's |
356 * This is a dreadful solution to the what-room-are-we-joining | 372 * internal I/O. This function will be called whenever it needs |
357 * problem. (There's no connection between the service | 373 * to send something. |
358 * request and the resulting redirect.) | 374 * |
359 */ | 375 */ |
360 char *pendingjoin; | 376 int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *); |
361 unsigned short pendingjoinexchange; | 377 |
362 | 378 /* |
363 /* | 379 * This is a dreadful solution to the what-room-are-we-joining |
364 * Outstanding snac handling | 380 * problem. (There's no connection between the service |
365 * | 381 * request and the resulting redirect.) |
366 * XXX: Should these be per-connection? -mid | 382 */ |
367 */ | 383 char *pendingjoin; |
368 struct aim_snac_t *snac_hash[FAIM_SNAC_HASH_SIZE]; | 384 fu16_t pendingjoinexchange; |
369 faim_mutex_t snac_hash_locks[FAIM_SNAC_HASH_SIZE]; | 385 |
370 unsigned long snac_nextid; | 386 /* |
371 | 387 * Outstanding snac handling |
372 struct { | 388 * |
373 char server[128]; | 389 * XXX: Should these be per-connection? -mid |
374 char username[128]; | 390 */ |
375 char password[128]; | 391 void *snac_hash[FAIM_SNAC_HASH_SIZE]; |
376 } socksproxy; | 392 faim_mutex_t snac_hash_locks[FAIM_SNAC_HASH_SIZE]; |
377 | 393 aim_snacid_t snacid_next; |
378 unsigned long flags; | 394 |
379 | 395 struct { |
380 int debug; | 396 char server[128]; |
381 void (*debugcb)(struct aim_session_t *sess, int level, const char *format, va_list va); /* same as faim_debugging_callback_t */ | 397 char username[128]; |
382 | 398 char password[128]; |
383 struct aim_msgcookie_t *msgcookies; | 399 } socksproxy; |
384 | 400 |
385 void *modlistv; | 401 fu32_t flags; /* AIM_SESS_FLAGS_ */ |
386 }; | 402 |
403 int debug; | |
404 void (*debugcb)(struct aim_session_s *sess, int level, const char *format, va_list va); /* same as faim_debugging_callback_t */ | |
405 | |
406 aim_msgcookie_t *msgcookies; | |
407 | |
408 void *modlistv; | |
409 } aim_session_t; | |
387 | 410 |
388 /* Values for sess->flags */ | 411 /* Values for sess->flags */ |
389 #define AIM_SESS_FLAGS_SNACLOGIN 0x00000001 | 412 #define AIM_SESS_FLAGS_SNACLOGIN 0x00000001 |
390 #define AIM_SESS_FLAGS_XORLOGIN 0x00000002 | 413 #define AIM_SESS_FLAGS_XORLOGIN 0x00000002 |
391 #define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004 | 414 #define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004 |
392 | 415 |
393 /* | 416 /* |
394 * AIM User Info, Standard Form. | 417 * AIM User Info, Standard Form. |
395 */ | 418 */ |
396 struct aim_userinfo_s { | 419 struct aim_userinfo_s { |
397 char sn[MAXSNLEN+1]; | 420 char sn[MAXSNLEN+1]; |
398 u_short warnlevel; | 421 fu16_t warnlevel; |
399 u_short idletime; | 422 fu16_t idletime; |
400 u_short flags; | 423 fu16_t flags; |
401 u_long membersince; | 424 fu32_t membersince; |
402 u_long onlinesince; | 425 fu32_t onlinesince; |
403 u_long sessionlen; | 426 fu32_t sessionlen; |
404 u_short capabilities; | 427 fu16_t capabilities; |
405 struct { | 428 struct { |
406 unsigned short status; | 429 fu16_t status; |
407 unsigned int ipaddr; | 430 fu32_t ipaddr; |
408 char crap[0x25]; /* until we figure it out... */ | 431 fu8_t crap[0x25]; /* until we figure it out... */ |
409 } icqinfo; | 432 } icqinfo; |
410 }; | 433 }; |
411 | 434 |
412 #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */ | 435 #define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */ |
413 #define AIM_FLAG_ADMINISTRATOR 0x0002 | 436 #define AIM_FLAG_ADMINISTRATOR 0x0002 |
414 #define AIM_FLAG_AOL 0x0004 | 437 #define AIM_FLAG_AOL 0x0004 |
425 /* | 448 /* |
426 * TLV handling | 449 * TLV handling |
427 */ | 450 */ |
428 | 451 |
429 /* Generic TLV structure. */ | 452 /* Generic TLV structure. */ |
430 struct aim_tlv_t { | 453 typedef struct aim_tlv_s { |
431 u_short type; | 454 fu16_t type; |
432 u_short length; | 455 fu16_t length; |
433 u_char *value; | 456 fu8_t *value; |
434 }; | 457 } aim_tlv_t; |
435 | 458 |
436 /* List of above. */ | 459 /* List of above. */ |
437 struct aim_tlvlist_t { | 460 typedef struct aim_tlvlist_s { |
438 struct aim_tlv_t *tlv; | 461 aim_tlv_t *tlv; |
439 struct aim_tlvlist_t *next; | 462 struct aim_tlvlist_s *next; |
440 }; | 463 } aim_tlvlist_t; |
441 | 464 |
442 /* TLV-handling functions */ | 465 /* TLV-handling functions */ |
443 faim_internal struct aim_tlvlist_t *aim_readtlvchain(const unsigned char *buf, const int maxlen); | 466 |
444 faim_internal void aim_freetlvchain(struct aim_tlvlist_t **list); | 467 #if 0 |
445 faim_internal struct aim_tlv_t *aim_grabtlv(const unsigned char *src); | 468 /* Very, very raw TLV handling. */ |
446 faim_internal struct aim_tlv_t *aim_grabtlvstr(const unsigned char *src); | 469 faim_internal int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v); |
447 faim_internal struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, const unsigned short, const int); | 470 faim_internal int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v); |
448 faim_internal char *aim_gettlv_str(struct aim_tlvlist_t *, const unsigned short, const int); | 471 faim_internal int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v); |
449 faim_internal unsigned char aim_gettlv8(struct aim_tlvlist_t *list, const unsigned short type, const int num); | 472 faim_internal int aim_puttlv_raw(fu8_t *buf, const fu16_t t, const fu16_t l, const fu8_t *v); |
450 faim_internal unsigned short aim_gettlv16(struct aim_tlvlist_t *list, const unsigned short type, const int num); | 473 #endif |
451 faim_internal unsigned long aim_gettlv32(struct aim_tlvlist_t *list, const unsigned short type, const int num); | 474 |
452 faim_internal int aim_puttlv (unsigned char *dest, struct aim_tlv_t *newtlv); | 475 /* TLV list handling. */ |
453 faim_internal struct aim_tlv_t *aim_createtlv(void); | 476 faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs); |
454 faim_internal int aim_freetlv(struct aim_tlv_t **oldtlv); | 477 faim_internal void aim_freetlvchain(aim_tlvlist_t **list); |
455 faim_internal int aim_puttlv_8(unsigned char *buf, const unsigned short t, const unsigned char v); | 478 faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *, fu16_t t, const int n); |
456 faim_internal int aim_puttlv_16(unsigned char *, const unsigned short, const unsigned short); | 479 faim_internal char *aim_gettlv_str(aim_tlvlist_t *, const fu16_t t, const int n); |
457 faim_internal int aim_puttlv_32(unsigned char *, const unsigned short, const unsigned long); | 480 faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t type, const int num); |
458 faim_internal int aim_puttlv_str(u_char *buf, const unsigned short t, const int l, const char *v); | 481 faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t t, const int n); |
459 faim_internal int aim_writetlvchain(unsigned char *buf, const int buflen, struct aim_tlvlist_t **list); | 482 faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t t, const int n); |
460 faim_internal int aim_addtlvtochain16(struct aim_tlvlist_t **list, const unsigned short type, const unsigned short val); | 483 faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list); |
461 faim_internal int aim_addtlvtochain32(struct aim_tlvlist_t **list, const unsigned short type, const unsigned long val); | 484 faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t t, const fu16_t v); |
462 faim_internal int aim_addtlvtochain_str(struct aim_tlvlist_t **list, const unsigned short type, const char *str, const int len); | 485 faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t type, const fu32_t v); |
463 faim_internal int aim_addtlvtochain_caps(struct aim_tlvlist_t **list, const unsigned short type, const unsigned short caps); | 486 faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t t, const fu16_t l, const fu8_t *v); |
464 faim_internal int aim_addtlvtochain_noval(struct aim_tlvlist_t **list, const unsigned short type); | 487 faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t t, const fu16_t caps); |
465 faim_internal int aim_counttlvchain(struct aim_tlvlist_t **list); | 488 faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t type); |
489 faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl); | |
490 faim_internal int aim_counttlvchain(aim_tlvlist_t **list); | |
491 faim_export int aim_sizetlvchain(aim_tlvlist_t **list); | |
466 #endif /* FAIM_INTERNAL */ | 492 #endif /* FAIM_INTERNAL */ |
467 | 493 |
468 /* | 494 /* |
469 * Get command from connections / Dispatch commands | 495 * Get command from connections |
470 * already in queue. | 496 * |
471 */ | 497 * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction. |
472 faim_export int aim_get_command(struct aim_session_t *, struct aim_conn_t *); | 498 * XXX Make this easily overridable. |
473 int aim_rxdispatch(struct aim_session_t *); | 499 * |
474 | 500 */ |
475 faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, struct aim_conn_t *conn); | 501 faim_export int aim_get_command(aim_session_t *, aim_conn_t *); |
476 | 502 |
477 faim_export int aim_logoff(struct aim_session_t *); | 503 /* |
504 * Dispatch commands that are in the rx queue. | |
505 */ | |
506 faim_export void aim_rxdispatch(aim_session_t *); | |
507 | |
508 faim_export int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn); | |
509 | |
510 faim_export int aim_logoff(aim_session_t *); | |
478 | 511 |
479 #if !defined(FAIM_INTERNAL) || defined(FAIM_INTERNAL_INSANE) | 512 #if !defined(FAIM_INTERNAL) || defined(FAIM_INTERNAL_INSANE) |
480 /* the library should never call aim_conn_kill */ | 513 /* the library should never call aim_conn_kill */ |
481 faim_export void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn); | 514 faim_export void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn); |
482 #endif | 515 #endif |
483 | 516 |
484 typedef int (*aim_rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...); | 517 typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...); |
485 | 518 |
486 /* aim_login.c */ | 519 /* aim_login.c */ |
487 faim_export int aim_sendflapver(struct aim_session_t *sess, struct aim_conn_t *conn); | 520 faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn); |
488 faim_export int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn); | 521 faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
489 faim_export int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *, char *key); | 522 faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key); |
490 faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest); | 523 faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest); |
491 faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, int errorcode, char *errorurl, char *bosip, char *cookie, char *email, int regstatus); | 524 faim_export int aim_sendauthresp(aim_session_t *sess, aim_conn_t *conn, const char *sn, int errorcode, const char *errorurl, const char *bosip, const char *cookie, const char *email, int regstatus); |
492 faim_export int aim_gencookie(unsigned char *buf); | 525 faim_export int aim_gencookie(unsigned char *buf); |
493 faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn); | 526 faim_export int aim_sendserverready(aim_session_t *sess, aim_conn_t *conn); |
494 faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short servid, char *ip, char *cookie); | 527 faim_export int aim_sendredirect(aim_session_t *sess, aim_conn_t *conn, fu16_t servid, const char *ip, const char *cookie); |
495 faim_export void aim_purge_rxqueue(struct aim_session_t *); | 528 faim_export void aim_purge_rxqueue(aim_session_t *); |
496 | 529 |
497 #define AIM_TX_QUEUED 0 /* default */ | 530 #define AIM_TX_QUEUED 0 /* default */ |
498 #define AIM_TX_IMMEDIATE 1 | 531 #define AIM_TX_IMMEDIATE 1 |
499 #define AIM_TX_USER 2 | 532 #define AIM_TX_USER 2 |
500 faim_export int aim_tx_setenqueue(struct aim_session_t *sess, int what, int (*func)(struct aim_session_t *, struct command_tx_struct *)); | 533 faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)); |
501 | 534 |
502 faim_export int aim_tx_flushqueue(struct aim_session_t *); | 535 faim_export int aim_tx_flushqueue(aim_session_t *); |
503 faim_export void aim_tx_purgequeue(struct aim_session_t *); | 536 faim_export void aim_tx_purgequeue(aim_session_t *); |
504 | 537 |
505 struct aim_rxcblist_t { | 538 faim_export int aim_conn_setlatency(aim_conn_t *conn, int newval); |
506 u_short family; | 539 |
507 u_short type; | 540 faim_export int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags); |
508 aim_rxcallback_t handler; | 541 faim_export int aim_clearhandlers(aim_conn_t *conn); |
509 u_short flags; | 542 |
510 struct aim_rxcblist_t *next; | 543 faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn); |
511 }; | 544 faim_export void aim_conn_close(aim_conn_t *deadconn); |
512 | 545 faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest); |
513 faim_export int aim_conn_setlatency(struct aim_conn_t *conn, int newval); | 546 faim_export int aim_conngetmaxfd(aim_session_t *); |
514 | 547 faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *); |
515 faim_export int aim_conn_addhandler(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags); | 548 faim_export int aim_conn_isready(aim_conn_t *); |
516 faim_export int aim_clearhandlers(struct aim_conn_t *conn); | 549 faim_export int aim_conn_setstatus(aim_conn_t *, int); |
517 | 550 faim_export int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn); |
518 faim_export struct aim_session_t *aim_conn_getsess(struct aim_conn_t *conn); | 551 faim_export int aim_conn_isconnecting(aim_conn_t *conn); |
519 faim_export void aim_conn_close(struct aim_conn_t *deadconn); | 552 |
520 faim_export struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest); | 553 typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va); |
521 faim_export int aim_conngetmaxfd(struct aim_session_t *); | 554 faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t); |
522 faim_export struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *); | 555 faim_export void aim_session_init(aim_session_t *, unsigned long flags, int debuglevel); |
523 faim_export int aim_conn_isready(struct aim_conn_t *); | 556 faim_export void aim_session_kill(aim_session_t *); |
524 faim_export int aim_conn_setstatus(struct aim_conn_t *, int); | 557 faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password); |
525 faim_export int aim_conn_completeconnect(struct aim_session_t *sess, struct aim_conn_t *conn); | 558 faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type); |
526 faim_export int aim_conn_isconnecting(struct aim_conn_t *conn); | 559 faim_export aim_conn_t *aim_getconn_type_all(aim_session_t *, int type); |
527 | 560 faim_export aim_conn_t *aim_getconn_fd(aim_session_t *, int fd); |
528 typedef void (*faim_debugging_callback_t)(struct aim_session_t *sess, int level, const char *format, va_list va); | |
529 faim_export int aim_setdebuggingcb(struct aim_session_t *sess, faim_debugging_callback_t); | |
530 faim_export void aim_session_init(struct aim_session_t *, unsigned long flags, int debuglevel); | |
531 faim_export void aim_session_kill(struct aim_session_t *); | |
532 faim_export void aim_setupproxy(struct aim_session_t *sess, char *server, char *username, char *password); | |
533 faim_export struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type); | |
534 faim_export struct aim_conn_t *aim_getconn_type_all(struct aim_session_t *, int type); | |
535 faim_export struct aim_conn_t *aim_getconn_fd(struct aim_session_t *, int fd); | |
536 | 561 |
537 /* aim_misc.c */ | 562 /* aim_misc.c */ |
538 | 563 |
539 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 | 564 #define AIM_VISIBILITYCHANGE_PERMITADD 0x05 |
540 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 | 565 #define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06 |
544 #define AIM_PRIVFLAGS_ALLOWIDLE 0x01 | 569 #define AIM_PRIVFLAGS_ALLOWIDLE 0x01 |
545 #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02 | 570 #define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02 |
546 | 571 |
547 #define AIM_WARN_ANON 0x01 | 572 #define AIM_WARN_ANON 0x01 |
548 | 573 |
549 faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, const char *destsn, unsigned long flags); | 574 faim_export int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags); |
550 faim_export unsigned long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *); | 575 faim_export int aim_bos_nop(aim_session_t *, aim_conn_t *); |
551 faim_export unsigned long aim_flap_nop(struct aim_session_t *sess, struct aim_conn_t *conn); | 576 faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn); |
552 faim_export unsigned long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); | 577 faim_export int aim_bos_setidle(aim_session_t *, aim_conn_t *, fu32_t); |
553 faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); | 578 faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *); |
554 faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *); | 579 faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *); |
555 faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess, struct aim_conn_t *conn, const char *profile, const char *awaymsg, unsigned short caps); | 580 faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu16_t caps); |
556 faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long); | 581 faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask); |
557 faim_export unsigned long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *); | 582 faim_export int aim_bos_clientready(aim_session_t *, aim_conn_t *); |
558 faim_export unsigned long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *); | 583 faim_export int aim_bos_reqrate(aim_session_t *, aim_conn_t *); |
559 faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *); | 584 faim_export int aim_bos_ackrateresp(aim_session_t *, aim_conn_t *); |
560 faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long); | 585 faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t); |
561 faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *); | 586 faim_export int aim_bos_reqpersonalinfo(aim_session_t *, aim_conn_t *); |
562 faim_export unsigned long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short); | 587 faim_export int aim_bos_reqservice(aim_session_t *, aim_conn_t *, fu16_t); |
563 faim_export unsigned long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *); | 588 faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *); |
564 faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *); | 589 faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *); |
565 faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *); | 590 faim_export int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *); |
566 faim_export unsigned long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); | 591 faim_export int aim_setversions(aim_session_t *sess, aim_conn_t *conn); |
567 faim_export unsigned long aim_auth_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); | 592 faim_export int aim_setdirectoryinfo(aim_session_t *sess, aim_conn_t *conn, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, fu16_t privacy); |
568 faim_export unsigned long aim_auth_reqconfirm(struct aim_session_t *sess, struct aim_conn_t *conn); | 593 faim_export int aim_setuserinterests(aim_session_t *sess, aim_conn_t *conn, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy); |
569 faim_export unsigned long aim_auth_getinfo(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short info); | 594 faim_export int aim_icq_setstatus(aim_session_t *sess, aim_conn_t *conn, fu32_t status); |
570 faim_export unsigned long aim_auth_setemail(struct aim_session_t *sess, struct aim_conn_t *conn, char *newemail); | 595 |
571 faim_export unsigned long aim_setdirectoryinfo(struct aim_session_t *sess, struct aim_conn_t *conn, char *first, char *middle, char *last, char *maiden, char *nickname, char *street, char *city, char *state, char *zip, int country, unsigned short privacy); | 596 faim_export struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *); |
572 faim_export unsigned long aim_setuserinterests(struct aim_session_t *sess, struct aim_conn_t *conn, char *interest1, char *interest2, char *interest3, char *interest4, char *interest5, unsigned short privacy); | |
573 faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned long status); | |
574 | |
575 faim_export struct aim_fileheader_t *aim_getlisting(struct aim_session_t *sess, FILE *); | |
576 | |
577 /* aim_rxhandlers.c */ | |
578 faim_export int aim_rxdispatch(struct aim_session_t *); | |
579 | 597 |
580 #define AIM_CLIENTTYPE_UNKNOWN 0x0000 | 598 #define AIM_CLIENTTYPE_UNKNOWN 0x0000 |
581 #define AIM_CLIENTTYPE_MC 0x0001 | 599 #define AIM_CLIENTTYPE_MC 0x0001 |
582 #define AIM_CLIENTTYPE_WINAIM 0x0002 | 600 #define AIM_CLIENTTYPE_WINAIM 0x0002 |
583 #define AIM_CLIENTTYPE_WINAIM41 0x0003 | 601 #define AIM_CLIENTTYPE_WINAIM41 0x0003 |
586 | 604 |
587 #define AIM_RATE_CODE_CHANGE 0x0001 | 605 #define AIM_RATE_CODE_CHANGE 0x0001 |
588 #define AIM_RATE_CODE_WARNING 0x0002 | 606 #define AIM_RATE_CODE_WARNING 0x0002 |
589 #define AIM_RATE_CODE_LIMIT 0x0003 | 607 #define AIM_RATE_CODE_LIMIT 0x0003 |
590 #define AIM_RATE_CODE_CLEARLIMIT 0x0004 | 608 #define AIM_RATE_CODE_CLEARLIMIT 0x0004 |
591 faim_export unsigned long aim_ads_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); | 609 faim_export int aim_ads_clientready(aim_session_t *sess, aim_conn_t *conn); |
592 faim_export unsigned long aim_ads_requestads(struct aim_session_t *sess, struct aim_conn_t *conn); | 610 faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn); |
593 | 611 |
594 /* aim_im.c */ | 612 /* aim_im.c */ |
595 struct aim_directim_priv { | |
596 unsigned char cookie[8]; | |
597 char sn[MAXSNLEN+1]; | |
598 char ip[30]; | |
599 }; | |
600 | 613 |
601 struct aim_fileheader_t { | 614 struct aim_fileheader_t { |
602 #if 0 | 615 #if 0 |
603 char magic[4]; /* 0 */ | 616 char magic[4]; /* 0 */ |
604 short hdrlen; /* 4 */ | 617 short hdrlen; /* 4 */ |
605 short hdrtype; /* 6 */ | 618 short hdrtype; /* 6 */ |
606 #endif | 619 #endif |
607 char bcookie[8]; /* 8 */ | 620 char bcookie[8]; /* 8 */ |
608 short encrypt; /* 16 */ | 621 short encrypt; /* 16 */ |
609 short compress; /* 18 */ | 622 short compress; /* 18 */ |
610 short totfiles; /* 20 */ | 623 short totfiles; /* 20 */ |
611 short filesleft; /* 22 */ | 624 short filesleft; /* 22 */ |
612 short totparts; /* 24 */ | 625 short totparts; /* 24 */ |
613 short partsleft; /* 26 */ | 626 short partsleft; /* 26 */ |
614 long totsize; /* 28 */ | 627 long totsize; /* 28 */ |
615 long size; /* 32 */ | 628 long size; /* 32 */ |
616 long modtime; /* 36 */ | 629 long modtime; /* 36 */ |
617 long checksum; /* 40 */ | 630 long checksum; /* 40 */ |
618 long rfrcsum; /* 44 */ | 631 long rfrcsum; /* 44 */ |
619 long rfsize; /* 48 */ | 632 long rfsize; /* 48 */ |
620 long cretime; /* 52 */ | 633 long cretime; /* 52 */ |
621 long rfcsum; /* 56 */ | 634 long rfcsum; /* 56 */ |
622 long nrecvd; /* 60 */ | 635 long nrecvd; /* 60 */ |
623 long recvcsum; /* 64 */ | 636 long recvcsum; /* 64 */ |
624 char idstring[32]; /* 68 */ | 637 char idstring[32]; /* 68 */ |
625 char flags; /* 100 */ | 638 char flags; /* 100 */ |
626 char lnameoffset; /* 101 */ | 639 char lnameoffset; /* 101 */ |
627 char lsizeoffset; /* 102 */ | 640 char lsizeoffset; /* 102 */ |
628 char dummy[69]; /* 103 */ | 641 char dummy[69]; /* 103 */ |
629 char macfileinfo[16]; /* 172 */ | 642 char macfileinfo[16]; /* 172 */ |
630 short nencode; /* 188 */ | 643 short nencode; /* 188 */ |
631 short nlanguage; /* 190 */ | 644 short nlanguage; /* 190 */ |
632 char name[64]; /* 192 */ | 645 char name[64]; /* 192 */ |
633 /* 256 */ | 646 /* 256 */ |
634 }; | 647 }; |
635 | 648 |
636 struct aim_filetransfer_priv { | 649 struct aim_filetransfer_priv { |
637 char sn[MAXSNLEN]; | 650 char sn[MAXSNLEN]; |
638 char cookie[8]; | 651 char cookie[8]; |
645 unsigned short exchange; | 658 unsigned short exchange; |
646 char *name; | 659 char *name; |
647 unsigned short instance; | 660 unsigned short instance; |
648 }; | 661 }; |
649 | 662 |
650 #define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */ | 663 #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */ |
651 #define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */ | 664 #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */ |
652 #define AIM_IMFLAGS_UNICODE 0x04 | 665 #define AIM_IMFLAGS_UNICODE 0x0004 |
653 #define AIM_IMFLAGS_ISO_8859_1 0x08 | 666 #define AIM_IMFLAGS_ISO_8859_1 0x0008 |
654 #define AIM_IMFLAGS_BUDDYREQ 0x10 /* buddy icon requested */ | 667 #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */ |
655 #define AIM_IMFLAGS_HASICON 0x20 /* already has icon (timestamp included) */ | 668 #define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */ |
656 #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x40 /* damn that Steve Jobs! */ | 669 #define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */ |
670 #define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */ | |
671 #define AIM_IMFLAGS_EXTDATA 0x0100 | |
657 | 672 |
658 struct aim_sendimext_args { | 673 struct aim_sendimext_args { |
674 | |
675 /* These are _required_ */ | |
659 const char *destsn; | 676 const char *destsn; |
660 unsigned short flags; | 677 fu32_t flags; |
661 const char *msg; | 678 const char *msg; |
662 int msglen; | 679 int msglen; |
663 int iconlen; | 680 |
681 /* Only used if AIM_IMFLAGS_HASICON is set */ | |
682 fu32_t iconlen; | |
664 time_t iconstamp; | 683 time_t iconstamp; |
665 unsigned short iconsum; | 684 fu32_t iconsum; |
685 | |
686 /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */ | |
687 fu8_t *features; | |
688 fu8_t featureslen; | |
666 }; | 689 }; |
667 | 690 |
668 struct aim_incomingim_ch1_args { | 691 struct aim_incomingim_ch1_args { |
692 | |
693 /* Always provided */ | |
669 char *msg; | 694 char *msg; |
670 int msglen; | 695 int msglen; |
671 unsigned long icbmflags; | 696 fu32_t icbmflags; |
672 unsigned short flag1; | 697 fu16_t flag1; |
673 unsigned short flag2; | 698 fu16_t flag2; |
674 int finlen; | 699 |
675 unsigned char fingerprint[10]; | 700 /* Only provided if AIM_IMFLAGS_HASICON is set */ |
676 time_t iconstamp; | 701 time_t iconstamp; |
677 unsigned long iconlength; | 702 fu32_t iconlen; |
678 unsigned long iconchecksum; | 703 fu32_t iconsum; |
679 int extdatalen; | 704 |
680 unsigned char *extdata; | 705 /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */ |
706 fu8_t *features; | |
707 fu8_t featureslen; | |
708 | |
709 /* Only provided if AIM_IMFLAGS_EXTDATA is set */ | |
710 fu8_t extdatalen; | |
711 fu8_t *extdata; | |
681 }; | 712 }; |
682 | 713 |
683 struct aim_incomingim_ch2_args { | 714 struct aim_incomingim_ch2_args { |
684 unsigned short reqclass; | 715 fu8_t cookie[8]; |
685 unsigned short status; | 716 fu16_t reqclass; |
717 fu16_t status; | |
686 union { | 718 union { |
687 struct { | 719 struct { |
688 unsigned long checksum; | 720 fu32_t checksum; |
689 unsigned int length; | 721 fu32_t length; |
690 time_t timestamp; | 722 time_t timestamp; |
691 unsigned char *icon; | 723 fu8_t *icon; |
692 } icon; | 724 } icon; |
693 struct { | 725 struct { |
694 } voice; | 726 } voice; |
695 struct aim_directim_priv *directim; | 727 struct { |
728 fu8_t ip[22]; /* xxx.xxx.xxx.xxx:xxxxx\0 */ | |
729 } imimage; | |
696 struct { | 730 struct { |
697 char *msg; | 731 char *msg; |
698 char *encoding; | 732 char *encoding; |
699 char *lang; | 733 char *lang; |
700 struct aim_chat_roominfo roominfo; | 734 struct aim_chat_roominfo roominfo; |
706 struct { | 740 struct { |
707 } sendfile; | 741 } sendfile; |
708 } info; | 742 } info; |
709 }; | 743 }; |
710 | 744 |
711 faim_export int aim_send_im_ext(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_sendimext_args *args); | 745 faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct aim_sendimext_args *args); |
712 faim_export int aim_send_im(struct aim_session_t *, struct aim_conn_t *, const char *destsn, unsigned short flags, const char *msg); | 746 faim_export int aim_send_im(aim_session_t *, aim_conn_t *, const char *destsn, unsigned short flags, const char *msg); |
713 faim_export int aim_send_icon(struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn, const unsigned char *icon, int iconlen, time_t stamp, unsigned short iconsum); | 747 faim_export int aim_send_icon(aim_session_t *sess, aim_conn_t *conn, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu32_t iconsum); |
714 faim_export unsigned short aim_iconsum(const unsigned char *buf, int buflen); | 748 faim_export fu32_t aim_iconsum(const fu8_t *buf, int buflen); |
715 faim_export int aim_send_im_direct(struct aim_session_t *, struct aim_conn_t *, char *); | 749 faim_export int aim_send_im_direct(aim_session_t *, aim_conn_t *, const char *msg); |
716 faim_export struct aim_conn_t * aim_directim_initiate(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *, char *destsn); | 750 faim_export const char *aim_directim_getsn(aim_conn_t *conn); |
717 faim_export struct aim_conn_t *aim_directim_connect(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *); | 751 faim_export aim_conn_t *aim_directim_initiate(aim_session_t *, aim_conn_t *, const char *destsn); |
718 | 752 faim_export aim_conn_t *aim_directim_connect(aim_session_t *, const char *sn, const char *addr, const fu8_t *cookie); |
719 faim_export struct aim_conn_t *aim_getfile_initiate(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn); | 753 |
720 faim_export int aim_oft_getfile_request(struct aim_session_t *sess, struct aim_conn_t *conn, const unsigned char *name, const int size); | 754 faim_export aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn); |
721 faim_export int aim_oft_getfile_ack(struct aim_session_t *sess, struct aim_conn_t *conn); | 755 faim_export int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size); |
722 faim_export int aim_oft_getfile_end(struct aim_session_t *sess, struct aim_conn_t *conn); | 756 faim_export int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn); |
757 faim_export int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn); | |
723 | 758 |
724 /* aim_info.c */ | 759 /* aim_info.c */ |
725 #define AIM_CAPS_BUDDYICON 0x0001 | 760 #define AIM_CAPS_BUDDYICON 0x0001 |
726 #define AIM_CAPS_VOICE 0x0002 | 761 #define AIM_CAPS_VOICE 0x0002 |
727 #define AIM_CAPS_IMIMAGE 0x0004 | 762 #define AIM_CAPS_IMIMAGE 0x0004 |
732 #define AIM_CAPS_SAVESTOCKS 0x0080 | 767 #define AIM_CAPS_SAVESTOCKS 0x0080 |
733 #define AIM_CAPS_SENDBUDDYLIST 0x0100 | 768 #define AIM_CAPS_SENDBUDDYLIST 0x0100 |
734 #define AIM_CAPS_GAMES2 0x0200 | 769 #define AIM_CAPS_GAMES2 0x0200 |
735 #define AIM_CAPS_LAST 0x8000 | 770 #define AIM_CAPS_LAST 0x8000 |
736 | 771 |
737 faim_export int aim_0002_000b(struct aim_session_t *sess, struct aim_conn_t *conn, const char *sn); | 772 faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
738 | 773 |
739 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0 | 774 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0 |
740 #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1 | 775 #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1 |
741 | 776 |
742 faim_export int aim_sendmemblock(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned long offset, unsigned long len, const unsigned char *buf, unsigned char flag); | 777 faim_export int aim_sendmemblock(aim_session_t *sess, aim_conn_t *conn, unsigned long offset, unsigned long len, const unsigned char *buf, unsigned char flag); |
743 | 778 |
744 #define AIM_GETINFO_GENERALINFO 0x00001 | 779 #define AIM_GETINFO_GENERALINFO 0x00001 |
745 #define AIM_GETINFO_AWAYMESSAGE 0x00003 | 780 #define AIM_GETINFO_AWAYMESSAGE 0x00003 |
746 | 781 |
747 struct aim_msgcookie_t { | |
748 unsigned char cookie[8]; | |
749 int type; | |
750 void *data; | |
751 time_t addtime; | |
752 struct aim_msgcookie_t *next; | |
753 }; | |
754 | |
755 struct aim_invite_priv { | 782 struct aim_invite_priv { |
756 char *sn; | 783 char *sn; |
757 char *roomname; | 784 char *roomname; |
758 int exchange; | 785 fu16_t exchange; |
759 int instance; | 786 fu16_t instance; |
760 }; | 787 }; |
761 | 788 |
762 #define AIM_COOKIETYPE_UNKNOWN 0x00 | 789 #define AIM_COOKIETYPE_UNKNOWN 0x00 |
763 #define AIM_COOKIETYPE_ICBM 0x01 | 790 #define AIM_COOKIETYPE_ICBM 0x01 |
764 #define AIM_COOKIETYPE_ADS 0x02 | 791 #define AIM_COOKIETYPE_ADS 0x02 |
774 #define AIM_COOKIETYPE_OFTSEND 0x12 | 801 #define AIM_COOKIETYPE_OFTSEND 0x12 |
775 #define AIM_COOKIETYPE_OFTVOICE 0x13 | 802 #define AIM_COOKIETYPE_OFTVOICE 0x13 |
776 #define AIM_COOKIETYPE_OFTIMAGE 0x14 | 803 #define AIM_COOKIETYPE_OFTIMAGE 0x14 |
777 #define AIM_COOKIETYPE_OFTICON 0x15 | 804 #define AIM_COOKIETYPE_OFTICON 0x15 |
778 | 805 |
779 faim_export int aim_handlerendconnect(struct aim_session_t *sess, struct aim_conn_t *cur); | 806 faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur); |
780 | 807 |
781 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 | 808 #define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000 |
782 #define AIM_TRANSFER_DENY_DECLINE 0x0001 | 809 #define AIM_TRANSFER_DENY_DECLINE 0x0001 |
783 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 | 810 #define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002 |
784 faim_export int aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, const char *sender, const char *cookie, unsigned short code); | 811 faim_export int aim_denytransfer(aim_session_t *sess, aim_conn_t *conn, const char *sender, const char *cookie, unsigned short code); |
785 faim_export struct aim_conn_t *aim_accepttransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *cookie, char *ip, unsigned short listingfiles, unsigned short listingtotsize, unsigned short listingsize, unsigned int listingchecksum, unsigned short rendid); | 812 faim_export aim_conn_t *aim_accepttransfer(aim_session_t *sess, aim_conn_t *conn, const char *sn, const fu8_t *cookie, const fu8_t *ip, fu16_t listingfiles, fu16_t listingtotsize, fu16_t listingsize, fu32_t listingchecksum, fu16_t rendid); |
786 | 813 |
787 faim_export int aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short); | 814 faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short); |
788 faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info); | 815 faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *info); |
789 faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn); | 816 faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn); |
790 | 817 |
791 #define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001 | 818 #define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001 |
792 #define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002 | 819 #define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002 |
793 | 820 |
794 /* This is what the server will give you if you don't set them yourself. */ | 821 /* This is what the server will give you if you don't set them yourself. */ |
817 unsigned short maxsenderwarn; /* this and below are *10 (999=99.9%) */ | 844 unsigned short maxsenderwarn; /* this and below are *10 (999=99.9%) */ |
818 unsigned short maxrecverwarn; | 845 unsigned short maxrecverwarn; |
819 unsigned long minmsginterval; /* in milliseconds? */ | 846 unsigned long minmsginterval; /* in milliseconds? */ |
820 }; | 847 }; |
821 | 848 |
822 faim_export unsigned long aim_reqicbmparams(struct aim_session_t *sess, struct aim_conn_t *conn); | 849 faim_export int aim_reqicbmparams(aim_session_t *sess, aim_conn_t *conn); |
823 faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_icbmparameters *params); | 850 faim_export int aim_seticbmparam(aim_session_t *sess, aim_conn_t *conn, struct aim_icbmparameters *params); |
824 | 851 |
825 | 852 |
826 /* aim_auth.c */ | 853 /* auth.c */ |
827 faim_export int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *); | 854 faim_export int aim_auth_sendcookie(aim_session_t *, aim_conn_t *, const fu8_t *); |
828 faim_export u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *); | 855 |
829 faim_export unsigned long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *); | 856 faim_export int aim_auth_clientready(aim_session_t *, aim_conn_t *); |
857 faim_export int aim_auth_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw); | |
858 faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn); | |
859 faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn); | |
860 faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info); | |
861 faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail); | |
830 | 862 |
831 /* aim_buddylist.c */ | 863 /* aim_buddylist.c */ |
832 faim_export unsigned long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *); | 864 faim_export int aim_add_buddy(aim_session_t *, aim_conn_t *, const char *); |
833 faim_export unsigned long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *); | 865 faim_export int aim_remove_buddy(aim_session_t *, aim_conn_t *, const char *); |
834 | 866 |
835 /* aim_search.c */ | 867 /* aim_search.c */ |
836 faim_export u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *); | 868 faim_export int aim_usersearch_address(aim_session_t *, aim_conn_t *, const char *); |
837 | 869 |
838 struct aim_chat_exchangeinfo { | 870 struct aim_chat_exchangeinfo { |
839 u_short number; | 871 fu16_t number; |
840 char *name; | 872 char *name; |
841 char *charset1; | 873 char *charset1; |
842 char *lang1; | 874 char *lang1; |
843 char *charset2; | 875 char *charset2; |
844 char *lang2; | 876 char *lang2; |
845 }; | 877 }; |
846 | 878 |
847 #define AIM_CHATFLAGS_NOREFLECT 0x0001 | 879 #define AIM_CHATFLAGS_NOREFLECT 0x0001 |
848 #define AIM_CHATFLAGS_AWAY 0x0002 | 880 #define AIM_CHATFLAGS_AWAY 0x0002 |
849 faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short flags, const char *msg, int msglen); | 881 faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen); |
850 faim_export unsigned long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname); | 882 faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance); |
851 faim_export unsigned long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); | 883 faim_export int aim_chat_clientready(aim_session_t *sess, aim_conn_t *conn); |
852 faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname); | 884 faim_export int aim_chat_attachname(aim_conn_t *conn, const char *roomname); |
853 faim_export char *aim_chat_getname(struct aim_conn_t *conn); | 885 faim_export char *aim_chat_getname(aim_conn_t *conn); |
854 faim_export struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name); | 886 faim_export aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name); |
855 | 887 |
856 faim_export unsigned long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn); | 888 faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn); |
857 faim_export unsigned long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn); | 889 faim_export int aim_chatnav_clientready(aim_session_t *sess, aim_conn_t *conn); |
858 | 890 |
859 faim_export unsigned long aim_chat_invite(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *msg, u_short exchange, char *roomname, u_short instance); | 891 faim_export int aim_chat_invite(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *msg, fu16_t exchange, const char *roomname, fu16_t instance); |
860 | 892 |
861 faim_export u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange); | 893 faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange); |
862 faim_export int aim_chat_leaveroom(struct aim_session_t *sess, char *name); | 894 faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name); |
863 | 895 |
864 /* aim_util.c */ | 896 /* aim_util.c */ |
865 #ifdef AIMUTIL_USEMACROS | |
866 /* | 897 /* |
867 * These are really ugly. You'd think this was LISP. I wish it was. | 898 * These are really ugly. You'd think this was LISP. I wish it was. |
899 * | |
900 * XXX With the advent of bstream's, these should be removed to enforce | |
901 * their use. | |
902 * | |
868 */ | 903 */ |
869 #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) | 904 #define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1) |
870 #define aimutil_get8(buf) ((*(buf))&0xff) | 905 #define aimutil_get8(buf) ((*(buf))&0xff) |
871 #define aimutil_put16(buf, data) ( \ | 906 #define aimutil_put16(buf, data) ( \ |
872 (*(buf) = (u_char)((data)>>8)&0xff), \ | 907 (*(buf) = (u_char)((data)>>8)&0xff), \ |
873 (*((buf)+1) = (u_char)(data)&0xff), \ | 908 (*((buf)+1) = (u_char)(data)&0xff), \ |
874 2) | 909 2) |
875 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | 910 #define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
876 #define aimutil_put32(buf, data) ( \ | 911 #define aimutil_put32(buf, data) ( \ |
877 (*((buf)) = (u_char)((data)>>24)&0xff), \ | 912 (*((buf)) = (u_char)((data)>>24)&0xff), \ |
878 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ | 913 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ |
879 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ | 914 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ |
880 (*((buf)+3) = (u_char)(data)&0xff), \ | 915 (*((buf)+3) = (u_char)(data)&0xff), \ |
881 4) | 916 4) |
882 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | 917 #define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \ |
883 (((*((buf)+1))<<16)&0x00ff0000) + \ | 918 (((*((buf)+1))<<16)&0x00ff0000) + \ |
884 (((*((buf)+2))<< 8)&0x0000ff00) + \ | 919 (((*((buf)+2))<< 8)&0x0000ff00) + \ |
885 (((*((buf)+3) )&0x000000ff))) | 920 (((*((buf)+3) )&0x000000ff))) |
886 #else | |
887 #warning Not using aimutil macros. May have performance problems. | |
888 int aimutil_put8(u_char *, u_char); | |
889 u_char aimutil_get8(u_char *buf); | |
890 int aimutil_put16(u_char *, u_short); | |
891 u_short aimutil_get16(u_char *); | |
892 int aimutil_put32(u_char *, u_long); | |
893 u_long aimutil_get32(u_char *); | |
894 #endif | |
895 | 921 |
896 faim_export int aimutil_putstr(u_char *, const char *, int); | 922 faim_export int aimutil_putstr(u_char *, const char *, int); |
897 faim_export int aimutil_tokslen(char *toSearch, int index, char dl); | 923 faim_export int aimutil_tokslen(char *toSearch, int index, char dl); |
898 faim_export int aimutil_itemcnt(char *toSearch, char dl); | 924 faim_export int aimutil_itemcnt(char *toSearch, char dl); |
899 faim_export char *aimutil_itemidx(char *toSearch, int index, char dl); | 925 faim_export char *aimutil_itemidx(char *toSearch, int index, char dl); |