]> andersk Git - libfaim.git/blobdiff - aim_rxhandlers.c
- Wed Nov 8 13:11:18 UTC 2000
[libfaim.git] / aim_rxhandlers.c
index 91db4a0057f6afb8a9df87f43924c61a00bec11c..220394f2abf907ce6a8aa264b42caf83449a0555 100644 (file)
@@ -188,49 +188,55 @@ faim_export int aim_conn_addhandler(struct aim_session_t *sess,
                        rxcallback_t newhandler,
                        u_short flags)
 {
-  struct aim_rxcblist_t *new,*cur;
+  struct aim_rxcblist_t *newcb;
 
   if (!conn)
     return -1;
 
   faimdprintf(1, "aim_conn_addhandler: adding for %04x/%04x\n", family, type);
 
-  new = (struct aim_rxcblist_t *)calloc(1, sizeof(struct aim_rxcblist_t));
-  new->family = family;
-  new->type = type;
-  new->flags = flags;
+  if (!(newcb = (struct aim_rxcblist_t *)calloc(1, sizeof(struct aim_rxcblist_t))))
+    return -1;
+  newcb->family = family;
+  newcb->type = type;
+  newcb->flags = flags;
   if (!newhandler)
-    new->handler = &bleck;
+    newcb->handler = &bleck;
   else
-    new->handler = newhandler;
-  new->next = NULL;
+    newcb->handler = newhandler;
+  newcb->next = NULL;
   
-  cur = conn->handlerlist;
-  if (!cur)
-    conn->handlerlist = new;
-  else 
-    {
-      while (cur->next)
-       cur = cur->next;
-      cur->next = new;
-    }
+  if (!conn->handlerlist)
+    conn->handlerlist = newcb;
+  else {
+    struct aim_rxcblist_t *cur;
+
+    cur = conn->handlerlist;
+
+    while (cur->next)
+      cur = cur->next;
+    cur->next = newcb;
+  }
 
   return 0;
 }
 
 faim_export int aim_clearhandlers(struct aim_conn_t *conn)
 {
- struct aim_rxcblist_t *cur,*tmp;
+ struct aim_rxcblist_t *cur;
+
  if (!conn)
    return -1;
 
  cur = conn->handlerlist;
- while(cur)
-   {
-     tmp = cur->next;
-     free(cur);
-     cur = tmp;
-   }
+ while(cur) {
+   struct aim_rxcblist_t *tmp;
+
+   tmp = cur->next;
+   free(cur);
+   cur = tmp;
+ }
+
  return 0;
 }
 
@@ -255,6 +261,7 @@ faim_internal rxcallback_t aim_callhandler(struct aim_conn_t *conn,
 
   if (type==0xffff)
     return NULL;
+
   return aim_callhandler(conn, family, 0xffff);
 }
 
@@ -336,16 +343,17 @@ faim_export int aim_rxdispatch(struct aim_session_t *sess)
        workingPtr->handled = 1;
        break;
       case AIM_CONN_TYPE_AUTH: {
-       u_long head;
+       unsigned long head;
        
        head = aimutil_get32(workingPtr->data);
-       if (head == 0x00000001) {
+       if ((head == 0x00000001) && (workingPtr->commandlen == 4)) {
          faimdprintf(1, "got connection ack on auth line\n");
          workingPtr->handled = 1;
-       } else if (workingPtr->hdr.oscar.type == 0x0004) {
+       } else if (workingPtr->hdr.oscar.type == 0x04) {
+         /* Used only by the older login protocol */
          workingPtr->handled = aim_authparse(sess, workingPtr);
         } else {
-         u_short family,subtype;
+         unsigned short family,subtype;
          
          family = aimutil_get16(workingPtr->data);
          subtype = aimutil_get16(workingPtr->data+2);
This page took 0.0364449999999999 seconds and 4 git commands to generate.