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