]> andersk Git - libfaim.git/blobdiff - aim_rxhandlers.c
- Wed Nov 8 13:11:18 UTC 2000
[libfaim.git] / aim_rxhandlers.c
index 4e76e2a3dbfc65dc8e016a5e303643efbf78f884..220394f2abf907ce6a8aa264b42caf83449a0555 100644 (file)
@@ -13,7 +13,7 @@
  * Bleck functions get called when there's no non-bleck functions
  * around to cleanup the mess...
  */
-int bleck(struct aim_session_t *sess,struct command_rx_struct *workingPtr, ...)
+faim_internal int bleck(struct aim_session_t *sess,struct command_rx_struct *workingPtr, ...)
 {
   u_short family;
   u_short subtype;
@@ -181,62 +181,68 @@ int bleck(struct aim_session_t *sess,struct command_rx_struct *workingPtr, ...)
   return 1;
 }
 
-int aim_conn_addhandler(struct aim_session_t *sess,
+faim_export int aim_conn_addhandler(struct aim_session_t *sess,
                        struct aim_conn_t *conn,
                        u_short family,
                        u_short type,
                        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;
 }
 
-int aim_clearhandlers(struct aim_conn_t *conn)
+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;
 }
 
-rxcallback_t aim_callhandler(struct aim_conn_t *conn,
-                   u_short family,
-                   u_short type)
+faim_internal rxcallback_t aim_callhandler(struct aim_conn_t *conn,
+                                        u_short family,
+                                        u_short type)
 {
   struct aim_rxcblist_t *cur;
 
@@ -255,14 +261,15 @@ rxcallback_t aim_callhandler(struct aim_conn_t *conn,
 
   if (type==0xffff)
     return NULL;
+
   return aim_callhandler(conn, family, 0xffff);
 }
 
-int aim_callhandler_noparam(struct aim_session_t *sess,
-                           struct aim_conn_t *conn,
-                           u_short family,
-                           u_short type,
-                           struct command_rx_struct *ptr)
+faim_internal int aim_callhandler_noparam(struct aim_session_t *sess,
+                                         struct aim_conn_t *conn,
+                                         u_short family,
+                                         u_short type,
+                                         struct command_rx_struct *ptr)
 {
   rxcallback_t userfunc = NULL;
   userfunc = aim_callhandler(conn, family, type);
@@ -294,7 +301,7 @@ int aim_callhandler_noparam(struct aim_session_t *sess,
   TODO: Allow for NULL handlers.
   
  */
-int aim_rxdispatch(struct aim_session_t *sess)
+faim_export int aim_rxdispatch(struct aim_session_t *sess)
 {
   int i = 0;
   struct command_rx_struct *workingPtr = NULL;
@@ -336,16 +343,17 @@ 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);
@@ -376,8 +384,8 @@ int aim_rxdispatch(struct aim_session_t *sess)
            /* Old login protocol */
            /* any user callbacks will be called from here */
            workingPtr->handled = aim_authparse(sess, workingPtr);
-           break;
 #endif
+           break;
          }
        }
        break;
@@ -614,7 +622,7 @@ int aim_rxdispatch(struct aim_session_t *sess)
   return 0;
 }
 
-int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command)
+faim_internal int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command)
 {
   rxcallback_t userfunc = NULL;
   char sn[MAXSNLEN];
@@ -630,7 +638,7 @@ int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct
   i++;
 
   memset(sn, 0, sizeof(sn));
-  strncpy(sn, command->data+i, snlen);
+  strncpy(sn, (char *)command->data+i, snlen);
 
   if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x000c)))
     ret =  userfunc(sess, command, type, sn);
@@ -638,7 +646,7 @@ int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct
   return ret;
 }
 
-int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command)
+faim_internal int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command)
 {
   rxcallback_t userfunc = NULL;
   int ret = 1;
@@ -657,7 +665,7 @@ int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_st
   return ret;
 }
 
-int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command)
+faim_internal int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command)
 {
   rxcallback_t userfunc = NULL;
   int ret = 1, pos;
@@ -682,8 +690,8 @@ int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_st
   return ret;
 }
 
-int aim_parsemotd_middle(struct aim_session_t *sess,
-                        struct command_rx_struct *command, ...)
+faim_internal int aim_parsemotd_middle(struct aim_session_t *sess,
+                                      struct command_rx_struct *command, ...)
 {
   rxcallback_t userfunc = NULL;
   char *msg;
@@ -724,12 +732,12 @@ int aim_parsemotd_middle(struct aim_session_t *sess,
   return ret;  
 }
 
-int aim_handleredirect_middle(struct aim_session_t *sess,
+faim_internal int aim_handleredirect_middle(struct aim_session_t *sess,
                              struct command_rx_struct *command, ...)
 {
   struct aim_tlv_t *tmptlv = NULL;
   int serviceid = 0x00;
-  char cookie[AIM_COOKIELEN];
+  unsigned char cookie[AIM_COOKIELEN];
   char *ip = NULL;
   rxcallback_t userfunc = NULL;
   struct aim_tlvlist_t *tlvlist;
@@ -791,8 +799,8 @@ int aim_handleredirect_middle(struct aim_session_t *sess,
   return ret;
 }
 
-int aim_parse_unknown(struct aim_session_t *sess,
-                     struct command_rx_struct *command, ...)
+faim_internal int aim_parse_unknown(struct aim_session_t *sess,
+                                         struct command_rx_struct *command, ...)
 {
   u_int i = 0;
 
@@ -812,8 +820,8 @@ int aim_parse_unknown(struct aim_session_t *sess,
 }
 
 
-int aim_negchan_middle(struct aim_session_t *sess,
-                      struct command_rx_struct *command)
+faim_internal int aim_negchan_middle(struct aim_session_t *sess,
+                                    struct command_rx_struct *command)
 {
   struct aim_tlvlist_t *tlvlist;
   char *msg = NULL;
@@ -847,8 +855,8 @@ int aim_negchan_middle(struct aim_session_t *sess,
  * Middle handler for 0x0001 snac of each family.
  *
  */
-int aim_parse_generalerrs(struct aim_session_t *sess,
-                         struct command_rx_struct *command, ...)
+faim_internal int aim_parse_generalerrs(struct aim_session_t *sess,
+                                       struct command_rx_struct *command, ...)
 {
   u_short family;
   u_short subtype;
This page took 0.048079 seconds and 4 git commands to generate.