]> andersk Git - libfaim.git/blobdiff - aim_search.c
- Thu Feb 8 02:31:25 UTC 2001
[libfaim.git] / aim_search.c
index a8c4e1cfd75143485428988fbad2920acef9e5a3..d1cba01b05ede42d0ea4ac20904873e3517e4cf7 100644 (file)
@@ -6,6 +6,7 @@
  *
  */
 
+#define FAIM_INTERNAL
 #include <faim/aim.h>
 
 faim_export unsigned long aim_usersearch_address(struct aim_session_t *sess,
@@ -33,3 +34,89 @@ faim_export unsigned long aim_usersearch_address(struct aim_session_t *sess,
   return sess->snac_nextid;
 }
 
+
+faim_internal unsigned long aim_parse_searcherror(struct aim_session_t *sess, struct command_rx_struct *command) 
+{
+  u_int i, ret;
+  int snacid;
+  rxcallback_t userfunc;
+  struct aim_snac_t *snac;
+
+  i = 6;
+
+  snacid = aimutil_get32(command->data+i);
+  i += 4;
+  
+  if(!(snac = aim_remsnac(sess, snacid))) {
+    faimdprintf(2, "faim: couldn't get a snac for %d, probably should crash.\n", snacid);
+    return 0;
+  }
+
+  if((userfunc = aim_callhandler(command->conn, 0x000a, 0x0001)))
+    ret = userfunc(sess, command, snac->data /* address */);
+  else
+    ret = 0;
+
+  if(snac) {
+    if(snac->data)
+      free(snac->data);
+    free(snac);
+  }
+
+  return ret;
+}
+       
+  
+faim_internal unsigned long aim_parse_searchreply(struct aim_session_t *sess, struct command_rx_struct *command)
+{
+  u_int i, j, m, ret;
+  int snacid;
+  struct aim_tlvlist_t *tlvlist;
+  char *cur = NULL, *buf = NULL;
+  rxcallback_t userfunc;
+  struct aim_snac_t *snac;
+
+  i = 6;
+
+  snacid = aimutil_get32(command->data+i);
+  i += 4;
+
+  if(!(snac = aim_remsnac(sess, snacid))) {
+    faimdprintf(2, "faim: couldn't get a snac for %d, probably should crash.\n", snacid);
+    return 0;
+  }
+
+  tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i);
+
+  j = 0;
+
+  m = aim_counttlvchain(&tlvlist);
+
+  while((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) {
+    if(!(buf = realloc(buf, (j+1) * (MAXSNLEN+1))))
+      faimdprintf(2, "faim: couldn't realloc buf. oh well.\n");
+
+    strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN);
+    free(cur);
+
+    j++; 
+  }
+
+  aim_freetlvchain(&tlvlist);
+
+  if((userfunc = aim_callhandler(command->conn, 0x000a, 0x0003)))
+    ret = userfunc(sess, command, snac->data /* address */, j, buf);
+  else
+    ret = 0;
+
+  if(snac) {
+    if(snac->data)
+      free(snac->data);
+    free(snac);
+  }
+
+  if(buf)
+    free(buf);
+
+  return ret;
+}
This page took 0.177854 seconds and 4 git commands to generate.