]> andersk Git - libfaim.git/blobdiff - aim_txqueue.c
- Wed Nov 8 02:23:25 UTC 2000
[libfaim.git] / aim_txqueue.c
index 3b78f86950a878f223b0b174dd1d480e351a3d2a..6f6b3c10d301313f1e354c8d81ffe2e8ff1cf454 100644 (file)
@@ -7,6 +7,10 @@
 
 #include <faim/aim.h>
 
+#ifndef _WIN32
+#include <sys/socket.h>
+#endif
+
 /*
  * Allocate a new tx frame.
  *
  * 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;
+  struct command_tx_struct *newtx;
 
   if (!conn) {
     printf("aim_tx_new: ERROR: no connection specified\n");
     return NULL;
   }
 
-  new = (struct command_tx_struct *)malloc(sizeof(struct command_tx_struct));
-  if (!new)
+  newtx = (struct command_tx_struct *)malloc(sizeof(struct command_tx_struct));
+  if (!newtx)
     return NULL;
-  memset(new, 0, sizeof(struct command_tx_struct));
+  memset(newtx, 0, sizeof(struct command_tx_struct));
 
-  new->conn = conn; 
+  newtx->conn = conn; 
 
   if(datalen) {
-    new->data = (u_char *)malloc(datalen);
-    new->commandlen = datalen;
+    newtx->data = (unsigned char *)malloc(datalen);
+    newtx->commandlen = datalen;
   } else
-    new->data = NULL;
-
-  new->hdrtype = framing;
-  if (new->hdrtype == AIM_FRAMETYPE_OSCAR) {
-    new->hdr.oscar.type = chan;
-  } else if (new->hdrtype == AIM_FRAMETYPE_OFT) {
-    new->hdr.oft.type = chan;
-    new->hdr.oft.hdr2len = 0; /* this will get setup by caller */
+    newtx->data = NULL;
+
+  newtx->hdrtype = framing;
+  if (newtx->hdrtype == AIM_FRAMETYPE_OSCAR) {
+    newtx->hdr.oscar.type = chan;
+  } else if (newtx->hdrtype == AIM_FRAMETYPE_OFT) {
+    newtx->hdr.oft.type = chan;
+    newtx->hdr.oft.hdr2len = 0; /* this will get setup by caller */
   } else { 
     printf("tx_new: unknown framing\n");
   }
 
-  return new;
+  return newtx;
 }
 
 /*
@@ -269,10 +273,10 @@ faim_internal int aim_tx_sendframe(struct aim_session_t *sess, struct command_tx
   } else if (cur->hdrtype == AIM_FRAMETYPE_OFT) {
     int z = 0;
 
-    z += aimutil_put8(curPacket+z, 0x4f);
-    z += aimutil_put8(curPacket+z, 0x44);
-    z += aimutil_put8(curPacket+z, 0x43);
-    z += aimutil_put8(curPacket+z, 0x32);
+    z += aimutil_put8(curPacket+z, cur->hdr.oft.magic[0]);
+    z += aimutil_put8(curPacket+z, cur->hdr.oft.magic[1]);
+    z += aimutil_put8(curPacket+z, cur->hdr.oft.magic[2]);
+    z += aimutil_put8(curPacket+z, cur->hdr.oft.magic[3]);
 
     z += aimutil_put16(curPacket+z, cur->hdr.oft.hdr2len + 8);
     z += aimutil_put16(curPacket+z, cur->hdr.oft.type);
@@ -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.
This page took 0.039954 seconds and 4 git commands to generate.