Author: ArcRiley
Date: 2009-01-09 23:55:02 -0500 (Fri, 09 Jan 2009)
New Revision: 1457

Modified:
   trunk/concordance/src/Core.c
   trunk/concordance/src/utils.c
   trunk/concordance/src/utils.h
Log:
 * fixed conSearchAttributes function to return NULL when attribute not found
 * now checking for NULL iq/message/presence from/to attributes


Modified: trunk/concordance/src/Core.c
===================================================================
--- trunk/concordance/src/Core.c        2009-01-10 04:02:10 UTC (rev 1456)
+++ trunk/concordance/src/Core.c        2009-01-10 04:55:02 UTC (rev 1457)
@@ -398,26 +398,6 @@
   #
   ###########################################################################
   #
-  # Convenience functions
-  #                                                                        */
-
-  static void
-  conCore_queueFreeMsg(conCoreQueueMsg* msg) {
-    /* free message struct and it's members
-
-       gchar*           g_string_free            (GString *string,
-                                                  gboolean free_segment);
-       void             g_free                   (gpointer mem);
-    */
-    g_string_free(msg->message, TRUE);
-    g_free(msg);
-  }
-
-
-  /*
-  #
-  ###########################################################################
-  #
   # MainLoop thread functions (nogil)
   #                                                                        */
 
@@ -611,6 +591,18 @@
   # Callback Queue Handling
   #                                                                        */
   static void
+  conCore_queueFreeMsg(conCoreQueueMsg* msg) {
+    /* free message struct and it's members
+
+       gchar*           g_string_free            (GString *string,
+                                                  gboolean free_segment);
+       void             g_free                   (gpointer mem);
+    */
+    g_string_free(msg->message, TRUE);
+    g_free(msg);
+  }
+
+  static void
   conCore_queuePush(conSession* session) {                                /*\
     cdef :                                                                \*/
       conCoreObject*        self = session->core;
@@ -1055,6 +1047,7 @@
       conCoreObject*        self = session->core;
       gchar**               element;
       gint                  i;
+      gchar*                attr;
 
     /* split name by namespace and element
 
@@ -1111,17 +1104,20 @@
             /* set the client mode */
             session->state = CON_E_CLIENT;
 
-            /* copy "from" and "to" attributes, will verify in conCore_xmlEnd
+            /* check and copy "to" and "from" attributes
 
                GString* g_string_assign          (GString *string,
                                                   const gchar *rval);
             */
-            session->eto = g_string_assign(session->eto,
-                                           conSearchAttributes(atts, "to"));
-            session->efrom = g_string_assign(session->efrom,
-                                           conSearchAttributes(atts, "from"));
+            if (!(attr = conSearchAttributes(atts, "to"))) 
+              attr = "";
+            session->eto = g_string_assign(session->eto, attr);
+            if (!(attr = conSearchAttributes(atts, "from"))) 
+              attr = "";
+            session->efrom = g_string_assign(session->efrom, attr);
+            printf("--------- from: %s to: %s\n", 
+                   session->efrom->str, session->eto->str);
 
-
             /* copy element and attributes to ebuff
 
                void     g_string_printf          (GString *string,
@@ -1145,8 +1141,8 @@
         if (g_ascii_strcasecmp(element[0],
                                "urn:ietf:params:xml:ns:xmpp-sasl") == 0) {
           if (g_ascii_strcasecmp(element[1], "auth") == 0) {
-            const gchar* mech = conSearchAttributes(atts, "mechanism");
-            if (gsasl_server_support_p(self->saslCntx, mech)) {
+            gchar* mech = conSearchAttributes(atts, "mechanism");
+            if (mech && gsasl_server_support_p(self->saslCntx, mech)) {
               /* initiate server session
 
                  int    gsasl_server_start       (Gsasl* ctx,

Modified: trunk/concordance/src/utils.c
===================================================================
--- trunk/concordance/src/utils.c       2009-01-10 04:02:10 UTC (rev 1456)
+++ trunk/concordance/src/utils.c       2009-01-10 04:55:02 UTC (rev 1457)
@@ -73,7 +73,7 @@
   return id;
 }
 
-const gchar*
+gchar*
 conSearchAttributes(const gchar** attrs, const gchar* key) {              /*\
   cdef :                                                                  \*/
     gint i;
@@ -89,7 +89,10 @@
   }
 
   /* return either the found attribute value or NULL */
-  return attrs[i+1];
+  if (attrs[i])
+    return (gchar*) attrs[i+1];
+  else
+    return NULL;
 }
 
 gchar*

Modified: trunk/concordance/src/utils.h
===================================================================
--- trunk/concordance/src/utils.h       2009-01-10 04:02:10 UTC (rev 1456)
+++ trunk/concordance/src/utils.h       2009-01-10 04:55:02 UTC (rev 1457)
@@ -32,7 +32,7 @@
                                         GIOCondition condition, 
                                         GSourceFunc callback, gpointer data,
                                         GMainContext* context);
-const gchar*  conSearchAttributes      (const gchar**, const gchar*);
+gchar*        conSearchAttributes      (const gchar**, const gchar*);
 gchar*        conPyUnicodeToUTF8       (PyObject* unicode);
 
 #endif

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to