You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by na...@apache.org on 2015/11/10 18:30:28 UTC
svn commit: r1713703 [1/2] - in /axis/axis2/c/core/trunk: axiom/include/
axiom/src/om/ src/core/deployment/ src/core/transport/http/sender/
src/modules/mod_addr/ util/src/
Author: nadiramra
Date: Tue Nov 10 17:30:28 2015
New Revision: 1713703
URL: http://svn.apache.org/viewvc?rev=1713703&view=rev
Log:
Simplify/cleanup code
Modified:
axis/axis2/c/core/trunk/axiom/include/axiom_attribute.h
axis/axis2/c/core/trunk/axiom/include/axiom_child_element_iterator.h
axis/axis2/c/core/trunk/axiom/include/axiom_children_iterator.h
axis/axis2/c/core/trunk/axiom/include/axiom_children_qname_iterator.h
axis/axis2/c/core/trunk/axiom/src/om/om_element.c
axis/axis2/c/core/trunk/src/core/deployment/desc_builder.c
axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c
axis/axis2/c/core/trunk/src/modules/mod_addr/addr_in_handler.c
axis/axis2/c/core/trunk/util/src/date_time.c
axis/axis2/c/core/trunk/util/src/env.c
axis/axis2/c/core/trunk/util/src/hash.c
Modified: axis/axis2/c/core/trunk/axiom/include/axiom_attribute.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_attribute.h?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_attribute.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_attribute.h Tue Nov 10 17:30:28 2015
@@ -43,10 +43,12 @@ extern "C"
/**
* creates an om_attribute struct
+ *
* @param env Environment. MUST NOT be NULL
* @param localname localname of the attribute, should not be a null value.
* @param value normalized attribute value. cannot be NULL
* @param ns namespace, if any, of the attribute. Optional, can be NULL om_attribute wont free the ns
+ *
* @return a pointer to newly created attribute struct, returns NULL on error with
* error code set in environment's error.
*/
@@ -61,6 +63,7 @@ extern "C"
* Free om attribute passed as void pointer. This will be
* cast into appropriate type and then pass the cast object
* into the om_attribute structure's free method
+ *
* @param om_attribute pointer to attribute struct to be freed
* @param env Environment. MUST NOT be NULL
*/
@@ -72,6 +75,7 @@ extern "C"
/**
* Free an axiom_attribute struct
+ *
* @param om_attribute pointer to attribute struct to be freed
* @param env Environment. MUST NOT be NULL
*/
@@ -83,9 +87,11 @@ extern "C"
/**
* Creates and returns a qname struct for this attribute
+ *
* @param om_attribute pointer to attribute struct
* for which the qname is to be returned
* @param env Environment. MUST NOT be NULL
+ *
* @return returns qname for given attribute.NULL on error
*/
@@ -96,9 +102,11 @@ extern "C"
/**
* Serialize op
+ *
* @param om_attribute pointer to attribute struct to be serialized
* @param env Environment. MUST NOT be NULL,
* @param om_output AXIOM output handler to be used in serializing
+ *
* @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
*/
@@ -109,8 +117,10 @@ extern "C"
axiom_output_t * om_output);
/** Returns the localname of this attribute
+ *
* @param om_attribute pointer to attribute struct
* @param env environment. MUST NOT not be NULL.
+ *
* @return localname returns NULL on error.
*/
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -120,8 +130,10 @@ extern "C"
/**
* returns value of this attribute
+ *
*@param om_attribute pointer to om_attribute struct
*@param env environment N not be null
+ *
*@return value , null on error
*/
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -131,8 +143,10 @@ extern "C"
/**
* returns namespace of this attribute
+ *
*@param om_attribute
*@param env environment MUST NOT be NULL
+ *
*@return a pointer to om_namespace struct , returns NULL on error.
*/
AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
@@ -141,9 +155,11 @@ extern "C"
const axutil_env_t * env);
/** sets the localname of the attribute
+ *
*@param om_attribute pointer to om attribute struct.
*@param env environment, MUST NOT be null.
- *@param localname localname that should be set for this attribute
+ *@param localname localname that should be set for this attribute
+ *
*@return status code AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -153,9 +169,11 @@ extern "C"
const axis2_char_t * localname);
/** set the attribute value
+ *
*@param om_attribute a pointer to om_attribute struct.
*@param env environment, MUST NOT be NULL.
- *@param value value that should be set for this attribute
+ *@param value value that should be set for this attribute
+ *
*@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
@@ -166,10 +184,12 @@ extern "C"
const axis2_char_t * value);
/** set namespace of the attribute
+ *
*@param om_attribute a pointer to om_attribute struct
*@param env environment, MUST NOT be NULL.
*@param om_namespace a pointer to om_namespace struct that should be set
* for this attribute
+ *
*@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -180,10 +200,11 @@ extern "C"
/**
* clones an om attribute
+ *
* @param om_attibute
* @param env environment
- * @returns pointer to cloned om attribute struct on success
- * NULL otherwise
+ *
+ * @returns pointer to cloned om attribute struct on success NULL otherwise
*/
AXIS2_EXTERN struct axiom_attribute *AXIS2_CALL
axiom_attribute_clone(
@@ -191,8 +212,10 @@ extern "C"
const axutil_env_t * env);
/** Increment the reference counter.
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -201,8 +224,10 @@ extern "C"
const axutil_env_t * env);
/** Create OM attribute
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL
@@ -213,8 +238,10 @@ extern "C"
axiom_namespace_t * ns);
/** Get the localname as a string
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axutil_string_t *AXIS2_CALL
@@ -223,8 +250,10 @@ extern "C"
const axutil_env_t * env);
/** Get the value as a string
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axutil_string_t *AXIS2_CALL
@@ -233,8 +262,10 @@ extern "C"
const axutil_env_t * env);
/** Set the localname of the attribute
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -244,8 +275,10 @@ extern "C"
axutil_string_t * localname);
/** Set the value of the attribute
+ *
* @param om_attribute a pointer to om_attribute struct
* @param env environment, MUST NOT be NULL.
+ *
* @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
Modified: axis/axis2/c/core/trunk/axiom/include/axiom_child_element_iterator.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_child_element_iterator.h?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_child_element_iterator.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_child_element_iterator.h Tue Nov 10 17:30:28 2015
@@ -32,8 +32,7 @@ extern "C"
{
#endif
- typedef struct axiom_child_element_iterator
- axiom_child_element_iterator_t;
+ typedef struct axiom_child_element_iterator axiom_child_element_iterator_t;
/**
* @defgroup axiom_child_element_iterator child element iterator
@@ -43,6 +42,7 @@ extern "C"
/**
* Free the iterator
+ *
* @param iterator a pointer to child element iterator struct
* @param env environment, MUST NOT be NULL.
*/
@@ -58,6 +58,7 @@ extern "C"
* call to <tt>next</tt>. The behavior of an iterator is unspecified if
* the underlying collection is modified while the iteration is in
* progress in any way other than by calling this method.
+ *
* @param iterator a pointer to child element iterator struct
* @param env environment, MUST NOT be NULL.
*/
@@ -71,11 +72,11 @@ extern "C"
* returns true if the iteration has more elements
* in otherwords it returns true if the next() would return an element
* rather than null with an error code set to environments error
+ *
* @param iterator a pointer to child element iterator struct
* @param env environment, MUST NOT be NULL.
*/
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-
axiom_child_element_iterator_has_next(
axiom_child_element_iterator_t * iterator,
const axutil_env_t * env);
@@ -83,6 +84,7 @@ extern "C"
/**
* Returns the next element in the iteration. Returns null if there
* is no more elements
+ *
* @param iterator a pointer to child element iterator struct
* @param env environment, MUST NOT be NULL.
*/
@@ -93,8 +95,10 @@ extern "C"
/**
* Create a child element interator for the current child
+ *
* @param current child
* @param env environment, MUST NOT be NULL.
+ *
* return axiom_child_element_iterator_t
*/
@@ -103,18 +107,6 @@ extern "C"
const axutil_env_t * env,
axiom_node_t * current_child);
-#define AXIOM_CHILD_ELEMENT_ITERATOR_FREE(iterator, env) \
- axiom_child_element_iterator_free(iterator, env)
-
-#define AXIOM_CHILD_ELEMENT_ITERATOR_REMOVE(iterator, env) \
- axiom_child_element_iterator_remove(iterator, env)
-
-#define AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(iterator, env) \
- axiom_child_element_iterator_has_next(iterator, env)
-
-#define AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(iterator, env) \
- axiom_child_element_iterator_next(iterator, env)
-
/** @} */
#ifdef __cplusplus
Modified: axis/axis2/c/core/trunk/axiom/include/axiom_children_iterator.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_children_iterator.h?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_children_iterator.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_children_iterator.h Tue Nov 10 17:30:28 2015
@@ -47,13 +47,13 @@ extern "C"
*/
AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL
-
axiom_children_iterator_create(
const axutil_env_t * env,
axiom_node_t * current_child);
/**
* Free the om_children_iterator struct
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
@@ -68,6 +68,7 @@ extern "C"
* call to <tt>next</tt>. The behavior of an iterator is unspecified if
* the underlying collection is modified while the iteration is in
* progress in any way other than by calling this method.
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
@@ -80,6 +81,7 @@ extern "C"
* @returns true if the iteration has more elements. In other
* words, returns true if next() would return an om_node_t struct
* rather than null with error code set in environment
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
@@ -92,6 +94,7 @@ extern "C"
/**
* Returns the next element in the iteration. Returns null if there are
* no more elements in the iteration
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
@@ -103,8 +106,10 @@ extern "C"
/**
* Resets the Iterator. This moves the cursor back to the initial.
* iterator chidren_iterator to be reset.
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
+ *
* @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -112,8 +117,6 @@ extern "C"
axiom_children_iterator_t * iterator,
const axutil_env_t * env);
- /************ Macros *********************************************/
-
/** @} */
#ifdef __cplusplus
Modified: axis/axis2/c/core/trunk/axiom/include/axiom_children_qname_iterator.h
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/include/axiom_children_qname_iterator.h?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/include/axiom_children_qname_iterator.h (original)
+++ axis/axis2/c/core/trunk/axiom/include/axiom_children_qname_iterator.h Tue Nov 10 17:30:28 2015
@@ -33,8 +33,7 @@ extern "C"
{
#endif
- typedef struct axiom_children_qname_iterator
- axiom_children_qname_iterator_t;
+ typedef struct axiom_children_qname_iterator axiom_children_qname_iterator_t;
/**
* @defgroup axiom_children_qname_iterator children qname iterator
@@ -49,7 +48,8 @@ extern "C"
axutil_qname_t * given_qname);
/**
- * free om_children_qname_iterator struct
+ * free om_children_qname_iterator struct
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
@@ -64,11 +64,11 @@ extern "C"
* call to <tt>next</tt>. The behavior of an iterator is unspecified if
* the underlying collection is modified while the iteration is in
* progress in any way other than by calling this method.
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
-
axiom_children_qname_iterator_remove(
axiom_children_qname_iterator_t * iterator,
const axutil_env_t * env);
@@ -77,18 +77,19 @@ extern "C"
* Returns <tt>true</tt> if the iteration has more elements. (In other
* words, returns <tt>true</tt> if <tt>next</tt> would return an
* axiom_node_t struct rather than null with error code set in environment
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-
axiom_children_qname_iterator_has_next(
axiom_children_qname_iterator_t * iterator,
const axutil_env_t * env);
/**
* Returns the next element in the iteration.
+ *
* @param iterator a pointer to axiom children iterator struct
* @param env environment, MUST NOT be NULL
*/
Modified: axis/axis2/c/core/trunk/axiom/src/om/om_element.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/src/om/om_element.c?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/src/om/om_element.c (original)
+++ axis/axis2/c/core/trunk/axiom/src/om/om_element.c Tue Nov 10 17:30:28 2015
@@ -57,6 +57,7 @@ struct axiom_element
/**
* Creates an AXIOM element with given local name
+ *
* @param env Environment. MUST NOT be NULL.
* @param parent parent of the element node to be created. can be NULL.
* @param localname local name of the element. cannot be NULL.
@@ -68,6 +69,7 @@ struct axiom_element
* @param node This is an out parameter. cannot be NULL.
* Returns the node corresponding to the comment created.
* Node type will be set to AXIOM_ELEMENT
+ *
* @return a pointer to the newly created element struct
*/
AXIS2_EXTERN axiom_element_t *AXIS2_CALL
@@ -84,14 +86,14 @@ axiom_element_create(
AXIS2_ASSERT(env != NULL);
(*node) = axiom_node_create(env);
- if(!(*node))
+ if (!(*node))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create axiom node needed by element");
return NULL;
}
element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t));
- if(!element)
+ if (!element)
{
axiom_node_free_tree(*node, env);
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -101,7 +103,7 @@ axiom_element_create(
memset(element, 0, sizeof(axiom_element_t));
element->localname = axutil_string_create(env, localname);
- if(!element->localname)
+ if (!element->localname)
{
AXIS2_FREE(env->allocator, element);/* Still we haven't set the data element. so, we have */
axiom_node_free_tree(*node, env); /* to free node and element separately */
@@ -109,16 +111,15 @@ axiom_element_create(
return NULL;
}
- if(parent)
- {
+ if (parent)
axiom_node_add_child(parent, env, (*node));
- }
+
axiom_node_set_node_type((*node), env, AXIOM_ELEMENT);
axiom_node_set_data_element((*node), env, element);
- if(ns)
+ if (ns)
{
- if(axiom_element_set_namespace(element, env, ns, *node) != AXIS2_SUCCESS)
+ if (axiom_element_set_namespace(element, env, ns, *node) != AXIS2_SUCCESS)
{
axiom_node_free_tree(*node, env); /* this will internally free axiom element */
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to set namespace of element");
@@ -131,12 +132,14 @@ axiom_element_create(
/**
* Creates an AXIOM element with given qname
+ *
* @param env Environment. MUST NOT be NULL.
* @param parent parent of the element node to be created. can be NULL.
* @param qname qname of the elment.cannot be NULL.
* @param node This is an out parameter. cannot be NULL.
* Returns the node corresponding to the comment created.
* Node type will be set to AXIOM_ELEMENT
+ *
* @return a pointer to the newly created element struct
*/
AXIS2_EXTERN axiom_element_t *AXIS2_CALL
@@ -159,7 +162,7 @@ axiom_element_create_with_qname(
AXIS2_ASSERT(localpart != NULL);
element = axiom_element_create(env, parent, localpart, NULL, node);
- if(!element)
+ if (!element)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create element with qname");
return NULL;
@@ -170,18 +173,16 @@ axiom_element_create_with_qname(
temp_nsuri = axutil_qname_get_uri(qname, env);
temp_prefix = axutil_qname_get_prefix(qname, env);
- if((!temp_nsuri) || (axutil_strcmp(temp_nsuri, "") == 0))
- {
- /** no namespace uri is available in given qname no need to bother about it */
+ /** if no namespace uri is available in given qname no need to bother about it */
+ if ((!temp_nsuri) || (axutil_strcmp(temp_nsuri, "") == 0))
return element;
- }
+ /** if could not find a namespace so declare namespace */
element->ns = axiom_element_find_namespace(element, env, (*node), temp_nsuri, temp_prefix);
- if(!element->ns)
+ if (!element->ns)
{
- /** could not find a namespace so declare namespace */
axiom_namespace_t *ns = axiom_namespace_create(env, temp_nsuri, temp_prefix);
- if(!ns)
+ if (!ns)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create namespace needed by element");
axiom_node_free_tree(*node, env);
@@ -189,7 +190,7 @@ axiom_element_create_with_qname(
return NULL;
}
- if(axiom_element_declare_namespace(element, env, *node, ns) != AXIS2_SUCCESS)
+ if (axiom_element_declare_namespace(element, env, *node, ns) != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to declare namespace needed by element");
axiom_node_free_tree(*node, env);
@@ -212,8 +213,10 @@ axiom_element_create_with_qname(
/**
* Frees given element
+ *
* @param element AXIOM element to be freed.
* @param env Environment. MUST NOT be NULL.
+ *
* @return status of the operation. AXIS2_SUCCESS on success ,AXIS2_FAILURE on error.
*/
AXIS2_EXTERN void AXIS2_CALL
@@ -226,12 +229,10 @@ axiom_element_free(
AXIS2_ASSERT(om_element->localname != NULL);
axutil_string_free(om_element->localname, env);
- if(om_element->ns)
- {
+ if (om_element->ns)
axiom_namespace_free(om_element->ns, env);
- }
- if(om_element->attributes)
+ if (om_element->attributes)
{
axutil_hash_index_t *hi;
void *val;
@@ -244,7 +245,7 @@ axiom_element_free(
axutil_hash_free(om_element->attributes, env);
}
- if(om_element->namespaces)
+ if (om_element->namespaces)
{
axutil_hash_index_t *hi;
void *val;
@@ -257,26 +258,23 @@ axiom_element_free(
axutil_hash_free(om_element->namespaces, env);
}
- if(om_element->qname)
- {
+ if (om_element->qname)
axutil_qname_free(om_element->qname, env);
- }
- if(om_element->children_iter)
- {
+
+ if (om_element->children_iter)
axiom_children_iterator_free(om_element->children_iter, env);
- }
- if(om_element->child_ele_iter)
- {
- AXIOM_CHILD_ELEMENT_ITERATOR_FREE(om_element->child_ele_iter, env);
- }
- if(om_element->children_qname_iter)
- {
+
+ if (om_element->child_ele_iter)
+ axiom_child_element_iterator_free(om_element->child_ele_iter, env);
+
+ if (om_element->children_qname_iter)
axiom_children_qname_iterator_free(om_element->children_qname_iter, env);
- }
- if(om_element->text_value)
+
+ if (om_element->text_value)
{
AXIS2_FREE(env->allocator, om_element->text_value);
}
+
AXIS2_FREE(env->allocator, om_element);
}
@@ -284,10 +282,12 @@ axiom_element_free(
* finds a namespace in current element's scope, by uri or prefix or both. Will not check in the
* parents, so even it is defined in parent nodes, this method will return NULL if it is not defined
* in element's scope
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param uri namespace uri, may be null
* @param prefix prefix
+ *
* @return axiom_namespace_t if found, else return NULL
*/
AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL
@@ -300,9 +300,9 @@ axiom_element_find_declared_namespace(
AXIS2_ASSERT(om_element != NULL);
AXIS2_ASSERT(env != NULL);
- if(om_element->namespaces)
+ if (om_element->namespaces)
{
- if(uri && (!prefix || axutil_strcmp(prefix, "") == 0))
+ if (uri && (!prefix || axutil_strcmp(prefix, "") == 0))
{
/** prefix is null , so iterate the namespaces hash to find the namespace */
axutil_hash_index_t *hashindex;
@@ -311,11 +311,11 @@ axiom_element_find_declared_namespace(
{
void *ns = NULL;
axutil_hash_this(hashindex, NULL, NULL, &ns);
- if(ns)
+ if (ns)
{
axiom_namespace_t *temp_ns = (axiom_namespace_t *)ns;
axis2_char_t *temp_nsuri = axiom_namespace_get_uri(temp_ns, env);
- if(axutil_strcmp(temp_nsuri, uri) == 0)
+ if (axutil_strcmp(temp_nsuri, uri) == 0)
{
/** namespace uri matches, so free hash index and return ns*/
AXIS2_FREE(env->allocator, hashindex);
@@ -324,18 +324,16 @@ axiom_element_find_declared_namespace(
}
}
}
- else if(prefix)
+ else if (prefix)
{
/** prefix is not null get namespace directly if exist */
- axiom_namespace_t *ns = (axiom_namespace_t *)axutil_hash_get(
- om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING);
- if(ns)
+ axiom_namespace_t *ns = (axiom_namespace_t *)axutil_hash_get(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING);
+ if (ns)
{
/* if uri provided, return found ns only if uri matches */
- if((uri) && (axutil_strcmp(axiom_namespace_get_uri(ns, env), uri) != 0))
- {
+ if ((uri) && (axutil_strcmp(axiom_namespace_get_uri(ns, env), uri) != 0))
ns = NULL;
- }
+
return ns;
}
}
@@ -346,11 +344,13 @@ axiom_element_find_declared_namespace(
/**
* Find a namespace in the scope of the document.
* Start to find from the given node and go up the hierarchy.
+ *
* @param om_element pointer to om_element_struct contained in node ,
* @param env Environment. MUST NOT be NULL.
* @param node node containing an instance of an AXIOM element,cannot be NULL.
* @param uri namespace uri..
* @param prefix namespace prefix. can be NULL.
+ *
* @return pointer to the namespace, if found, else NULL. On error, returns
* NULL and sets error code in environment,s error
*/
@@ -371,18 +371,16 @@ axiom_element_find_namespace(
/* check whether we can find the namespace in current element scope */
ns = axiom_element_find_declared_namespace(om_element, env, uri, prefix);
- if(ns)
- {
+ if (ns)
return ns;
- }
/* could not find the namespace in current element scope look in the parent */
parent = axiom_node_get_parent(element_node, env);
- if((parent) && (axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT))
+ if ((parent) && (axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT))
{
axiom_element_t *om_element;
om_element = (axiom_element_t *)axiom_node_get_data_element(parent, env);
- if(om_element)
+ if (om_element)
{
/** parent exist, parent is om element so find in parent*/
return axiom_element_find_namespace(om_element, env, parent, uri, prefix);
@@ -393,10 +391,12 @@ axiom_element_find_namespace(
/**
* Finds a namespace using qname. Start to find from the given node and go up the hierarchy.
+ *
* @param om_element om_element contained in node
* @param env Environment. MUST NOT be NULL.
* @param node node containing an instance of an AXIOM element, cannot be NULL.
* @param qname qname of the namespace to be found. cannot be NULL.
+ *
* @return pointer to the namespace, if found, else NULL. On error, returns
* NULL and sets the error code in environment's error struct.
*/
@@ -410,17 +410,20 @@ axiom_element_find_namespace_with_qname(
AXIS2_ASSERT(qname != NULL);
AXIS2_ASSERT(axutil_qname_get_uri(qname, env) != NULL);
- return axiom_element_find_namespace(element, env, node, axutil_qname_get_uri(qname, env),
- axutil_qname_get_prefix(qname, env));
+ return axiom_element_find_namespace(element, env, node,
+ axutil_qname_get_uri(qname, env),
+ axutil_qname_get_prefix(qname, env));
}
/**
* Declare a namespace in current element (in the scope of this element ).
* It checks to see if it is already declared at this level or in its ancestors
+ *
* @param om_element contained in the om node struct
* @param env Environment. MUST NOT be NULL.
* @param node node containing an instance of an AXIOM element.
* @param ns pointer to the namespace struct to be declared. Should not be null
+ *
* @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE.
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -441,37 +444,33 @@ axiom_element_declare_namespace(
uri = axiom_namespace_get_uri(ns, env);
prefix = axiom_namespace_get_prefix(ns, env);
+
+ /* If namespace already declared, return */
declared_ns = axiom_element_find_namespace(om_element, env, node, uri, prefix);
- if(declared_ns)
- {
- /*Namespace already declared, so return */
+ if (declared_ns)
return AXIS2_SUCCESS;
- }
- if(!om_element->namespaces)
+ if (!om_element->namespaces)
{
om_element->namespaces = axutil_hash_make(env);
- if(!om_element->namespaces)
+ if (!om_element->namespaces)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create namespaces hash map");
return AXIS2_FAILURE;
}
}
- if(prefix)
- {
+ if (prefix)
axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
- }
else
{
/* create a key with empty string */
axis2_char_t *key;
key = AXIS2_MALLOC(env->allocator, sizeof(char) * 1);
- if(!key)
+ if (!key)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Insufficient memory to create key to store namespace");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create key to store namespace");
}
key[0] = '\0';
axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns);
@@ -482,9 +481,11 @@ axiom_element_declare_namespace(
/**
* retrieves the default namespace of this element
+ *
* @param om_element pointer to om element
* @param env axutil_environment MUST Not be NULL
* @param element_node corresponding om element node of this om element
+ *
* @returns pointer to default namespace if available , NULL otherwise
*/
axiom_namespace_t *AXIS2_CALL
@@ -498,18 +499,16 @@ axiom_element_get_default_namespace(
AXIS2_ASSERT(env != NULL);
AXIS2_ASSERT(element_node != NULL);
- if(om_element->namespaces)
+ if (om_element->namespaces)
{
axiom_namespace_t *default_ns;
default_ns = axutil_hash_get(om_element->namespaces, "", AXIS2_HASH_KEY_STRING);
- if(default_ns)
- {
+ if (default_ns)
return default_ns;
- }
}
parent_node = axiom_node_get_parent(element_node, env);
- if((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
+ if ((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
{
axiom_element_t *parent_ele;
parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env);
@@ -520,8 +519,10 @@ axiom_element_get_default_namespace(
/**
* get the namespace of om_element
+ *
* @param om_element om_element struct
* @param env environment, MUST NOT be NULL.
+ *
* @returns pointer to axiom_namespace_t struct
* NULL if there is no namespace associated with the element,
* NULL on error with error code set to environment's error
@@ -537,15 +538,11 @@ axiom_element_get_namespace(
AXIS2_ASSERT(env != NULL);
AXIS2_ASSERT(ele_node != NULL);
- if(om_element->ns)
- {
+ if (om_element->ns)
ns = om_element->ns;
- }
else
- {
ns = axiom_element_get_default_namespace(om_element, env, ele_node);
- }
return ns;
}
@@ -572,7 +569,7 @@ axiom_element_set_namespace(
AXIS2_ASSERT(ns != NULL);
AXIS2_ASSERT(node != NULL);
- if(axiom_element_declare_namespace(om_element, env, node, ns) != AXIS2_SUCCESS)
+ if (axiom_element_declare_namespace(om_element, env, node, ns) != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to declare namespace given");
return AXIS2_FAILURE;
@@ -584,8 +581,10 @@ axiom_element_set_namespace(
/**
* get the namespace list of the element
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
+ *
* @returns axutil_hash pointer to namespaces hash
* this hash table is read only
*/
@@ -622,21 +621,20 @@ axiom_element_add_attribute(
AXIS2_ASSERT(om_element != NULL);
om_namespace = axiom_attribute_get_namespace(attribute, env);
- if(om_namespace)
+ if (om_namespace)
{
/* Declare the namespace in element */
- if(axiom_element_declare_namespace(om_element, env, element_node, om_namespace)
- != AXIS2_SUCCESS)
+ if (axiom_element_declare_namespace(om_element, env, element_node, om_namespace) != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to declare attribute namespace");
return AXIS2_FAILURE;
}
}
- if(!om_element->attributes)
+ if (!om_element->attributes)
{
om_element->attributes = axutil_hash_make(env);
- if(!om_element->attributes)
+ if (!om_element->attributes)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create hash map to store attributes");
return AXIS2_FAILURE;
@@ -644,7 +642,7 @@ axiom_element_add_attribute(
}
qname = axiom_attribute_get_qname(attribute, env);
- if(qname)
+ if (qname)
{
axis2_char_t *name = axutil_qname_to_string(qname, env);
axutil_hash_set(om_element->attributes, name, AXIS2_HASH_KEY_STRING, attribute);
@@ -661,9 +659,11 @@ axiom_element_add_attribute(
/**
* Gets (finds) the attribute with the given qname
+ *
* @param element element whose attribute is to be found.
* @param env Environment. MUST NOT be NULL.
- * @qname qname qname of the attribute to be found. should not be NULL.
+ * @param qname qname of the attribute to be found. should not be NULL.
+ *
* @return a pointer to the attribute with given qname if found, else NULL.
* On error, returns NULL and sets the error code in environment's error struct.
*/
@@ -681,13 +681,11 @@ axiom_element_get_attribute(
AXIS2_ASSERT(om_element != NULL);
/* if there are no attributes, then return NULL */
- if(!om_element->attributes)
- {
+ if (!om_element->attributes)
return NULL;
- }
name = axutil_qname_to_string(qname, env);
- if(!name)
+ if (!name)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to get string representation of qname");
return NULL;
@@ -699,8 +697,10 @@ axiom_element_get_attribute(
/**
* get the attribute list of the element
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
+ *
* @returns axutil_hash pointer to attributes hash
* This hash table is read only
*/
@@ -709,15 +709,16 @@ axiom_element_get_all_attributes(
axiom_element_t * om_element,
const axutil_env_t * env)
{
-
return om_element->attributes;
}
/**
* Gets (finds) the attribute value with the given qname
+ *
* @param element element whose attribute is to be found.
* @param env Environment. MUST NOT be NULL.
- * @qname qname qname of the attribute to be found. should not be NULL.
+ * @param qname qname of the attribute to be found. should not be NULL.
+ *
* @return the attribute value with given qname if found, else NULL.
* On error, returns NULL and sets the error code in environment's error struct.
*/
@@ -728,18 +729,15 @@ axiom_element_get_attribute_value(
axutil_qname_t * qname)
{
axiom_attribute_t *attr = axiom_element_get_attribute(om_element, env, qname);
- if(!attr)
- {
- /* cannot find the attribute with given name. But this might not be an error, and a valid
- * case */
+ if (!attr)
return NULL;
- }
return axiom_attribute_get_value(attr, env);
}
/**
* Extract attributes , returns a clones hash table of attributes,
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
@@ -757,14 +755,11 @@ axiom_element_extract_attributes(
AXIS2_ASSERT(env != NULL);
AXIS2_ASSERT(ele_node != NULL);
- if(!om_element->attributes)
- {
- /* no attributes defined */
+ if (!om_element->attributes)
return NULL;
- }
ht_cloned = axutil_hash_make(env);
- if(!ht_cloned)
+ if (!ht_cloned)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create hashmap to extract attributes");
return NULL;
@@ -780,19 +775,15 @@ axiom_element_extract_attributes(
AXIS2_ASSERT(val != NULL);
cloned_attr = axiom_attribute_clone((axiom_attribute_t*)val, env);
- if(cloned_attr)
+ if (cloned_attr)
{
axutil_qname_t *qn = axiom_attribute_get_qname(cloned_attr, env);
- if(qn)
- {
+ if (qn)
key = axutil_qname_to_string(qn, env);
- }
}
- if(key)
- {
+ if (key)
axutil_hash_set(ht_cloned, key, AXIS2_HASH_KEY_STRING, cloned_attr);
- }
else
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to clone attribute");
@@ -821,11 +812,8 @@ axiom_element_get_attribute_value_by_nam
AXIS2_ASSERT(om_element != NULL);
AXIS2_ASSERT(env != NULL);
- if(!om_element->attributes)
- {
- /* no attributes are defined. */
+ if (!om_element->attributes)
return NULL;
- }
for(hi = axutil_hash_first(om_element->attributes, env); hi; hi = axutil_hash_next(env, hi))
{
@@ -839,14 +827,14 @@ axiom_element_get_attribute_value_by_nam
this_attr_name = axiom_attribute_get_localname((axiom_attribute_t*)attr, env);
attr_ns = axiom_attribute_get_namespace((axiom_attribute_t*)attr, env);
- if(attr_ns && (prefix = axiom_namespace_get_prefix(attr_ns, env)) &&
+ if (attr_ns && (prefix = axiom_namespace_get_prefix(attr_ns, env)) &&
(axutil_strcmp(prefix, "") != 0))
{
/* namespace is defined and prefix is not empty. So, prefix:localname should match
* with given name
*/
axis2_char_t *attr_qn_str = axutil_strcat(env, prefix, ":", this_attr_name, NULL);
- if(axutil_strcmp(attr_qn_str, attr_name) != 0)
+ if (axutil_strcmp(attr_qn_str, attr_name) != 0)
{
/* not the attribute we are looking for */
AXIS2_FREE(env->allocator, attr_qn_str);
@@ -857,7 +845,7 @@ axiom_element_get_attribute_value_by_nam
else
{
/* no namespace or no prefix. so compare only local name */
- if(axutil_strcmp(this_attr_name, attr_name) != 0)
+ if (axutil_strcmp(this_attr_name, attr_name) != 0)
{
/* not the attribute we are looking for */
continue;
@@ -895,7 +883,7 @@ axiom_element_get_text(
AXIS2_ASSERT(element_node != NULL);
AXIS2_ASSERT(om_element != NULL);
- if(om_element->text_value)
+ if (om_element->text_value)
{
AXIS2_FREE(env->allocator, om_element->text_value);
om_element->text_value = NULL;
@@ -904,7 +892,7 @@ axiom_element_get_text(
temp_node = axiom_node_get_first_child(element_node, env);
while(temp_node)
{
- if(axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT)
+ if (axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT)
{
const axis2_char_t *temp_text;
axiom_text_t *text_ele;
@@ -912,16 +900,14 @@ axiom_element_get_text(
text_ele = (axiom_text_t *)axiom_node_get_data_element(temp_node, env);
AXIS2_ASSERT(text_ele != NULL);
temp_text = axiom_text_get_value(text_ele, env);
- if(dest && temp_text && axutil_strcmp(temp_text, "") != 0)
+ if (dest && temp_text && axutil_strcmp(temp_text, "") != 0)
{
axis2_char_t *temp_dest = axutil_stracat(env, dest, temp_text);
AXIS2_FREE(env->allocator, dest);
dest = temp_dest;
}
- else if(!dest && temp_text && axutil_strcmp(temp_text, "") != 0)
- {
+ else if (!dest && temp_text && axutil_strcmp(temp_text, "") != 0)
dest = axutil_strdup(env, temp_text);
- }
}
temp_node = axiom_node_get_next_sibling(temp_node, env);
}
@@ -934,12 +920,13 @@ axiom_element_get_text(
* Sets the text of the given element.
* caution - This method will wipe out all the text elements (and hence any mixed content)
* before setting the text
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param text text to set.
* @param element_node node of element.
- * @return AXIS2_SUCCESS if attribute was found and removed, else
- * AXIS2_FAILURE
+ *
+ * @return AXIS2_SUCCESS if attribute was found and removed, else AXIS2_FAILURE
*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_element_set_text(
@@ -960,13 +947,11 @@ axiom_element_set_text(
{
temp_node = next_node;
next_node = axiom_node_get_next_sibling(temp_node, env);
- if(axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT)
- {
+ if (axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT)
axiom_node_free_tree(temp_node, env);
- }
}
- if(!axiom_text_create(env, element_node, text, &temp_node))
+ if (!axiom_text_create(env, element_node, text, &temp_node))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to set text to element");
return AXIS2_FAILURE;
@@ -1012,7 +997,7 @@ axiom_element_set_localname(
AXIS2_ASSERT(env != NULL);
new_name = axutil_string_create(env, localname);
- if(!new_name)
+ if (!new_name)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to set local name of element");
return AXIS2_FAILURE;
@@ -1041,14 +1026,14 @@ axiom_element_get_qname(
AXIS2_ASSERT(env != NULL);
AXIS2_ASSERT(ele_node != NULL);
- if(!om_element->qname)
+ if (!om_element->qname)
{
axiom_namespace_t *ns = axiom_element_get_namespace(om_element, env, ele_node);
const axis2_char_t *localname = axutil_string_get_buffer(om_element->localname, env);
axis2_char_t *prefix = NULL;
axis2_char_t *uri = NULL;
- if(ns)
+ if (ns)
{
prefix = axiom_namespace_get_prefix(ns, env);
uri = axiom_namespace_get_uri(ns, env);
@@ -1076,24 +1061,22 @@ axiom_element_get_children(
AXIS2_ASSERT(om_element != NULL);
AXIS2_ASSERT(env != NULL);
- if(!om_element->children_iter)
- {
- om_element->children_iter = axiom_children_iterator_create(env,
- axiom_node_get_first_child(element_node, env));
- }
+ if (!om_element->children_iter)
+ om_element->children_iter = axiom_children_iterator_create(env, axiom_node_get_first_child(element_node, env));
else
- {
axiom_children_iterator_reset(om_element->children_iter, env);
- }
+
return om_element->children_iter;
}
/**
* returns a list of children iterator with qname. Returned iterator is freed when om element
* struct is freed
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param element_node pointer to this element node
+ *
* @returns children qname iterator struct
*/
AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL
@@ -1107,10 +1090,9 @@ axiom_element_get_children_with_qname(
AXIS2_ASSERT(element_qname != NULL);
AXIS2_ASSERT(om_element != NULL);
- if(om_element->children_qname_iter)
- {
+ if (om_element->children_qname_iter)
axiom_children_qname_iterator_free(om_element->children_qname_iter, env);
- }
+
om_element->children_qname_iter = axiom_children_qname_iterator_create(env,
axiom_node_get_first_child(element_node, env), element_qname);
return om_element->children_qname_iter;
@@ -1118,12 +1100,14 @@ axiom_element_get_children_with_qname(
/**
* Returns the first om_element corresponding to element_qname
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param element_qname qname of the element
* @param om_node pointer to this element node
* @param element_node
* @param child_node
+ *
* @returns children qname iterator struct
*/
AXIS2_EXTERN axiom_element_t *AXIS2_CALL
@@ -1136,22 +1120,21 @@ axiom_element_get_first_child_with_qname
{
axiom_children_qname_iterator_t *children_iterator;
children_iterator = axiom_element_get_children_with_qname(om_element, env, qname, element_node);
- if(!children_iterator)
+ if (!children_iterator)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not get children qname iterator");
return NULL;
}
- if(axiom_children_qname_iterator_has_next(children_iterator, env))
+ if (axiom_children_qname_iterator_has_next(children_iterator, env))
{
axiom_node_t *om_node = axiom_children_qname_iterator_next(children_iterator, env);
AXIS2_ASSERT(om_node != NULL);
AXIS2_ASSERT(axiom_node_get_node_type(om_node, env) == AXIOM_ELEMENT);
- if(child_node)
- {
+ if (child_node)
*child_node = om_node;
- }
+
return (axiom_element_t *)axiom_node_get_data_element(om_node, env);
}
@@ -1180,18 +1163,15 @@ axiom_element_get_first_element(
temp_node = axiom_node_get_first_child(element_node, env);
while(temp_node)
{
- if(axiom_node_get_node_type(temp_node, env) == AXIOM_ELEMENT)
+ if (axiom_node_get_node_type(temp_node, env) == AXIOM_ELEMENT)
{
- if(first_ele_node)
- {
+ if (first_ele_node)
*first_ele_node = temp_node;
- }
+
return (axiom_element_t *)axiom_node_get_data_element(temp_node, env);
}
else
- {
temp_node = axiom_node_get_next_sibling(temp_node, env);
- }
}
return NULL;
}
@@ -1214,16 +1194,14 @@ axiom_element_get_child_elements(
AXIS2_ASSERT(om_element != NULL);
AXIS2_ASSERT(element_node != NULL);
- if(om_element->child_ele_iter)
- {
+ if (om_element->child_ele_iter)
return om_element->child_ele_iter;
- }
else
{
axiom_node_t *first_node;
axiom_element_t *ele;
ele = axiom_element_get_first_element(om_element, env, element_node, &first_node);
- if(ele)
+ if (ele)
{
AXIS2_ASSERT(first_node != NULL);
om_element->child_ele_iter = axiom_child_element_iterator_create(env, first_node);
@@ -1239,9 +1217,11 @@ axiom_element_get_child_elements(
* Collect all the namespaces with distinct prefixes in the parents of the given element.
* Effectively this is the set of namespaces declared above this element and might be used by it
* or its children. Output of this will be used later by axiom_element_redeclare_parent_namespaces
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
+ *
* @returns pointer to hash of relevant namespaces
*/
axutil_hash_t * AXIS2_CALL
@@ -1258,15 +1238,15 @@ axiom_element_gather_parent_namespaces(
AXIS2_ASSERT(om_node != NULL);
inscope_namespaces = axutil_hash_make(env);
- if(!inscope_namespaces)
+ if (!inscope_namespaces)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"Unable to create hashmap needed to gather parent namespace");
return NULL;
}
- while((parent_node = axiom_node_get_parent(parent_node, env)) &&
- (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
+ while ((parent_node = axiom_node_get_parent(parent_node, env))
+ && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
{
axiom_element_t *parent_element;
axutil_hash_t *parent_namespaces;
@@ -1274,13 +1254,12 @@ axiom_element_gather_parent_namespaces(
parent_element = (axiom_element_t *)axiom_node_get_data_element(parent_node, env);
parent_namespaces = axiom_element_get_namespaces(parent_element, env);
- if(!parent_namespaces)
- {
- /* no namespaces are declared. So, continue without processing */
+
+ /* If no namespaces are declared. So, continue without processing */
+ if (!parent_namespaces)
continue;
- }
- for(hi = axutil_hash_first(parent_namespaces, env); hi; hi = axutil_hash_next(env, hi))
+ for (hi = axutil_hash_first(parent_namespaces, env); hi; hi = axutil_hash_next(env, hi))
{
axis2_char_t *key;
void *val;
@@ -1288,13 +1267,11 @@ axiom_element_gather_parent_namespaces(
AXIS2_ASSERT(val != NULL);
key = axiom_namespace_get_prefix((axiom_namespace_t *)val, env);
- if(!key)
- {
+ if (!key)
key = "";
- }
/* Check if prefix already associated with some namespace in a parent node */
- if(!axutil_hash_get(inscope_namespaces, key, AXIS2_HASH_KEY_STRING))
+ if (!axutil_hash_get(inscope_namespaces, key, AXIS2_HASH_KEY_STRING))
{
/* Remember this namespace as needing to be declared, if used */
axutil_hash_set(inscope_namespaces, key, AXIS2_HASH_KEY_STRING, val);
@@ -1309,6 +1286,7 @@ axiom_element_gather_parent_namespaces(
* If the provided namespace used by the provided element is one of the namespaces from the
* parent of the detached node, redeclares that namespace at the element level and removes it
* from the hash of parent namespaces
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
@@ -1327,19 +1305,17 @@ axiom_element_use_parent_namespace(
AXIS2_ASSERT(env != NULL);
AXIS2_ASSERT(om_node != NULL);
- if(ns && inscope_namespaces)
+ if (ns && inscope_namespaces)
{
axiom_namespace_t *parent_ns;
axis2_char_t *key = axiom_namespace_get_prefix(ns, env);
- if(!key)
- {
+ if (!key)
key = "";
- }
parent_ns = axutil_hash_get(inscope_namespaces, key, AXIS2_HASH_KEY_STRING);
/* Check if namespace is a namespace declared in a parent and not also declared at an
* intermediate level */
- if(parent_ns)
+ if (parent_ns)
{
/* declare the namespace. If it is already declared in intermediate level,
* axiom_elment_declare_namespace will handle it
@@ -1358,6 +1334,7 @@ axiom_element_use_parent_namespace(
* declared, redeclares that namespace at the level of the subtree root and removes
* it from the set of parent inscope_namespaces. inscope_namespaces contains all the parent
* namespaces which should be redeclared at some point.
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
@@ -1381,7 +1358,7 @@ axiom_element_redeclare_parent_namespace
/* for each attribute, ensure the attribute's namespace is declared */
attributes = om_element->attributes;
- if(attributes)
+ if (attributes)
{
axutil_hash_index_t *hi;
for(hi = axutil_hash_first(attributes, env); hi; hi = axutil_hash_next(env, hi))
@@ -1401,7 +1378,7 @@ axiom_element_redeclare_parent_namespace
child_node = axiom_node_get_first_child(om_node, env);
while(child_node && (axutil_hash_count(inscope_namespaces) > 0))
{
- if(axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
+ if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
{
axiom_element_redeclare_parent_namespaces(axiom_node_get_data_element(child_node, env),
env, child_node, inscope_namespaces);
@@ -1431,15 +1408,15 @@ axiom_element_serialize_start_part(
AXIS2_ASSERT(om_output != NULL);
AXIS2_ASSERT(ele_node != NULL);
- if(om_element->is_empty)
+ if (om_element->is_empty)
{
- if(om_element->ns)
+ if (om_element->ns)
{
axis2_char_t *uri = axiom_namespace_get_uri(om_element->ns, env);
axis2_char_t *prefix = axiom_namespace_get_prefix(om_element->ns, env);
AXIS2_ASSERT(uri != NULL);
- if(prefix && (axutil_strcmp(prefix, "") != 0))
+ if (prefix && (axutil_strcmp(prefix, "") != 0))
{
status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 4,
axutil_string_get_buffer(om_element-> localname, env), uri, prefix, NULL);
@@ -1458,13 +1435,13 @@ axiom_element_serialize_start_part(
}
else
{
- if(om_element->ns)
+ if (om_element->ns)
{
axis2_char_t *uri = axiom_namespace_get_uri(om_element->ns, env);
axis2_char_t *prefix = axiom_namespace_get_prefix(om_element->ns, env);
AXIS2_ASSERT(uri != NULL);
- if(prefix && (axutil_strcmp(prefix, "") != 0))
+ if (prefix && (axutil_strcmp(prefix, "") != 0))
{
status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 3,
axutil_string_get_buffer(om_element-> localname, env), uri, prefix);
@@ -1482,13 +1459,13 @@ axiom_element_serialize_start_part(
}
}
- if(status != AXIS2_SUCCESS)
+ if (status != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "element serialized failed");
return AXIS2_FAILURE;
}
- if(om_element->attributes)
+ if (om_element->attributes)
{
axutil_hash_index_t *hi;
void *val;
@@ -1497,7 +1474,7 @@ axiom_element_serialize_start_part(
axutil_hash_this(hi, NULL, NULL, &val);
AXIS2_ASSERT(val != NULL);
- if(axiom_attribute_serialize((axiom_attribute_t *)val, env, om_output) != AXIS2_SUCCESS)
+ if (axiom_attribute_serialize((axiom_attribute_t *)val, env, om_output) != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "element attribute serialize failed");
AXIS2_FREE(env->allocator, hi);
@@ -1506,7 +1483,7 @@ axiom_element_serialize_start_part(
}
}
- if(om_element->namespaces)
+ if (om_element->namespaces)
{
axutil_hash_index_t *hi;
void *val;
@@ -1515,7 +1492,7 @@ axiom_element_serialize_start_part(
axutil_hash_this(hi, NULL, NULL, &val);
AXIS2_ASSERT(val != NULL);
- if(axiom_namespace_serialize((axiom_namespace_t *)val, env, om_output) != AXIS2_SUCCESS)
+ if (axiom_namespace_serialize((axiom_namespace_t *)val, env, om_output) != AXIS2_SUCCESS)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "element namespace serialize failed");
AXIS2_FREE(env->allocator, hi);
@@ -1530,10 +1507,12 @@ axiom_element_serialize_start_part(
/**
* Serializes the end part of the given element. serialize_start_part must
* have been called before calling this method.
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
* @param om_output AXIOM output handler to be used in serializing
+ *
* @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
*/
axis2_status_t AXIS2_CALL
@@ -1576,9 +1555,11 @@ axiom_element_get_is_empty(
/**
* This method will declare the namespace without checking whether it is already declared.
* (This method is only used by codegen. We have to remove this method in future)
+ *
* @param om_element pointer to om_element
* @param env environment MUST not be NULL
* @param om_node pointer to this element node
+ *
* @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
*
*/
@@ -1590,17 +1571,17 @@ axiom_element_declare_namespace_assume_p
{
axis2_char_t *prefix = NULL;
- if(!ns || !om_element)
+ if (!ns || !om_element)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "namespace or om_element is NULL");
return AXIS2_FAILURE;
}
- if(!(om_element->namespaces))
+ if (!(om_element->namespaces))
{
om_element->namespaces = axutil_hash_make(env);
- if(!(om_element->namespaces))
+ if (!(om_element->namespaces))
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create namespaces hash map");
return AXIS2_FAILURE;
@@ -1608,20 +1589,17 @@ axiom_element_declare_namespace_assume_p
}
prefix = axiom_namespace_get_prefix(ns, env);
- if(prefix)
- {
+ if (prefix)
axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns);
- }
else
{
/* create a key with empty string */
axis2_char_t *key;
key = AXIS2_MALLOC(env->allocator, sizeof(char) * 1);
- if(!key)
+ if (!key)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Insufficient memory to create key to store namespace");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Insufficient memory to create key to store namespace");
}
key[0] = '\0';
axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns);
@@ -1641,25 +1619,20 @@ axiom_element_build(
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE);
- if(axiom_node_get_node_type(om_ele_node, env) != AXIOM_ELEMENT)
- {
+ if (axiom_node_get_node_type(om_ele_node, env) != AXIOM_ELEMENT)
return AXIS2_FAILURE;
- }
builder = axiom_node_get_builder(om_ele_node, env);
- if(!builder)
- {
+ if (!builder)
return AXIS2_FAILURE;
- }
+
while(!axiom_node_is_complete(om_ele_node, env)
&& !axiom_stax_builder_is_complete(builder, env))
{
void *value = NULL;
value = axiom_stax_builder_next(builder, env);
- if(!value)
- {
+ if (!value)
return AXIS2_FAILURE;
- }
}
return AXIS2_SUCCESS;
}
@@ -1683,24 +1656,20 @@ axiom_element_find_namespace_uri(
AXIS2_PARAM_CHECK(env->error, element_node, NULL);
AXIS2_PARAM_CHECK(env->error, prefix, NULL);
- if(om_element->namespaces)
+ if (om_element->namespaces)
{
ns = axutil_hash_get(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING);
- if(ns)
- {
+ if (ns)
return ns;
- }
}
parent_node = axiom_node_get_parent(element_node, env);
- if((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
+ if ((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT))
{
axiom_element_t *parent_ele = NULL;
parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env);
- if(parent_ele)
- {
+ if (parent_ele)
return axiom_element_find_namespace_uri(parent_ele, env, prefix, parent_node);
- }
}
return NULL;
}
@@ -1722,7 +1691,7 @@ axiom_element_set_localname_str(
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE);
- if(om_element->localname)
+ if (om_element->localname)
{
axutil_string_free(om_element->localname, env);
om_element->localname = NULL;
@@ -1730,10 +1699,9 @@ axiom_element_set_localname_str(
om_element->localname = axutil_string_clone(localname, env);
- if(!(om_element->localname))
- {
+ if (!(om_element->localname))
return AXIS2_FAILURE;
- }
+
return AXIS2_SUCCESS;
}
@@ -1772,20 +1740,17 @@ axiom_element_declare_default_namespace(
AXIS2_ENV_CHECK(env, NULL);
AXIS2_PARAM_CHECK(env->error, uri, NULL);
- if(axutil_strcmp(uri, "") == 0)
- {
+ if (axutil_strcmp(uri, "") == 0)
return NULL;
- }
default_ns = axiom_namespace_create(env, uri, "");
- if(!default_ns)
- {
+ if (!default_ns)
return NULL;
- }
- if(!om_element->namespaces)
+
+ if (!om_element->namespaces)
{
om_element->namespaces = axutil_hash_make(env);
- if(!(om_element->namespaces))
+ if (!(om_element->namespaces))
{
axiom_namespace_free(default_ns, env);
return NULL;
@@ -1807,7 +1772,7 @@ axiom_element_create_str(
{
axiom_element_t *element;
- if(!localname || !node)
+ if (!localname || !node)
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "localname or node is NULL");
@@ -1815,7 +1780,7 @@ axiom_element_create_str(
}
(*node) = axiom_node_create(env);
- if(!(*node))
+ if (!(*node))
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create axiom node");
@@ -1823,7 +1788,7 @@ axiom_element_create_str(
}
element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t));
- if(!element)
+ if (!element)
{
AXIS2_FREE(env->allocator, (*node));
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -1835,14 +1800,13 @@ axiom_element_create_str(
element->localname = axutil_string_clone(localname, env);
/* clone can't be null so, no need to check for null validity*/
- if(parent)
- {
+ if (parent)
axiom_node_add_child(parent, env, (*node));
- }
+
axiom_node_set_node_type((*node), env, AXIOM_ELEMENT);
axiom_node_set_data_element((*node), env, element);
- if(ns)
+ if (ns)
{
axis2_char_t *uri = NULL;
axis2_char_t *prefix = NULL;
@@ -1851,17 +1815,13 @@ axiom_element_create_str(
prefix = axiom_namespace_get_prefix(ns, env);
element->ns = axiom_element_find_namespace(element, env, *node, uri, prefix);
- if(!(element->ns))
+ if (!(element->ns))
{
- if(axiom_element_declare_namespace(element, env, *node, ns) == AXIS2_SUCCESS)
- {
+ if (axiom_element_declare_namespace(element, env, *node, ns) == AXIS2_SUCCESS)
element->ns = ns;
- }
}
- if(prefix && axutil_strcmp(prefix, "") == 0)
- {
+ if (prefix && axutil_strcmp(prefix, "") == 0)
element->ns = NULL;
- }
}
return element;
@@ -1878,11 +1838,11 @@ axiom_element_remove_attribute(
AXIS2_PARAM_CHECK(env->error, om_attribute, AXIS2_FAILURE);
qname = axiom_attribute_get_qname(om_attribute, env);
- if(qname && (om_element->attributes))
+ if (qname && (om_element->attributes))
{
axis2_char_t *name = NULL;
name = axutil_qname_to_string(qname, env);
- if(name)
+ if (name)
{
axutil_hash_set(om_element->attributes, name, AXIS2_HASH_KEY_STRING, NULL);
return AXIS2_SUCCESS;
Modified: axis/axis2/c/core/trunk/src/core/deployment/desc_builder.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/deployment/desc_builder.c?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/deployment/desc_builder.c (original)
+++ axis/axis2/c/core/trunk/src/core/deployment/desc_builder.c Tue Nov 10 17:30:28 2015
@@ -575,14 +575,14 @@ set_attrs_and_value(
value_list = axutil_array_list_create(env, 0);
axutil_param_set_value_list(param, env, value_list);
- while(AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(childs, env))
+ while (axiom_child_element_iterator_has_next(childs, env))
{
axiom_node_t *node = NULL;
axiom_element_t *element = NULL;
axutil_param_t *param = NULL;
axis2_char_t *pname = NULL;
- node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(childs, env);
+ node = axiom_child_element_iterator_next(childs, env);
element = axiom_node_get_data_element(node, env);
param = axutil_param_create(env, NULL, NULL);
pname = axiom_element_get_localname(element, env);
Modified: axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c (original)
+++ axis/axis2/c/core/trunk/src/core/transport/http/sender/http_sender.c Tue Nov 10 17:30:28 2015
@@ -3576,7 +3576,7 @@ axis2_http_sender_get_param_string(
if(iterator)
{
- while(AXIS2_TRUE == AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(iterator, env))
+ while (AXIS2_TRUE == axiom_child_element_iterator_has_next(iterator, env))
{
axiom_node_t *node = NULL;
axiom_element_t *element = NULL;
@@ -3584,7 +3584,7 @@ axis2_http_sender_get_param_string(
axis2_char_t *value = NULL;
axis2_char_t *encoded_value = NULL;
- node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(iterator, env);
+ node = axiom_child_element_iterator_next(iterator, env);
element = axiom_node_get_data_element(node, env);
name = axiom_element_get_localname(element, env);
value = axiom_element_get_text(element, env, node);
Modified: axis/axis2/c/core/trunk/src/modules/mod_addr/addr_in_handler.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/src/modules/mod_addr/addr_in_handler.c?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/src/modules/mod_addr/addr_in_handler.c (original)
+++ axis/axis2/c/core/trunk/src/modules/mod_addr/addr_in_handler.c Tue Nov 10 17:30:28 2015
@@ -515,12 +515,12 @@ axis2_addr_in_extract_epr_information(
epr_ref_qn = axutil_qname_create(env, EPR_REFERENCE_PARAMETERS, addr_ns_str, NULL);
wsa_meta_qn = axutil_qname_create(env, AXIS2_WSA_METADATA, addr_ns_str, NULL);
- while(AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(child_ele_iter, env))
+ while (axiom_child_element_iterator_has_next(child_ele_iter, env))
{
axiom_node_t *child_node = NULL;
axiom_element_t *child_ele = NULL;
axutil_qname_t *child_qn = NULL;
- child_node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(child_ele_iter, env);
+ child_node = axiom_child_element_iterator_next(child_ele_iter, env);
child_ele = (axiom_element_t *)axiom_node_get_data_element(child_node, env);
child_qn = axiom_element_get_qname(child_ele, env, child_node);
@@ -536,11 +536,11 @@ axis2_addr_in_extract_epr_information(
ref_param_iter = axiom_element_get_child_elements(child_ele, env, child_node);
if(ref_param_iter)
{
- while(AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(ref_param_iter, env))
+ while (axiom_child_element_iterator_has_next(ref_param_iter, env))
{
axiom_node_t *om_node = NULL;
/*axiom_element_t *om_ele = NULL; */
- om_node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(ref_param_iter, env);
+ om_node = axiom_child_element_iterator_next(ref_param_iter, env);
/*om_ele = (axiom_element_t *)axiom_node_get_data_element(om_node, env); */
axis2_endpoint_ref_add_ref_param(endpoint_ref, env, om_node);
}
Modified: axis/axis2/c/core/trunk/util/src/date_time.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/util/src/date_time.c?rev=1713703&r1=1713702&r2=1713703&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/util/src/date_time.c (original)
+++ axis/axis2/c/core/trunk/util/src/date_time.c Tue Nov 10 17:30:28 2015
@@ -107,18 +107,15 @@ axutil_date_time_deserialize_time(
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
sscanf(time_str, "%d:%d:%fZ", &hour, &min, &sec);
- if(hour < 0 || hour > 23)
- {
+ if (hour < 0 || hour > 23)
return AXIS2_FAILURE;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return AXIS2_FAILURE;
- }
- if(sec < 0 || sec >= 60)
- {
+
+ if (sec < 0 || sec >= 60)
return AXIS2_FAILURE;
- }
+
date_time->hour = hour;
date_time->min = min;
date_time->sec = sec;
@@ -141,47 +138,34 @@ axutil_date_time_deserialize_time_with_t
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if(strchr(time_str, 'Z'))
- {
+ if (strchr(time_str, 'Z'))
return AXIS2_FAILURE;
- }
- else if(!strchr(time_str, '+'))
- {
+ else if (!strchr(time_str, '+'))
tz_pos = AXIS2_FALSE;
- }
- if(tz_pos)
- {
+ if (tz_pos)
sscanf(time_str, "%d:%d:%f+%d:%d", &hour, &min, &sec, &tz_hour, &tz_min);
- }
else
- {
sscanf(time_str, "%d:%d:%f-%d:%d", &hour, &min, &sec, &tz_hour, &tz_min);
- }
- if(hour < 0 || hour > 23)
- {
+
+ if (hour < 0 || hour > 23)
return AXIS2_FAILURE;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return AXIS2_FAILURE;
- }
- if(sec < 0 || sec >= 60)
- {
+
+ if (sec < 0 || sec >= 60)
return AXIS2_FAILURE;
- }
- if(tz_hour < 0 || tz_hour > 14)
- {
+
+ if (tz_hour < 0 || tz_hour > 14)
return AXIS2_FAILURE;
- }
- if(tz_min < 0 || tz_min > 59)
- {
+
+ if (tz_min < 0 || tz_min > 59)
return AXIS2_FAILURE;
- }
- if(tz_hour == 14 && tz_min != 0)
- {
+
+ if (tz_hour == 14 && tz_min != 0)
return AXIS2_FAILURE;
- }
+
date_time->hour = hour;
date_time->min = min;
date_time->sec = sec;
@@ -203,46 +187,37 @@ axutil_date_time_deserialize_date(
int is_year_neg = 0;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if(!date_str || *date_str == '+')
- {
+ if (!date_str || *date_str == '+')
return AXIS2_FAILURE;
- }
- if(strchr(date_str,'T'))
- {
+
+ if (strchr(date_str,'T'))
return AXIS2_FAILURE;
- }
- if(*date_str == '-')
- {
+
+ if (*date_str == '-')
is_year_neg++;
- }
+
sscanf(date_str + is_year_neg, "%d-%d-%d", &year, &mon, &day);
- if(is_year_neg)
- {
+ if (is_year_neg)
year *= -1;
- }
- if(mon < 1 || mon > 12)
- {
+
+ if (mon < 1 || mon > 12)
return AXIS2_FAILURE;
- }
- if(day < 1 || day > 31)
- {
+
+ if (day < 1 || day > 31)
return AXIS2_FAILURE;
- }
- if(day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
- {
+
+ if (day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
return AXIS2_FAILURE;
- }
- if(day == 30 && mon == 2)
- {
+
+ if (day == 30 && mon == 2)
return AXIS2_FAILURE;
- }
- if(day == 29 && mon == 2)
+
+ if (day == 29 && mon == 2)
{
if(year % 4 != 0 || year % 400 == 0)
- {
return AXIS2_FAILURE;
- }
}
+
date_time->year = year - 1900;
date_time->mon = mon - 1;
date_time->day = day;
@@ -264,55 +239,44 @@ axutil_date_time_deserialize_date_time(
int is_year_neg = 0;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if(!date_time_str || *date_time_str == '+')
- {
+ if (!date_time_str || *date_time_str == '+')
return AXIS2_FAILURE;
- }
- if(*date_time_str == '-')
- {
+
+ if (*date_time_str == '-')
is_year_neg++;
- }
+
sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%fZ", &year, &mon, &day, &hour, &min, &sec);
- if(is_year_neg)
- {
+ if (is_year_neg)
year *= -1;
- }
- if(mon < 1 || mon > 12)
- {
+
+ if (mon < 1 || mon > 12)
return AXIS2_FAILURE;
- }
- if(day < 1 || day > 31)
- {
+
+ if (day < 1 || day > 31)
return AXIS2_FAILURE;
- }
- if(day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
- {
+
+ if (day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
return AXIS2_FAILURE;
- }
- if(day == 30 && mon == 2)
- {
+
+ if (day == 30 && mon == 2)
return AXIS2_FAILURE;
- }
- if(day == 29 && mon == 2)
+
+ if (day == 29 && mon == 2)
{
if(year % 4 != 0 || year % 400 == 0)
- {
return AXIS2_FAILURE;
- }
}
- if(hour < 0 || hour > 23)
- {
+
+ if (hour < 0 || hour > 23)
return AXIS2_FAILURE;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return AXIS2_FAILURE;
- }
- if(sec < 0 || sec >= 60)
- {
+
+ if (sec < 0 || sec >= 60)
return AXIS2_FAILURE;
- }
+
date_time->year = year - 1900;
date_time->mon = mon - 1;
date_time->day = day;
@@ -341,86 +305,69 @@ axutil_date_time_deserialize_date_time_w
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if(!date_time_str || *date_time_str == '+')
- {
+ if (!date_time_str || *date_time_str == '+')
return AXIS2_FAILURE;
- }
- if(*date_time_str == '-')
- {
+
+ if (*date_time_str == '-')
is_year_neg++;
- }
- if(strchr(date_time_str, 'Z'))
- {
+ if (strchr(date_time_str, 'Z'))
return AXIS2_FAILURE;
- }
else if(strchr(date_time_str, '+'))
- {
tz_pos = AXIS2_TRUE;
- }
- if(tz_pos)
+ if (tz_pos)
{
- sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%f+%d:%d", &year, &mon, &day, &hour,
- &min, &sec, &tz_hour, &tz_min);
+ sscanf(date_time_str + is_year_neg,
+ "%d-%d-%dT%d:%d:%f+%d:%d",
+ &year, &mon, &day, &hour, &min, &sec, &tz_hour, &tz_min);
}
else
{
- sscanf(date_time_str + is_year_neg, "%d-%d-%dT%d:%d:%f-%d:%d", &year, &mon, &day, &hour,
- &min, &sec, &tz_hour, &tz_min);
+ sscanf(date_time_str + is_year_neg,
+ "%d-%d-%dT%d:%d:%f-%d:%d",
+ &year, &mon, &day, &hour, &min, &sec, &tz_hour, &tz_min);
}
- if(is_year_neg)
- {
+ if (is_year_neg)
year *= -1;
- }
- if(mon < 1 || mon > 12)
- {
+
+ if (mon < 1 || mon > 12)
return AXIS2_FAILURE;
- }
- if(day < 1 || day > 31)
- {
+
+ if (day < 1 || day > 31)
return AXIS2_FAILURE;
- }
- if(day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
- {
+
+ if (day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
return AXIS2_FAILURE;
- }
- if(day == 30 && mon == 2)
- {
+
+ if (day == 30 && mon == 2)
return AXIS2_FAILURE;
- }
- if(day == 29 && mon == 2)
+
+ if (day == 29 && mon == 2)
{
if(year % 4 != 0 || year % 400 == 0)
- {
return AXIS2_FAILURE;
- }
}
- if(hour < 0 || hour > 23)
- {
+
+ if (hour < 0 || hour > 23)
return AXIS2_FAILURE;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return AXIS2_FAILURE;
- }
- if(sec < 0 || sec >= 60)
- {
+
+ if (sec < 0 || sec >= 60)
return AXIS2_FAILURE;
- }
- if(tz_hour < 0 || tz_hour > 14)
- {
+
+ if (tz_hour < 0 || tz_hour > 14)
return AXIS2_FAILURE;
- }
- if(tz_min < 0 || tz_min > 59)
- {
+
+ if (tz_min < 0 || tz_min > 59)
return AXIS2_FAILURE;
- }
- if(tz_hour == 14 && tz_min != 0)
- {
+
+ if (tz_hour == 14 && tz_min != 0)
return AXIS2_FAILURE;
- }
+
date_time->year = year - 1900;
date_time->mon = mon - 1;
date_time->day = day;
@@ -446,32 +393,20 @@ axutil_date_time_compare(
int ref_hour;
AXIS2_ENV_CHECK(env, AXIS2_DATE_TIME_COMP_RES_FAILURE);
- if(date_time->year < ref->year)
- {
+ if (date_time->year < ref->year)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(date_time->year > ref->year)
- {
+ else if (date_time->year > ref->year)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
- if(date_time->mon < ref->mon)
- {
+ if (date_time->mon < ref->mon)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(date_time->mon > ref->mon)
- {
+ else if (date_time->mon > ref->mon)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
- if(date_time->day < ref->day)
- {
+ if (date_time->day < ref->day)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(date_time->day > ref->day)
- {
+ else if (date_time->day > ref->day)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
dt_min = date_time->tz_min;
dt_hour = date_time->tz_hour;
@@ -493,32 +428,20 @@ axutil_date_time_compare(
ref_min += ref->min;
ref_hour += ref->hour;
- if(dt_hour < ref_hour)
- {
+ if (dt_hour < ref_hour)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(dt_hour > ref_hour)
- {
+ else if (dt_hour > ref_hour)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
- if(dt_min < ref_min)
- {
+ if (dt_min < ref_min)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(dt_min > ref_min)
- {
+ else if (dt_min > ref_min)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
- if(date_time->sec < ref->sec)
- {
+ if (date_time->sec < ref->sec)
return AXIS2_DATE_TIME_COMP_RES_NOT_EXPIRED;
- }
- else if(date_time->sec > ref->sec)
- {
+ else if (date_time->sec > ref->sec)
return AXIS2_DATE_TIME_COMP_RES_EXPIRED;
- }
return AXIS2_DATE_TIME_COMP_RES_EQUAL;
}
@@ -533,17 +456,14 @@ axutil_date_time_set_time_zone(
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
if(hour < 0 || hour > 14)
- {
return AXIS2_FAILURE;
- }
+
if(min < 0 || min > 59)
- {
return AXIS2_FAILURE;
- }
+
if(hour == 14 && min != 0)
- {
return AXIS2_FAILURE;
- }
+
date_time->tz_pos = is_positive;
date_time->tz_hour = hour;
date_time->tz_min = min;
@@ -564,45 +484,35 @@ axutil_date_time_set_date_time(
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- if(mon < 1 || mon > 12)
- {
+ if (mon < 1 || mon > 12)
return AXIS2_FAILURE;
- }
- if(day < 1 || day > 31)
- {
+
+ if (day < 1 || day > 31)
return AXIS2_FAILURE;
- }
- if(day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
- {
+
+ if (day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
return AXIS2_FAILURE;
- }
- if(day == 30 && mon == 2)
- {
+
+ if (day == 30 && mon == 2)
return AXIS2_FAILURE;
- }
- if(day == 29 && mon == 2)
+
+ if (day == 29 && mon == 2)
{
if(year % 4 != 0 || year % 400 == 0)
- {
return AXIS2_FAILURE;
- }
}
- if(hour < 0 || hour > 23)
- {
+
+ if (hour < 0 || hour > 23)
return AXIS2_FAILURE;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return AXIS2_FAILURE;
- }
- if(sec < 0 || sec > 59)
- {
+
+ if (sec < 0 || sec > 59)
return AXIS2_FAILURE;
- }
- if(msec < 0 || msec > 999)
- {
+
+ if (msec < 0 || msec > 999)
return AXIS2_FAILURE;
- }
date_time->year = year - 1900;
date_time->mon = mon - 1;
@@ -647,14 +557,15 @@ axutil_date_time_serialize_time_with_tim
AXIS2_ENV_CHECK(env, NULL);
- if(!date_time->tz_hour && !date_time->tz_min)
+ if (!date_time->tz_hour && !date_time->tz_min)
{
return axutil_date_time_serialize_time(date_time, env);
}
time_str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 37);
- sprintf(time_str, "%02d:%02d:%06.3f%c%02d:%02d", date_time->hour, date_time->min,
- date_time->sec, date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
+ sprintf(time_str, "%02d:%02d:%06.3f%c%02d:%02d",
+ date_time->hour, date_time->min,
+ date_time->sec, date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
/*
* Ensure that milliseconds are separated with dot,
@@ -678,7 +589,8 @@ axutil_date_time_serialize_date(
date_str = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 32);
- sprintf(date_str, "%d-%02d-%02d", date_time->year + 1900, date_time->mon + 1, date_time->day);
+ sprintf(date_str, "%d-%02d-%02d",
+ date_time->year + 1900, date_time->mon + 1, date_time->day);
return date_str;
}
@@ -692,8 +604,10 @@ axutil_date_time_serialize_date_time(
AXIS2_ENV_CHECK(env, NULL);
date_time_str = AXIS2_MALLOC(env->allocator, sizeof(char) * 32);
- sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%06.3fZ", date_time->year + 1900, date_time->mon
- + 1, date_time->day, date_time->hour, date_time->min, date_time->sec);
+ sprintf(date_time_str,
+ "%d-%02d-%02dT%02d:%02d:%06.3fZ",
+ date_time->year + 1900, date_time->mon + 1, date_time->day,
+ date_time->hour, date_time->min, date_time->sec);
/*
* Ensure that milliseconds are separated with dot,
@@ -716,8 +630,10 @@ axutil_date_time_serialize_date_time_wit
AXIS2_ENV_CHECK(env, NULL);
date_time_str = AXIS2_MALLOC(env->allocator, sizeof(char) * 32);
- sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%02.0fZ", date_time->year + 1900, date_time->mon
- + 1, date_time->day, date_time->hour, date_time->min, date_time->sec);
+ sprintf(date_time_str,
+ "%d-%02d-%02dT%02d:%02d:%02.0fZ",
+ date_time->year + 1900, date_time->mon + 1, date_time->day,
+ date_time->hour, date_time->min, date_time->sec);
return date_time_str;
}
@@ -730,15 +646,17 @@ axutil_date_time_serialize_date_time_wit
AXIS2_ENV_CHECK(env, NULL);
- if(!date_time->tz_hour && !date_time->tz_min)
+ if (!date_time->tz_hour && !date_time->tz_min)
{
return axutil_date_time_serialize_date_time(date_time, env);
}
date_time_str = AXIS2_MALLOC(env->allocator, sizeof(char) * 37);
- sprintf(date_time_str, "%d-%02d-%02dT%02d:%02d:%06.3f%c%02d:%02d", date_time->year + 1900,
- date_time->mon + 1, date_time->day, date_time->hour, date_time->min, date_time->sec,
- date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
+ sprintf(date_time_str,
+ "%d-%02d-%02dT%02d:%02d:%06.3f%c%02d:%02d",
+ date_time->year + 1900, date_time->mon + 1, date_time->day,
+ date_time->hour, date_time->min, date_time->sec,
+ date_time->tz_pos ? '+' : '-', date_time->tz_hour, date_time->tz_min);
/*
* Ensure that milliseconds are separated with dot,
@@ -848,10 +766,9 @@ axutil_date_time_is_utc(
const axutil_env_t *env)
{
axis2_bool_t is_utc = AXIS2_TRUE;
- if(date_time->tz_hour || date_time->tz_min)
- {
+ if (date_time->tz_hour || date_time->tz_min)
is_utc = AXIS2_FALSE;
- }
+
return is_utc;
}
@@ -941,54 +858,43 @@ axutil_date_time_local_to_utc(
mon++;
}
else
- {
break;
- }
}
else if(day > 29)
{
- if(mon == 4 || mon == 6 || mon == 9 || mon == 11)
- {
+ if (mon == 4 || mon == 6 || mon == 9 || mon == 11)
day -= 30;
- }
- else if(day > 30)
- {
+ else if (day > 30)
day -= 31;
- }
else
- {
break;
- }
+
mon++;
}
else
- {
break;
- }
+
if(mon > 12)
{
mon = 1;
year++;
}
}
+
while(day < 0)
{
- if(mon == 3)
+ if (mon == 3)
{
day += 28;
- if(year % 4 == 0 || year % 400 != 0)
- {
+ if (year % 4 == 0 || year % 400 != 0)
day++;
- }
}
- if(mon == 5 || mon == 7 || mon == 10 || mon == 12)
- {
+
+ if (mon == 5 || mon == 7 || mon == 10 || mon == 12)
day += 30;
- }
else
- {
day += 31;
- }
+
mon--;
if(mon < 1)
{
@@ -998,41 +904,32 @@ axutil_date_time_local_to_utc(
}
day++;
- if(mon < 1 || mon > 12)
- {
+ if (mon < 1 || mon > 12)
return NULL;
- }
- if(day < 1 || day > 31)
- {
+
+ if (day < 1 || day > 31)
return NULL;
- }
- if(day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
- {
+
+ if (day == 31 && (mon == 2 || mon == 4 || mon == 6 || mon == 9 || mon == 11))
return NULL;
- }
- if(day == 30 && mon == 2)
- {
+
+ if (day == 30 && mon == 2)
return NULL;
- }
- if(day == 29 && mon == 2)
+
+ if (day == 29 && mon == 2)
{
if(year % 4 != 0 || year % 400 == 0)
- {
return NULL;
- }
}
- if(hour < 0 || hour > 23)
- {
+
+ if (hour < 0 || hour > 23)
return NULL;
- }
- if(min < 0 || min > 59)
- {
+
+ if (min < 0 || min > 59)
return NULL;
- }
- if(sec < 0 || sec >= 60)
- {
+
+ if (sec < 0 || sec >= 60)
return NULL;
- }
ret = axutil_date_time_create(env);
ret->year = year - 1900;
@@ -1054,10 +951,9 @@ axutil_date_time_utc_to_local(
{
axutil_date_time_t *date_time = NULL;
axutil_date_time_t *ret = NULL;
- if(date_time_in->tz_hour && date_time_in->tz_min)
- {
+ if (date_time_in->tz_hour && date_time_in->tz_min)
return NULL;
- }
+
date_time->year = date_time_in->year;
date_time->mon = date_time_in->mon;
date_time->day = date_time_in->day;