]> andersk Git - libfaim.git/blobdiff - aim_misc.c
- Fri Sep 1 23:34:28 UTC 2000
[libfaim.git] / aim_misc.c
index dae9e9e490ceeab525db41eb843d9a2b4ee950f3..4b38852197bb0cbf8ccb00ebaa6c0c331a722439 100644 (file)
@@ -61,7 +61,8 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
                                struct aim_conn_t *conn, 
                                int changetype, char *denylist)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
+  int packlen = 0;
   u_short subtype;
 
   char *localcpy = NULL;
@@ -72,24 +73,16 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
   if (!denylist)
     return 0;
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
-
   localcpy = (char *) malloc(strlen(denylist)+1);
   memcpy(localcpy, denylist, strlen(denylist)+1);
   
   listcount = aimutil_itemcnt(localcpy, '&');
-  newpacket.commandlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
+  packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
 
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
   switch(changetype)
     {
@@ -98,12 +91,13 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
     case AIM_VISIBILITYCHANGE_DENYADD:      subtype = 0x07; break;
     case AIM_VISIBILITYCHANGE_DENYREMOVE:   subtype = 0x08; break;
     default:
-      free(newpacket.data);
+      free(newpacket->data);
+      free(newpacket);
       return 0;
     }
 
   /* We actually DO NOT send a SNAC ID with this one! */
-  aim_putsnac(newpacket.data, 0x0009, subtype, 0x00, 0);
+  aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0);
  
   j = 10;  /* the next byte */
   
@@ -111,16 +105,16 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
     {
       tmpptr = aimutil_itemidx(localcpy, i, '&');
 
-      newpacket.data[j] = strlen(tmpptr);
-      memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr));
+      newpacket->data[j] = strlen(tmpptr);
+      memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
       j += strlen(tmpptr)+1;
       free(tmpptr);
     }
   free(localcpy);
 
-  newpacket.lock = 0;
+  newpacket->lock = 0;
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid); /* dont increment */
 
@@ -135,7 +129,9 @@ u_long aim_bos_changevisibility(struct aim_session_t *sess,
  *
  * buddy_list = "Screen Name One&ScreenNameTwo&";
  *
- * TODO: Clean this up.
+ * TODO: Clean this up.  
+ *
+ * XXX: I can't stress the TODO enough.
  *
  */
 u_long aim_bos_setbuddylist(struct aim_session_t *sess,
@@ -144,78 +140,63 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
 {
   int i, j;
 
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
 
-  int packet_login_phase3c_hi_b_len = 0;
+  int len = 0;
 
   char *localcpy = NULL;
   char *tmpptr = NULL;
 
-  packet_login_phase3c_hi_b_len = 16; /* 16b for FLAP and SNAC headers */
+  len = 10; /* 10B SNAC headers */
 
-  /* bail out if we can't make the packet */
-  if (buddy_list == NULL)
-    {
-      printf("\nNO BUDDIES!  ARE YOU THAT LONELY???\n");
-      return 0;
-    }
-#if debug > 0
-  printf("****buddy list: %s\n", buddy_list);
-  printf("****buddy list len: %d (%x)\n", strlen(buddy_list), strlen(buddy_list));
-#endif
-
-  localcpy = (char *) malloc(strlen(buddy_list)+1);
-  memcpy(localcpy, buddy_list, strlen(buddy_list)+1);
+  if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) 
+    return -1;
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
 
   i = 0;
   tmpptr = strtok(localcpy, "&");
-  while ((tmpptr != NULL) && (i < 100))
-    {
+  while ((tmpptr != NULL) && (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      packet_login_phase3c_hi_b_len += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    len += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 #if debug > 0
-  printf("*** send buddy list len: %d (%x)\n", packet_login_phase3c_hi_b_len, packet_login_phase3c_hi_b_len);
+  printf("*** send buddy list len: %d (%x)\n", len, len);
 #endif
-  free(localcpy);
 
-  newpacket.type = 0x02;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.commandlen = packet_login_phase3c_hi_b_len - 6;
-  newpacket.lock = 1;
-  
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, len)))
+    return -1;
 
-  aim_putsnac(newpacket.data, 0x0003, 0x0004, 0x0000, sess->snac_nextid);
+  newpacket->lock = 1;
+  
+  aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0);
 
   j = 10;  /* the next byte */
 
+  strncpy(localcpy, buddy_list, strlen(buddy_list)+1);
   i = 0;
-  tmpptr = strtok(buddy_list, "&");
-  while ((tmpptr != NULL) & (i < 100))
-    {
+  tmpptr = strtok(localcpy, "&");
+  while ((tmpptr != NULL) & (i < 150)) {
 #if debug > 0
-      printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr));
+    printf("---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr));
 #endif
-      newpacket.data[j] = strlen(tmpptr);
-      memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr));
-      j += strlen(tmpptr)+1;
-      i++;
-      tmpptr = strtok(NULL, "&");
-    }
+    newpacket->data[j] = strlen(tmpptr);
+    memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr));
+    j += 1+strlen(tmpptr);
+    i++;
+    tmpptr = strtok(NULL, "&");
+  }
 
-  newpacket.lock = 0;
+  newpacket->lock = 0;
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  free(localcpy);
+
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -223,59 +204,41 @@ u_long aim_bos_setbuddylist(struct aim_session_t *sess,
  *
  * Gives BOS your profile.
  *
+ * 
  */
 u_long aim_bos_setprofile(struct aim_session_t *sess,
                          struct aim_conn_t *conn, 
-                         char *profile)
+                         char *profile,
+                         char *awaymsg,
+                         unsigned int caps)
 {
-  int packet_profile_len = 0;
-  struct command_tx_struct newpacket;
-  int i = 0;
-
-  /* len: SNAC */
-  packet_profile_len = 10;
-  /* len: T+L (where t(0001)) */
-  packet_profile_len += 2 + 2;
-  /* len: V (where t(0001)) */
-  packet_profile_len += strlen("text/x-aolrtf");
-  /* len: T+L (where t(0002)) */
-  packet_profile_len += 2 + 2;
-  /* len: V (where t(0002)) */
-  packet_profile_len += strlen(profile);
-
-  newpacket.type = 0x02;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.commandlen = packet_profile_len;
-  newpacket.data = (char *) malloc(packet_profile_len);
+  struct command_tx_struct *newpacket;
+  int i = 0, tmp, caplen;
 
-  i = 0;
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0))))
+    return -1;
 
-  i += aim_putsnac(newpacket.data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
-
-  /* TLV t(0001) */
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x01;
-  /* TLV l(000d) */
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x0d;
-  /* TLV v(text/x-aolrtf) */
-  memcpy(&(newpacket.data[i]), "text/x-aolrtf", 0x000d);
-  i += 0x000d;
+  i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid);
+  i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
+  i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile);
+  /* why do we send this twice?  */
+  i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\"");
   
-  /* TLV t(0002) */
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x02;
-  /* TLV l() */
-  newpacket.data[i++] = (strlen(profile) >> 8) & 0xFF;
-  newpacket.data[i++] = (strlen(profile) & 0xFF);
-  /* TLV v(profile) */
-  memcpy(&(newpacket.data[i]), profile, strlen(profile));
-
-  aim_tx_enqueue(sess, &newpacket);
+  /* Away message -- we send this no matter what, even if its blank */
+  if (awaymsg)
+    i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg);
+  else
+    i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL);
+
+  /* Capability information. */
+  tmp = (i += aimutil_put16(newpacket->data+i, 0x0005));
+  i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */
+  i += (caplen = aim_putcap(newpacket->data+i, 512, caps));
+  aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */
+
+  newpacket->commandlen = i;
+  aim_tx_enqueue(sess, newpacket);
   
   return (sess->snac_nextid++);
 }
@@ -283,7 +246,11 @@ u_long aim_bos_setprofile(struct aim_session_t *sess,
 /* 
  * aim_bos_setgroupperm(mask)
  * 
- * Set group permisson mask.  Normally 0x1f.
+ * Set group permisson mask.  Normally 0x1f (all classes).
+ *
+ * The group permission mask allows you to keep users of a certain
+ * class or classes from talking to you.  The mask should be
+ * a bitwise OR of all the user classes you want to see you.
  *
  */
 u_long aim_bos_setgroupperm(struct aim_session_t *sess,
@@ -312,7 +279,8 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x01,   
      0x00, 0x03, 
      0x00, 0x04, 
-     0x06, 0x86,  
+     0x07, 0xda,  
+
      0x00, 0x02, 
      0x00, 0x01,  
      0x00, 0x04, 
@@ -321,7 +289,8 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x03, 
      0x00, 0x01,  
      0x00, 0x04, 
-     0x00, 0x01, 
+     0x00, 0x01,
      0x00, 0x04, 
      0x00, 0x01, 
      0x00, 0x04,
@@ -351,33 +320,26 @@ u_long aim_bos_clientready(struct aim_session_t *sess,
      0x00, 0x01
   };
   int command_2_len = 0x52;
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = command_2_len;
-  newpacket.data = (char *) malloc (newpacket.commandlen);
-  memcpy(newpacket.data, command_2, newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, command_2_len)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  memcpy(newpacket->data, command_2, command_2_len);
   
   /* This write over the dynamic parts of the byte block */
-  aim_putsnac(newpacket.data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
 
 /* 
- *  send_login_phase3(int socket)   
- *
  *  Request Rate Information.
  * 
- *  TODO: Move to aim_conn.
- *  TODO: Move to SNAC interface.
  */
 u_long aim_bos_reqrate(struct aim_session_t *sess,
                       struct aim_conn_t *conn)
@@ -386,39 +348,30 @@ u_long aim_bos_reqrate(struct aim_session_t *sess,
 }
 
 /* 
- *  send_login_phase3b(int socket)   
- *
  *  Rate Information Response Acknowledge.
  *
  */
 u_long aim_bos_ackrateresp(struct aim_session_t *sess,
                           struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
-
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 18;
-
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  aim_putsnac(newpacket.data, 0x0001, 0x0008, 0x0000, sess->snac_nextid);
+  struct command_tx_struct *newpacket;
+  int packlen = 20, i=0;
 
-  newpacket.data[10] = 0x00;
-  newpacket.data[11] = 0x01;
-  newpacket.data[12] = 0x00;
-  newpacket.data[13] = 0x02;
-  newpacket.data[14] = 0x00;
-  newpacket.data[15] = 0x03;
-  newpacket.data[16] = 0x00;
-  newpacket.data[17] = 0x04;
-
-  aim_tx_enqueue(sess, &newpacket);
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
+  
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0);
+  i += aimutil_put16(newpacket->data+i, 0x0001); 
+  i += aimutil_put16(newpacket->data+i, 0x0002);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x0004);
+  i += aimutil_put16(newpacket->data+i, 0x0005);
+  
+  aim_tx_enqueue(sess, newpacket);
 
-  return (sess->snac_nextid++);
+  return (sess->snac_nextid);
 }
 
 /* 
@@ -427,7 +380,7 @@ u_long aim_bos_ackrateresp(struct aim_session_t *sess,
  * Sets privacy flags. Normally 0x03.
  *
  *  Bit 1:  Allows other AIM users to see how long you've been idle.
- *
+ *  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,
@@ -447,82 +400,66 @@ u_long aim_bos_setprivacyflags(struct aim_session_t *sess,
 u_long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
                               struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
-  
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 12;
-
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  aim_putsnac(newpacket.data, 0x000a, 0x0001, 0x000e /* huh? */, sess->snac_nextid);
-  
-  newpacket.data[10] = 0x0d;
-  newpacket.data[11] = 0xda;
-
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
-
-  return (sess->snac_nextid++);
+  return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
 }
 
 u_long aim_setversions(struct aim_session_t *sess,
                                struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
-  int i,j;
+  struct command_tx_struct *newpacket;
+  int i;
 
-  newpacket.lock = 1;
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
-  newpacket.commandlen = 10 + (4*13);
-
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  i = aim_putsnac(newpacket.data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
-
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0003);
-  i += aimutil_put16(newpacket.data+i, 0x0002);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0003);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0004);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0006);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0008);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0009);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x000a);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x000b);
-  i += aimutil_put16(newpacket.data+i, 0x0002);
-  i += aimutil_put16(newpacket.data+i, 0x000c);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0015);
-  i += aimutil_put16(newpacket.data+i, 0x0003);
-  i += aimutil_put16(newpacket.data+i, 0x000f);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
-  i += aimutil_put16(newpacket.data+i, 0x0005);
-  i += aimutil_put16(newpacket.data+i, 0x0001);
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12))))
+    return -1;
+
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
+
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+
+  i += aimutil_put16(newpacket->data+i, 0x0002);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0004);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0006);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0008);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0009);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x000a);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x000b);
+  i += aimutil_put16(newpacket->data+i, 0x0002);
+
+  i += aimutil_put16(newpacket->data+i, 0x000c);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0013);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
+
+  i += aimutil_put16(newpacket->data+i, 0x0015);
+  i += aimutil_put16(newpacket->data+i, 0x0001);
 
 #if 0
-  for (j = 0; j < 0x10; j++)
-A
-    {
-      i += aimutil_put16(newpacket.data+i, j); /* family */
-      i += aimutil_put16(newpacket.data+i, 0x0003); /* version */
-    }
+  for (j = 0; j < 0x10; j++) {
+    i += aimutil_put16(newpacket->data+i, j); /* family */
+    i += aimutil_put16(newpacket->data+i, 0x0003); /* version */
+  }
 #endif
-  newpacket.lock = 0;
-  aim_tx_enqueue(sess, &newpacket);
+  newpacket->lock = 0;
+  aim_tx_enqueue(sess, newpacket);
 
   return (sess->snac_nextid++);
 }
@@ -541,6 +478,19 @@ u_long aim_bos_reqservice(struct aim_session_t *sess,
   return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid);
 }
 
+/*
+ * aim_bos_nop()
+ *
+ * No-op.  WinAIM sends these every 4min or so to keep
+ * the connection alive.  Its not real necessary.
+ *
+ */
+u_long aim_bos_nop(struct aim_session_t *sess,
+                  struct aim_conn_t *conn)
+{
+  return aim_genericreq_n(sess, conn, 0x0001, 0x0016);
+}
+
 /*
  * aim_bos_reqrights()
  *
@@ -565,6 +515,57 @@ u_long aim_bos_reqbuddyrights(struct aim_session_t *sess,
   return aim_genericreq_n(sess, conn, 0x0003, 0x0002);
 }
 
+/*
+ * aim_send_warning(struct aim_session_t *sess, 
+ *                  struct aim_conn_t *conn, char *destsn, int anon)
+ * send a warning to destsn.
+ * anon is anonymous or not;
+ *  AIM_WARN_ANON anonymous
+ *
+ * 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)
+{
+  struct command_tx_struct *newpacket;
+  int curbyte;
+
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(destsn)+13)))
+    return -1;
+
+  newpacket->lock = 1;
+
+  curbyte  = 0;
+  curbyte += aim_putsnac(newpacket->data+curbyte,
+                        0x0004, 0x0008, 0x0000, sess->snac_nextid);
+
+  curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0);
+
+  curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn));
+
+  curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn));
+
+  newpacket->commandlen = curbyte;
+  newpacket->lock = 0;
+
+  aim_tx_enqueue(sess, newpacket);
+
+  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)
+{
+  return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT);
+}
+
 /*
  * Generic routine for sending commands.
  *
@@ -581,24 +582,16 @@ u_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;
-
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-  newpacket.type = 0x02;
+  struct command_tx_struct *newpacket;
 
-  newpacket.commandlen = 10;
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10)))
+    return 0;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
  
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
@@ -610,34 +603,25 @@ u_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;
+  struct command_tx_struct *newpacket;
   u_long newlong;
 
   /* If we don't have data, there's no reason to use this function */
   if (!longdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
-
-  newpacket.commandlen = 10+sizeof(u_long);
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_long))))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
 
   /* copy in data */
   newlong = htonl(*longdata);
-  memcpy(&(newpacket.data[10]), &newlong, sizeof(u_long));
+  memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long));
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
@@ -645,34 +629,25 @@ u_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;
+  struct command_tx_struct *newpacket;
   u_short newshort;
 
   /* If we don't have data, there's no reason to use this function */
   if (!shortdata)
     return aim_genericreq_n(sess, conn, family, subtype);
 
-  newpacket.lock = 1;
-
-  if (conn)
-    newpacket.conn = conn;
-  else
-    newpacket.conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS);
-
-  newpacket.type = 0x02;
-
-  newpacket.commandlen = 10+sizeof(u_short);
+  if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_short))))
+    return -1;
 
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  memset(newpacket.data, 0x00, newpacket.commandlen);
+  newpacket->lock = 1;
 
-  aim_putsnac(newpacket.data, family, subtype, 0x0000, sess->snac_nextid);
+  aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
 
   /* copy in data */
   newshort = htons(*shortdata);
-  memcpy(&(newpacket.data[10]), &newshort, sizeof(u_short));
+  memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short));
 
-  aim_tx_enqueue(sess, &newpacket);
+  aim_tx_enqueue(sess, newpacket);
   return (sess->snac_nextid++);
 }
 
@@ -689,7 +664,7 @@ u_long aim_bos_reqlocaterights(struct aim_session_t *sess,
 }
 
 /*
- * aim_bos_reqicbmparaminfo()
+* aim_bos_reqicbmparaminfo()
  *
  * Request ICBM parameter information.
  *
@@ -699,3 +674,32 @@ u_long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
 {
   return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
 }
+
+/*
+ * Add ICBM parameter? Huh?
+ */
+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;
+
+  if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
+    return (sess->snac_nextid);
+  
+  newpacket->lock = 1;
+
+  i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000);
+  i += aimutil_put16(newpacket->data+i, 0x0003);
+  i += aimutil_put16(newpacket->data+i, 0x1f40);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x03e7);
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  i += aimutil_put16(newpacket->data+i, 0x0000); 
+  
+  aim_tx_enqueue(sess, newpacket);
+
+  return (sess->snac_nextid);
+}
This page took 0.061842 seconds and 4 git commands to generate.