]> andersk Git - libfaim.git/blobdiff - aim_rxhandlers.c
Minor typo.
[libfaim.git] / aim_rxhandlers.c
index fa2429e3454b0f82fa80ee847a284de3ab880779..bc67cbf0193783064e1936238b4ca85131d3eadc 100644 (file)
@@ -188,14 +188,15 @@ faim_export int aim_conn_addhandler(struct aim_session_t *sess,
                        rxcallback_t newhandler,
                        u_short flags)
 {
-  struct aim_rxcblist_t *newcb,*cur;
+  struct aim_rxcblist_t *newcb;
 
   if (!conn)
     return -1;
 
   faimdprintf(1, "aim_conn_addhandler: adding for %04x/%04x\n", family, type);
 
-  newcb = (struct aim_rxcblist_t *)calloc(1, sizeof(struct aim_rxcblist_t));
+  if (!(newcb = (struct aim_rxcblist_t *)calloc(1, sizeof(struct aim_rxcblist_t))))
+    return -1;
   newcb->family = family;
   newcb->type = type;
   newcb->flags = flags;
@@ -205,32 +206,37 @@ faim_export int aim_conn_addhandler(struct aim_session_t *sess,
     newcb->handler = newhandler;
   newcb->next = NULL;
   
-  cur = conn->handlerlist;
-  if (!cur)
+  if (!conn->handlerlist)
     conn->handlerlist = newcb;
-  else 
-    {
-      while (cur->next)
-       cur = cur->next;
-      cur->next = 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) {
+         workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, workingPtr);
+       } 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);
@@ -397,7 +405,7 @@ faim_export int aim_rxdispatch(struct aim_session_t *sess)
        switch (family) {
        case 0x0000: /* not really a family, but it works */
          if (subtype == 0x0001)
-           workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0000, 0x0001, workingPtr);
+           workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, workingPtr);
          else
            workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_UNKNOWN, workingPtr);
          break;
@@ -533,10 +541,9 @@ faim_export int aim_rxdispatch(struct aim_session_t *sess)
        u_short subtype;
        family = aimutil_get16(workingPtr->data);
        subtype= aimutil_get16(workingPtr->data+2);
-       
-       if ((family == 0x0002) && (subtype == 0x0006)) {
-         workingPtr->handled = 1;
-         aim_conn_setstatus(workingPtr->conn, AIM_CONN_STATUS_READY);
+
+       if ((family == 0x0000) && (subtype == 0x00001)) {
+         workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, workingPtr);
        } else if ((family == 0x000d) && (subtype == 0x0009)) {
          workingPtr->handled = aim_chatnav_parse_info(sess, workingPtr);
        } else {
@@ -550,9 +557,9 @@ faim_export int aim_rxdispatch(struct aim_session_t *sess)
        family = aimutil_get16(workingPtr->data);
        subtype= aimutil_get16(workingPtr->data+2);
        
-       if ((family == 0x0000) && (subtype == 0x00001))
-         workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0000, 0x0001, workingPtr);
-       else if (family == 0x0001) {
+       if ((family == 0x0000) && (subtype == 0x00001)) {
+         workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, workingPtr);
+       else if (family == 0x0001) {
          if (subtype == 0x0001)
            workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x0001, workingPtr);
          else if (subtype == 0x0003)
@@ -796,6 +803,9 @@ faim_internal int aim_parse_unknown(struct aim_session_t *sess,
 {
   u_int i = 0;
 
+  if (!sess || !command)
+    return 1;
+
   faimdprintf(1, "\nRecieved unknown packet:");
 
   for (i = 0; i < command->commandlen; i++)
This page took 0.066353 seconds and 4 git commands to generate.