diff libfaim/aim_auth.c @ 237:6ced2f1c8b24

[gaim-migrate @ 247] How cool is this, libfaim is making a comeback. I completely redid everything, as was necessary because of the updates to libfaim since gaim 0.9.7. You can sign on and send/recv IMs, but there's a bad lag between display updates that I haven't figured out how to fix yet. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 20 May 2000 00:30:53 +0000
parents 68b230f8da5f
children 0f14e6d8a51b
line wrap: on
line diff
--- a/libfaim/aim_auth.c	Thu May 18 18:20:18 2000 +0000
+++ b/libfaim/aim_auth.c	Sat May 20 00:30:53 2000 +0000
@@ -5,145 +5,103 @@
 
  */
 
-#include "aim.h"
+#include <aim.h> 
 
 /* this just pushes the passed cookie onto the passed connection -- NO SNAC! */
-int aim_auth_sendcookie(struct aim_conn_t *conn, char *chipsahoy)
+int aim_auth_sendcookie(struct aim_session_t *sess, 
+			struct aim_conn_t *conn, 
+			u_char *chipsahoy)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int curbyte=0;
   
-  newpacket.lock = 1;
+  if (!(newpacket = aim_tx_new(0x0001, conn, 4+2+2+AIM_COOKIELEN)))
+    return -1;
 
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
+  newpacket->lock = 1;
 
-  newpacket.type = 0x0001;  /* channel 1 (no SNACs, you know) */
-  
-  newpacket.commandlen = 4 + 2 + 2 + 0x100;
-  newpacket.data = (char *) calloc(1, newpacket.commandlen);
-  
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0000);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0006);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0100);
-  memcpy(&(newpacket.data[curbyte]), chipsahoy, 0x100);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0006);
+  curbyte += aimutil_put16(newpacket->data+curbyte, AIM_COOKIELEN);
+  memcpy(newpacket->data+curbyte, chipsahoy, AIM_COOKIELEN);
 
-  aim_tx_enqueue(&newpacket);
-  
-  return 0;
+  return aim_tx_enqueue(sess, newpacket);
 }
 
-u_long aim_auth_clientready(struct aim_conn_t *conn)
+u_long aim_auth_clientready(struct aim_session_t *sess,
+			    struct aim_conn_t *conn)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int curbyte = 0;
 
-  newpacket.lock = 1;
+  if (!(newpacket = aim_tx_new(0x0002, conn, 26)))
+    return -1;
 
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
+  newpacket->lock = 1;
 
-  newpacket.type = 0x0002;
-  
-  newpacket.commandlen = 26;
-  newpacket.data = (char *) malloc(newpacket.commandlen);
-  
-  curbyte += aim_putsnac(newpacket.data+curbyte, 0x0001, 0x0002, 0x0000, aim_snac_nextid);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0002);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0013);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0007);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
-  curbyte += aimutil_put16(newpacket.data+curbyte, 0x0001);
+  curbyte += aim_putsnac(newpacket->data+curbyte, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0013);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0007);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
+  curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001);
 
-  aim_tx_enqueue(&newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
     
-    snac.id = aim_snac_nextid;
+    snac.id = sess->snac_nextid;
     snac.family = 0x0001;
     snac.type = 0x0004;
     snac.flags = 0x0000;
 
     snac.data = NULL;
 
-    aim_newsnac(&snac);
+    aim_newsnac(sess, &snac);
   }
 
-  return (aim_snac_nextid++);
+  return (sess->snac_nextid++);
 }
 
-u_long aim_auth_changepasswd(struct aim_conn_t *conn, char *new, char *current)
+u_long aim_auth_changepasswd(struct aim_session_t *sess,
+			     struct aim_conn_t *conn, 
+			     char *new, char *current)
 {
-  struct command_tx_struct newpacket;
+  struct command_tx_struct *newpacket;
   int i;
 
-  newpacket.lock = 1;
-
-  if (conn==NULL)
-    newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_AUTH);
-  else
-    newpacket.conn = conn;
-
-  newpacket.type = 0x0002;
-  
-  newpacket.commandlen = 10 + 4 + strlen(current) + 4 + strlen(new);
-  newpacket.data = (char *) malloc(newpacket.commandlen);
+  if (!(newpacket = aim_tx_new(0x0002, conn, 10+4+strlen(current)+4+strlen(new))))
+    return -1;
 
-  newpacket.data[0] = 0x00;
-  newpacket.data[1] = 0x07;
-
-  newpacket.data[2] = 0x00;
-  newpacket.data[3] = 0x04;
+  newpacket->lock = 1;
 
-  newpacket.data[4] = 0x00;
-  newpacket.data[5] = 0x00;
-
-  /* SNAC reqid */
-  newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF;
-  newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF;
-  newpacket.data[8] = (aim_snac_nextid >>  8) & 0xFF;
-  newpacket.data[9] = (aim_snac_nextid) & 0xFF;
+  i = aim_putsnac(newpacket->data, 0x0007, 0x0004, 0x0000, sess->snac_nextid);
 
   /* current password TLV t(0002) */
-  i = 10;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x02;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = strlen(current) & 0xff;
-  memcpy(&(newpacket.data[i]), current, strlen(current));
-  i += strlen(current);
+  i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(current), current);
 
   /* new password TLV t(0012) */
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = 0x12;
-  newpacket.data[i++] = 0x00;
-  newpacket.data[i++] = strlen(new) & 0xff;
-  memcpy(&(newpacket.data[i]), new, strlen(new));
-  i+=strlen(new);
+  i += aim_puttlv_str(newpacket->data+i, 0x0012, strlen(new), new);
 
-  aim_tx_enqueue(&newpacket);
+  aim_tx_enqueue(sess, newpacket);
 
   {
     struct aim_snac_t snac;
     
-    snac.id = aim_snac_nextid;
+    snac.id = sess->snac_nextid;
     snac.family = 0x0001;
     snac.type = 0x0004;
     snac.flags = 0x0000;
 
     snac.data = NULL;
 
-    aim_newsnac(&snac);
+    aim_newsnac(sess, &snac);
   }
 
-  return (aim_snac_nextid++);
+  return (sess->snac_nextid++);
 }