You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2005/12/21 10:05:37 UTC

svn commit: r358233 - in /webservices/axis2/trunk/c: include/axis2_soap_utils.h modules/xml/soap/src/axis2_soap_utils.c

Author: nandika
Date: Wed Dec 21 01:05:28 2005
New Revision: 358233

URL: http://svn.apache.org/viewcvs?rev=358233&view=rev
Log:
soap_utils added contains two utility functions

Added:
    webservices/axis2/trunk/c/include/axis2_soap_utils.h
    webservices/axis2/trunk/c/modules/xml/soap/src/axis2_soap_utils.c

Added: webservices/axis2/trunk/c/include/axis2_soap_utils.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_soap_utils.h?rev=358233&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_soap_utils.h (added)
+++ webservices/axis2/trunk/c/include/axis2_soap_utils.h Wed Dec 21 01:05:28 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#ifndef AXIS2_SOAP_UTILS_H
+#define AXIS2_SOAP_UTILS_H
+ 
+   /**
+    * @file axis2_soap_utils.h
+    * @brief axis2_soap_utils utility functions
+    */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/**
+ * @defgroup axis2_soap_utils
+ * @ingroup axis2_soap_utils
+ * @{
+ */
+
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_soap_utils_get_child_with_name(axis2_env_t **env,
+                                     axis2_om_node_t *om_node,
+                                     axis2_char_t *localname);
+                                     
+AXIS2_DECLARE(axis2_status_t)
+axis2_soap_utils_set_new_node(axis2_env_t **env,
+                              axis2_om_node_t *parent,
+                              axis2_om_node_t **my_node,
+                              axis2_om_node_t  *new_node);
+                                                                     
+ /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_SOAP_UTILS_H */
\ No newline at end of file

Added: webservices/axis2/trunk/c/modules/xml/soap/src/axis2_soap_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/src/axis2_soap_utils.c?rev=358233&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/src/axis2_soap_utils.c (added)
+++ webservices/axis2/trunk/c/modules/xml/soap/src/axis2_soap_utils.c Wed Dec 21 01:05:28 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+ #include <axis2_om_element.h>
+ #include <axis2_om_node.h>
+ #include <axis2_soap_utils.h>
+ 
+AXIS2_DECLARE(axis2_om_node_t *)
+axis2_soap_utils_get_child_with_name(axis2_env_t **env,
+                                     axis2_om_node_t *om_node,
+                                     axis2_char_t *localname)
+{
+    axis2_om_children_iterator_t *iter = NULL;
+    axis2_om_element_t *om_ele = NULL;
+    axis2_om_node_t *iter_node = NULL;
+    axis2_om_element_t *iter_ele = NULL;
+    axis2_char_t *name = NULL;
+    AXIS2_PARAM_CHECK((*env)->error, om_node, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, localname, NULL);
+    if(AXIS2_OM_NODE_GET_NODE_TYPE(om_node, env) != AXIS2_OM_ELEMENT)
+        return NULL;
+    om_ele = (axis2_om_element_t*) 
+            AXIS2_OM_NODE_GET_DATA_ELEMENT(om_node, env);
+            
+    iter = AXIS2_OM_ELEMENT_GET_CHILDREN(om_ele, env, om_node);
+    while(AXIS2_OM_CHILDREN_ITERATOR_HAS_NEXT(iter, env))
+    {
+        iter_node = AXIS2_OM_CHILD_ELEMENT_ITERATOR_NEXT(iter, env);
+        if(AXIS2_OM_NODE_GET_NODE_TYPE(iter_node, env) == AXIS2_OM_ELEMENT)
+        {
+            iter_ele = (axis2_om_element_t*) 
+                        AXIS2_OM_NODE_GET_DATA_ELEMENT(iter_node, env);
+            
+            name = AXIS2_OM_ELEMENT_GET_LOCALNAME(iter_ele, env);
+            if(AXIS2_STRCMP(name, localname) == 0)
+            {
+                AXIS2_OM_CHILDREN_ITERATOR_FREE(iter , env);
+                   return iter_node;
+            }
+       }
+    }
+    AXIS2_OM_CHILDREN_ITERATOR_FREE(iter , env);
+    return NULL;
+}                                     
+                                     
+                                     
+                                     
+AXIS2_DECLARE(axis2_status_t)
+axis2_soap_utils_set_new_node(axis2_env_t **env,
+                              axis2_om_node_t *parent,
+                              axis2_om_node_t **my_node,
+                              axis2_om_node_t  *new_node)
+{
+    if(*my_node)
+    {
+        AXIS2_OM_NODE_FREE_TREE(*my_node, env);
+    }
+    AXIS2_OM_NODE_ADD_CHILD(new_node, env, parent);
+    *my_node = new_node;
+    return AXIS2_SUCCESS;
+}                              
+                              
\ No newline at end of file