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