diff libfaim/im.c @ 1746:bacb77b0eb06

[gaim-migrate @ 1756] this won't help. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 25 Apr 2001 01:53:56 +0000
parents 3fe5799b7823
children 109cacf1ff97
line wrap: on
line diff
--- a/libfaim/im.c	Tue Apr 24 23:23:40 2001 +0000
+++ b/libfaim/im.c	Wed Apr 25 01:53:56 2001 +0000
@@ -75,18 +75,18 @@
  *                        when the message is received (of type 0x0004/0x000c)
  *
  */
-faim_export unsigned long aim_send_im(struct aim_session_t *sess,
-				      struct aim_conn_t *conn, 
-				      char *destsn, u_int flags, char *msg)
-{   
-
+faim_export unsigned long aim_send_im(struct aim_session_t *sess, struct aim_conn_t *conn, const char *destsn, unsigned short flags, const char *msg, int msglen)
+{
   int curbyte,i;
   struct command_tx_struct *newpacket;
-  
-  if (strlen(msg) >= MAXMSGLEN)
+
+  if (!msg || (msglen <= 0))
     return -1;
 
-  if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, strlen(msg)+256)))
+  if (msglen >= MAXMSGLEN)
+    return -1;
+
+  if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, msglen+256)))
     return -1;
 
   newpacket->lock = 1; /* lock struct */
@@ -122,7 +122,7 @@
    * metaTLV start.
    */
   curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x10);
+  curbyte += aimutil_put16(newpacket->data+curbyte, msglen + 0x10);
 
   /*
    * Flag data / ICBM Parameters?
@@ -145,7 +145,7 @@
   /* 
    * Message block length.
    */
-  curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04);
+  curbyte += aimutil_put16(newpacket->data+curbyte, msglen + 0x04);
 
   /*
    * Character set data? 
@@ -156,7 +156,7 @@
   /*
    * Message.  Not terminated.
    */
-  curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg));
+  curbyte += aimutil_putstr(newpacket->data+curbyte,msg, msglen);
 
   /*
    * Set the Request Acknowledge flag.