]> andersk Git - libfaim.git/blobdiff - src/im.c
- Mon May 7 15:19:55 PDT 2001
[libfaim.git] / src / im.c
index ed4bbc9b89b3af6b838b3479a593a9b3769959fd..0f2fbe7443887ea7ec06e4ff0410a370042e0ed5 100644 (file)
--- a/src/im.c
+++ b/src/im.c
@@ -75,18 +75,18 @@ faim_export unsigned short aim_fingerprintclient(unsigned char *msghdr, int len)
  *                        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 (msglen >= MAXMSGLEN)
     return -1;
 
-  if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, strlen(msg)+256)))
+  if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, msglen+256)))
     return -1;
 
   newpacket->lock = 1; /* lock struct */
@@ -122,7 +122,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess,
    * 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 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess,
   /* 
    * 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 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess,
   /*
    * 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.  
@@ -188,7 +188,7 @@ faim_export unsigned long aim_send_im(struct aim_session_t *sess,
 static int outgoingim(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
 {
   unsigned int i, ret = 0;
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   unsigned char cookie[8];
   int channel;
   struct aim_tlvlist_t *tlvlist;
@@ -252,7 +252,7 @@ static int outgoingim(struct aim_session_t *sess, aim_module_t *mod, struct comm
 
 static int incomingim_ch1(struct aim_session_t *sess, aim_module_t *mod,  struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned short channel, struct aim_userinfo_s *userinfo, struct aim_tlvlist_t *tlvlist, unsigned char *cookie)
 {
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   int i, j = 0, y = 0, z = 0, ret = 0;
   char *msg = NULL;
   unsigned long icbmflags = 0;
@@ -353,7 +353,7 @@ static int incomingim_ch1(struct aim_session_t *sess, aim_module_t *mod,  struct
 
 static int incomingim_ch2(struct aim_session_t *sess, aim_module_t *mod,  struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned short channel, struct aim_userinfo_s *userinfo, struct aim_tlvlist_t *tlvlist, unsigned char *cookie)
 {
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   struct aim_tlv_t *block1;
   struct aim_tlvlist_t *list2;
   unsigned short reqclass = 0;
@@ -804,7 +804,7 @@ static int paraminfo(struct aim_session_t *sess, aim_module_t *mod, struct comma
 {
   unsigned long defflags, minmsginterval;
   unsigned short maxicbmlen, maxsenderwarn, maxrecverwarn, maxchannel;
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   int i = 0;
 
   maxchannel = aimutil_get16(data+i);
@@ -834,7 +834,7 @@ static int paraminfo(struct aim_session_t *sess, aim_module_t *mod, struct comma
 static int missedcall(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
 {
   int i = 0;
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   unsigned short channel, nummissed, reason;
   struct aim_userinfo_s userinfo;
  
@@ -868,7 +868,7 @@ static int missedcall(struct aim_session_t *sess, aim_module_t *mod, struct comm
 
 static int msgack(struct aim_session_t *sess, aim_module_t *mod, struct command_rx_struct *rx, aim_modsnac_t *snac, unsigned char *data, int datalen)
 {
-  rxcallback_t userfunc;
+  aim_rxcallback_t userfunc;
   char sn[MAXSNLEN];
   unsigned char ck[8];
   unsigned short type;
This page took 0.108683 seconds and 4 git commands to generate.