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