#include <faimconfig.h>
#include <aim_cbtypes.h>
-#if !defined(FAIM_USEPTHREADS) && !defined(FAIM_USEFAKELOCKS) && !defined(FAIM_USENOPLOCKS)
-#error pthreads, fakelocks, or noplocks are currently required.
-#endif
-
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
typedef fu32_t aim_snacid_t;
typedef fu16_t flap_seqnum_t;
-#ifdef FAIM_USEPTHREADS
-#include <pthread.h>
-#define faim_mutex_t pthread_mutex_t
-#define faim_mutex_init(x) pthread_mutex_init(x, NULL)
-#define faim_mutex_lock(x) pthread_mutex_lock(x)
-#define faim_mutex_unlock(x) pthread_mutex_unlock(x)
-#define faim_mutex_destroy(x) pthread_mutex_destroy(x)
-#elif defined(FAIM_USEFAKELOCKS)
-/*
- * For platforms without pthreads, we also assume
- * we're not linking against a threaded app. Which
- * means we don't have to do real locking. The
- * macros below do nothing really. They're a joke.
- * But they get it to compile.
- *
- * XXX NOTE that locking hasn't really been tested in a long time,
- * and most code written after dec2000 --is not thread safe--. You'll
- * want to audit locking use before you use less-than-library level
- * concurrency.
- *
- */
-#define faim_mutex_t fu8_t
-#define faim_mutex_init(x) *x = 0
-#define faim_mutex_lock(x) while(*x != 0) {/* spin */}; *x = 1;
-#define faim_mutex_unlock(x) while(*x != 0) {/* spin spin spin */}; *x = 0;
-#define faim_mutex_destroy(x) while(*x != 0) {/* spiiiinnn */}; *x = 0;
-#elif defined(FAIM_USENOPLOCKS)
-#define faim_mutex_t fu8_t
-#define faim_mutex_init(x)
-#define faim_mutex_lock(x)
-#define faim_mutex_unlock(x)
-#define faim_mutex_destroy(x)
-#endif
-
/* Portability stuff (DMP) */
#ifdef _WIN32
flap_seqnum_t seqnum;
fu32_t status;
void *priv; /* misc data the client may want to store */
+ void *internal; /* internal conn-specific libfaim data */
time_t lastactivity; /* time of last transmit */
int forcedlatency;
void *handlerlist;
- faim_mutex_t active; /* lock around read/writes */
- faim_mutex_t seqnum_lock; /* lock around ->seqnum changes */
void *sessv; /* pointer to parent session */
+ void *inside; /* only accessible from inside libfaim */
struct aim_conn_s *next;
} aim_conn_t;
/* Connection information */
aim_conn_t *connlist;
- faim_mutex_t connlistlock;
/*
* Transmit/receive queues.
* XXX: Should these be per-connection? -mid
*/
void *snac_hash[FAIM_SNAC_HASH_SIZE];
- faim_mutex_t snac_hash_locks[FAIM_SNAC_HASH_SIZE];
aim_snacid_t snacid_next;
struct {
faim_export int aim_conn_addhandler(aim_session_t *, aim_conn_t *conn, u_short family, u_short type, aim_rxcallback_t newhandler, u_short flags);
faim_export int aim_clearhandlers(aim_conn_t *conn);
+faim_export aim_conn_t *aim_conn_findbygroup(aim_session_t *sess, fu16_t group);
faim_export aim_session_t *aim_conn_getsess(aim_conn_t *conn);
faim_export void aim_conn_close(aim_conn_t *deadconn);
faim_export aim_conn_t *aim_newconn(aim_session_t *, int type, const char *dest);
#define AIM_WARN_ANON 0x01
+faim_export int aim_sendpauseack(aim_session_t *sess, aim_conn_t *conn);
faim_export int aim_send_warning(aim_session_t *sess, aim_conn_t *conn, const char *destsn, fu32_t flags);
faim_export int aim_bos_nop(aim_session_t *, aim_conn_t *);
faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
faim_export int aim_ads_requestads(aim_session_t *sess, aim_conn_t *conn);
/* aim_im.c */
-struct aim_directim_priv {
- fu8_t cookie[8];
- char sn[MAXSNLEN+1];
- fu8_t ip[30];
-};
struct aim_fileheader_t {
#if 0
unsigned short instance;
};
-#define AIM_IMFLAGS_AWAY 0x01 /* mark as an autoreply */
-#define AIM_IMFLAGS_ACK 0x02 /* request a receipt notice */
-#define AIM_IMFLAGS_UNICODE 0x04
-#define AIM_IMFLAGS_ISO_8859_1 0x08
-#define AIM_IMFLAGS_BUDDYREQ 0x10 /* buddy icon requested */
-#define AIM_IMFLAGS_HASICON 0x20 /* already has icon (timestamp included) */
-#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x40 /* damn that Steve Jobs! */
+#define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */
+#define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */
+#define AIM_IMFLAGS_UNICODE 0x0004
+#define AIM_IMFLAGS_ISO_8859_1 0x0008
+#define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */
+#define AIM_IMFLAGS_HASICON 0x0020 /* already has icon */
+#define AIM_IMFLAGS_SUBENC_MACINTOSH 0x0040 /* damn that Steve Jobs! */
+#define AIM_IMFLAGS_CUSTOMFEATURES 0x0080 /* features field present */
+#define AIM_IMFLAGS_EXTDATA 0x0100
struct aim_sendimext_args {
+
+ /* These are _required_ */
const char *destsn;
- unsigned short flags;
+ fu32_t flags;
const char *msg;
int msglen;
- int iconlen;
+
+ /* Only used if AIM_IMFLAGS_HASICON is set */
+ fu32_t iconlen;
time_t iconstamp;
- unsigned short iconsum;
+ fu32_t iconsum;
+
+ /* Only used if AIM_IMFLAGS_CUSTOMFEATURES is set */
+ fu8_t *features;
+ fu8_t featureslen;
};
struct aim_incomingim_ch1_args {
+
+ /* Always provided */
char *msg;
int msglen;
- unsigned long icbmflags;
- unsigned short flag1;
- unsigned short flag2;
- int finlen;
- unsigned char fingerprint[10];
+ fu32_t icbmflags;
+ fu16_t flag1;
+ fu16_t flag2;
+
+ /* Only provided if AIM_IMFLAGS_HASICON is set */
time_t iconstamp;
- unsigned long iconlength;
- unsigned long iconchecksum;
- int extdatalen;
- unsigned char *extdata;
+ fu32_t iconlen;
+ fu32_t iconsum;
+
+ /* Only provided if AIM_IMFLAGS_CUSTOMFEATURES is set */
+ fu8_t *features;
+ fu8_t featureslen;
+
+ /* Only provided if AIM_IMFLAGS_EXTDATA is set */
+ fu8_t extdatalen;
+ fu8_t *extdata;
};
struct aim_incomingim_ch2_args {
- unsigned short reqclass;
- unsigned short status;
+ fu8_t cookie[8];
+ fu16_t reqclass;
+ fu16_t status;
union {
struct {
- unsigned long checksum;
- unsigned int length;
+ fu32_t checksum;
+ fu32_t length;
time_t timestamp;
- unsigned char *icon;
+ fu8_t *icon;
} icon;
struct {
} voice;
- struct aim_directim_priv *directim;
+ struct {
+ fu8_t ip[22]; /* xxx.xxx.xxx.xxx:xxxxx\0 */
+ } imimage;
struct {
char *msg;
char *encoding;
faim_export int aim_send_im_ext(aim_session_t *sess, aim_conn_t *conn, struct aim_sendimext_args *args);
faim_export int aim_send_im(aim_session_t *, aim_conn_t *, const char *destsn, unsigned short flags, const char *msg);
-faim_export int aim_send_icon(aim_session_t *sess, aim_conn_t *conn, const char *sn, const unsigned char *icon, int iconlen, time_t stamp, unsigned short iconsum);
-faim_export unsigned short aim_iconsum(const unsigned char *buf, int buflen);
+faim_export int aim_send_icon(aim_session_t *sess, aim_conn_t *conn, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu32_t iconsum);
+faim_export fu32_t aim_iconsum(const fu8_t *buf, int buflen);
faim_export int aim_send_im_direct(aim_session_t *, aim_conn_t *, const char *msg);
-faim_export aim_conn_t *aim_directim_initiate(aim_session_t *, aim_conn_t *, struct aim_directim_priv *, const char *destsn);
-faim_export aim_conn_t *aim_directim_connect(aim_session_t *, aim_conn_t *, struct aim_directim_priv *);
+faim_export const char *aim_directim_getsn(aim_conn_t *conn);
+faim_export aim_conn_t *aim_directim_initiate(aim_session_t *, aim_conn_t *, const char *destsn);
+faim_export aim_conn_t *aim_directim_connect(aim_session_t *, const char *sn, const char *addr, const fu8_t *cookie);
faim_export aim_conn_t *aim_getfile_initiate(aim_session_t *sess, aim_conn_t *conn, const char *destsn);
faim_export int aim_oft_getfile_request(aim_session_t *sess, aim_conn_t *conn, const char *name, int size);