]> andersk Git - libfaim.git/blame - include/aim.h
- Sat Sep 8 07:32:27 PDT 2001
[libfaim.git] / include / aim.h
CommitLineData
bd71fa88 1/*
2 * Main libfaim header. Must be included in client for prototypes/macros.
3 *
fd0b7da6 4 * "come on, i turned a chick lesbian; i think this is the hackish equivalent"
5 * -- Josh Meyer
6 *
bd71fa88 7 */
8
9#ifndef __AIM_H__
10#define __AIM_H__
11
0cc57340 12#define FAIM_VERSION_MAJOR 0
13#define FAIM_VERSION_MINOR 99
37ee990e 14#define FAIM_VERSION_MINORMINOR 1
0cc57340 15
dd60ff8b 16#include <faimconfig.h>
17#include <aim_cbtypes.h>
bd71fa88 18
37ee990e 19#if !defined(FAIM_USEPTHREADS) && !defined(FAIM_USEFAKELOCKS) && !defined(FAIM_USENOPLOCKS)
20#error pthreads, fakelocks, or noplocks are currently required.
e88ba395 21#endif
22
bd71fa88 23#include <stdio.h>
24#include <string.h>
25#include <fcntl.h>
26#include <sys/types.h>
27#include <stdlib.h>
28#include <stdarg.h>
29#include <errno.h>
646c6b52 30#include <time.h>
bd71fa88 31
7392c79f 32#ifdef _WIN32
33#include <windows.h>
7392c79f 34#include <io.h>
35#else
7392c79f 36#include <sys/time.h>
37#include <unistd.h>
a15d82b1 38#include <netinet/in.h>
37ee990e 39#include <sys/socket.h>
7392c79f 40#endif
41
d410cf58 42/* XXX adjust these based on autoconf-detected platform */
43typedef unsigned char fu8_t;
44typedef unsigned short fu16_t;
45typedef unsigned long fu32_t;
46typedef fu32_t aim_snacid_t;
47typedef fu16_t flap_seqnum_t;
48
e88ba395 49#ifdef FAIM_USEPTHREADS
50#include <pthread.h>
51#define faim_mutex_t pthread_mutex_t
b13c9e13 52#define faim_mutex_init(x) pthread_mutex_init(x, NULL)
53#define faim_mutex_lock(x) pthread_mutex_lock(x)
54#define faim_mutex_unlock(x) pthread_mutex_unlock(x)
55#define faim_mutex_destroy(x) pthread_mutex_destroy(x)
81d7797e 56#elif defined(FAIM_USEFAKELOCKS)
57/*
58 * For platforms without pthreads, we also assume
59 * we're not linking against a threaded app. Which
60 * means we don't have to do real locking. The
61 * macros below do nothing really. They're a joke.
62 * But they get it to compile.
d410cf58 63 *
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 *
81d7797e 69 */
d410cf58 70#define faim_mutex_t fu8_t
d9142146 71#define faim_mutex_init(x) *x = 0
37ee990e 72#define faim_mutex_lock(x) while(*x != 0) {/* spin */}; *x = 1;
73#define faim_mutex_unlock(x) while(*x != 0) {/* spin spin spin */}; *x = 0;
74#define faim_mutex_destroy(x) while(*x != 0) {/* spiiiinnn */}; *x = 0;
75#elif defined(FAIM_USENOPLOCKS)
d410cf58 76#define faim_mutex_t fu8_t
37ee990e 77#define faim_mutex_init(x)
78#define faim_mutex_lock(x)
79#define faim_mutex_unlock(x)
80#define faim_mutex_destroy(x)
e88ba395 81#endif
82
bd71fa88 83/* Portability stuff (DMP) */
84
85#ifdef _WIN32
6b9df03c 86#define sleep(x) Sleep((x)*1000)
5ac21963 87#define snprintf _snprintf /* I'm not sure whats wrong with Microsoft here */
5aab5195 88#define close(x) closesocket(x) /* no comment */
bd71fa88 89#endif
90
040457cc 91#if defined(mach) && defined(__APPLE__)
92#define gethostbyname(x) gethostbyname2(x, AF_INET)
93#endif
bd71fa88 94
78b3fb13 95#if defined(_WIN32) || defined(STRICT_ANSI)
96#define faim_shortfunc
97#else
98#define faim_shortfunc inline
99#endif
100
5ac21963 101#if defined(_WIN32) && !defined(WIN32_STATIC)
78b3fb13 102/*
103 * For a win32 DLL, we define WIN32_INDLL if this file
104 * is included while compiling the DLL. If its not
105 * defined (its included in a client app), the symbols
106 * will be imported instead of exported.
107 */
108#ifdef WIN32_INDLL
109#define faim_export __declspec(dllexport)
110#else
111#define faim_export __declspec(dllimport)
112#endif /* WIN32_INDLL */
113#define faim_internal
114#else
115/*
116 * Nothing normally needed for unix...
117 */
118#define faim_export
119#define faim_internal
81d7797e 120#endif
121
bd71fa88 122/*
123 * Current Maximum Length for Screen Names (not including NULL)
68ac63c2 124 *
125 * Currently only names up to 16 characters can be registered
126 * however it is aparently legal for them to be larger.
bd71fa88 127 */
68ac63c2 128#define MAXSNLEN 32
bd71fa88 129
91931247 130/*
131 * Current Maximum Length for Instant Messages
132 *
133 * This was found basically by experiment, but not wholly
134 * accurate experiment. It should not be regarded
135 * as completely correct. But its a decent approximation.
136 *
137 * Note that although we can send this much, its impossible
138 * for WinAIM clients (up through the latest (4.0.1957)) to
139 * send any more than 1kb. Amaze all your windows friends
5e02cf44 140 * with utterly oversized instant messages!
98c88242 141 *
142 * XXX: the real limit is the total SNAC size at 8192. Fix this.
91931247 143 *
144 */
b69540e3 145#define MAXMSGLEN 7987
91931247 146
7b91722d 147/*
148 * Maximum size of a Buddy Icon.
149 */
150#define MAXICONLEN 7168
151#define AIM_ICONIDENT "AVT1picture.id"
152
91931247 153/*
154 * Current Maximum Length for Chat Room Messages
155 *
156 * This is actually defined by the protocol to be
157 * dynamic, but I have yet to see due cause to
158 * define it dynamically here. Maybe later.
159 *
160 */
161#define MAXCHATMSGLEN 512
162
bd71fa88 163/*
164 * Standard size of an AIM authorization cookie
165 */
166#define AIM_COOKIELEN 0x100
167
b5bc2a8c 168#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
169
bd71fa88 170/*
171 * Client info. Filled in by the client and passed
172 * in to aim_login(). The information ends up
173 * getting passed to OSCAR through the initial
174 * login command.
175 *
176 * XXX: Should this be per-session? -mid
177 *
178 */
179struct client_info_s {
d410cf58 180 char clientstring[100]; /* arbitrary size */
181 int major;
182 int minor;
183 int build;
184 char country[3];
185 char lang[3];
186 int major2;
187 int minor2;
188 long unknown;
bd71fa88 189};
190
b1eac25a 191#define AIM_CLIENTINFO_KNOWNGOOD_3_5_1670 { \
d410cf58 192 "AOL Instant Messenger (SM), version 3.5.1670/WIN32", \
193 0x0003, \
194 0x0005, \
195 0x0686, \
196 "us", \
197 "en", \
198 0x0004, \
199 0x0000, \
200 0x0000002a, \
154b4093 201}
202
b1eac25a 203#define AIM_CLIENTINFO_KNOWNGOOD_4_1_2010 { \
d410cf58 204 "AOL Instant Messenger (SM), version 4.1.2010/WIN32", \
205 0x0004, \
206 0x0001, \
207 0x07da, \
208 "us", \
209 "en", \
210 0x0004, \
211 0x0000, \
212 0x0000004b, \
b1eac25a 213}
214
215/*
216 * I would make 4.1.2010 the default, but they seem to have found
217 * an alternate way of breaking that one.
218 *
219 * 3.5.1670 should work fine, however, you will be subjected to the
220 * memory test, which may require you to have a WinAIM binary laying
221 * around. (see login.c::memrequest())
222 */
223#define AIM_CLIENTINFO_KNOWNGOOD AIM_CLIENTINFO_KNOWNGOOD_3_5_1670
224
bd71fa88 225#ifndef TRUE
226#define TRUE 1
227#define FALSE 0
228#endif
229
230/*
231 * These could be arbitrary, but its easier to use the actual AIM values
232 */
233#define AIM_CONN_TYPE_AUTH 0x0007
234#define AIM_CONN_TYPE_ADS 0x0005
235#define AIM_CONN_TYPE_BOS 0x0002
236#define AIM_CONN_TYPE_CHAT 0x000e
237#define AIM_CONN_TYPE_CHATNAV 0x000d
7392c79f 238
239/* they start getting arbitrary in rendezvous stuff =) */
d410cf58 240#define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak FLAP! */
7392c79f 241#define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */
242
243/*
244 * Subtypes, we need these for OFT stuff.
245 */
246#define AIM_CONN_SUBTYPE_OFT_DIRECTIM 0x0001
247#define AIM_CONN_SUBTYPE_OFT_GETFILE 0x0002
248#define AIM_CONN_SUBTYPE_OFT_SENDFILE 0x0003
249#define AIM_CONN_SUBTYPE_OFT_BUDDYICON 0x0004
250#define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005
bd71fa88 251
252/*
253 * Status values returned from aim_conn_new(). ORed together.
254 */
255#define AIM_CONN_STATUS_READY 0x0001
256#define AIM_CONN_STATUS_INTERNALERR 0x0002
22517493 257#define AIM_CONN_STATUS_RESOLVERR 0x0040
258#define AIM_CONN_STATUS_CONNERR 0x0080
259#define AIM_CONN_STATUS_INPROGRESS 0x0100
bd71fa88 260
d410cf58 261#define AIM_FRAMETYPE_FLAP 0x0000
262#define AIM_FRAMETYPE_OFT 0x0001
263
264typedef struct aim_conn_s {
265 int fd;
266 fu16_t type;
267 fu16_t subtype;
268 flap_seqnum_t seqnum;
269 fu32_t status;
270 void *priv; /* misc data the client may want to store */
c5f5b7f1 271 void *internal; /* internal conn-specific libfaim data */
d410cf58 272 time_t lastactivity; /* time of last transmit */
273 int forcedlatency;
274 void *handlerlist;
275 faim_mutex_t active; /* lock around read/writes */
276 faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */
277 void *sessv; /* pointer to parent session */
278 struct aim_conn_s *next;
279} aim_conn_t;
bd71fa88 280
d410cf58 281/*
282 * Byte Stream type. Sort of.
283 *
284 * Use of this type serves a couple purposes:
285 * - Buffer/buflen pairs are passed all around everywhere. This turns
286 * that into one value, as well as abstracting it slightly.
287 * - Through the abstraction, it is possible to enable bounds checking
288 * for robustness at the cost of performance. But a clean failure on
289 * weird packets is much better than a segfault.
290 * - I like having variables named "bs".
291 *
292 * Don't touch the insides of this struct. Or I'll have to kill you.
293 *
294 */
295typedef struct aim_bstream_s {
296 fu8_t *data;
297 fu16_t len;
298 fu16_t offset;
299} aim_bstream_t;
300
301typedef struct aim_frame_s {
302 fu8_t hdrtype; /* defines which piece of the union to use */
303 union {
304 struct {
305 fu8_t type;
306 flap_seqnum_t seqnum;
307 } flap;
308 struct {
309 fu16_t type;
310 fu8_t magic[4]; /* ODC2 OFT2 */
311 fu16_t hdr2len;
312 fu8_t *hdr2; /* rest of bloated header */
313 } oft;
314 } hdr;
315 aim_bstream_t data; /* payload stream */
316 fu8_t handled; /* 0 = new, !0 = been handled */
317 fu8_t nofree; /* 0 = free data on purge, 1 = only unlink */
318 aim_conn_t *conn; /* the connection it came in on... */
319 struct aim_frame_s *next;
320} aim_frame_t;
321
322typedef struct aim_msgcookie_s {
323 unsigned char cookie[8];
324 int type;
325 void *data;
326 time_t addtime;
327 struct aim_msgcookie_s *next;
328} aim_msgcookie_t;
bd71fa88 329
bd71fa88 330/*
331 * AIM Session: The main client-data interface.
332 *
333 */
d410cf58 334typedef struct aim_session_s {
335
336 /* ---- Client Accessible ------------------------ */
337
338 /* Our screen name. */
339 char sn[MAXSNLEN+1];
340
341 /*
342 * Pointer to anything the client wants to
343 * explicitly associate with this session.
344 *
345 * This is for use in the callbacks mainly. In any
346 * callback, you can access this with sess->aux_data.
347 *
348 */
349 void *aux_data;
350
351 /* ---- Internal Use Only ------------------------ */
352
353 /* Connection information */
354 aim_conn_t *connlist;
355 faim_mutex_t connlistlock;
356
357 /*
358 * Transmit/receive queues.
359 *
360 * These are only used when you don't use your own lowlevel
361 * I/O. I don't suggest that you use libfaim's internal I/O.
362 * Its really bad and the API/event model is quirky at best.
363 *
364 */
365 aim_frame_t *queue_outgoing;
366 aim_frame_t *queue_incoming;
367
368 /*
369 * Tx Enqueuing function.
370 *
371 * This is how you override the transmit direction of libfaim's
372 * internal I/O. This function will be called whenever it needs
373 * to send something.
374 *
375 */
376 int (*tx_enqueue)(struct aim_session_s *, aim_frame_t *);
377
378 /*
379 * This is a dreadful solution to the what-room-are-we-joining
380 * problem. (There's no connection between the service
381 * request and the resulting redirect.)
382 */
383 char *pendingjoin;
384 fu16_t pendingjoinexchange;
385
386 /*
387 * Outstanding snac handling
388 *
389 * XXX: Should these be per-connection? -mid
390 */
391 void *snac_hash[FAIM_SNAC_HASH_SIZE];
392 faim_mutex_t snac_hash_locks[FAIM_SNAC_HASH_SIZE];
393 aim_snacid_t snacid_next;
394
395 struct {
396 char server[128];
397 char username[128];
398 char password[128];
399 } socksproxy;
400
401 fu32_t flags; /* AIM_SESS_FLAGS_ */
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;
bd71fa88 410
22517493 411/* Values for sess->flags */
412#define AIM_SESS_FLAGS_SNACLOGIN 0x00000001
413#define AIM_SESS_FLAGS_XORLOGIN 0x00000002
414#define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004
bd71fa88 415
416/*
417 * AIM User Info, Standard Form.
418 */
419struct aim_userinfo_s {
d410cf58 420 char sn[MAXSNLEN+1];
421 fu16_t warnlevel;
422 fu16_t idletime;
423 fu16_t flags;
424 fu32_t membersince;
425 fu32_t onlinesince;
426 fu32_t sessionlen;
427 fu16_t capabilities;
428 struct {
429 fu16_t status;
430 fu32_t ipaddr;
431 fu8_t crap[0x25]; /* until we figure it out... */
432 } icqinfo;
bd71fa88 433};
434
a15d82b1 435#define AIM_FLAG_UNCONFIRMED 0x0001 /* "damned transients" */
436#define AIM_FLAG_ADMINISTRATOR 0x0002
437#define AIM_FLAG_AOL 0x0004
438#define AIM_FLAG_OSCAR_PAY 0x0008
439#define AIM_FLAG_FREE 0x0010
440#define AIM_FLAG_AWAY 0x0020
441#define AIM_FLAG_UNKNOWN40 0x0040
442#define AIM_FLAG_UNKNOWN80 0x0080
0c20631f 443
a15d82b1 444#define AIM_FLAG_ALLUSERS 0x001f
98c88242 445
37ee990e 446
24fbfcf3 447#if defined(FAIM_INTERNAL) || defined(FAIM_NEED_TLV)
bd71fa88 448/*
449 * TLV handling
450 */
451
452/* Generic TLV structure. */
d410cf58 453typedef struct aim_tlv_s {
454 fu16_t type;
455 fu16_t length;
456 fu8_t *value;
457} aim_tlv_t;
bd71fa88 458
459/* List of above. */
d410cf58 460typedef struct aim_tlvlist_s {
461 aim_tlv_t *tlv;
462 struct aim_tlvlist_s *next;
463} aim_tlvlist_t;
bd71fa88 464
465/* TLV-handling functions */
d410cf58 466
467#if 0
468/* Very, very raw TLV handling. */
469faim_internal int aim_puttlv_8(fu8_t *buf, const fu16_t t, const fu8_t v);
470faim_internal int aim_puttlv_16(fu8_t *buf, const fu16_t t, const fu16_t v);
471faim_internal int aim_puttlv_32(fu8_t *buf, const fu16_t t, const fu32_t v);
472faim_internal int aim_puttlv_raw(fu8_t *buf, const fu16_t t, const fu16_t l, const fu8_t *v);
473#endif
474
475/* TLV list handling. */
476faim_internal aim_tlvlist_t *aim_readtlvchain(aim_bstream_t *bs);
477faim_internal void aim_freetlvchain(aim_tlvlist_t **list);
478faim_internal aim_tlv_t *aim_gettlv(aim_tlvlist_t *, fu16_t t, const int n);
479faim_internal char *aim_gettlv_str(aim_tlvlist_t *, const fu16_t t, const int n);
480faim_internal fu8_t aim_gettlv8(aim_tlvlist_t *list, const fu16_t type, const int num);
481faim_internal fu16_t aim_gettlv16(aim_tlvlist_t *list, const fu16_t t, const int n);
482faim_internal fu32_t aim_gettlv32(aim_tlvlist_t *list, const fu16_t t, const int n);
483faim_internal int aim_writetlvchain(aim_bstream_t *bs, aim_tlvlist_t **list);
484faim_internal int aim_addtlvtochain16(aim_tlvlist_t **list, const fu16_t t, const fu16_t v);
485faim_internal int aim_addtlvtochain32(aim_tlvlist_t **list, const fu16_t type, const fu32_t v);
486faim_internal int aim_addtlvtochain_raw(aim_tlvlist_t **list, const fu16_t t, const fu16_t l, const fu8_t *v);
487faim_internal int aim_addtlvtochain_caps(aim_tlvlist_t **list, const fu16_t t, const fu16_t caps);
488faim_internal int aim_addtlvtochain_noval(aim_tlvlist_t **list, const fu16_t type);
489faim_internal int aim_addtlvtochain_frozentlvlist(aim_tlvlist_t **list, fu16_t type, aim_tlvlist_t **tl);
490faim_internal int aim_counttlvchain(aim_tlvlist_t **list);
491faim_export int aim_sizetlvchain(aim_tlvlist_t **list);
37ee990e 492#endif /* FAIM_INTERNAL */
bd71fa88 493
494/*
d410cf58 495 * Get command from connections
496 *
497 * aim_get_commmand() is the libfaim lowlevel I/O in the receive direction.
498 * XXX Make this easily overridable.
499 *
500 */
501faim_export int aim_get_command(aim_session_t *, aim_conn_t *);
502
503/*
504 * Dispatch commands that are in the rx queue.
bd71fa88 505 */
d410cf58 506faim_export void aim_rxdispatch(aim_session_t *);
7392c79f 507
d410cf58 508faim_export int aim_debugconn_sendconnect(aim_session_t *sess, aim_conn_t *conn);
7392c79f 509
d410cf58 510faim_export int aim_logoff(aim_session_t *);
bd71fa88 511
50038c74 512#if !defined(FAIM_INTERNAL) || defined(FAIM_INTERNAL_INSANE)
646c6b52 513/* the library should never call aim_conn_kill */
d410cf58 514faim_export void aim_conn_kill(aim_session_t *sess, aim_conn_t **deadconn);
50038c74 515#endif
bd71fa88 516
d410cf58 517typedef int (*aim_rxcallback_t)(aim_session_t *, aim_frame_t *, ...);
bd71fa88 518
bd71fa88 519/* aim_login.c */
d410cf58 520faim_export int aim_sendflapver(aim_session_t *sess, aim_conn_t *conn);
521faim_export int aim_request_login(aim_session_t *sess, aim_conn_t *conn, const char *sn);
522faim_export int aim_send_login(aim_session_t *, aim_conn_t *, const char *, const char *, struct client_info_s *, const char *key);
9f1a4013 523faim_export int aim_encode_password_md5(const char *password, const char *key, unsigned char *digest);
d410cf58 524faim_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);
78b3fb13 525faim_export int aim_gencookie(unsigned char *buf);
d410cf58 526faim_export int aim_sendserverready(aim_session_t *sess, aim_conn_t *conn);
527faim_export int aim_sendredirect(aim_session_t *sess, aim_conn_t *conn, fu16_t servid, const char *ip, const char *cookie);
528faim_export void aim_purge_rxqueue(aim_session_t *);
37ee990e 529
b8c79ca7 530#define AIM_TX_QUEUED 0 /* default */
531#define AIM_TX_IMMEDIATE 1
532#define AIM_TX_USER 2
d410cf58 533faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *));
534
535faim_export int aim_tx_flushqueue(aim_session_t *);
536faim_export void aim_tx_purgequeue(aim_session_t *);
537
538faim_export int aim_conn_setlatency(aim_conn_t *conn, int newval);
539
540faim_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);
541faim_export int aim_clearhandlers(aim_conn_t *conn);
542
543faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn);
544faim_export void aim_conn_close(aim_conn_t *deadconn);
545faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest);
546faim_export int aim_conngetmaxfd(aim_session_t *);
547faim_export aim_conn_t *aim_select(aim_session_t *, struct timeval *, int *);
548faim_export int aim_conn_isready(aim_conn_t *);
549faim_export int aim_conn_setstatus(aim_conn_t *, int);
550faim_export int aim_conn_completeconnect(aim_session_t *sess, aim_conn_t *conn);
551faim_export int aim_conn_isconnecting(aim_conn_t *conn);
552
553typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
554faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
555faim_export void aim_session_init(aim_session_t *, unsigned long flags, int debuglevel);
556faim_export void aim_session_kill(aim_session_t *);
557faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
558faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type);
559faim_export aim_conn_t *aim_getconn_type_all(aim_session_t *, int type);
560faim_export aim_conn_t *aim_getconn_fd(aim_session_t *, int fd);
bd71fa88 561
562/* aim_misc.c */
563
564#define AIM_VISIBILITYCHANGE_PERMITADD 0x05
565#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
566#define AIM_VISIBILITYCHANGE_DENYADD 0x07
567#define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08
568
98c88242 569#define AIM_PRIVFLAGS_ALLOWIDLE 0x01
570#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02
571
572#define AIM_WARN_ANON 0x01
573
d410cf58 574faim_export int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags);
575faim_export int aim_bos_nop(aim_session_t *, aim_conn_t *);
576faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
577faim_export int aim_bos_setidle(aim_session_t *, aim_conn_t *, fu32_t);
578faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *);
579faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *);
580faim_export int aim_bos_setprofile(aim_session_t *sess, aim_conn_t *conn, const char *profile, const char *awaymsg, fu16_t caps);
581faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask);
582faim_export int aim_bos_clientready(aim_session_t *, aim_conn_t *);
583faim_export int aim_bos_reqrate(aim_session_t *, aim_conn_t *);
584faim_export int aim_bos_ackrateresp(aim_session_t *, aim_conn_t *);
585faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t);
586faim_export int aim_bos_reqpersonalinfo(aim_session_t *, aim_conn_t *);
587faim_export int aim_bos_reqservice(aim_session_t *, aim_conn_t *, fu16_t);
588faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
589faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *);
590faim_export int aim_bos_reqlocaterights(aim_session_t *, aim_conn_t *);
591faim_export int aim_setversions(aim_session_t *sess, aim_conn_t *conn);
592faim_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);
593faim_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);
594faim_export int aim_icq_setstatus(aim_session_t *sess, aim_conn_t *conn, fu32_t status);
595
596faim_export struct aim_fileheader_t *aim_getlisting(aim_session_t *sess, FILE *);
37ee990e 597
9d83220c 598#define AIM_CLIENTTYPE_UNKNOWN 0x0000
599#define AIM_CLIENTTYPE_MC 0x0001
600#define AIM_CLIENTTYPE_WINAIM 0x0002
601#define AIM_CLIENTTYPE_WINAIM41 0x0003
602#define AIM_CLIENTTYPE_AOL_TOC 0x0004
603faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len);
604
275a2ff8 605#define AIM_RATE_CODE_CHANGE 0x0001
606#define AIM_RATE_CODE_WARNING 0x0002
607#define AIM_RATE_CODE_LIMIT 0x0003
608#define AIM_RATE_CODE_CLEARLIMIT 0x0004
d410cf58 609faim_export int aim_ads_clientready(aim_session_t *sess, aim_conn_t *conn);
610faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
37ee990e 611
bd71fa88 612/* aim_im.c */
7392c79f 613
7392c79f 614struct aim_fileheader_t {
615#if 0
d410cf58 616 char magic[4]; /* 0 */
617 short hdrlen; /* 4 */
618 short hdrtype; /* 6 */
7392c79f 619#endif
d410cf58 620 char bcookie[8]; /* 8 */
621 short encrypt; /* 16 */
622 short compress; /* 18 */
623 short totfiles; /* 20 */
624 short filesleft; /* 22 */
625 short totparts; /* 24 */
626 short partsleft; /* 26 */
627 long totsize; /* 28 */
628 long size; /* 32 */
629 long modtime; /* 36 */
630 long checksum; /* 40 */
631 long rfrcsum; /* 44 */
632 long rfsize; /* 48 */
633 long cretime; /* 52 */
634 long rfcsum; /* 56 */
635 long nrecvd; /* 60 */
636 long recvcsum; /* 64 */
637 char idstring[32]; /* 68 */
638 char flags; /* 100 */
639 char lnameoffset; /* 101 */
640 char lsizeoffset; /* 102 */
641 char dummy[69]; /* 103 */
642 char macfileinfo[16]; /* 172 */
643 short nencode; /* 188 */
644 short nlanguage; /* 190 */
645 char name[64]; /* 192 */
646 /* 256 */
7392c79f 647};
648
649struct aim_filetransfer_priv {
1dcd23dd 650 char sn[MAXSNLEN];
651 char cookie[8];
652 char ip[30];
653 int state;
654 struct aim_fileheader_t fh;
040457cc 655};
7392c79f 656
7b91722d 657struct aim_chat_roominfo {
1dcd23dd 658 unsigned short exchange;
659 char *name;
660 unsigned short instance;
7b91722d 661};
37ee990e 662
84e0ca17 663#define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
664#define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
665#define AIM_IMFLAGS_UNICODE 0x0004
666#define AIM_IMFLAGS_ISO_8859_1 0x0008
667#define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
668#define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
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
7b91722d 672
673struct aim_sendimext_args {
84e0ca17 674
675 /* These are _required_ */
1dcd23dd 676 const char *destsn;
84e0ca17 677 fu32_t flags;
1dcd23dd 678 const char *msg;
679 int msglen;
84e0ca17 680
681 /* Only used if AIM_IMFLAGS_HASICON is set */
682 fu32_t iconlen;
1dcd23dd 683 time_t iconstamp;
84e0ca17 684 fu32_t iconsum;
685
686 /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */
687 fu8_t *features;
688 fu8_t featureslen;
7b91722d 689};
690
691struct aim_incomingim_ch1_args {
84e0ca17 692
693 /* Always provided */
1dcd23dd 694 char *msg;
695 int msglen;
84e0ca17 696 fu32_t icbmflags;
697 fu16_t flag1;
698 fu16_t flag2;
699
700 /* Only provided if AIM_IMFLAGS_HASICON is set */
1dcd23dd 701 time_t iconstamp;
84e0ca17 702 fu32_t iconlen;
703 fu32_t iconsum;
704
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;
7b91722d 712};
37ee990e 713
7b91722d 714struct aim_incomingim_ch2_args {
c5f5b7f1 715 fu8_t cookie[8];
716 fu16_t reqclass;
717 fu16_t status;
1dcd23dd 718 union {
719 struct {
e1b8c575 720 fu32_t checksum;
721 fu32_t length;
1dcd23dd 722 time_t timestamp;
e1b8c575 723 fu8_t *icon;
1dcd23dd 724 } icon;
725 struct {
726 } voice;
c5f5b7f1 727 struct {
728 fu8_t ip[22]; /* xxx.xxx.xxx.xxx:xxxxx\0 */
729 } imimage;
1dcd23dd 730 struct {
731 char *msg;
732 char *encoding;
733 char *lang;
734 struct aim_chat_roominfo roominfo;
735 } chat;
736 struct {
737 char *ip;
738 unsigned char *cookie;
739 } getfile;
740 struct {
741 } sendfile;
742 } info;
7b91722d 743};
744
d410cf58 745faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct aim_sendimext_args *args);
746faim_export int aim_send_im(aim_session_t *, aim_conn_t *, const char *destsn, unsigned short flags, const char *msg);
e1b8c575 747faim_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);
748faim_export fu32_t aim_iconsum(const fu8_t *buf, int buflen);
d410cf58 749faim_export int aim_send_im_direct(aim_session_t *, aim_conn_t *, const char *msg);
c5f5b7f1 750faim_export const char *aim_directim_getsn(aim_conn_t *conn);
751faim_export aim_conn_t *aim_directim_initiate(aim_session_t *, aim_conn_t *, const char *destsn);
752faim_export aim_conn_t *aim_directim_connect(aim_session_t *, const char *sn, const char *addr, const fu8_t *cookie);
37ee990e 753
d410cf58 754faim_export aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn);
755faim_export int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size);
756faim_export int aim_oft_getfile_ack(aim_session_t *sess, aim_conn_t *conn);
757faim_export int aim_oft_getfile_end(aim_session_t *sess, aim_conn_t *conn);
37ee990e 758
759/* aim_info.c */
f7bb124a 760#define AIM_CAPS_BUDDYICON 0x0001
761#define AIM_CAPS_VOICE 0x0002
762#define AIM_CAPS_IMIMAGE 0x0004
763#define AIM_CAPS_CHAT 0x0008
764#define AIM_CAPS_GETFILE 0x0010
765#define AIM_CAPS_SENDFILE 0x0020
766#define AIM_CAPS_GAMES 0x0040
767#define AIM_CAPS_SAVESTOCKS 0x0080
768#define AIM_CAPS_SENDBUDDYLIST 0x0100
769#define AIM_CAPS_GAMES2 0x0200
770#define AIM_CAPS_LAST 0x8000
37ee990e 771
d410cf58 772faim_export int aim_0002_000b(aim_session_t *sess, aim_conn_t *conn, const char *sn);
d2698e03 773
774#define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0
775#define AIM_SENDMEMBLOCK_FLAG_ISHASH 1
776
d410cf58 777faim_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);
e80a0fa9 778
37ee990e 779#define AIM_GETINFO_GENERALINFO 0x00001
780#define AIM_GETINFO_AWAYMESSAGE 0x00003
781
37ee990e 782struct aim_invite_priv {
d410cf58 783 char *sn;
784 char *roomname;
785 fu16_t exchange;
786 fu16_t instance;
37ee990e 787};
788
7392c79f 789#define AIM_COOKIETYPE_UNKNOWN 0x00
790#define AIM_COOKIETYPE_ICBM 0x01
791#define AIM_COOKIETYPE_ADS 0x02
792#define AIM_COOKIETYPE_BOS 0x03
793#define AIM_COOKIETYPE_IM 0x04
794#define AIM_COOKIETYPE_CHAT 0x05
795#define AIM_COOKIETYPE_CHATNAV 0x06
37ee990e 796#define AIM_COOKIETYPE_INVITE 0x07
7392c79f 797/* we'll move OFT up a bit to give breathing room. not like it really
798 * matters. */
799#define AIM_COOKIETYPE_OFTIM 0x10
800#define AIM_COOKIETYPE_OFTGET 0x11
801#define AIM_COOKIETYPE_OFTSEND 0x12
802#define AIM_COOKIETYPE_OFTVOICE 0x13
803#define AIM_COOKIETYPE_OFTIMAGE 0x14
804#define AIM_COOKIETYPE_OFTICON 0x15
805
d410cf58 806faim_export int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur);
040457cc 807
808#define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
809#define AIM_TRANSFER_DENY_DECLINE 0x0001
810#define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
d410cf58 811faim_export int aim_denytransfer(aim_session_t *sess, aim_conn_t *conn, const char *sender, const char *cookie, unsigned short code);
812faim_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);
78b3fb13 813
d410cf58 814faim_export int aim_getinfo(aim_session_t *, aim_conn_t *, const char *, unsigned short);
815faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, struct aim_userinfo_s *info);
816faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn);
37ee990e 817
355229fe 818#define AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED 0x00000001
819#define AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED 0x00000002
820
821/* This is what the server will give you if you don't set them yourself. */
822#define AIM_IMPARAM_DEFAULTS { \
823 0, \
824 AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
825 512, /* !! Note how small this is. */ \
826 (99.9)*10, (99.9)*10, \
827 1000 \
828}
829
830/* This is what most AIM versions use. */
831#define AIM_IMPARAM_REASONABLE { \
832 0, \
833 AIM_IMPARAM_FLAG_CHANMSGS_ALLOWED | AIM_IMPARAM_FLAG_MISSEDCALLS_ENABLED, \
834 8000, \
835 (99.9)*10, (99.9)*10, \
836 0 \
837}
838
839
840struct aim_icbmparameters {
841 unsigned short maxchan;
842 unsigned long flags; /* AIM_IMPARAM_FLAG_ */
843 unsigned short maxmsglen; /* message size that you will accept */
844 unsigned short maxsenderwarn; /* this and below are *10 (999=99.9%) */
845 unsigned short maxrecverwarn;
846 unsigned long minmsginterval; /* in milliseconds? */
847};
848
d410cf58 849faim_export int aim_reqicbmparams(aim_session_t *sess, aim_conn_t *conn);
850faim_export int aim_seticbmparam(aim_session_t *sess, aim_conn_t *conn, struct aim_icbmparameters *params);
355229fe 851
f1a5efe0 852
d410cf58 853/* auth.c */
854faim_export int aim_auth_sendcookie(aim_session_t *, aim_conn_t *, const fu8_t *);
855
856faim_export int aim_auth_clientready(aim_session_t *, aim_conn_t *);
857faim_export int aim_auth_changepasswd(aim_session_t *, aim_conn_t *, const char *newpw, const char *curpw);
858faim_export int aim_auth_setversions(aim_session_t *sess, aim_conn_t *conn);
859faim_export int aim_auth_reqconfirm(aim_session_t *sess, aim_conn_t *conn);
860faim_export int aim_auth_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info);
861faim_export int aim_auth_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail);
bd71fa88 862
863/* aim_buddylist.c */
d410cf58 864faim_export int aim_add_buddy(aim_session_t *, aim_conn_t *, const char *);
865faim_export int aim_remove_buddy(aim_session_t *, aim_conn_t *, const char *);
37ee990e 866
bd71fa88 867/* aim_search.c */
d410cf58 868faim_export int aim_usersearch_address(aim_session_t *, aim_conn_t *, const char *);
bd71fa88 869
37ee990e 870struct aim_chat_exchangeinfo {
d410cf58 871 fu16_t number;
872 char *name;
873 char *charset1;
874 char *lang1;
875 char *charset2;
876 char *lang2;
37ee990e 877};
878
a2244dd9 879#define AIM_CHATFLAGS_NOREFLECT 0x0001
880#define AIM_CHATFLAGS_AWAY 0x0002
d410cf58 881faim_export int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, fu16_t flags, const char *msg, int msglen);
882faim_export int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, fu16_t exchange, const char *roomname, fu16_t instance);
883faim_export int aim_chat_clientready(aim_session_t *sess, aim_conn_t *conn);
884faim_export int aim_chat_attachname(aim_conn_t *conn, const char *roomname);
885faim_export char *aim_chat_getname(aim_conn_t *conn);
886faim_export aim_conn_t *aim_chat_getconn(aim_session_t *, const char *name);
78b3fb13 887
d410cf58 888faim_export int aim_chatnav_reqrights(aim_session_t *sess, aim_conn_t *conn);
889faim_export int aim_chatnav_clientready(aim_session_t *sess, aim_conn_t *conn);
78b3fb13 890
d410cf58 891faim_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);
0c20631f 892
d410cf58 893faim_export int aim_chatnav_createroom(aim_session_t *sess, aim_conn_t *conn, const char *name, fu16_t exchange);
894faim_export int aim_chat_leaveroom(aim_session_t *sess, const char *name);
0c20631f 895
bd71fa88 896/* aim_util.c */
f1a5efe0 897/*
898 * These are really ugly. You'd think this was LISP. I wish it was.
d410cf58 899 *
900 * XXX With the advent of bstream's, these should be removed to enforce
901 * their use.
902 *
f1a5efe0 903 */
904#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
905#define aimutil_get8(buf) ((*(buf))&0xff)
906#define aimutil_put16(buf, data) ( \
d410cf58 907 (*(buf) = (u_char)((data)>>8)&0xff), \
908 (*((buf)+1) = (u_char)(data)&0xff), \
909 2)
f1a5efe0 910#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
911#define aimutil_put32(buf, data) ( \
d410cf58 912 (*((buf)) = (u_char)((data)>>24)&0xff), \
913 (*((buf)+1) = (u_char)((data)>>16)&0xff), \
914 (*((buf)+2) = (u_char)((data)>>8)&0xff), \
915 (*((buf)+3) = (u_char)(data)&0xff), \
916 4)
f1a5efe0 917#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
d410cf58 918 (((*((buf)+1))<<16)&0x00ff0000) + \
919 (((*((buf)+2))<< 8)&0x0000ff00) + \
920 (((*((buf)+3) )&0x000000ff)))
f1a5efe0 921
78b3fb13 922faim_export int aimutil_putstr(u_char *, const char *, int);
923faim_export int aimutil_tokslen(char *toSearch, int index, char dl);
924faim_export int aimutil_itemcnt(char *toSearch, char dl);
925faim_export char *aimutil_itemidx(char *toSearch, int index, char dl);
bd71fa88 926
78b3fb13 927faim_export int aim_snlen(const char *sn);
928faim_export int aim_sncmp(const char *sn1, const char *sn2);
e6b05d80 929
a3619f23 930/* for libc's that dont have it */
78b3fb13 931faim_export char *aim_strsep(char **pp, const char *delim);
a3619f23 932
0cc57340 933/* aim_meta.c */
78b3fb13 934faim_export char *aim_getbuilddate(void);
935faim_export char *aim_getbuildtime(void);
00ef5271 936faim_export int aim_getbuildstring(char *buf, int buflen);
37ee990e 937
9e8c4225 938#include <aim_internal.h>
0cc57340 939
bd71fa88 940#endif /* __AIM_H__ */
941
This page took 0.214053 seconds and 5 git commands to generate.