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