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