changeset 283:0f14e6d8a51b

[gaim-migrate @ 293] - Good fun things here. Sometimes I think Adam does things just to make it difficult for me, I swear (j/k :) ). - I moved all the .h files into the faim/ directory because I'm tired of changing faim/aim.h to just aim.h every time Adam makes an update. - libfaim can now send messages much longer than WinAIM or TOC can. But, the length checking code is still in conversation.c, and I haven't changed it yet, mostly because I'm lazy. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 31 May 2000 03:20:11 +0000
parents 918db59d3814
children bafaf1b68f9a
files configure.in libfaim/CHANGES libfaim/CHANGES.gaim libfaim/Makefile.am libfaim/README.gaim libfaim/aim.h libfaim/aim_auth.c libfaim/aim_buddylist.c libfaim/aim_cbtypes.h libfaim/aim_chat.c libfaim/aim_chatnav.c libfaim/aim_conn.c libfaim/aim_im.c libfaim/aim_info.c libfaim/aim_login.c libfaim/aim_logoff.c libfaim/aim_meta.c libfaim/aim_misc.c libfaim/aim_rxhandlers.c libfaim/aim_rxqueue.c libfaim/aim_search.c libfaim/aim_snac.c libfaim/aim_tlv.c libfaim/aim_txqueue.c libfaim/aim_util.c libfaim/faim/aim.h libfaim/faim/aim_cbtypes.h libfaim/faim/faimconfig.h libfaim/faimconfig.h src/conversation.c src/oscar.c src/server.c
diffstat 32 files changed, 957 insertions(+), 878 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Wed May 31 00:57:39 2000 +0000
+++ b/configure.in	Wed May 31 03:20:11 2000 +0000
@@ -48,7 +48,7 @@
 fi
 
 if test "$enable_oscar" = yes ; then
-	GAIM_CFLAGS="$GAIM_CFLAGS -DUSE_OSCAR -I../libfaim"
+	GAIM_CFLAGS="$GAIM_CFLAGS -DUSE_OSCAR -I../libfaim/faim"
         GAIM_LDADD="$GAIM_LDADD -L../libfaim -lfaim"
         LIBFAIM_DO="libfaim.a"
 fi
--- a/libfaim/CHANGES	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/CHANGES	Wed May 31 03:20:11 2000 +0000
@@ -1,6 +1,13 @@
 
 No release numbers
 ------------------
+ - Wed May 31 01:17:24 UTC 2000
+   - Added constants for message sizes (MAXMSGLEN, MAXCHATMSGLEN)
+     - Note that the new max message size is defined as 7988bytes,
+         drastically larger than WinAIM lets you put out.  This is a
+         libfaim-exclusive feature :)
+   - Reduced base buffer size on aim_send_im()  
+ 
  - Tue May 30 22:32:31 UTC 2000
    - Added lock around tx seqnum to prevent that race when transmitting
        from diverse threads. (actually committed earlier today)
--- a/libfaim/CHANGES.gaim	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/CHANGES.gaim	Wed May 31 03:20:11 2000 +0000
@@ -1,3 +1,12 @@
+
+Wed May 31 02:50:36 UTC 2000 EWarmenhoven
+	- Good fun things here. Sometimes I think Adam does things just to make
+	  it difficult for me, I swear (j/k :) ).
+	- I moved all the .h files into the faim/ directory because I'm tired
+	  of changing faim/aim.h to just aim.h every time Adam makes an update.
+	- libfaim can now send messages much longer than WinAIM or TOC can. But,
+	  the length checking code is still in conversation.c, and I haven't
+	  changed it yet, mostly because I'm lazy.
 
 Wed May 31 00:40:42 UTC 2000 EWarmenhoven
 	- Adam added a file to libfaim, aim_meta.c, that has one main function:
--- a/libfaim/Makefile.am	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/Makefile.am	Wed May 31 03:20:11 2000 +0000
@@ -2,8 +2,8 @@
 
 EXTRA_LIBRARIES = libfaim.a
 
-EXTRA_DIST = aim.h aim_cbtypes.h faimconfig.h README README.gaim CHANGES \
-		CHANGES.gaim COPYING BUGS
+EXTRA_DIST = faim/aim.h faim/aim_cbtypes.h faim/faimconfig.h README \
+		README.gaim CHANGES CHANGES.gaim COPYING BUGS
 
 #libfaim_a_SOURCES = aim_chatnav.c aim_info.c aim_rxhandlers.c \
 #                    aim_tlv.c aim_auth.c aim_conn.c aim_login.c \
@@ -15,5 +15,5 @@
 		    aim_meta.c aim_misc.c aim_rxhandlers.c aim_rxqueue.c \
 		    aim_search.c aim_snac.c aim_tlv.c aim_txqueue.c aim_util.c
 
-CFLAGS += $(GAIM_CFLAGS) -I../src -DAIM_BUILDDATE=`date +%Y%m%e` -DAIM_BUILDTIME=`date +%H%M%S`
+CFLAGS += $(GAIM_CFLAGS) -I../src -DAIM_BUILDDATE=\"`date +%Y%m%e`\" -DAIM_BUILDTIME=\"`date +%H%M%S`\"
 
--- a/libfaim/README.gaim	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/README.gaim	Wed May 31 03:20:11 2000 +0000
@@ -8,18 +8,29 @@
 
 I'm going to try to make as few modifications as possible to the libfaim code.
 The only two modifications I'll probably ever make to it are 1) to make my life
-easier (like putting all the .h files in the same directory as the .c files) or
-2) to fix a compilation error that I happen to be able to fix very easily (like
-with a typo or something). That means that what you're getting when you enable
-oscar is basically faimtest (the very instructional program included with the
-libfaim source on sourceforge) with the Gaim GTK front-end. I'll put any changes
-I make into a file, but so far, I haven't made any changes other than moving the
-.h files down a directory.
+easier or 2) to fix a compilation error. That means that what you're getting
+when you enable oscar is basically faimtest (the very instructional program
+included with the libfaim source on sourceforge) with the Gaim GTK front-end.
+I'll put any changes I make into a file. So far the few changes I've made have
+been to make a few printf's not print, and removing a few defines from a .h and
+putting them in the Makefile/build process.
 
 And finally, a word of warning. Gaim/Faim is VERY buggy. Please, don't use this
 for anything other than laughs right now. Hopefully we'll get it working better
 soon (please help!).
 
+I think I'm ready to start dealing with bugs being reported against it now
+though. If you're going to report a bug, please check first that a) you're using
+the to-the-second absolute latest CVS version, b) it's not in the unsupported
+features/known issues lists below, c) someone hasn't already reported the bug on
+sourceforge (please check BOTH the open and closed bugs), and finally d) that
+you can reproduce it.
+
+Also, please *don't* IM me about a bug, as I have a tendency to forget things
+like that. Reporting it on sourceforge is a much better way of reporting bugs,
+because then other people can see that the bug is already known, and it's harder
+for me to forget.
+
 CURRENTLY SUPPORTED FEATURES
 ============================
 Signing on
@@ -59,6 +70,13 @@
 want to know. I'm not worried about it, I never use chat. It's not exactly high-
 priority.
 
+- The permit list sometimes has problems when you start gaim, but if you change
+to it in the middle of a session there don't seem to be any problems.
+
+- "Allow anyone" and "Deny some" serve the same function. That's not a bug. But
+"Allow anyone" works all the time (?) and "Deny some" doesn't work some of the
+time. That's a bug.
+
 - Gaim/TOC can do file transfers, but Gaim/Faim cannot. This is not because
 there is any difference in the two protocols as far as the actual transfer is
 concerned. The only thing preventing this is it is currently not possible to
--- a/libfaim/aim.h	Wed May 31 00:57:39 2000 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,528 +0,0 @@
-/* 
- * Main libfaim header.  Must be included in client for prototypes/macros.
- *
- */
-
-#ifndef __AIM_H__
-#define __AIM_H__
-
-#include <faimconfig.h>
-#include <aim_cbtypes.h>
-
-#ifndef FAIM_USEPTHREADS
-#error pthreads are currently required.
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <errno.h>
-
-#ifdef FAIM_USEPTHREADS
-#include <pthread.h>
-#define faim_mutex_t pthread_mutex_t 
-#define faim_mutex_init pthread_mutex_init
-#define faim_mutex_lock pthread_mutex_lock
-#define faim_mutex_unlock pthread_mutex_unlock
-#endif
-
-#ifdef _WIN32
-#include <windows.h>
-#include <time.h>
-#include <io.h>
-#else
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-/* Portability stuff (DMP) */
-
-#ifdef _WIN32
-#define sleep Sleep
-#define strlen(x) (int)strlen(x)  /* win32 has a unsigned size_t */
-#endif
-
-#if defined(_WIN32) || (defined(mach) && defined(__APPLE__)) 
-#define gethostbyname2(x,y) gethostbyname(x) /* revert to IPv4 */
-#endif 
-
-/* 
- * Current Maximum Length for Screen Names (not including NULL) 
- */
-#define MAXSNLEN 16
-
-/*
- * Standard size of an AIM authorization cookie
- */
-#define AIM_COOKIELEN            0x100
-
-#if debug > 0
-#define faimdprintf(l, x...) {if (l >= debug) printf(x); }
-#else
-#define faimdprintf(l, x...)
-#endif
-
-/*
- * Login info.  Passes information from the Authorization
- * stage of login to the service (BOS, etc) connection
- * phase.
- *
- */
-struct aim_login_struct {
-  char screen_name[MAXSNLEN+1];
-  char *BOSIP;
-  char cookie[AIM_COOKIELEN];
-  char *email;
-  u_short regstatus;
-  char *errorurl;
-  u_short errorcode;
-};
-
-/*
- * Client info.  Filled in by the client and passed
- * in to aim_login().  The information ends up
- * getting passed to OSCAR through the initial
- * login command.
- *
- * XXX: Should this be per-session? -mid
- *
- */
-struct client_info_s {
-  char clientstring[100]; /* arbitrary size */
-  int major;
-  int minor;
-  int build;
-  char country[3];
-  char lang[3];
-};
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-/* 
- * These could be arbitrary, but its easier to use the actual AIM values 
- */
-#define AIM_CONN_TYPE_AUTH          0x0007
-#define AIM_CONN_TYPE_ADS           0x0005
-#define AIM_CONN_TYPE_BOS           0x0002
-#define AIM_CONN_TYPE_CHAT          0x000e
-#define AIM_CONN_TYPE_CHATNAV       0x000d
-
-/*
- * Status values returned from aim_conn_new().  ORed together.
- */
-#define AIM_CONN_STATUS_READY       0x0001
-#define AIM_CONN_STATUS_INTERNALERR 0x0002
-#define AIM_CONN_STATUS_RESOLVERR   0x0080
-#define AIM_CONN_STATUS_CONNERR     0x0040
-
-struct aim_conn_t {
-  int fd;
-  int type;
-  int seqnum;
-  int status;
-  void *priv; /* misc data the client may want to store */
-  time_t lastactivity; /* time of last transmit */
-  int forcedlatency; 
-  struct aim_rxcblist_t *handlerlist;
-  faim_mutex_t active; /* lock around read/writes */
-  faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */
-};
-
-/* struct for incoming commands */
-struct command_rx_struct {
-                            /* byte 1 assumed to always be 0x2a */
-  char type;                /* type code (byte 2) */
-  u_int seqnum;             /* sequence number (bytes 3 and 4) */
-  u_int commandlen;         /* total packet len - 6 (bytes 5 and 6) */
-  u_char *data;             /* packet data (from 7 byte on) */
-  u_int lock;               /* 0 = open, !0 = locked */
-  u_int handled;            /* 0 = new, !0 = been handled */
-  u_int nofree;		    /* 0 = free data on purge, 1 = only unlink */
-  struct aim_conn_t *conn;  /* the connection it came in on... */
-  struct command_rx_struct *next; /* ptr to next struct in list */
-};
-
-/* struct for outgoing commands */
-struct command_tx_struct {
-                            /* byte 1 assumed to be 0x2a */
-  char type;                /* type/family code */
-  u_int seqnum;             /* seqnum dynamically assigned on tx */
-  u_int commandlen;         /* SNAC length */
-  u_char *data;             /* packet data */
-  u_int lock;               /* 0 = open, !0 = locked */
-  u_int sent;               /* 0 = pending, !0 = has been sent */
-  struct aim_conn_t *conn; 
-  struct command_tx_struct *next; /* ptr to next struct in list */
-};
-
-
-/*
- * AIM Session: The main client-data interface.  
- *
- */
-struct aim_session_t {
-
-  /* ---- Client Accessible ------------------------ */
-  /* 
-   * Login information.  See definition above.
-   *
-   */
-  struct aim_login_struct logininfo;
-  
-  /*
-   * Pointer to anything the client wants to 
-   * explicitly associate with this session.
-   */
-  void *aux_data;
-
-
-  /* ---- Internal Use Only ------------------------ */
-  /* 
-   * Connection information
-   */
-  struct aim_conn_t conns[AIM_CONN_MAX];
-  
-  /* 
-   * TX/RX queues 
-   */
-  struct command_tx_struct *queue_outgoing;   
-  struct command_rx_struct *queue_incoming; 
-  
-  /*
-   * Tx Enqueuing function
-   */
-  int (*tx_enqueue)(struct aim_session_t *, struct command_tx_struct *);
-
-  /*
-   * This is a dreadful solution to the what-room-are-we-joining
-   * problem.  (There's no connection between the service
-   * request and the resulting redirect.)
-   */ 
-  char *pendingjoin;
-
-  /*
-   * Outstanding snac handling 
-   *
-   * XXX: Should these be per-connection? -mid
-   **/
-  struct aim_snac_t *outstanding_snacs;
-  u_long snac_nextid;
-};
-
-
-/*
- * AIM User Info, Standard Form.
- */
-struct aim_userinfo_s {
-  char sn[MAXSNLEN+1];
-  u_short warnlevel;
-  u_short idletime;
-  u_short class;
-  u_long membersince;
-  u_long onlinesince;
-  u_long sessionlen;  
-  u_short capabilities;
-};
-
-#define AIM_CLASS_TRIAL 	0x0001
-#define AIM_CLASS_UNKNOWN2	0x0002
-#define AIM_CLASS_AOL		0x0004
-#define AIM_CLASS_UNKNOWN4	0x0008
-#define AIM_CLASS_FREE 		0x0010
-#define AIM_CLASS_AWAY		0x0020
-#define AIM_CLASS_UNKNOWN40	0x0040
-#define AIM_CLASS_UNKNOWN80	0x0080
-
-/*
- * TLV handling
- */
-
-/* Generic TLV structure. */
-struct aim_tlv_t {
-  u_short type;
-  u_short length;
-  u_char *value;
-};
-
-/* List of above. */
-struct aim_tlvlist_t {
-  struct aim_tlv_t *tlv;
-  struct aim_tlvlist_t *next;
-};
-
-/* TLV-handling functions */
-struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen);
-void aim_freetlvchain(struct aim_tlvlist_t **list);
-struct aim_tlv_t *aim_grabtlv(u_char *src);
-struct aim_tlv_t *aim_grabtlvstr(u_char *src);
-struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, u_short, int);
-char *aim_gettlv_str(struct aim_tlvlist_t *, u_short, int);
-int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv);
-struct aim_tlv_t *aim_createtlv(void);
-int aim_freetlv(struct aim_tlv_t **oldtlv);
-int aim_puttlv_16(u_char *, u_short, u_short);
-int aim_puttlv_32(u_char *, u_short, u_long);
-int aim_puttlv_str(u_char *buf, u_short t, u_short l, u_char *v);
-int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list);
-int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val);
-int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val);
-int aim_addtlvtochain_str(struct aim_tlvlist_t **list, unsigned short type, char *str, int len);
-int aim_counttlvchain(struct aim_tlvlist_t **list);
-
-/*
- * Get command from connections / Dispatch commands
- * already in queue.
- */
-int aim_get_command(struct aim_session_t *, struct aim_conn_t *);
-int aim_rxdispatch(struct aim_session_t *);
-
-int aim_logoff(struct aim_session_t *);
-
-
-typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...);
-int aim_register_callbacks(rxcallback_t *);
-
-u_long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype);
-u_long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *);
-u_long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *);
-
-/* aim_login.c */
-int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn);
-int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
-int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *);
-int aim_encode_password(const char *, u_char *);
-unsigned long aim_sendauthresp(struct aim_session_t *sess, 
-			       struct aim_conn_t *conn, 
-			       char *sn, char *bosip, 
-			       char *cookie, char *email, 
-			       int regstatus);
-int aim_gencookie(unsigned char *buf);
-int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn);
-unsigned long aim_sendredirect(struct aim_session_t *sess, 
-			       struct aim_conn_t *conn, 
-			       unsigned short servid, 
-			       char *ip,
-			       char *cookie);
-void aim_purge_rxqueue(struct aim_session_t *);
-
-
-int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...);
-int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...);
-int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
-
-struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int);
-int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *);
-int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *);
-#define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y))
-int aim_tx_sendframe(struct command_tx_struct *cur);
-u_int aim_get_next_txseqnum(struct aim_conn_t *);
-int aim_tx_flushqueue(struct aim_session_t *);
-int aim_tx_printqueue(struct aim_session_t *);
-void aim_tx_purgequeue(struct aim_session_t *);
-
-struct aim_rxcblist_t {
-  u_short family;
-  u_short type;
-  rxcallback_t handler;
-  u_short flags;
-  struct aim_rxcblist_t *next;
-};
-
-int aim_conn_setlatency(struct aim_conn_t *conn, int newval);
-
-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);
-rxcallback_t aim_callhandler(struct aim_conn_t *conn, u_short family, u_short type);
-int aim_clearhandlers(struct aim_conn_t *conn);
-
-/*
- * Generic SNAC structure.  Rarely if ever used.
- */
-struct aim_snac_t {
-  u_long id;
-  u_short family;
-  u_short type;
-  u_short flags;
-  void *data;
-  time_t issuetime;
-  struct aim_snac_t *next;
-};
-u_long aim_newsnac(struct aim_session_t *, struct aim_snac_t *newsnac);
-struct aim_snac_t *aim_remsnac(struct aim_session_t *, u_long id);
-int aim_cleansnacs(struct aim_session_t *, int maxage);
-int aim_putsnac(u_char *, int, int, int, u_long);
-
-
-void aim_connrst(struct aim_session_t *);
-struct aim_conn_t *aim_conn_getnext(struct aim_session_t *);
-void aim_conn_close(struct aim_conn_t *deadconn);
-struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type);
-struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest);
-int aim_conngetmaxfd(struct aim_session_t *);
-struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *);
-int aim_conn_isready(struct aim_conn_t *);
-int aim_conn_setstatus(struct aim_conn_t *, int);
-void aim_session_init(struct aim_session_t *);
-
-/* aim_misc.c */
-
-#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
-#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
-#define AIM_VISIBILITYCHANGE_DENYADD      0x07
-#define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
-
-u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long);
-u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *);
-u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *);
-u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int);
-u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long);
-u_long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long);
-u_long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short);
-u_long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn);
-
-/* aim_rxhandlers.c */
-int aim_rxdispatch(struct aim_session_t *);
-int aim_authparse(struct aim_session_t *, struct command_rx_struct *);
-int aim_handleredirect_middle(struct aim_session_t *, struct command_rx_struct *, ...);
-int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *, ...);
-int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
-int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...);
-int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...);
-
-/* aim_im.c */
-#define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */
-#define AIM_IMFLAGS_ACK  0x02 /* request a receipt notice */
-
-u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *);
-int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *);
-u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn);
-int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *);
-
-/* aim_info.c */
-#define AIM_CAPS_BUDDYICON 0x01
-#define AIM_CAPS_VOICE 0x02
-#define AIM_CAPS_IMIMAGE 0x04
-#define AIM_CAPS_CHAT 0x08
-#define AIM_CAPS_GETFILE 0x10
-#define AIM_CAPS_SENDFILE 0x20
-extern u_char aim_caps[6][16];
-
-#define AIM_GETINFO_GENERALINFO 0x00001
-#define AIM_GETINFO_AWAYMESSAGE 0x00003
-
-u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
-int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
-int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
-int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *);
-int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *);
-int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info);
-int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info);
-int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
-
-
-/* aim_auth.c */
-int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *);
-u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *);
-u_long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *);
-
-/* aim_buddylist.c */
-u_long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
-u_long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
-
-/* aim_search.c */
-u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *);
-/* u_long aim_usersearch_name(struct aim_session_t *, struct aim_conn_t *, char *); */
-
-
-struct aim_chat_roominfo {
-  u_short exchange;
-  char *name;
-  u_short instance;
-};
-int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo);
-int aim_chat_parse_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command);
-int aim_chat_parse_joined(struct aim_session_t *sess, struct command_rx_struct *command);
-int aim_chat_parse_leave(struct aim_session_t *sess, struct command_rx_struct *command);
-int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command);
-u_long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg);
-u_long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname);
-u_long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
-int aim_chat_attachname(struct aim_conn_t *conn, char *roomname);
-char *aim_chat_getname(struct aim_conn_t *conn);
-struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name);
-
-u_long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn);
-u_long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
-
-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);
-
-struct aim_chat_exchangeinfo {
-  u_short number;
-  char *name;
-  char *charset1;
-  char *lang1;
-  char *charset2;
-  char *lang2;
-};
-int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command);
-u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange);
-int aim_chat_leaveroom(struct aim_session_t *sess, char *name);
-
-/* aim_util.c */
-#ifdef AIMUTIL_USEMACROS
-/*
- * These are really ugly.  You'd think this was LISP.  I wish it was.
- */
-#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
-#define aimutil_get8(buf) ((*(buf))&0xff)
-#define aimutil_put16(buf, data) ( \
-                                  (*(buf) = (u_char)((data)>>8)&0xff), \
-				  (*((buf)+1) = (u_char)(data)&0xff),  \
-				  2)
-#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
-#define aimutil_put32(buf, data) ( \
-                                  (*((buf)) = (u_char)((data)>>24)&0xff), \
-				  (*((buf)+1) = (u_char)((data)>>16)&0xff), \
-				  (*((buf)+2) = (u_char)((data)>>8)&0xff), \
-				  (*((buf)+3) = (u_char)(data)&0xff), \
-                                  4)
-#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
-                            (((*((buf)+1))<<16)&0x00ff0000) + \
-                            (((*((buf)+2))<< 8)&0x0000ff00) + \
-                            (((*((buf)+3)    )&0x000000ff)))
-#else
-#warning Not using aimutil macros.  May have performance problems.
-int aimutil_put8(u_char *, u_char);
-u_char aimutil_get8(u_char *buf);
-int aimutil_put16(u_char *, u_short);
-u_short aimutil_get16(u_char *);
-int aimutil_put32(u_char *, u_long);
-u_long aimutil_get32(u_char *);
-#endif
-
-int aimutil_putstr(u_char *, const u_char *, int);
-int aimutil_tokslen(char *toSearch, int index, char dl);
-int aimutil_itemcnt(char *toSearch, char dl);
-char *aimutil_itemidx(char *toSearch, int index, char dl);
-
-int aim_snlen(const char *sn);
-int aim_sncmp(const char *sn1, const char *sn2);
-
-#endif /* __AIM_H__ */
-
--- a/libfaim/aim_auth.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_auth.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
 
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */
 int aim_auth_sendcookie(struct aim_session_t *sess, 
--- a/libfaim/aim_buddylist.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_buddylist.c	Wed May 31 03:20:11 2000 +0000
@@ -1,5 +1,5 @@
 
-#include <aim.h>
+#include <faim/aim.h>
 
 /*
  * aim_add_buddy()
--- a/libfaim/aim_cbtypes.h	Wed May 31 00:57:39 2000 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,197 +0,0 @@
-/*
- * AIM Callback Types
- *
- */
-#ifndef __AIM_CBTYPES_H__
-#define __AIM_CBTYPES_H__
-
-/*
- * SNAC Families.
- */
-#define AIM_CB_FAM_ACK 0x0000
-#define AIM_CB_FAM_GEN 0x0001
-#define AIM_CB_FAM_LOC 0x0002
-#define AIM_CB_FAM_BUD 0x0003
-#define AIM_CB_FAM_MSG 0x0004
-#define AIM_CB_FAM_ADS 0x0005
-#define AIM_CB_FAM_INV 0x0006
-#define AIM_CB_FAM_ADM 0x0007
-#define AIM_CB_FAM_POP 0x0008
-#define AIM_CB_FAM_BOS 0x0009
-#define AIM_CB_FAM_LOK 0x000a
-#define AIM_CB_FAM_STS 0x000b
-#define AIM_CB_FAM_TRN 0x000c
-#define AIM_CB_FAM_CTN 0x000d /* ChatNav */
-#define AIM_CB_FAM_CHT 0x000e /* Chat */
-#define AIM_CB_FAM_ATH 0x0017
-#define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */
-
-/*
- * SNAC Family: Ack.
- * 
- * Not really a family, but treating it as one really
- * helps it fit into the libfaim callback structure better.
- *
- */
-#define AIM_CB_ACK_ACK 0x0001
-
-/*
- * SNAC Family: General.
- */ 
-#define AIM_CB_GEN_ERROR 0x0001
-#define AIM_CB_GEN_CLIENTREADY 0x0002
-#define AIM_CB_GEN_SERVERREADY 0x0003
-#define AIM_CB_GEN_SERVICEREQ 0x0004
-#define AIM_CB_GEN_REDIRECT 0x0005
-#define AIM_CB_GEN_RATEINFOREQ 0x0006
-#define AIM_CB_GEN_RATEINFO 0x0007
-#define AIM_CB_GEN_RATEINFOACK 0x0008
-#define AIM_CB_GEN_RATECHANGE 0x000a
-#define AIM_CB_GEN_SERVERPAUSE 0x000b
-#define AIM_CB_GEN_SERVERRESUME 0x000d
-#define AIM_CB_GEN_REQSELFINFO 0x000e
-#define AIM_CB_GEN_SELFINFO 0x000f
-#define AIM_CB_GEN_EVIL 0x0010
-#define AIM_CB_GEN_SETIDLE 0x0011
-#define AIM_CB_GEN_MIGRATIONREQ 0x0012
-#define AIM_CB_GEN_MOTD 0x0013
-#define AIM_CB_GEN_SETPRIVFLAGS 0x0014
-#define AIM_CB_GEN_WELLKNOWNURL 0x0015
-#define AIM_CB_GEN_NOP 0x0016
-#define AIM_CB_GEN_DEFAULT 0xffff
-
-/*
- * SNAC Family: Location Services.
- */ 
-#define AIM_CB_LOC_ERROR 0x0001
-#define AIM_CB_LOC_REQRIGHTS 0x0002
-#define AIM_CB_LOC_RIGHTSINFO 0x0003
-#define AIM_CB_LOC_SETUSERINFO 0x0004
-#define AIM_CB_LOC_REQUSERINFO 0x0005
-#define AIM_CB_LOC_USERINFO 0x0006
-#define AIM_CB_LOC_WATCHERSUBREQ 0x0007
-#define AIM_CB_LOC_WATCHERNOT 0x0008
-#define AIM_CB_LOC_DEFAULT 0xffff
-
-/*
- * SNAC Family: Buddy List Management Services.
- */ 
-#define AIM_CB_BUD_ERROR 0x0001
-#define AIM_CB_BUD_REQRIGHTS 0x0002
-#define AIM_CB_BUD_RIGHTSINFO 0x0003
-#define AIM_CB_BUD_ADDBUDDY 0x0004
-#define AIM_CB_BUD_REMBUDDY 0x0005
-#define AIM_CB_BUD_REJECT 0x000a
-#define AIM_CB_BUD_ONCOMING 0x000b
-#define AIM_CB_BUD_OFFGOING 0x000c
-#define AIM_CB_BUD_DEFAULT 0xffff
-
-/*
- * SNAC Family: Messeging Services.
- */ 
-#define AIM_CB_MSG_ERROR 0x0001
-#define AIM_CB_MSG_PARAMINFO 0x0005
-#define AIM_CB_MSG_INCOMING 0x0007
-#define AIM_CB_MSG_EVIL 0x0009
-#define AIM_CB_MSG_MISSEDCALL 0x000a
-#define AIM_CB_MSG_CLIENTERROR 0x000b
-#define AIM_CB_MSG_ACK 0x000c
-#define AIM_CB_MSG_DEFAULT 0xffff
-
-/*
- * SNAC Family: Advertisement Services
- */ 
-#define AIM_CB_ADS_ERROR 0x0001
-#define AIM_CB_ADS_DEFAULT 0xffff
-
-/*
- * SNAC Family: Invitation Services.
- */ 
-#define AIM_CB_INV_ERROR 0x0001
-#define AIM_CB_INV_DEFAULT 0xffff
-
-/*
- * SNAC Family: Administrative Services.
- */ 
-#define AIM_CB_ADM_ERROR 0x0001
-#define AIM_CB_ADM_INFOCHANGE_REPLY 0x0005
-#define AIM_CB_ADM_DEFAULT 0xffff
-
-/*
- * SNAC Family: Popup Messages
- */ 
-#define AIM_CB_POP_ERROR 0x0001
-#define AIM_CB_POP_DEFAULT 0xffff
-
-/*
- * SNAC Family: Misc BOS Services.
- */ 
-#define AIM_CB_BOS_ERROR 0x0001
-#define AIM_CB_BOS_DEFAULT 0xffff
-
-/*
- * SNAC Family: User Lookup Services
- */ 
-#define AIM_CB_LOK_ERROR 0x0001
-#define AIM_CB_LOK_DEFAULT 0xffff
-
-/*
- * SNAC Family: User Status Services
- */ 
-#define AIM_CB_STS_ERROR 0x0001
-#define AIM_CB_STS_SETREPORTINTERVAL 0x0002
-#define AIM_CB_STS_REPORTACK 0x0004
-#define AIM_CB_STS_DEFAULT 0xffff
-
-/*
- * SNAC Family: Translation Services
- */ 
-#define AIM_CB_TRN_ERROR 0x0001
-#define AIM_CB_TRN_DEFAULT 0xffff
-
-/*
- * SNAC Family: Chat Navigation Services
- */ 
-#define AIM_CB_CTN_ERROR 0x0001
-#define AIM_CB_CTN_CREATE 0x0008
-#define AIM_CB_CTN_INFO 0x0009
-#define AIM_CB_CTN_DEFAULT 0xffff
-
-/*
- * SNAC Family: Chat Services
- */ 
-#define AIM_CB_CHT_ERROR 0x0001
-#define AIM_CB_CHT_ROOMINFOUPDATE 0x0002
-#define AIM_CB_CHT_USERJOIN 0x0003
-#define AIM_CB_CHT_USERLEAVE 0x0004
-#define AIM_CB_CHT_OUTGOINGMSG 0x0005
-#define AIM_CB_CHT_INCOMINGMSG 0x0006
-#define AIM_CB_CHT_DEFAULT 0xffff
-
-/*
- * SNAC Family: Authorizer
- *
- * Used only in protocol versions three and above.
- *
- */
-#define AIM_CB_ATH_ERROR 0x0001
-#define AIM_CB_ATH_LOGINREQEST 0x0002
-#define AIM_CB_ATH_LOGINRESPONSE 0x0003
-#define AIM_CB_ATH_AUTHREQ 0x0006
-#define AIM_CB_ATH_AUTHRESPONSE 0x0007
-
-/*
- * SNAC Family: Internal Messages
- *
- * This isn't truely a SNAC family either, but using
- * these, we can integrated non-SNAC services into
- * the SNAC-centered libfaim callback structure.
- *
- */ 
-#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
-#define AIM_CB_SPECIAL_AUTHOTHER 0x0002
-#define AIM_CB_SPECIAL_UNKNOWN 0xffff
-#define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
-
-
-#endif/*__AIM_CBTYPES_H__ */
--- a/libfaim/aim_chat.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_chat.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
  *
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 char *aim_chat_getname(struct aim_conn_t *conn)
 {
--- a/libfaim/aim_chatnav.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_chatnav.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 
 /*
--- a/libfaim/aim_conn.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_conn.c	Wed May 31 03:20:11 2000 +0000
@@ -6,7 +6,7 @@
  *
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 void aim_connrst(struct aim_session_t *sess)
 {
@@ -34,7 +34,8 @@
   deadconn->seqnum = 0;
   deadconn->lastactivity = 0;
   deadconn->forcedlatency = 0;
-  aim_clearhandlers(deadconn);
+  if (deadconn->handlerlist)
+    aim_clearhandlers(deadconn);
   deadconn->handlerlist = NULL;
   if (deadconn->priv)
     free(deadconn->priv);
@@ -238,6 +239,7 @@
   sess->logininfo.email = NULL;
   sess->logininfo.regstatus = 0x00;
 
+  memset(sess->conns, 0, sizeof(struct aim_conn_t)*AIM_CONN_MAX);
   aim_connrst(sess);
 
   sess->queue_outgoing = NULL;
--- a/libfaim/aim_im.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_im.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 /*
  * Send an ICBM (instant message).  
@@ -25,7 +25,10 @@
   int curbyte,i;
   struct command_tx_struct *newpacket;
   
-  if (!(newpacket = aim_tx_new(0x0002, conn, 1152)))
+  if (strlen(msg) >= MAXMSGLEN)
+    return -1;
+
+  if (!(newpacket = aim_tx_new(0x0002, conn, strlen(msg)+256)))
     return -1;
 
   newpacket->lock = 1; /* lock struct */
--- a/libfaim/aim_info.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_info.c	Wed May 31 03:20:11 2000 +0000
@@ -7,7 +7,7 @@
  */
 
 
-#include <aim.h>
+#include <faim/aim.h>
 
 struct aim_priv_inforeq {
   char sn[MAXSNLEN];
--- a/libfaim/aim_login.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_login.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 
 /*
--- a/libfaim/aim_logoff.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_logoff.c	Wed May 31 03:20:11 2000 +0000
@@ -4,7 +4,7 @@
  *
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 /* 
  * aim_logoff()
--- a/libfaim/aim_meta.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_meta.c	Wed May 31 03:20:11 2000 +0000
@@ -10,12 +10,12 @@
 #include <faim/aim.h>
 /* #include <aim_buildcode.h> /* generated by mkbuildinfo.sh */
 
-long long aim_getbuilddate(void)
+char *aim_getbuilddate(void)
 {
   return AIM_BUILDDATE;
 }
 
-long long aim_getbuildtime(void)
+char *aim_getbuildtime(void)
 {
   return AIM_BUILDTIME;
 }
@@ -24,7 +24,7 @@
 {
   static char string[100];
 
-  snprintf(string, 99, "%d.%d.%d-%Ld%Ld", 
+  snprintf(string, 99, "%d.%d.%d-%s%s", 
 	   FAIM_VERSION_MAJOR,
 	   FAIM_VERSION_MINOR,
 	   FAIM_VERSION_MINORMINOR,
--- a/libfaim/aim_misc.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_misc.c	Wed May 31 03:20:11 2000 +0000
@@ -11,7 +11,7 @@
  *
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 /*
  * aim_bos_setidle()
--- a/libfaim/aim_rxhandlers.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_rxhandlers.c	Wed May 31 03:20:11 2000 +0000
@@ -10,7 +10,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 /*
  * Bleck functions get called when there's no non-bleck functions
--- a/libfaim/aim_rxqueue.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_rxqueue.c	Wed May 31 03:20:11 2000 +0000
@@ -6,7 +6,7 @@
  * aim_rxhandlers.c.
  */
 
-#include <aim.h> 
+#include <faim/aim.h> 
 
 /*
  * Grab a single command sequence off the socket, and enqueue
--- a/libfaim/aim_search.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_search.c	Wed May 31 03:20:11 2000 +0000
@@ -6,7 +6,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 u_long aim_usersearch_address(struct aim_session_t *sess,
 			      struct aim_conn_t *conn, 
--- a/libfaim/aim_snac.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_snac.c	Wed May 31 03:20:11 2000 +0000
@@ -12,7 +12,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 u_long aim_newsnac(struct aim_session_t *sess,
 		   struct aim_snac_t *newsnac) 
--- a/libfaim/aim_tlv.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_tlv.c	Wed May 31 03:20:11 2000 +0000
@@ -1,4 +1,4 @@
-#include <aim.h>
+#include <faim/aim.h>
 
 struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen)
 {
--- a/libfaim/aim_txqueue.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_txqueue.c	Wed May 31 03:20:11 2000 +0000
@@ -5,7 +5,7 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 
 /*
  * Allocate a new tx frame.
--- a/libfaim/aim_util.c	Wed May 31 00:57:39 2000 +0000
+++ b/libfaim/aim_util.c	Wed May 31 03:20:11 2000 +0000
@@ -4,13 +4,13 @@
  *
  */
 
-#include <aim.h>
+#include <faim/aim.h>
 #include <ctype.h>
 
 #define AIMUTIL_USEMACROS
 
 #ifdef AIMUTIL_USEMACROS
-/* macros in aim.h */
+/* macros in faim/aim.h */
 #else
 inline int aimutil_put8(u_char *buf, u_char data)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libfaim/faim/aim.h	Wed May 31 03:20:11 2000 +0000
@@ -0,0 +1,562 @@
+/* 
+ * Main libfaim header.  Must be included in client for prototypes/macros.
+ *
+ */
+
+#ifndef __AIM_H__
+#define __AIM_H__
+
+#define FAIM_VERSION_MAJOR 0
+#define FAIM_VERSION_MINOR 99
+#define FAIM_VERSION_MINORMINOR 0
+
+#include <faimconfig.h>
+#include <aim_cbtypes.h>
+
+#ifndef FAIM_USEPTHREADS
+#error pthreads are currently required.
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+
+#ifdef FAIM_USEPTHREADS
+#include <pthread.h>
+#define faim_mutex_t pthread_mutex_t 
+#define faim_mutex_init pthread_mutex_init
+#define faim_mutex_lock pthread_mutex_lock
+#define faim_mutex_unlock pthread_mutex_unlock
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#include <time.h>
+#include <io.h>
+#else
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+/* Portability stuff (DMP) */
+
+#ifdef _WIN32
+#define sleep Sleep
+#define strlen(x) (int)strlen(x)  /* win32 has a unsigned size_t */
+#endif
+
+#if defined(_WIN32) || (defined(mach) && defined(__APPLE__)) 
+#define gethostbyname2(x,y) gethostbyname(x) /* revert to IPv4 */
+#endif 
+
+/* 
+ * Current Maximum Length for Screen Names (not including NULL) 
+ */
+#define MAXSNLEN 16
+
+/*
+ * Current Maximum Length for Instant Messages
+ *
+ * This was found basically by experiment, but not wholly
+ * accurate experiment.  It should not be regarded
+ * as completely correct.  But its a decent approximation.
+ *
+ * Note that although we can send this much, its impossible
+ * for WinAIM clients (up through the latest (4.0.1957)) to
+ * send any more than 1kb.  Amaze all your windows friends
+ * with uterrly oversized instant messages!
+ * 
+ */
+#define MAXMSGLEN 7988
+
+/*
+ * Current Maximum Length for Chat Room Messages
+ *
+ * This is actually defined by the protocol to be
+ * dynamic, but I have yet to see due cause to 
+ * define it dynamically here.  Maybe later.
+ *
+ */
+#define MAXCHATMSGLEN 512
+
+/*
+ * Standard size of an AIM authorization cookie
+ */
+#define AIM_COOKIELEN            0x100
+
+#if debug > 0
+#define faimdprintf(l, x...) {if (l >= debug) printf(x); }
+#else
+#define faimdprintf(l, x...)
+#endif
+
+/*
+ * Login info.  Passes information from the Authorization
+ * stage of login to the service (BOS, etc) connection
+ * phase.
+ *
+ */
+struct aim_login_struct {
+  char screen_name[MAXSNLEN+1];
+  char *BOSIP;
+  char cookie[AIM_COOKIELEN];
+  char *email;
+  u_short regstatus;
+  char *errorurl;
+  u_short errorcode;
+};
+
+/*
+ * Client info.  Filled in by the client and passed
+ * in to aim_login().  The information ends up
+ * getting passed to OSCAR through the initial
+ * login command.
+ *
+ * XXX: Should this be per-session? -mid
+ *
+ */
+struct client_info_s {
+  char clientstring[100]; /* arbitrary size */
+  int major;
+  int minor;
+  int build;
+  char country[3];
+  char lang[3];
+};
+
+#ifndef TRUE
+#define TRUE 1
+#define FALSE 0
+#endif
+
+/* 
+ * These could be arbitrary, but its easier to use the actual AIM values 
+ */
+#define AIM_CONN_TYPE_AUTH          0x0007
+#define AIM_CONN_TYPE_ADS           0x0005
+#define AIM_CONN_TYPE_BOS           0x0002
+#define AIM_CONN_TYPE_CHAT          0x000e
+#define AIM_CONN_TYPE_CHATNAV       0x000d
+
+/*
+ * Status values returned from aim_conn_new().  ORed together.
+ */
+#define AIM_CONN_STATUS_READY       0x0001
+#define AIM_CONN_STATUS_INTERNALERR 0x0002
+#define AIM_CONN_STATUS_RESOLVERR   0x0080
+#define AIM_CONN_STATUS_CONNERR     0x0040
+
+struct aim_conn_t {
+  int fd;
+  int type;
+  int seqnum;
+  int status;
+  void *priv; /* misc data the client may want to store */
+  time_t lastactivity; /* time of last transmit */
+  int forcedlatency; 
+  struct aim_rxcblist_t *handlerlist;
+  faim_mutex_t active; /* lock around read/writes */
+  faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */
+};
+
+/* struct for incoming commands */
+struct command_rx_struct {
+                            /* byte 1 assumed to always be 0x2a */
+  char type;                /* type code (byte 2) */
+  u_int seqnum;             /* sequence number (bytes 3 and 4) */
+  u_int commandlen;         /* total packet len - 6 (bytes 5 and 6) */
+  u_char *data;             /* packet data (from 7 byte on) */
+  u_int lock;               /* 0 = open, !0 = locked */
+  u_int handled;            /* 0 = new, !0 = been handled */
+  u_int nofree;		    /* 0 = free data on purge, 1 = only unlink */
+  struct aim_conn_t *conn;  /* the connection it came in on... */
+  struct command_rx_struct *next; /* ptr to next struct in list */
+};
+
+/* struct for outgoing commands */
+struct command_tx_struct {
+                            /* byte 1 assumed to be 0x2a */
+  char type;                /* type/family code */
+  u_int seqnum;             /* seqnum dynamically assigned on tx */
+  u_int commandlen;         /* SNAC length */
+  u_char *data;             /* packet data */
+  u_int lock;               /* 0 = open, !0 = locked */
+  u_int sent;               /* 0 = pending, !0 = has been sent */
+  struct aim_conn_t *conn; 
+  struct command_tx_struct *next; /* ptr to next struct in list */
+};
+
+
+/*
+ * AIM Session: The main client-data interface.  
+ *
+ */
+struct aim_session_t {
+
+  /* ---- Client Accessible ------------------------ */
+  /* 
+   * Login information.  See definition above.
+   *
+   */
+  struct aim_login_struct logininfo;
+  
+  /*
+   * Pointer to anything the client wants to 
+   * explicitly associate with this session.
+   */
+  void *aux_data;
+
+
+  /* ---- Internal Use Only ------------------------ */
+  /* 
+   * Connection information
+   */
+  struct aim_conn_t conns[AIM_CONN_MAX];
+  
+  /* 
+   * TX/RX queues 
+   */
+  struct command_tx_struct *queue_outgoing;   
+  struct command_rx_struct *queue_incoming; 
+  
+  /*
+   * Tx Enqueuing function
+   */
+  int (*tx_enqueue)(struct aim_session_t *, struct command_tx_struct *);
+
+  /*
+   * This is a dreadful solution to the what-room-are-we-joining
+   * problem.  (There's no connection between the service
+   * request and the resulting redirect.)
+   */ 
+  char *pendingjoin;
+
+  /*
+   * Outstanding snac handling 
+   *
+   * XXX: Should these be per-connection? -mid
+   **/
+  struct aim_snac_t *outstanding_snacs;
+  u_long snac_nextid;
+};
+
+
+/*
+ * AIM User Info, Standard Form.
+ */
+struct aim_userinfo_s {
+  char sn[MAXSNLEN+1];
+  u_short warnlevel;
+  u_short idletime;
+  u_short class;
+  u_long membersince;
+  u_long onlinesince;
+  u_long sessionlen;  
+  u_short capabilities;
+};
+
+#define AIM_CLASS_TRIAL 	0x0001
+#define AIM_CLASS_UNKNOWN2	0x0002
+#define AIM_CLASS_AOL		0x0004
+#define AIM_CLASS_UNKNOWN4	0x0008
+#define AIM_CLASS_FREE 		0x0010
+#define AIM_CLASS_AWAY		0x0020
+#define AIM_CLASS_UNKNOWN40	0x0040
+#define AIM_CLASS_UNKNOWN80	0x0080
+
+/*
+ * TLV handling
+ */
+
+/* Generic TLV structure. */
+struct aim_tlv_t {
+  u_short type;
+  u_short length;
+  u_char *value;
+};
+
+/* List of above. */
+struct aim_tlvlist_t {
+  struct aim_tlv_t *tlv;
+  struct aim_tlvlist_t *next;
+};
+
+/* TLV-handling functions */
+struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen);
+void aim_freetlvchain(struct aim_tlvlist_t **list);
+struct aim_tlv_t *aim_grabtlv(u_char *src);
+struct aim_tlv_t *aim_grabtlvstr(u_char *src);
+struct aim_tlv_t *aim_gettlv(struct aim_tlvlist_t *, u_short, int);
+char *aim_gettlv_str(struct aim_tlvlist_t *, u_short, int);
+int aim_puttlv (u_char *dest, struct aim_tlv_t *newtlv);
+struct aim_tlv_t *aim_createtlv(void);
+int aim_freetlv(struct aim_tlv_t **oldtlv);
+int aim_puttlv_16(u_char *, u_short, u_short);
+int aim_puttlv_32(u_char *, u_short, u_long);
+int aim_puttlv_str(u_char *buf, u_short t, u_short l, u_char *v);
+int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list);
+int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val);
+int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val);
+int aim_addtlvtochain_str(struct aim_tlvlist_t **list, unsigned short type, char *str, int len);
+int aim_counttlvchain(struct aim_tlvlist_t **list);
+
+/*
+ * Get command from connections / Dispatch commands
+ * already in queue.
+ */
+int aim_get_command(struct aim_session_t *, struct aim_conn_t *);
+int aim_rxdispatch(struct aim_session_t *);
+
+int aim_logoff(struct aim_session_t *);
+
+
+typedef int (*rxcallback_t)(struct aim_session_t *, struct command_rx_struct *, ...);
+int aim_register_callbacks(rxcallback_t *);
+
+u_long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype);
+u_long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *);
+u_long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *);
+
+/* aim_login.c */
+int aim_sendconnack(struct aim_session_t *sess, struct aim_conn_t *conn);
+int aim_request_login (struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
+int aim_send_login (struct aim_session_t *, struct aim_conn_t *, char *, char *, struct client_info_s *);
+int aim_encode_password(const char *, u_char *);
+unsigned long aim_sendauthresp(struct aim_session_t *sess, 
+			       struct aim_conn_t *conn, 
+			       char *sn, char *bosip, 
+			       char *cookie, char *email, 
+			       int regstatus);
+int aim_gencookie(unsigned char *buf);
+int aim_sendserverready(struct aim_session_t *sess, struct aim_conn_t *conn);
+unsigned long aim_sendredirect(struct aim_session_t *sess, 
+			       struct aim_conn_t *conn, 
+			       unsigned short servid, 
+			       char *ip,
+			       char *cookie);
+void aim_purge_rxqueue(struct aim_session_t *);
+
+
+int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *command, ...);
+int aim_parse_missed_im(struct aim_session_t *, struct command_rx_struct *, ...);
+int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
+
+struct command_tx_struct *aim_tx_new(int, struct aim_conn_t *, int);
+int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *);
+int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *);
+#define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y))
+int aim_tx_sendframe(struct command_tx_struct *cur);
+u_int aim_get_next_txseqnum(struct aim_conn_t *);
+int aim_tx_flushqueue(struct aim_session_t *);
+int aim_tx_printqueue(struct aim_session_t *);
+void aim_tx_purgequeue(struct aim_session_t *);
+
+struct aim_rxcblist_t {
+  u_short family;
+  u_short type;
+  rxcallback_t handler;
+  u_short flags;
+  struct aim_rxcblist_t *next;
+};
+
+int aim_conn_setlatency(struct aim_conn_t *conn, int newval);
+
+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);
+rxcallback_t aim_callhandler(struct aim_conn_t *conn, u_short family, u_short type);
+int aim_clearhandlers(struct aim_conn_t *conn);
+
+/*
+ * Generic SNAC structure.  Rarely if ever used.
+ */
+struct aim_snac_t {
+  u_long id;
+  u_short family;
+  u_short type;
+  u_short flags;
+  void *data;
+  time_t issuetime;
+  struct aim_snac_t *next;
+};
+u_long aim_newsnac(struct aim_session_t *, struct aim_snac_t *newsnac);
+struct aim_snac_t *aim_remsnac(struct aim_session_t *, u_long id);
+int aim_cleansnacs(struct aim_session_t *, int maxage);
+int aim_putsnac(u_char *, int, int, int, u_long);
+
+
+void aim_connrst(struct aim_session_t *);
+struct aim_conn_t *aim_conn_getnext(struct aim_session_t *);
+void aim_conn_close(struct aim_conn_t *deadconn);
+struct aim_conn_t *aim_getconn_type(struct aim_session_t *, int type);
+struct aim_conn_t *aim_newconn(struct aim_session_t *, int type, char *dest);
+int aim_conngetmaxfd(struct aim_session_t *);
+struct aim_conn_t *aim_select(struct aim_session_t *, struct timeval *, int *);
+int aim_conn_isready(struct aim_conn_t *);
+int aim_conn_setstatus(struct aim_conn_t *, int);
+void aim_session_init(struct aim_session_t *);
+
+/* aim_misc.c */
+
+#define AIM_VISIBILITYCHANGE_PERMITADD    0x05
+#define AIM_VISIBILITYCHANGE_PERMITREMOVE 0x06
+#define AIM_VISIBILITYCHANGE_DENYADD      0x07
+#define AIM_VISIBILITYCHANGE_DENYREMOVE   0x08
+
+u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long);
+u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *);
+u_long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *);
+u_long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned int);
+u_long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long);
+u_long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long);
+u_long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short);
+u_long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn);
+
+/* aim_rxhandlers.c */
+int aim_rxdispatch(struct aim_session_t *);
+int aim_authparse(struct aim_session_t *, struct command_rx_struct *);
+int aim_handleredirect_middle(struct aim_session_t *, struct command_rx_struct *, ...);
+int aim_parse_unknown(struct aim_session_t *, struct command_rx_struct *, ...);
+int aim_parse_last_bad(struct aim_session_t *, struct command_rx_struct *, ...);
+int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...);
+int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...);
+
+/* aim_im.c */
+#define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */
+#define AIM_IMFLAGS_ACK  0x02 /* request a receipt notice */
+
+u_long aim_send_im(struct aim_session_t *, struct aim_conn_t *, char *, u_int, char *);
+int aim_parse_incoming_im_middle(struct aim_session_t *, struct command_rx_struct *);
+u_long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn);
+int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *);
+
+/* aim_info.c */
+#define AIM_CAPS_BUDDYICON 0x01
+#define AIM_CAPS_VOICE 0x02
+#define AIM_CAPS_IMIMAGE 0x04
+#define AIM_CAPS_CHAT 0x08
+#define AIM_CAPS_GETFILE 0x10
+#define AIM_CAPS_SENDFILE 0x20
+extern u_char aim_caps[6][16];
+
+#define AIM_GETINFO_GENERALINFO 0x00001
+#define AIM_GETINFO_AWAYMESSAGE 0x00003
+
+u_long aim_getinfo(struct aim_session_t *, struct aim_conn_t *, const char *, unsigned short);
+int aim_extractuserinfo(u_char *, struct aim_userinfo_s *);
+int aim_parse_userinfo_middle(struct aim_session_t *, struct command_rx_struct *);
+int aim_parse_oncoming_middle(struct aim_session_t *, struct command_rx_struct *);
+int aim_parse_offgoing_middle(struct aim_session_t *, struct command_rx_struct *);
+int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info);
+int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info);
+int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn);
+
+
+/* aim_auth.c */
+int aim_auth_sendcookie(struct aim_session_t *, struct aim_conn_t *, u_char *);
+u_long aim_auth_clientready(struct aim_session_t *, struct aim_conn_t *);
+u_long aim_auth_changepasswd(struct aim_session_t *, struct aim_conn_t *, char *, char *);
+
+/* aim_buddylist.c */
+u_long aim_add_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
+u_long aim_remove_buddy(struct aim_session_t *, struct aim_conn_t *, char *);
+
+/* aim_search.c */
+u_long aim_usersearch_address(struct aim_session_t *, struct aim_conn_t *, char *);
+/* u_long aim_usersearch_name(struct aim_session_t *, struct aim_conn_t *, char *); */
+
+
+struct aim_chat_roominfo {
+  u_short exchange;
+  char *name;
+  u_short instance;
+};
+int aim_chat_readroominfo(u_char *buf, struct aim_chat_roominfo *outinfo);
+int aim_chat_parse_infoupdate(struct aim_session_t *sess, struct command_rx_struct *command);
+int aim_chat_parse_joined(struct aim_session_t *sess, struct command_rx_struct *command);
+int aim_chat_parse_leave(struct aim_session_t *sess, struct command_rx_struct *command);
+int aim_chat_parse_incoming(struct aim_session_t *sess, struct command_rx_struct *command);
+u_long aim_chat_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, char *msg);
+u_long aim_chat_join(struct aim_session_t *sess, struct aim_conn_t *conn, u_short exchange, const char *roomname);
+u_long aim_chat_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
+int aim_chat_attachname(struct aim_conn_t *conn, char *roomname);
+char *aim_chat_getname(struct aim_conn_t *conn);
+struct aim_conn_t *aim_chat_getconn(struct aim_session_t *, char *name);
+
+u_long aim_chatnav_reqrights(struct aim_session_t *sess, struct aim_conn_t *conn);
+u_long aim_chatnav_clientready(struct aim_session_t *sess, struct aim_conn_t *conn);
+
+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);
+
+struct aim_chat_exchangeinfo {
+  u_short number;
+  char *name;
+  char *charset1;
+  char *lang1;
+  char *charset2;
+  char *lang2;
+};
+int aim_chatnav_parse_info(struct aim_session_t *sess, struct command_rx_struct *command);
+u_long aim_chatnav_createroom(struct aim_session_t *sess, struct aim_conn_t *conn, char *name, u_short exchange);
+int aim_chat_leaveroom(struct aim_session_t *sess, char *name);
+
+/* aim_util.c */
+#ifdef AIMUTIL_USEMACROS
+/*
+ * These are really ugly.  You'd think this was LISP.  I wish it was.
+ */
+#define aimutil_put8(buf, data) ((*(buf) = (u_char)(data)&0xff),1)
+#define aimutil_get8(buf) ((*(buf))&0xff)
+#define aimutil_put16(buf, data) ( \
+                                  (*(buf) = (u_char)((data)>>8)&0xff), \
+				  (*((buf)+1) = (u_char)(data)&0xff),  \
+				  2)
+#define aimutil_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
+#define aimutil_put32(buf, data) ( \
+                                  (*((buf)) = (u_char)((data)>>24)&0xff), \
+				  (*((buf)+1) = (u_char)((data)>>16)&0xff), \
+				  (*((buf)+2) = (u_char)((data)>>8)&0xff), \
+				  (*((buf)+3) = (u_char)(data)&0xff), \
+                                  4)
+#define aimutil_get32(buf) ((((*(buf))<<24)&0xff000000) + \
+                            (((*((buf)+1))<<16)&0x00ff0000) + \
+                            (((*((buf)+2))<< 8)&0x0000ff00) + \
+                            (((*((buf)+3)    )&0x000000ff)))
+#else
+#warning Not using aimutil macros.  May have performance problems.
+int aimutil_put8(u_char *, u_char);
+u_char aimutil_get8(u_char *buf);
+int aimutil_put16(u_char *, u_short);
+u_short aimutil_get16(u_char *);
+int aimutil_put32(u_char *, u_long);
+u_long aimutil_get32(u_char *);
+#endif
+
+int aimutil_putstr(u_char *, const u_char *, int);
+int aimutil_tokslen(char *toSearch, int index, char dl);
+int aimutil_itemcnt(char *toSearch, char dl);
+char *aimutil_itemidx(char *toSearch, int index, char dl);
+
+int aim_snlen(const char *sn);
+int aim_sncmp(const char *sn1, const char *sn2);
+
+/* aim_meta.c */
+char *aim_getbuilddate(void);
+char *aim_getbuildtime(void);
+char *aim_getbuildstring(void);
+
+#endif /* __AIM_H__ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libfaim/faim/aim_cbtypes.h	Wed May 31 03:20:11 2000 +0000
@@ -0,0 +1,197 @@
+/*
+ * AIM Callback Types
+ *
+ */
+#ifndef __AIM_CBTYPES_H__
+#define __AIM_CBTYPES_H__
+
+/*
+ * SNAC Families.
+ */
+#define AIM_CB_FAM_ACK 0x0000
+#define AIM_CB_FAM_GEN 0x0001
+#define AIM_CB_FAM_LOC 0x0002
+#define AIM_CB_FAM_BUD 0x0003
+#define AIM_CB_FAM_MSG 0x0004
+#define AIM_CB_FAM_ADS 0x0005
+#define AIM_CB_FAM_INV 0x0006
+#define AIM_CB_FAM_ADM 0x0007
+#define AIM_CB_FAM_POP 0x0008
+#define AIM_CB_FAM_BOS 0x0009
+#define AIM_CB_FAM_LOK 0x000a
+#define AIM_CB_FAM_STS 0x000b
+#define AIM_CB_FAM_TRN 0x000c
+#define AIM_CB_FAM_CTN 0x000d /* ChatNav */
+#define AIM_CB_FAM_CHT 0x000e /* Chat */
+#define AIM_CB_FAM_ATH 0x0017
+#define AIM_CB_FAM_SPECIAL 0xffff /* Internal libfaim use */
+
+/*
+ * SNAC Family: Ack.
+ * 
+ * Not really a family, but treating it as one really
+ * helps it fit into the libfaim callback structure better.
+ *
+ */
+#define AIM_CB_ACK_ACK 0x0001
+
+/*
+ * SNAC Family: General.
+ */ 
+#define AIM_CB_GEN_ERROR 0x0001
+#define AIM_CB_GEN_CLIENTREADY 0x0002
+#define AIM_CB_GEN_SERVERREADY 0x0003
+#define AIM_CB_GEN_SERVICEREQ 0x0004
+#define AIM_CB_GEN_REDIRECT 0x0005
+#define AIM_CB_GEN_RATEINFOREQ 0x0006
+#define AIM_CB_GEN_RATEINFO 0x0007
+#define AIM_CB_GEN_RATEINFOACK 0x0008
+#define AIM_CB_GEN_RATECHANGE 0x000a
+#define AIM_CB_GEN_SERVERPAUSE 0x000b
+#define AIM_CB_GEN_SERVERRESUME 0x000d
+#define AIM_CB_GEN_REQSELFINFO 0x000e
+#define AIM_CB_GEN_SELFINFO 0x000f
+#define AIM_CB_GEN_EVIL 0x0010
+#define AIM_CB_GEN_SETIDLE 0x0011
+#define AIM_CB_GEN_MIGRATIONREQ 0x0012
+#define AIM_CB_GEN_MOTD 0x0013
+#define AIM_CB_GEN_SETPRIVFLAGS 0x0014
+#define AIM_CB_GEN_WELLKNOWNURL 0x0015
+#define AIM_CB_GEN_NOP 0x0016
+#define AIM_CB_GEN_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Location Services.
+ */ 
+#define AIM_CB_LOC_ERROR 0x0001
+#define AIM_CB_LOC_REQRIGHTS 0x0002
+#define AIM_CB_LOC_RIGHTSINFO 0x0003
+#define AIM_CB_LOC_SETUSERINFO 0x0004
+#define AIM_CB_LOC_REQUSERINFO 0x0005
+#define AIM_CB_LOC_USERINFO 0x0006
+#define AIM_CB_LOC_WATCHERSUBREQ 0x0007
+#define AIM_CB_LOC_WATCHERNOT 0x0008
+#define AIM_CB_LOC_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Buddy List Management Services.
+ */ 
+#define AIM_CB_BUD_ERROR 0x0001
+#define AIM_CB_BUD_REQRIGHTS 0x0002
+#define AIM_CB_BUD_RIGHTSINFO 0x0003
+#define AIM_CB_BUD_ADDBUDDY 0x0004
+#define AIM_CB_BUD_REMBUDDY 0x0005
+#define AIM_CB_BUD_REJECT 0x000a
+#define AIM_CB_BUD_ONCOMING 0x000b
+#define AIM_CB_BUD_OFFGOING 0x000c
+#define AIM_CB_BUD_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Messeging Services.
+ */ 
+#define AIM_CB_MSG_ERROR 0x0001
+#define AIM_CB_MSG_PARAMINFO 0x0005
+#define AIM_CB_MSG_INCOMING 0x0007
+#define AIM_CB_MSG_EVIL 0x0009
+#define AIM_CB_MSG_MISSEDCALL 0x000a
+#define AIM_CB_MSG_CLIENTERROR 0x000b
+#define AIM_CB_MSG_ACK 0x000c
+#define AIM_CB_MSG_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Advertisement Services
+ */ 
+#define AIM_CB_ADS_ERROR 0x0001
+#define AIM_CB_ADS_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Invitation Services.
+ */ 
+#define AIM_CB_INV_ERROR 0x0001
+#define AIM_CB_INV_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Administrative Services.
+ */ 
+#define AIM_CB_ADM_ERROR 0x0001
+#define AIM_CB_ADM_INFOCHANGE_REPLY 0x0005
+#define AIM_CB_ADM_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Popup Messages
+ */ 
+#define AIM_CB_POP_ERROR 0x0001
+#define AIM_CB_POP_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Misc BOS Services.
+ */ 
+#define AIM_CB_BOS_ERROR 0x0001
+#define AIM_CB_BOS_DEFAULT 0xffff
+
+/*
+ * SNAC Family: User Lookup Services
+ */ 
+#define AIM_CB_LOK_ERROR 0x0001
+#define AIM_CB_LOK_DEFAULT 0xffff
+
+/*
+ * SNAC Family: User Status Services
+ */ 
+#define AIM_CB_STS_ERROR 0x0001
+#define AIM_CB_STS_SETREPORTINTERVAL 0x0002
+#define AIM_CB_STS_REPORTACK 0x0004
+#define AIM_CB_STS_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Translation Services
+ */ 
+#define AIM_CB_TRN_ERROR 0x0001
+#define AIM_CB_TRN_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Chat Navigation Services
+ */ 
+#define AIM_CB_CTN_ERROR 0x0001
+#define AIM_CB_CTN_CREATE 0x0008
+#define AIM_CB_CTN_INFO 0x0009
+#define AIM_CB_CTN_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Chat Services
+ */ 
+#define AIM_CB_CHT_ERROR 0x0001
+#define AIM_CB_CHT_ROOMINFOUPDATE 0x0002
+#define AIM_CB_CHT_USERJOIN 0x0003
+#define AIM_CB_CHT_USERLEAVE 0x0004
+#define AIM_CB_CHT_OUTGOINGMSG 0x0005
+#define AIM_CB_CHT_INCOMINGMSG 0x0006
+#define AIM_CB_CHT_DEFAULT 0xffff
+
+/*
+ * SNAC Family: Authorizer
+ *
+ * Used only in protocol versions three and above.
+ *
+ */
+#define AIM_CB_ATH_ERROR 0x0001
+#define AIM_CB_ATH_LOGINREQEST 0x0002
+#define AIM_CB_ATH_LOGINRESPONSE 0x0003
+#define AIM_CB_ATH_AUTHREQ 0x0006
+#define AIM_CB_ATH_AUTHRESPONSE 0x0007
+
+/*
+ * SNAC Family: Internal Messages
+ *
+ * This isn't truely a SNAC family either, but using
+ * these, we can integrated non-SNAC services into
+ * the SNAC-centered libfaim callback structure.
+ *
+ */ 
+#define AIM_CB_SPECIAL_AUTHSUCCESS 0x0001
+#define AIM_CB_SPECIAL_AUTHOTHER 0x0002
+#define AIM_CB_SPECIAL_UNKNOWN 0xffff
+#define AIM_CB_SPECIAL_DEFAULT AIM_CB_SPECIAL_UNKNOWN
+
+
+#endif/*__AIM_CBTYPES_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libfaim/faim/faimconfig.h	Wed May 31 03:20:11 2000 +0000
@@ -0,0 +1,117 @@
+/*
+ *  faimconfig.h
+ *
+ * Contains various compile-time options that apply _only_ to libfaim.
+ * Note that setting any of these options in a frontend header does not imply
+ * that they'll get set here.  Notably, the 'debug' of this file is _not_ 
+ * the same as the frontend 'debug'.  They can be different values.
+ *
+ */
+
+#ifndef __FAIMCONFIG_H__
+#define __FAIMCONFIG_H__
+
+/* 
+ * set debug to be > 0 if you want debugging information spewing
+ * on the attached tty.  set to 0 for daily use.  this value
+ * is _not_ inherited by the frontend, only this backend.
+ *
+ * Default: 0  
+*/
+#define debug 0
+
+/*
+ * Maximum number of connections the library can simultaneously
+ * handle per session structure.  Five is fairly arbitrary.  
+ * 
+ * Normally, only one connection gets used at a time.  However, if
+ * chat is used, its easily possible for several connections to be
+ * open simultaneously.
+ *
+ * Normal connection list looks like this:
+ *   1 -- used for authentication at login (closed after login)
+ *   1 -- used for BOS (general messaging) (stays open for entire session)
+ *   1 -- used for chatnav (room creation, etc) (opened at random)
+ *  1n -- used for n connected chat rooms (AOL limits to three)
+ *
+ * Default: 7
+ *
+ */
+#define AIM_CONN_MAX 7
+
+/*
+ * USE_SNAC_FOR_IMS is an old feature that allowed better
+ * tracking of error messages by caching SNAC IDs of outgoing
+ * ICBMs and comparing them to incoming errors.  However,
+ * its a helluvalot of overhead for something that should
+ * rarely happen.  
+ *
+ * Default: defined.  This is now defined by default
+ * because it should be stable and its not too bad.  
+ * And Josh wanted it.
+ *
+ */
+#define USE_SNAC_FOR_IMS
+
+/*
+ * As of AIM 3.5 or so, AOL as added a better way of
+ * logging in.  Define this to use it instead of the 
+ * old Version 1.0 way.  
+ *
+ * The largest caveat here is that I have no idea
+ * how to encode passwords using the new 3.5 way.
+ * Until someone figures that out the...
+ *
+ * Default: Undefined.
+ *
+ */
+#undef SNACLOGIN
+
+/*
+ * Default Authorizer server name and TCP port for the OSCAR farm.  
+ *
+ * You shouldn't need to change this unless you're writing
+ * your own server. 
+ *
+ * Note that only one server is needed to start the whole
+ * AIM process.  The later server addresses come from
+ * the authorizer service.
+ *
+ * This is only here for convenience.  Its still up to
+ * the client to connect to it.
+ *
+ */
+#define FAIM_LOGIN_SERVER "login.oscar.aol.com"
+#define FAIM_LOGIN_PORT 5190
+
+/*
+ * MAX_READ_ERROR can be decreased if you find dead connections
+ * lingering around, and not getting detected, for too long.
+ *
+ * Default: 100
+ *
+ */
+#define MAX_READ_ERROR 100
+
+/*
+ * The integer extraction/copying functions in aim_util.c have
+ * both a function version and a macro version.  The macro 
+ * version is suggested.  Since the function version is more
+ * readable, I leave both around for reference.
+ *
+ * Default: defined.
+ */
+#define AIMUTIL_USEMACROS
+
+/*
+ * Select whether or not to use POSIX thread functionality.
+ * 
+ * Default: defined on Linux, otherwise undefined
+ */
+#ifdef __linux__
+#define FAIM_USEPTHREADS
+#endif
+
+#endif /* __FAIMCONFIG_H__ */
+
+
--- a/libfaim/faimconfig.h	Wed May 31 00:57:39 2000 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- *  faimconfig.h
- *
- * Contains various compile-time options that apply _only_ to libfaim.
- * Note that setting any of these options in a frontend header does not imply
- * that they'll get set here.  Notably, the 'debug' of this file is _not_ 
- * the same as the frontend 'debug'.  They can be different values.
- *
- */
-
-#ifndef __FAIMCONFIG_H__
-#define __FAIMCONFIG_H__
-
-/* 
- * set debug to be > 0 if you want debugging information spewing
- * on the attached tty.  set to 0 for daily use.  this value
- * is _not_ inherited by the frontend, only this backend.
- *
- * Default: 0  
-*/
-#define debug 0
-
-/*
- * Maximum number of connections the library can simultaneously
- * handle per session structure.  Five is fairly arbitrary.  
- * 
- * Normally, only one connection gets used at a time.  However, if
- * chat is used, its easily possible for several connections to be
- * open simultaneously.
- *
- * Normal connection list looks like this:
- *   1 -- used for authentication at login (closed after login)
- *   1 -- used for BOS (general messaging) (stays open for entire session)
- *   1 -- used for chatnav (room creation, etc) (opened at random)
- *  1n -- used for n connected chat rooms (AOL limits to three)
- *
- * Default: 7
- *
- */
-#define AIM_CONN_MAX 7
-
-/*
- * USE_SNAC_FOR_IMS is an old feature that allowed better
- * tracking of error messages by caching SNAC IDs of outgoing
- * ICBMs and comparing them to incoming errors.  However,
- * its a helluvalot of overhead for something that should
- * rarely happen.  
- *
- * Default: defined.  This is now defined by default
- * because it should be stable and its not too bad.  
- * And Josh wanted it.
- *
- */
-#define USE_SNAC_FOR_IMS
-
-/*
- * As of AIM 3.5 or so, AOL as added a better way of
- * logging in.  Define this to use it instead of the 
- * old Version 1.0 way.  
- *
- * The largest caveat here is that I have no idea
- * how to encode passwords using the new 3.5 way.
- * Until someone figures that out the...
- *
- * Default: Undefined.
- *
- */
-#undef SNACLOGIN
-
-/*
- * Default Authorizer server name and TCP port for the OSCAR farm.  
- *
- * You shouldn't need to change this unless you're writing
- * your own server. 
- *
- * Note that only one server is needed to start the whole
- * AIM process.  The later server addresses come from
- * the authorizer service.
- *
- * This is only here for convenience.  Its still up to
- * the client to connect to it.
- *
- */
-#define FAIM_LOGIN_SERVER "login.oscar.aol.com"
-#define FAIM_LOGIN_PORT 5190
-
-/*
- * MAX_READ_ERROR can be decreased if you find dead connections
- * lingering around, and not getting detected, for too long.
- *
- * Default: 100
- *
- */
-#define MAX_READ_ERROR 100
-
-/*
- * The integer extraction/copying functions in aim_util.c have
- * both a function version and a macro version.  The macro 
- * version is suggested.  Since the function version is more
- * readable, I leave both around for reference.
- *
- * Default: defined.
- */
-#define AIMUTIL_USEMACROS
-
-/*
- * Select whether or not to use POSIX thread functionality.
- * 
- * Default: defined on Linux, otherwise undefined
- */
-#ifdef __linux__
-#define FAIM_USEPTHREADS
-#endif
-
-#endif /* __FAIMCONFIG_H__ */
-
-
--- a/src/conversation.c	Wed May 31 00:57:39 2000 +0000
+++ b/src/conversation.c	Wed May 31 03:20:11 2000 +0000
@@ -411,6 +411,9 @@
 	gchar *buf4;
         int hdrlen;
 
+	/* FIXME : for USE_OSCAR, libfaim can send messages much longer
+	 * than this (I think it's about 7K rather than 4K. So we need
+	 * to do these checks a little bit differently here */
 	buf4 = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1);
 	g_snprintf(buf, BUF_LONG, "%s", buf4);
 	g_free(buf4);
--- a/src/oscar.c	Wed May 31 00:57:39 2000 +0000
+++ b/src/oscar.c	Wed May 31 03:20:11 2000 +0000
@@ -35,7 +35,7 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include "gaim.h"
-#include "aim.h"
+#include <aim.h>
 #include "gnome_applet_mgr.h"
 
 static int inpa = -1;
@@ -486,6 +486,9 @@
 					     msg);
 		} else if (rendtype == 1) {
 			/* FIXME : voice chat */
+		} else {
+			sprintf(debug_buff, "Unknown rendtype %d\n", rendtype);
+			debug_print(debug_buff);
 		}
 		/* libfaim doesn't do file transfer yet, from what i can tell */
 	}
--- a/src/server.c	Wed May 31 00:57:39 2000 +0000
+++ b/src/server.c	Wed May 31 03:20:11 2000 +0000
@@ -28,7 +28,7 @@
 #include <unistd.h>
 #include <gtk/gtk.h>
 #ifdef USE_OSCAR
-#include "../libfaim/aim.h"
+#include <aim.h>
 extern int gaim_caps;
 #endif
 #include "gaim.h"