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