From 5ac21963e7e99cbffce3b0bb009a1320885776c7 Mon Sep 17 00:00:00 2001 From: mid Date: Tue, 5 Sep 2000 04:12:41 +0000 Subject: [PATCH] - Tue Sep 5 03:47:26 GMT 2000 - More ANSIfication for win32 - Forgot aim_misc last time. --- CHANGES | 4 ++ aim_chat.c | 2 +- aim_conn.c | 2 +- aim_ft.c | 60 ++++++++++++++++++----- aim_im.c | 2 +- aim_info.c | 2 +- aim_login.c | 12 ++--- aim_misc.c | 119 +++++++++++++++++++++++----------------------- aim_rxqueue.c | 4 +- aim_tlv.c | 2 +- aim_txqueue.c | 10 ++-- faim/aim.h | 58 +++++++++++----------- faim/faimconfig.h | 7 +++ md5.c | 1 + 14 files changed, 169 insertions(+), 116 deletions(-) diff --git a/CHANGES b/CHANGES index 07efd4b..7c926c2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ No release numbers ------------------ + - Tue Sep 5 03:47:26 GMT 2000 + - More ANSIfication for win32 + - Forgot aim_misc last time. + - Mon Sep 4 22:08:35 GMT 2000 - Forgot aim_snac and aim_search diff --git a/aim_chat.c b/aim_chat.c index cf7a21b..ee40b0a 100644 --- a/aim_chat.c +++ b/aim_chat.c @@ -68,7 +68,7 @@ faim_export unsigned long aim_chat_send_im(struct aim_session_t *sess, * Generate a random message cookie */ for (i=0;i<8;i++) - curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random()); + curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) rand()); aim_cachecookie(sess, aim_mkcookie(newpacket->data+curbyte-8, AIM_COOKIETYPE_CHAT, NULL)); diff --git a/aim_conn.c b/aim_conn.c index f76eeba..edf6164 100644 --- a/aim_conn.c +++ b/aim_conn.c @@ -202,7 +202,7 @@ faim_export struct aim_conn_t *aim_newconn(struct aim_session_t *sess, * */ - for(i=0;i +#ifndef _WIN32 #include #include #include #include /* for aim_directim_initiate */ #include /* for inet_ntoa */ +#endif /* aim_msgcookies.c is mostly new. just look at the diff and replace yours, easiest. */ @@ -59,8 +61,6 @@ faim_export int aim_handlerendconnect(struct aim_session_t *sess, struct aim_con case AIM_CONN_SUBTYPE_OFT_GETFILE: { struct aim_filetransfer_priv *priv; - priv->state = 0; - priv = (struct aim_filetransfer_priv *)calloc(1, sizeof(struct aim_filetransfer_priv)); snprintf(priv->ip, sizeof(priv->ip), "%s:%u", inet_ntoa(((struct sockaddr_in *)&cliaddr)->sin_addr), ntohs(((struct sockaddr_in *)&cliaddr)->sin_port)); @@ -261,7 +261,7 @@ faim_export struct aim_conn_t *aim_directim_initiate(struct aim_session_t *sess, short port = 4443; struct hostent *hptr; - struct utsname myname; + char localhost[129]; unsigned char cap[16]; char d[4]; /* XXX: IPv6. *cough* */ @@ -277,10 +277,10 @@ faim_export struct aim_conn_t *aim_directim_initiate(struct aim_session_t *sess, * get our local IP */ - if(uname(&myname) < 0) + if(gethostname(localhost, 128) < 0) return NULL; - if( (hptr = gethostbyname(myname.nodename)) == NULL) + if( (hptr = gethostbyname(localhost)) == NULL) return NULL; memcpy(&d, hptr->h_addr_list[0], 4); /* XXX: this probably isn't quite kosher, but it works */ @@ -305,7 +305,7 @@ faim_export struct aim_conn_t *aim_directim_initiate(struct aim_session_t *sess, * This cookie needs to be alphanumeric and NULL-terminated to be TOC-compatible. */ for (i=0;i<7;i++) - curbyte += aimutil_put8(newpacket->data+curbyte, 0x30 + ((u_char) random() % 20)); + curbyte += aimutil_put8(newpacket->data+curbyte, 0x30 + ((u_char) rand() % 20)); curbyte += aimutil_put8(newpacket->data+curbyte, 0x00); /* @@ -406,8 +406,10 @@ faim_export struct aim_conn_t *aim_directim_initiate(struct aim_session_t *sess, * allocate and set up our connection */ +#if 0 i = fcntl(listenfd, F_GETFL, 0); fcntl(listenfd, F_SETFL, i | O_NONBLOCK); +#endif newconn = aim_newconn(sess, AIM_CONN_TYPE_RENDEZVOUS_OUT, NULL); if (!newconn) { @@ -644,6 +646,7 @@ faim_internal struct aim_fileheader_t *aim_getlisting(struct aim_session_t *sess faim_internal int aim_listenestablish(u_short portnum) { +#if defined(__linux__) /* XXX what other OS's support getaddrinfo? */ int listenfd; const int on = 1; struct addrinfo hints, *res, *ressave; @@ -675,6 +678,37 @@ faim_internal int aim_listenestablish(u_short portnum) } freeaddrinfo(ressave); return listenfd; +#else + int listenfd; + const int on = 1; + struct sockaddr_in sockin; + + if ((listenfd = socket(PF_INET, SOCK_STREAM, AF_INET)) < 0) { + perror("socket(listenfd)"); + return -1; + } + if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on) != 0)) { + perror("setsockopt(listenfd)"); + close(listenfd); + return -1; + } + memset(&sockin, 0, sizeof(struct sockaddr_in)); + sockin.sin_family = AF_INET; + sockin.sin_port = htons(portnum); + if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { + perror("bind(listenfd)"); + close(listenfd); + return -1; + } + if (listen(listenfd, 4) != 0) { + perror("listen(listenfd)"); + close(listenfd); + return -1; + } + + return listenfd; +} +#endif } faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *conn) @@ -693,7 +727,7 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct faim_mutex_lock(&conn->active); /* gets locked down for the entirety */ - if ( (hdrlen = read(conn->fd, hdrbuf1, 6)) < 6) { + if ( (hdrlen = aim_recv(conn->fd, hdrbuf1, 6)) < 6) { if(hdrlen < 0) perror("read"); printf("faim: rend: read error (fd: %i) %02x%02x%02x%02x%02x%02x (%i)\n", conn->fd, hdrbuf1[0],hdrbuf1[1],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrbuf1[0],hdrlen); @@ -708,7 +742,7 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct if (!(hdr = malloc(hdrlen))) return -1; - if (read(conn->fd, hdr, hdrlen) < hdrlen) { + if (aim_recv(conn->fd, hdr, hdrlen) < hdrlen) { perror("read"); printf("faim: rend: read2 error\n"); free(hdr); @@ -750,7 +784,7 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct return 0; } - if (recv(conn->fd, msg, payloadlength, MSG_WAITALL) < payloadlength) { + if (aim_recv(conn->fd, msg, payloadlength) < payloadlength) { perror("read"); printf("faim: rend: read3 error\n"); free(msg); @@ -809,7 +843,7 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct data = calloc(1, commandlen); memcpy(data, "01/01/1999 00:00 100 file.txt\r\n", commandlen); - if (write(conn->fd, data, commandlen) != commandlen) { + if (send(conn->fd, data, commandlen, 0) != commandlen) { perror("listing write error"); } faim_mutex_unlock(&conn->active); @@ -905,8 +939,8 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct if(newoft->commandlen > 0) { int i; - bzero(newoft->data, newoft->commandlen); - for(i = 0; i < newoft->commandlen; i++) + memset(newoft->data, 0, newoft->commandlen); + for(i = 0; i < (signed)newoft->commandlen; i++) newoft->data[i] = 0x30 + (i%10); // memcpy(newoft->data, "This has been a Test\r\n-josh\r\n", newoft->commandlen); @@ -988,7 +1022,7 @@ faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct for(i = 0; i < fh->size; i++) c[i] = 0x30 + (i%10); - if ( (i = write(conn->fd, c, fh->size)) != fh->size ) { + if ( (i = send(conn->fd, c, fh->size, 0)) != fh->size ) { printf("whoopsy, didn't write it all...\n"); } diff --git a/aim_im.c b/aim_im.c index ed2e021..82ce16c 100644 --- a/aim_im.c +++ b/aim_im.c @@ -47,7 +47,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess, * */ for (i=0;i<8;i++) - curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) random()); + curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) rand()); /* * Channel ID diff --git a/aim_info.c b/aim_info.c index 06051b8..4f53747 100644 --- a/aim_info.c +++ b/aim_info.c @@ -568,7 +568,7 @@ faim_internal int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); /* XXX: should put caps here */ - aim_addtlvtochain32(&tlvlist, (info->class)&AIM_CLASS_AOL?0x0010:0x000f, info->sessionlen); + aim_addtlvtochain32(&tlvlist, (unsigned short)((info->class)&AIM_CLASS_AOL?0x0010:0x000f), info->sessionlen); i += aim_writetlvchain(buf+i, buflen-i, &tlvlist); aim_freetlvchain(&tlvlist); diff --git a/aim_login.c b/aim_login.c index 30e3e87..4420256 100644 --- a/aim_login.c +++ b/aim_login.c @@ -107,11 +107,11 @@ faim_export int aim_send_login (struct aim_session_t *sess, if (strlen(clientinfo->clientstring)) curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, clientinfo->major2); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, clientinfo->major); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, clientinfo->minor); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, clientinfo->minor2); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, (unsigned short)clientinfo->major2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, (unsigned short)clientinfo->major); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, (unsigned short)clientinfo->minor); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, (unsigned short)clientinfo->minor2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, (unsigned short)clientinfo->build); curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); @@ -352,7 +352,7 @@ faim_export unsigned long aim_sendauthresp(struct aim_session_t *sess, aim_addtlvtochain_str(&tlvlist, 0x0005, bosip, strlen(bosip)); aim_addtlvtochain_str(&tlvlist, 0x0006, cookie, AIM_COOKIELEN); aim_addtlvtochain_str(&tlvlist, 0x0011, email, strlen(email)); - aim_addtlvtochain16(&tlvlist, 0x0013, regstatus); + aim_addtlvtochain16(&tlvlist, 0x0013, (unsigned short)regstatus); } tx->commandlen = aim_writetlvchain(tx->data, tx->commandlen, &tlvlist); diff --git a/aim_misc.c b/aim_misc.c index eddf377..3ba7722 100644 --- a/aim_misc.c +++ b/aim_misc.c @@ -21,9 +21,9 @@ * time. * */ -u_long aim_bos_setidle(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_long idletime) +faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_long idletime) { return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); } @@ -57,9 +57,10 @@ u_long aim_bos_setidle(struct aim_session_t *sess, * * */ -u_long aim_bos_changevisibility(struct aim_session_t *sess, - struct aim_conn_t *conn, - int changetype, char *denylist) +faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *sess, + struct aim_conn_t *conn, + int changetype, + char *denylist) { struct command_tx_struct *newpacket; int packlen = 0; @@ -134,9 +135,9 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess, * XXX: I can't stress the TODO enough. * */ -u_long aim_bos_setbuddylist(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *buddy_list) +faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess, + struct aim_conn_t *conn, + char *buddy_list) { int i, j; @@ -206,11 +207,11 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess, * * */ -u_long aim_bos_setprofile(struct aim_session_t *sess, - struct aim_conn_t *conn, - char *profile, - char *awaymsg, - unsigned int caps) +faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess, + struct aim_conn_t *conn, + char *profile, + char *awaymsg, + unsigned short caps) { struct command_tx_struct *newpacket; int i = 0, tmp, caplen; @@ -253,15 +254,15 @@ u_long aim_bos_setprofile(struct aim_session_t *sess, * a bitwise OR of all the user classes you want to see you. * */ -u_long aim_bos_setgroupperm(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_long mask) +faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_long mask) { return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); } -int aim_parse_bosrights(struct aim_session_t *sess, - struct command_rx_struct *command, ...) +faim_internal int aim_parse_bosrights(struct aim_session_t *sess, + struct command_rx_struct *command, ...) { rxcallback_t userfunc = NULL; int ret=1; @@ -307,8 +308,8 @@ int aim_parse_bosrights(struct aim_session_t *sess, * TODO: Dynamisize. * */ -u_long aim_bos_clientready(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess, + struct aim_conn_t *conn) { u_char command_2[] = { /* placeholders for dynamic data */ @@ -380,8 +381,8 @@ u_long aim_bos_clientready(struct aim_session_t *sess, * Request Rate Information. * */ -u_long aim_bos_reqrate(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0001, 0x0006); } @@ -390,8 +391,8 @@ u_long aim_bos_reqrate(struct aim_session_t *sess, * Rate Information Response Acknowledge. * */ -u_long aim_bos_ackrateresp(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess, + struct aim_conn_t *conn) { struct command_tx_struct *newpacket; int packlen = 20, i=0; @@ -422,9 +423,9 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess, * Bit 2: Allows other AIM users to see how long you've been a member. * */ -u_long aim_bos_setprivacyflags(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_long flags) +faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_long flags) { return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); } @@ -436,14 +437,14 @@ u_long aim_bos_setprivacyflags(struct aim_session_t *sess, * because aparently it uses SNAC flags. * */ -u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0001, 0x000e); } -u_long aim_setversions(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_setversions(struct aim_session_t *sess, + struct aim_conn_t *conn) { struct command_tx_struct *newpacket; int i; @@ -510,7 +511,7 @@ u_long aim_setversions(struct aim_session_t *sess, * Service request. * */ -u_long aim_bos_reqservice(struct aim_session_t *sess, +faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess, struct aim_conn_t *conn, u_short serviceid) { @@ -524,8 +525,8 @@ u_long aim_bos_reqservice(struct aim_session_t *sess, * the connection alive. Its not real necessary. * */ -u_long aim_bos_nop(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_nop(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0001, 0x0016); } @@ -536,8 +537,8 @@ u_long aim_bos_nop(struct aim_session_t *sess, * Request BOS rights. * */ -u_long aim_bos_reqrights(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0009, 0x0002); } @@ -548,8 +549,8 @@ u_long aim_bos_reqrights(struct aim_session_t *sess, * Request Buddy List rights. * */ -u_long aim_bos_reqbuddyrights(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0003, 0x0002); } @@ -564,7 +565,7 @@ u_long aim_bos_reqbuddyrights(struct aim_session_t *sess, * returns -1 on error (couldn't alloc packet), next snacid on success. * */ -int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) +faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) { struct command_tx_struct *newpacket; int curbyte; @@ -592,15 +593,13 @@ int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char * return (sess->snac_nextid++); } - - /* * aim_debugconn_sendconnect() * * For aimdebugd. If you don't know what it is, you don't want to. */ -u_long aim_debugconn_sendconnect(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT); } @@ -617,9 +616,9 @@ u_long aim_debugconn_sendconnect(struct aim_session_t *sess, * back to the single. I don't see any advantage to doing it either way. * */ -u_long aim_genericreq_n(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_short family, u_short subtype) +faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_short family, u_short subtype) { struct command_tx_struct *newpacket; @@ -638,9 +637,10 @@ u_long aim_genericreq_n(struct aim_session_t *sess, * * */ -u_long aim_genericreq_l(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_short family, u_short subtype, u_long *longdata) +faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_short family, u_short subtype, + u_long *longdata) { struct command_tx_struct *newpacket; u_long newlong; @@ -664,9 +664,10 @@ u_long aim_genericreq_l(struct aim_session_t *sess, return (sess->snac_nextid++); } -u_long aim_genericreq_s(struct aim_session_t *sess, - struct aim_conn_t *conn, - u_short family, u_short subtype, u_short *shortdata) +faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess, + struct aim_conn_t *conn, + u_short family, u_short subtype, + u_short *shortdata) { struct command_tx_struct *newpacket; u_short newshort; @@ -696,8 +697,8 @@ u_long aim_genericreq_s(struct aim_session_t *sess, * Request Location services rights. * */ -u_long aim_bos_reqlocaterights(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0002, 0x0002); } @@ -708,8 +709,8 @@ u_long aim_bos_reqlocaterights(struct aim_session_t *sess, * Request ICBM parameter information. * */ -u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, + struct aim_conn_t *conn) { return aim_genericreq_n(sess, conn, 0x0004, 0x0004); } @@ -717,8 +718,8 @@ u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, /* * Add ICBM parameter? Huh? */ -unsigned long aim_addicbmparam(struct aim_session_t *sess, - struct aim_conn_t *conn) +faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess, + struct aim_conn_t *conn) { struct command_tx_struct *newpacket; int packlen = 10+16, i=0; diff --git a/aim_rxqueue.c b/aim_rxqueue.c index 8a1a50d..021fe95 100644 --- a/aim_rxqueue.c +++ b/aim_rxqueue.c @@ -18,7 +18,7 @@ * take more for a badly fragmented packet. * */ -static int aim_recv(int fd, void *buf, size_t count) +faim_internal int aim_recv(int fd, void *buf, size_t count) { #ifdef MSG_WAITALL return recv(fd, buf, count, MSG_WAITALL); @@ -28,7 +28,7 @@ static int aim_recv(int fd, void *buf, size_t count) left = count; while (left) { - ret = read(fd, ((unsigned char *)buf)+cur, left); + ret = recv(fd, ((unsigned char *)buf)+cur, left, 0); if (ret == -1) return -1; if (ret == 0) diff --git a/aim_tlv.c b/aim_tlv.c index 17aebc7..838259d 100644 --- a/aim_tlv.c +++ b/aim_tlv.c @@ -349,7 +349,7 @@ faim_internal int aim_puttlv_32(u_char *buf, u_short t, u_long v) return curbyte; } -faim_internal int aim_puttlv_str(u_char *buf, u_short t, u_short l, char *v) +faim_internal int aim_puttlv_str(u_char *buf, u_short t, int l, char *v) { int curbyte; diff --git a/aim_txqueue.c b/aim_txqueue.c index 3b78f86..11c1660 100644 --- a/aim_txqueue.c +++ b/aim_txqueue.c @@ -7,6 +7,10 @@ #include +#ifndef _WIN32 +#include +#endif + /* * Allocate a new tx frame. * @@ -19,7 +23,7 @@ * chan = channel for OSCAR, hdrtype for OFT * */ -faim_internal struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen) +faim_internal struct command_tx_struct *aim_tx_new(unsigned char framing, int chan, struct aim_conn_t *conn, int datalen) { struct command_tx_struct *new; @@ -286,7 +290,7 @@ faim_internal int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx * since OFT allows us to do the data in a different write (yay!). */ faim_mutex_lock(&cur->conn->active); - if ( (u_int)write(cur->conn->fd, curPacket, buflen) != buflen) { + if (send(cur->conn->fd, curPacket, buflen, 0) != buflen) { faim_mutex_unlock(&cur->conn->active); cur->sent = 1; aim_conn_kill(sess, &cur->conn); @@ -294,7 +298,7 @@ faim_internal int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx } if ((cur->hdrtype == AIM_FRAMETYPE_OFT) && cur->commandlen) { - if (write(cur->conn->fd, cur->data, cur->commandlen) != cur->commandlen) { + if (send(cur->conn->fd, cur->data, cur->commandlen, 0) != (int)cur->commandlen) { /* * Theres nothing we can do about this since we've already sent the * header! The connection is unstable. diff --git a/faim/aim.h b/faim/aim.h index 98bd142..ddeaadd 100644 --- a/faim/aim.h +++ b/faim/aim.h @@ -60,7 +60,8 @@ #ifdef _WIN32 #define sleep Sleep -#define strlen(x) (int)strlen(x) /* win32 has a unsigned size_t */ +#define socklen_t int /* this must be a POSIXy thing */ +#define snprintf _snprintf /* I'm not sure whats wrong with Microsoft here */ #endif #if defined(mach) && defined(__APPLE__) @@ -73,7 +74,7 @@ #define faim_shortfunc inline #endif -#if defined(_WIN32) +#if defined(_WIN32) && !defined(WIN32_STATIC) /* * For a win32 DLL, we define WIN32_INDLL if this file * is included while compiling the DLL. If its not @@ -386,7 +387,7 @@ faim_internal struct aim_tlv_t *aim_createtlv(void); faim_internal int aim_freetlv(struct aim_tlv_t **oldtlv); faim_internal int aim_puttlv_16(u_char *, u_short, u_short); faim_internal int aim_puttlv_32(u_char *, u_short, u_long); -faim_internal int aim_puttlv_str(u_char *buf, u_short t, u_short l, char *v); +faim_internal int aim_puttlv_str(u_char *buf, u_short t, int l, char *v); faim_internal int aim_writetlvchain(u_char *buf, int buflen, struct aim_tlvlist_t **list); faim_internal int aim_addtlvtochain16(struct aim_tlvlist_t **list, unsigned short type, unsigned short val); faim_internal int aim_addtlvtochain32(struct aim_tlvlist_t **list, unsigned short type, unsigned long val); @@ -400,7 +401,7 @@ faim_internal int aim_counttlvchain(struct aim_tlvlist_t **list); faim_export int aim_get_command(struct aim_session_t *, struct aim_conn_t *); int aim_rxdispatch(struct aim_session_t *); -u_long aim_debugconn_sendconnect(struct aim_session_t *sess, struct aim_conn_t *conn); +faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, struct aim_conn_t *conn); int aim_logoff(struct aim_session_t *); @@ -409,9 +410,9 @@ faim_export void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **d 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 *); +faim_internal unsigned long aim_genericreq_n(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype); +faim_internal unsigned long aim_genericreq_l(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_long *); +faim_internal unsigned long aim_genericreq_s(struct aim_session_t *, struct aim_conn_t *conn, u_short family, u_short subtype, u_short *); faim_internal struct aim_fileheader_t *aim_oft_getfh(unsigned char *hdr); @@ -426,13 +427,14 @@ faim_internal int aim_authkeyparse(struct aim_session_t *sess, struct command_rx faim_export unsigned long aim_sendredirect(struct aim_session_t *sess, struct aim_conn_t *conn, unsigned short servid, char *ip, char *cookie); faim_export void aim_purge_rxqueue(struct aim_session_t *); faim_internal void aim_rxqueue_cleanbyconn(struct aim_session_t *sess, struct aim_conn_t *conn); +faim_internal int aim_recv(int fd, void *buf, size_t count); 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 *, ...); faim_internal int aim_get_command_rendezvous(struct aim_session_t *sess, struct aim_conn_t *conn); -faim_internal struct command_tx_struct *aim_tx_new(unsigned short framing, int chan, struct aim_conn_t *conn, int datalen); +faim_internal struct command_tx_struct *aim_tx_new(unsigned char framing, int chan, struct aim_conn_t *conn, int datalen); faim_internal int aim_tx_enqueue__queuebased(struct aim_session_t *, struct command_tx_struct *); faim_internal int aim_tx_enqueue__immediate(struct aim_session_t *, struct command_tx_struct *); #define aim_tx_enqueue(x, y) ((*(x->tx_enqueue))(x, y)) @@ -498,25 +500,25 @@ faim_export void aim_session_init(struct aim_session_t *); #define AIM_WARN_ANON 0x01 -int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon); -u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *); -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); -unsigned 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); -unsigned 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 *); -unsigned long aim_addicbmparam(struct aim_session_t *sess,struct aim_conn_t *conn); -u_long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); +faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon); +faim_export unsigned long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); +faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); +faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *, struct aim_conn_t *, char *); +faim_export unsigned long aim_bos_setprofile(struct aim_session_t *, struct aim_conn_t *, char *, char *, unsigned short); +faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *, struct aim_conn_t *, u_long); +faim_export unsigned long aim_bos_clientready(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_reqrate(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *, struct aim_conn_t *, u_long); +faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_reqservice(struct aim_session_t *, struct aim_conn_t *, u_short); +faim_export unsigned long aim_bos_reqrights(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *, struct aim_conn_t *); +faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess,struct aim_conn_t *conn); +faim_export unsigned long aim_setversions(struct aim_session_t *sess, struct aim_conn_t *conn); faim_internal struct aim_fileheader_t *aim_getlisting(struct aim_session_t*); faim_internal int aim_listenestablish(u_short); @@ -552,7 +554,7 @@ faim_internal int aim_parse_outgoing_im_middle(struct aim_session_t *, struct co faim_export unsigned long aim_seticbmparam(struct aim_session_t *, struct aim_conn_t *conn); faim_internal int aim_parse_msgerror_middle(struct aim_session_t *, struct command_rx_struct *); faim_internal int aim_negchan_middle(struct aim_session_t *sess, struct command_rx_struct *command); -int aim_parse_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...); +faim_internal int aim_parse_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...); faim_internal int aim_parse_missedcall(struct aim_session_t *sess, struct command_rx_struct *command); faim_export struct aim_conn_t * aim_directim_initiate(struct aim_session_t *, struct aim_conn_t *, struct aim_directim_priv *, char *); diff --git a/faim/faimconfig.h b/faim/faimconfig.h index c5d3d6b..5beb92f 100644 --- a/faim/faimconfig.h +++ b/faim/faimconfig.h @@ -103,6 +103,13 @@ */ #define FAIM_SNAC_HASH_SIZE 16 +/* + * If building on Win32,define WIN32_STATIC if you don't want + * to compile libfaim as a DLL (and instead link it right into + * your app). + */ +#define WIN32_STATIC + #endif /* __FAIMCONFIG_H__ */ diff --git a/md5.c b/md5.c index 037612d..9b1ce6f 100644 --- a/md5.c +++ b/md5.c @@ -39,6 +39,7 @@ */ #include "md5.h" +#include #ifdef TEST /* -- 2.45.2