]> andersk Git - libfaim.git/blame - faim/aim.h
- Mon Sep 4 21:38:09 GMT 2000
[libfaim.git] / faim / aim.h
CommitLineData
bd71fa88 1/*
2 * Main libfaim header. Must be included in client for prototypes/macros.
3 *
4 */
5
6#ifndef __AIM_H__
7#define __AIM_H__
8
0cc57340 9#define FAIM_VERSION_MAJOR 0
10#define FAIM_VERSION_MINOR 99
11#define FAIM_VERSION_MINORMINOR 0
12
bd71fa88 13#include <faim/faimconfig.h>
14#include <faim/aim_cbtypes.h>
15
d6d6932a 16#if !defined(FAIM_USEPTHREADS) && !defined(FAIM_USEFAKELOCKS)
81d7797e 17#error pthreads or fakelocks are currently required.
e88ba395 18#endif
19
bd71fa88 20#include <stdio.h>
21#include <string.h>
22#include <fcntl.h>
23#include <sys/types.h>
24#include <stdlib.h>
25#include <stdarg.h>
26#include <errno.h>
27
7392c79f 28#ifdef _WIN32
29#include <windows.h>
30#include <time.h>
31#include <io.h>
32#else
7392c79f 33#include <sys/time.h>
34#include <unistd.h>
35#endif
36
e88ba395 37#ifdef FAIM_USEPTHREADS
38#include <pthread.h>
39#define faim_mutex_t pthread_mutex_t
b13c9e13 40#define faim_mutex_init(x) pthread_mutex_init(x, NULL)
41#define faim_mutex_lock(x) pthread_mutex_lock(x)
42#define faim_mutex_unlock(x) pthread_mutex_unlock(x)
43#define faim_mutex_destroy(x) pthread_mutex_destroy(x)
81d7797e 44#elif defined(FAIM_USEFAKELOCKS)
45/*
46 * For platforms without pthreads, we also assume
47 * we're not linking against a threaded app. Which
48 * means we don't have to do real locking. The
49 * macros below do nothing really. They're a joke.
50 * But they get it to compile.
51 */
52#define faim_mutex_t char
d9142146 53#define faim_mutex_init(x) *x = 0
81d7797e 54#define faim_mutex_lock(x) *x = 1;
55#define faim_mutex_unlock(x) *x = 0;
4d7c1bfb 56#define faim_mutex_destroy(x) *x = 0;
e88ba395 57#endif
58
bd71fa88 59/* Portability stuff (DMP) */
60
61#ifdef _WIN32
62#define sleep Sleep
63#define strlen(x) (int)strlen(x) /* win32 has a unsigned size_t */
64#endif
65
040457cc 66#if defined(mach) && defined(__APPLE__)
67#define gethostbyname(x) gethostbyname2(x, AF_INET)
68#endif
bd71fa88 69
78b3fb13 70#if defined(_WIN32) || defined(STRICT_ANSI)
71#define faim_shortfunc
72#else
73#define faim_shortfunc inline
74#endif
75
76#if defined(_WIN32)
77/*
78 * For a win32 DLL, we define WIN32_INDLL if this file
79 * is included while compiling the DLL. If its not
80 * defined (its included in a client app), the symbols
81 * will be imported instead of exported.
82 */
83#ifdef WIN32_INDLL
84#define faim_export __declspec(dllexport)
85#else
86#define faim_export __declspec(dllimport)
87#endif /* WIN32_INDLL */
88#define faim_internal
89#else
90/*
91 * Nothing normally needed for unix...
92 */
93#define faim_export
94#define faim_internal
81d7797e 95#endif
96
bd71fa88 97/*
98 * Current Maximum Length for Screen Names (not including NULL)
68ac63c2 99 *
100 * Currently only names up to 16 characters can be registered
101 * however it is aparently legal for them to be larger.
bd71fa88 102 */
68ac63c2 103#define MAXSNLEN 32
bd71fa88 104
91931247 105/*
106 * Current Maximum Length for Instant Messages
107 *
108 * This was found basically by experiment, but not wholly
109 * accurate experiment. It should not be regarded
110 * as completely correct. But its a decent approximation.
111 *
112 * Note that although we can send this much, its impossible
113 * for WinAIM clients (up through the latest (4.0.1957)) to
114 * send any more than 1kb. Amaze all your windows friends
5e02cf44 115 * with utterly oversized instant messages!
98c88242 116 *
117 * XXX: the real limit is the total SNAC size at 8192. Fix this.
91931247 118 *
119 */
b69540e3 120#define MAXMSGLEN 7987
91931247 121
122/*
123 * Current Maximum Length for Chat Room Messages
124 *
125 * This is actually defined by the protocol to be
126 * dynamic, but I have yet to see due cause to
127 * define it dynamically here. Maybe later.
128 *
129 */
130#define MAXCHATMSGLEN 512
131
bd71fa88 132/*
133 * Standard size of an AIM authorization cookie
134 */
135#define AIM_COOKIELEN 0x100
136
b5bc2a8c 137#define AIM_MD5_STRING "AOL Instant Messenger (SM)"
138
bd71fa88 139/*
140 * Login info. Passes information from the Authorization
141 * stage of login to the service (BOS, etc) connection
142 * phase.
143 *
144 */
145struct aim_login_struct {
146 char screen_name[MAXSNLEN+1];
147 char *BOSIP;
78b3fb13 148 unsigned char cookie[AIM_COOKIELEN];
bd71fa88 149 char *email;
150 u_short regstatus;
01b59e1e 151 char *errorurl;
152 u_short errorcode;
bd71fa88 153};
154
155/*
156 * Client info. Filled in by the client and passed
157 * in to aim_login(). The information ends up
158 * getting passed to OSCAR through the initial
159 * login command.
160 *
161 * XXX: Should this be per-session? -mid
162 *
163 */
164struct client_info_s {
165 char clientstring[100]; /* arbitrary size */
166 int major;
167 int minor;
168 int build;
169 char country[3];
170 char lang[3];
13ebc4c4 171 int major2;
172 int minor2;
173 long unknown;
bd71fa88 174};
175
176#ifndef TRUE
177#define TRUE 1
178#define FALSE 0
179#endif
180
181/*
182 * These could be arbitrary, but its easier to use the actual AIM values
183 */
184#define AIM_CONN_TYPE_AUTH 0x0007
185#define AIM_CONN_TYPE_ADS 0x0005
186#define AIM_CONN_TYPE_BOS 0x0002
187#define AIM_CONN_TYPE_CHAT 0x000e
188#define AIM_CONN_TYPE_CHATNAV 0x000d
7392c79f 189
190/* they start getting arbitrary in rendezvous stuff =) */
040457cc 191#define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak OSCAR! */
7392c79f 192#define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */
193
194/*
195 * Subtypes, we need these for OFT stuff.
196 */
197#define AIM_CONN_SUBTYPE_OFT_DIRECTIM 0x0001
198#define AIM_CONN_SUBTYPE_OFT_GETFILE 0x0002
199#define AIM_CONN_SUBTYPE_OFT_SENDFILE 0x0003
200#define AIM_CONN_SUBTYPE_OFT_BUDDYICON 0x0004
201#define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005
bd71fa88 202
203/*
204 * Status values returned from aim_conn_new(). ORed together.
205 */
206#define AIM_CONN_STATUS_READY 0x0001
207#define AIM_CONN_STATUS_INTERNALERR 0x0002
208#define AIM_CONN_STATUS_RESOLVERR 0x0080
209#define AIM_CONN_STATUS_CONNERR 0x0040
210
b69540e3 211#define AIM_FRAMETYPE_OSCAR 0x0000
212#define AIM_FRAMETYPE_OFT 0x0001
213
bd71fa88 214struct aim_conn_t {
215 int fd;
7392c79f 216 unsigned short type;
217 unsigned short subtype;
bd71fa88 218 int seqnum;
219 int status;
220 void *priv; /* misc data the client may want to store */
221 time_t lastactivity; /* time of last transmit */
222 int forcedlatency;
223 struct aim_rxcblist_t *handlerlist;
df5a99fb 224 faim_mutex_t active; /* lock around read/writes */
225 faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */
040457cc 226 struct aim_conn_t *next;
bd71fa88 227};
228
229/* struct for incoming commands */
230struct command_rx_struct {
b69540e3 231 unsigned char hdrtype; /* defines which piece of the union to use */
232 union {
233 struct {
7392c79f 234 char type;
b69540e3 235 unsigned short seqnum;
236 } oscar;
237 struct {
238 unsigned short type;
7392c79f 239 unsigned char magic[4]; /* ODC2 OFT2 */
b69540e3 240 unsigned short hdr2len;
241 unsigned char *hdr2; /* rest of bloated header */
242 } oft;
243 } hdr;
244 unsigned short commandlen; /* total payload length */
245 unsigned char *data; /* packet data (from 7 byte on) */
246 unsigned char lock; /* 0 = open, !0 = locked */
247 unsigned char handled; /* 0 = new, !0 = been handled */
248 unsigned char nofree; /* 0 = free data on purge, 1 = only unlink */
bd71fa88 249 struct aim_conn_t *conn; /* the connection it came in on... */
250 struct command_rx_struct *next; /* ptr to next struct in list */
251};
252
253/* struct for outgoing commands */
254struct command_tx_struct {
b69540e3 255 unsigned char hdrtype; /* defines which piece of the union to use */
256 union {
257 struct {
258 unsigned char type;
259 unsigned short seqnum;
260 } oscar;
261 struct {
262 unsigned short type;
7392c79f 263 unsigned char magic[4]; /* ODC2 OFT2 */
b69540e3 264 unsigned short hdr2len;
265 unsigned char *hdr2;
266 } oft;
267 } hdr;
268 u_int commandlen;
269 u_char *data;
bd71fa88 270 u_int lock; /* 0 = open, !0 = locked */
271 u_int sent; /* 0 = pending, !0 = has been sent */
272 struct aim_conn_t *conn;
273 struct command_tx_struct *next; /* ptr to next struct in list */
274};
275
276
277/*
278 * AIM Session: The main client-data interface.
279 *
280 */
281struct aim_session_t {
282
283 /* ---- Client Accessible ------------------------ */
284 /*
285 * Login information. See definition above.
286 *
287 */
288 struct aim_login_struct logininfo;
289
290 /*
291 * Pointer to anything the client wants to
292 * explicitly associate with this session.
293 */
294 void *aux_data;
295
296
297 /* ---- Internal Use Only ------------------------ */
298 /*
299 * Connection information
300 */
040457cc 301 struct aim_conn_t *connlist;
302 faim_mutex_t connlistlock;
bd71fa88 303
304 /*
305 * TX/RX queues
306 */
e88ba395 307 struct command_tx_struct *queue_outgoing;
bd71fa88 308 struct command_rx_struct *queue_incoming;
309
e88ba395 310 /*
311 * Tx Enqueuing function
312 */
313 int (*tx_enqueue)(struct aim_session_t *, struct command_tx_struct *);
314
0c20631f 315 /*
316 * This is a dreadful solution to the what-room-are-we-joining
317 * problem. (There's no connection between the service
318 * request and the resulting redirect.)
319 */
320 char *pendingjoin;
321
bd71fa88 322 /*
323 * Outstanding snac handling
324 *
325 * XXX: Should these be per-connection? -mid
b13c9e13 326 */
327 struct aim_snac_t *snac_hash[FAIM_SNAC_HASH_SIZE];
328 faim_mutex_t snac_hash_locks[FAIM_SNAC_HASH_SIZE];
bd71fa88 329 u_long snac_nextid;
040457cc 330
331 struct aim_msgcookie_t *msgcookies;
bd71fa88 332};
333
334
335/*
336 * AIM User Info, Standard Form.
337 */
338struct aim_userinfo_s {
339 char sn[MAXSNLEN+1];
340 u_short warnlevel;
341 u_short idletime;
342 u_short class;
343 u_long membersince;
344 u_long onlinesince;
345 u_long sessionlen;
5b79dc93 346 u_short capabilities;
bd71fa88 347};
348
98c88242 349#define AIM_CLASS_TRIAL 0x0001 /* "damned transients" */
350#define AIM_CLASS_ADMINISTRATOR 0x0002
0c20631f 351#define AIM_CLASS_AOL 0x0004
98c88242 352#define AIM_CLASS_OSCAR_PAY 0x0008
0c20631f 353#define AIM_CLASS_FREE 0x0010
354#define AIM_CLASS_AWAY 0x0020
355#define AIM_CLASS_UNKNOWN40 0x0040
356#define AIM_CLASS_UNKNOWN80 0x0080
357
98c88242 358#define AIM_CLASS_ALLUSERS 0x001f
359
bd71fa88 360/*
361 * TLV handling
362 */
363
364/* Generic TLV structure. */
365struct aim_tlv_t {
366 u_short type;
367 u_short length;
368 u_char *value;
369};
370
371/* List of above. */
372struct aim_tlvlist_t {
373 struct aim_tlv_t *tlv;
374 struct aim_tlvlist_t *next;
375};
376
377/* TLV-handling functions */
78b3fb13 378faim_internal struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen);
379faim_internal void aim_freetlvchain(struct aim_tlvlist_t **list);
380faim_internal struct aim_tlv_t *aim_grabtlv(u_char *src);
381faim_internal struct aim_tlv_t *aim_grabtlvstr(u_char *src);
382faim_internal struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, u_short, int);
383faim_internal char *aim_gettlv_str(struct aim_tlvlist_t *, u_short, int);
384faim_internal int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv);
385faim_internal struct aim_tlv_t *aim_createtlv(void);
386faim_internal int aim_freetlv(struct aim_tlv_t **oldtlv);
387faim_internal int aim_puttlv_16(u_char *, u_short, u_short);
388faim_internal int aim_puttlv_32(u_char *, u_short, u_long);
389faim_internal int aim_puttlv_str(u_char *buf, u_short t, u_short l, char *v);
390faim_internal int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list);
391faim_internal int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val);
392faim_internal int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val);
393faim_internal int aim_addtlvtochain_str(struct aim_tlvlist_t **list, unsigned short type, char *str, int len);
394faim_internal int aim_counttlvchain(struct aim_tlvlist_t **list);
bd71fa88 395
396/*
397 * Get command from connections / Dispatch commands
398 * already in queue.
399 */
78b3fb13 400faim_export int aim_get_command(struct aim_session_t *, struct aim_conn_t *);
bd71fa88 401int aim_rxdispatch(struct aim_session_t *);
7392c79f 402
403u_long aim_debugconn_sendconnect(struct aim_session_t *sess, struct aim_conn_t *conn);
404
bd71fa88 405int aim_logoff(struct aim_session_t *);
406
78b3fb13 407faim_export void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn);
bd71fa88 408
409typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...);
410int aim_register_callbacks(rxcallback_t *);
411
412u_long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype);
413u_long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *);
414u_long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *);
415
78b3fb13 416faim_internal struct aim_fileheader_t *aim_oft_getfh(unsigned char *hdr);
7392c79f 417
bd71fa88 418/* aim_login.c */
78b3fb13 419faim_export int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn);
420faim_export int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
421faim_export int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *, char *key);
422faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn, char *bosip, char *cookie, char *email, int regstatus);
423faim_export int aim_gencookie(unsigned char *buf);
424faim_export int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn);
425faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx_struct *command);
426faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short servid, char *ip, char *cookie);
427faim_export void aim_purge_rxqueue(struct aim_session_t *);
428faim_internal void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn);
bd71fa88 429
430int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...);
431int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...);
432int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
78b3fb13 433faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *conn);
b69540e3 434
78b3fb13 435faim_internal struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen);
436faim_internal int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *);
437faim_internal int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *);
e88ba395 438#define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y))
78b3fb13 439faim_internal int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx_struct *cur);
440faim_internal unsigned int aim_get_next_txseqnum(struct aim_conn_t *);
441faim_export int aim_tx_flushqueue(struct aim_session_t *);
442faim_internal int aim_tx_printqueue(struct aim_session_t *);
443faim_export void aim_tx_purgequeue(struct aim_session_t *);
bd71fa88 444
445struct aim_rxcblist_t {
446 u_short family;
447 u_short type;
448 rxcallback_t handler;
449 u_short flags;
450 struct aim_rxcblist_t *next;
451};
452
78b3fb13 453faim_export int aim_conn_setlatency(struct aim_conn_t *conn, int newval);
bd71fa88 454
78b3fb13 455faim_export int aim_conn_addhandler(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short type, rxcallback_t newhandler, u_short flags);
456faim_internal rxcallback_t aim_callhandler(struct aim_conn_t *conn, u_short family, u_short type);
457faim_export int aim_clearhandlers(struct aim_conn_t *conn);
bd71fa88 458
459/*
460 * Generic SNAC structure. Rarely if ever used.
461 */
462struct aim_snac_t {
463 u_long id;
464 u_short family;
465 u_short type;
466 u_short flags;
467 void *data;
468 time_t issuetime;
469 struct aim_snac_t *next;
470};
b13c9e13 471void aim_initsnachash(struct aim_session_t *sess);
bd71fa88 472u_long aim_newsnac(struct aim_session_t *, struct aim_snac_t *newsnac);
473struct aim_snac_t *aim_remsnac(struct aim_session_t *, u_long id);
474int aim_cleansnacs(struct aim_session_t *, int maxage);
475int aim_putsnac(u_char *, int, int, int, u_long);
476
477
78b3fb13 478faim_internal void aim_connrst(struct aim_session_t *);
479faim_internal struct aim_conn_t *aim_conn_getnext(struct aim_session_t *);
480faim_export void aim_conn_close(struct aim_conn_t *deadconn);
481faim_internal struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type);
482faim_export struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest);
483faim_export int aim_conngetmaxfd(struct aim_session_t *);
484faim_export struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *);
485faim_export int aim_conn_isready(struct aim_conn_t *);
486faim_export int aim_conn_setstatus(struct aim_conn_t *, int);
487faim_export void aim_session_init(struct aim_session_t *);
bd71fa88 488
489/* aim_misc.c */
490
491#define AIM_VISIBILITYCHANGE_PERMITADD 0x05
492#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
493#define AIM_VISIBILITYCHANGE_DENYADD 0x07
494#define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08
495
98c88242 496#define AIM_PRIVFLAGS_ALLOWIDLE 0x01
497#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02
498
499#define AIM_WARN_ANON 0x01
500
501int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon);
f0a7908e 502u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *);
bd71fa88 503u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long);
504u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *);
505u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *);
5b79dc93 506u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int);
bd71fa88 507u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long);
78b3fb13 508unsigned long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *);
bd71fa88 509u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *);
510u_long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *);
511u_long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long);
512u_long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *);
513u_long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short);
78b3fb13 514unsigned long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *);
bd71fa88 515u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *);
516u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *);
517u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *);
c78446b5 518unsigned long aim_addicbmparam(struct aim_session_t *sess,struct aim_conn_t *conn);
0c20631f 519u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn);
bd71fa88 520
78b3fb13 521faim_internal struct aim_fileheader_t *aim_getlisting(struct aim_session_t*);
522faim_internal int aim_listenestablish(u_short);
7392c79f 523
bd71fa88 524/* aim_rxhandlers.c */
78b3fb13 525faim_export int aim_rxdispatch(struct aim_session_t *);
526faim_internal int aim_authparse(struct aim_session_t *, struct command_rx_struct *);
527faim_internal int aim_handleredirect_middle(struct aim_session_t *, struct command_rx_struct *, ...);
528faim_internal int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *, ...);
bd71fa88 529int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
78b3fb13 530faim_internal int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...);
531faim_internal int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...);
532faim_internal int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command);
533faim_internal int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command);
534faim_internal int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command);
535
536faim_export unsigned long aim_ads_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
537faim_export unsigned long aim_ads_requestads(struct aim_session_t *sess, struct aim_conn_t *conn);
bd71fa88 538
539/* aim_im.c */
7392c79f 540struct aim_directim_priv {
541 unsigned char cookie[8];
542 char sn[MAXSNLEN+1];
543 char ip[30];
544};
545
bd71fa88 546#define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */
547#define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */
548
78b3fb13 549faim_export unsigned long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *);
550faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *);
551faim_internal int aim_parse_outgoing_im_middle(struct aim_session_t *, struct command_rx_struct *);
552faim_export unsigned long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn);
553faim_internal int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *);
554faim_internal int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command);
96f8b1ed 555int aim_parse_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...);
78b3fb13 556faim_internal int aim_parse_missedcall(struct aim_session_t *sess, struct command_rx_struct *command);
bd71fa88 557
78b3fb13 558faim_export struct aim_conn_t * aim_directim_initiate(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *, char *);
559faim_export int aim_send_im_direct(struct aim_session_t *, struct aim_conn_t *, char *);
560faim_export struct aim_conn_t *aim_directim_connect(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *);
7392c79f 561
bd71fa88 562/* aim_info.c */
5b79dc93 563#define AIM_CAPS_BUDDYICON 0x01
564#define AIM_CAPS_VOICE 0x02
565#define AIM_CAPS_IMIMAGE 0x04
566#define AIM_CAPS_CHAT 0x08
567#define AIM_CAPS_GETFILE 0x10
568#define AIM_CAPS_SENDFILE 0x20
b69540e3 569
5b79dc93 570extern u_char aim_caps[6][16];
78b3fb13 571faim_internal unsigned short aim_getcap(unsigned char *capblock, int buflen);
572faim_internal int aim_putcap(unsigned char *capblock, int buflen, u_short caps);
262272cc 573
574#define AIM_GETINFO_GENERALINFO 0x00001
575#define AIM_GETINFO_AWAYMESSAGE 0x00003
576
040457cc 577struct aim_msgcookie_t {
578 unsigned char cookie[8];
040457cc 579 int type;
580 void *data;
581 time_t addtime;
582 struct aim_msgcookie_t *next;
583};
584
7392c79f 585struct aim_fileheader_t {
586#if 0
587 char magic[4]; /* 0 */
588 short hdrlen; /* 4 */
589 short hdrtype; /* 6 */
590#endif
591 char bcookie[8]; /* 8 */
592 short encrypt; /* 16 */
593 short compress; /* 18 */
594 short totfiles; /* 20 */
595 short filesleft; /* 22 */
596 short totparts; /* 24 */
597 short partsleft; /* 26 */
598 long totsize; /* 28 */
599 long size; /* 32 */
600 long modtime; /* 36 */
601 long checksum; /* 40 */
602 long rfrcsum; /* 44 */
603 long rfsize; /* 48 */
604 long cretime; /* 52 */
605 long rfcsum; /* 56 */
606 long nrecvd; /* 60 */
607 long recvcsum; /* 64 */
608 char idstring[32]; /* 68 */
609 char flags; /* 100 */
610 char lnameoffset; /* 101 */
611 char lsizeoffset; /* 102 */
612 char dummy[69]; /* 103 */
613 char macfileinfo[16]; /* 172 */
614 short nencode; /* 188 */
615 short nlanguage; /* 190 */
616 char name[64]; /* 192 */
617 /* 256 */
618};
619
620struct aim_filetransfer_priv {
621 char sn[MAXSNLEN];
622 char cookie[8];
040457cc 623 char ip[30];
7392c79f 624 int state;
625 struct aim_fileheader_t fh;
040457cc 626};
7392c79f 627
628#define AIM_COOKIETYPE_UNKNOWN 0x00
629#define AIM_COOKIETYPE_ICBM 0x01
630#define AIM_COOKIETYPE_ADS 0x02
631#define AIM_COOKIETYPE_BOS 0x03
632#define AIM_COOKIETYPE_IM 0x04
633#define AIM_COOKIETYPE_CHAT 0x05
634#define AIM_COOKIETYPE_CHATNAV 0x06
635/* we'll move OFT up a bit to give breathing room. not like it really
636 * matters. */
637#define AIM_COOKIETYPE_OFTIM 0x10
638#define AIM_COOKIETYPE_OFTGET 0x11
639#define AIM_COOKIETYPE_OFTSEND 0x12
640#define AIM_COOKIETYPE_OFTVOICE 0x13
641#define AIM_COOKIETYPE_OFTIMAGE 0x14
642#define AIM_COOKIETYPE_OFTICON 0x15
643
78b3fb13 644faim_internal int aim_cachecookie(struct aim_session_t *sess, struct aim_msgcookie_t *cookie);
645faim_export int aim_purgecookies(struct aim_session_t *sess, int maxage);
646faim_internal struct aim_msgcookie_t *aim_uncachecookie(struct aim_session_t *sess, unsigned char *cookie, int type);
647faim_internal struct aim_msgcookie_t *aim_mkcookie(unsigned char *, int, void *);
648faim_internal struct aim_msgcookie_t *aim_checkcookie(struct aim_session_t *, unsigned char *, int);
649faim_internal int aim_msgcookie_gettype(int reqclass);
7392c79f 650
78b3fb13 651faim_export int aim_handlerendconnect(struct aim_session_t *sess, struct aim_conn_t *cur);
040457cc 652
653#define AIM_TRANSFER_DENY_NOTSUPPORTED 0x0000
654#define AIM_TRANSFER_DENY_DECLINE 0x0001
655#define AIM_TRANSFER_DENY_NOTACCEPTING 0x0002
78b3fb13 656faim_export unsigned long aim_denytransfer(struct aim_session_t *sess, struct aim_conn_t *conn, char *sender, char *cookie, unsigned short code);
657faim_export unsigned long aim_accepttransfer(struct aim_session_t *sess, struct aim_conn_t *conn,struct aim_conn_t *oftconn, char *sender, char *cookie, unsigned short rendid);
658
659faim_export unsigned long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
660faim_internal int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
661faim_internal int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
662faim_internal int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *);
663faim_internal int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *);
664faim_internal int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info);
665faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info);
666faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
667faim_internal int aim_parse_locateerr(struct aim_session_t *sess, struct command_rx_struct *command);
f1a5efe0 668
bd71fa88 669/* aim_auth.c */
78b3fb13 670faim_export int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *);
671faim_export u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *);
672faim_export unsigned long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *);
bd71fa88 673
674/* aim_buddylist.c */
78b3fb13 675faim_export unsigned long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
676faim_export unsigned long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
677faim_internal int aim_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...);
bd71fa88 678
679/* aim_search.c */
680u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *);
681/* u_long aim_usersearch_name(struct aim_session_t *, struct aim_conn_t *, char *); */
682
0c20631f 683
684struct aim_chat_roominfo {
685 u_short exchange;
686 char *name;
687 u_short instance;
688};
78b3fb13 689faim_internal int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo);
690faim_internal int aim_chat_parse_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command);
691faim_internal int aim_chat_parse_joined(struct aim_session_t *sess, struct command_rx_struct *command);
692faim_internal int aim_chat_parse_leave(struct aim_session_t *sess, struct command_rx_struct *command);
693faim_internal int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command);
694faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg);
695faim_export unsigned long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname);
696faim_export unsigned long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
697faim_export int aim_chat_attachname(struct aim_conn_t *conn, char *roomname);
698faim_export char *aim_chat_getname(struct aim_conn_t *conn);
699faim_export struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name);
700
701faim_export unsigned long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn);
702faim_export unsigned long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
703
704faim_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);
0c20631f 705
706struct aim_chat_exchangeinfo {
707 u_short number;
708 char *name;
709 char *charset1;
710 char *lang1;
711 char *charset2;
712 char *lang2;
713};
78b3fb13 714faim_internal int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command);
715faim_export u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange);
716faim_export int aim_chat_leaveroom(struct aim_session_t *sess, char *name);
0c20631f 717
bd71fa88 718/* aim_util.c */
f1a5efe0 719#ifdef AIMUTIL_USEMACROS
720/*
721 * These are really ugly. You'd think this was LISP. I wish it was.
722 */
723#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
724#define aimutil_get8(buf) ((*(buf))&0xff)
725#define aimutil_put16(buf, data) ( \
726 (*(buf) = (u_char)((data)>>8)&0xff), \
727 (*((buf)+1) = (u_char)(data)&0xff), \
728 2)
729#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
730#define aimutil_put32(buf, data) ( \
731 (*((buf)) = (u_char)((data)>>24)&0xff), \
732 (*((buf)+1) = (u_char)((data)>>16)&0xff), \
733 (*((buf)+2) = (u_char)((data)>>8)&0xff), \
734 (*((buf)+3) = (u_char)(data)&0xff), \
735 4)
736#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
737 (((*((buf)+1))<<16)&0x00ff0000) + \
738 (((*((buf)+2))<< 8)&0x0000ff00) + \
739 (((*((buf)+3) )&0x000000ff)))
740#else
741#warning Not using aimutil macros. May have performance problems.
bd71fa88 742int aimutil_put8(u_char *, u_char);
743u_char aimutil_get8(u_char *buf);
744int aimutil_put16(u_char *, u_short);
745u_short aimutil_get16(u_char *);
746int aimutil_put32(u_char *, u_long);
747u_long aimutil_get32(u_char *);
f1a5efe0 748#endif
749
78b3fb13 750faim_export int aimutil_putstr(u_char *, const char *, int);
751faim_export int aimutil_tokslen(char *toSearch, int index, char dl);
752faim_export int aimutil_itemcnt(char *toSearch, char dl);
753faim_export char *aimutil_itemidx(char *toSearch, int index, char dl);
bd71fa88 754
78b3fb13 755faim_export int aim_snlen(const char *sn);
756faim_export int aim_sncmp(const char *sn1, const char *sn2);
e6b05d80 757
a3619f23 758/* for libc's that dont have it */
78b3fb13 759faim_export char *aim_strsep(char **pp, const char *delim);
a3619f23 760
0cc57340 761/* aim_meta.c */
78b3fb13 762faim_export char *aim_getbuilddate(void);
763faim_export char *aim_getbuildtime(void);
764faim_export char *aim_getbuildstring(void);
765faim_internal void faimdprintf(int dlevel, const char *format, ...);
0cc57340 766
bd71fa88 767#endif /* __AIM_H__ */
768
This page took 0.16626 seconds and 5 git commands to generate.