Author: shankar
Date: Thu Sep 10 13:05:03 2009
New Revision: 813414
URL: http://svn.apache.org/viewvc?rev=813414&view=rev
Log:
code formatting
Modified:
webservices/rampart/trunk/c/src/omxmlsec/c14n/c14n.c
Modified: webservices/rampart/trunk/c/src/omxmlsec/c14n/c14n.c
URL:
http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/c14n/c14n.c?rev=813414&r1=813413&r2=813414&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/c14n/c14n.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/c14n/c14n.c Thu Sep 10 13:05:03
2009
@@ -16,7 +16,6 @@
* limitations under the License.
*/
-
#include <stdio.h>
#include <axis2_const.h>
#include <axutil_error.h>
@@ -118,15 +117,13 @@
static c14n_ns_stack_t*
c14n_ns_stack_create(
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
c14n_ns_stack_t *ns_stack = NULL;
- ns_stack = (c14n_ns_stack_t *)(AXIS2_MALLOC(ctx->env->allocator,
- sizeof(c14n_ns_stack_t)));
+ ns_stack = (c14n_ns_stack_t *) (AXIS2_MALLOC(ctx->env->allocator,
sizeof(c14n_ns_stack_t)));
- if (ns_stack)
+ if(ns_stack)
{
ns_stack->head = 0;
ns_stack->size = 0;
@@ -139,40 +136,36 @@
return ns_stack;
}
-static axis2_status_t
-c14n_ns_stack_add(
+static axis2_status_t c14n_ns_stack_add(
axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
c14n_ns_stack_t *ns_stack = ctx->ns_stack;
- if (!ns_stack->stack)
+ if(!ns_stack->stack)
{
- ns_stack->stack = (axiom_namespace_t **)(AXIS2_MALLOC(
- ctx->env->allocator,
- sizeof(axiom_namespace_t*) *
DEFAULT_STACK_SIZE));
- if (!ns_stack->stack)
+ ns_stack->stack = (axiom_namespace_t **)
(AXIS2_MALLOC(ctx->env->allocator,
+ sizeof(axiom_namespace_t*) * DEFAULT_STACK_SIZE));
+ if(!ns_stack->stack)
{
- AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
AXIS2_FAILURE);
return AXIS2_FAILURE;
}
- else ns_stack->size = DEFAULT_STACK_SIZE;
+ else
+ ns_stack->size = DEFAULT_STACK_SIZE;
}
- else if (ns_stack->head >= ns_stack->size)
+ else if(ns_stack->head >= ns_stack->size)
{
int size = 2 * ns_stack->size;
- axiom_namespace_t **tmp_stack = (axiom_namespace_t **)(AXIS2_MALLOC(
- ctx->env->allocator,
sizeof(axiom_namespace_t*) * size));
- if (tmp_stack)
+ axiom_namespace_t **tmp_stack = (axiom_namespace_t **)
(AXIS2_MALLOC(ctx->env->allocator,
+ sizeof(axiom_namespace_t*) * size));
+ if(tmp_stack)
{
/*int i = 0;*/
/* TODO:DONE use memcpy for this.*/
/*for (i=0; i<ns_stack->size; i++)
- tmp_stack[i] = (ns_stack->stack)[i];*/
- memcpy(tmp_stack, ns_stack,
- sizeof(axiom_namespace_t*) * ns_stack->size);
+ tmp_stack[i] = (ns_stack->stack)[i];*/
+ memcpy(tmp_stack, ns_stack, sizeof(axiom_namespace_t*) *
ns_stack->size);
ns_stack->size = size;
@@ -181,8 +174,7 @@
}
else
{
- AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
AXIS2_FAILURE);
return AXIS2_FAILURE;
}
}
@@ -203,27 +195,23 @@
* </b>
* </a>
* */
-static axis2_status_t
-c14n_ns_stack_find_with_prefix_uri(
+static axis2_status_t c14n_ns_stack_find_with_prefix_uri(
const axis2_char_t *prefix,
const axis2_char_t *uri,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
int i;
c14n_ns_stack_t *ns_stack = ctx->ns_stack;
- if (ns_stack->stack) /*Is this necessary?*/
+ if(ns_stack->stack) /*Is this necessary?*/
{
- for (i = ns_stack->head-1; i>=0; i--)
+ for(i = ns_stack->head - 1; i >= 0; i--)
{
- axis2_char_t *prefix_i = axiom_namespace_get_prefix(
- (ns_stack->stack)[i], ctx->env);
+ axis2_char_t *prefix_i =
axiom_namespace_get_prefix((ns_stack->stack)[i], ctx->env);
- if (axutil_strcmp(prefix_i, prefix) == 0)
+ if(axutil_strcmp(prefix_i, prefix) == 0)
{
- axis2_char_t *uri_i =
axiom_namespace_get_uri((ns_stack->stack)[i],
- ctx->env);
- if (axutil_strcmp(uri_i, uri) == 0)
+ axis2_char_t *uri_i =
axiom_namespace_get_uri((ns_stack->stack)[i], ctx->env);
+ if(axutil_strcmp(uri_i, uri) == 0)
return AXIS2_SUCCESS;
else
return AXIS2_FALSE;
@@ -236,27 +224,21 @@
return AXIS2_FAILURE;
}
-static axis2_status_t
-c14n_ns_stack_find(
+static axis2_status_t c14n_ns_stack_find(
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
- return (c14n_ns_stack_find_with_prefix_uri(
- axiom_namespace_get_prefix((axiom_namespace_t *)ns, ctx->env),
- axiom_namespace_get_uri((axiom_namespace_t *)ns, ctx->env),
ctx)
- );
+ return
(c14n_ns_stack_find_with_prefix_uri(axiom_namespace_get_prefix((axiom_namespace_t
*) ns,
+ ctx->env), axiom_namespace_get_uri((axiom_namespace_t *) ns,
ctx->env), ctx));
}
-static void
-c14n_ns_stack_free(
- c14n_ctx_t *ctx
-)
+static void c14n_ns_stack_free(
+ c14n_ctx_t *ctx)
{
- if (ctx->ns_stack->stack)
+ if(ctx->ns_stack->stack)
{
AXIS2_FREE(ctx->env->allocator, ctx->ns_stack->stack);
- ctx->ns_stack->stack=NULL;
+ ctx->ns_stack->stack = NULL;
}
ctx->ns_stack->stack = NULL;
ctx->ns_stack->head = 0;
@@ -272,120 +254,102 @@
static axis2_status_t
c14n_apply_on_element(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_status_t
c14n_apply_on_namespace_axis(
const axiom_element_t *ele,
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_status_t
c14n_apply_on_namespace_axis_exclusive(
const axiom_element_t *ele,
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_status_t
c14n_apply_on_attribute_axis(
const axiom_element_t *ele,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_status_t
-c14n_apply_on_node (
+c14n_apply_on_node(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static void
-c14n_apply_on_comment (
+c14n_apply_on_comment(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static void
c14n_output(
const axis2_char_t *str,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static int
attr_compare(
const void *a1,
const void *a2,
- const void *context
-);
+ const void *context);
static int
ns_prefix_compare(
const void *ns1,
const void *ns2,
- const void *context
-);
+ const void *context);
static int
ns_uri_compare(
const void *ns1,
const void *ns2,
- const void *context
-);
+ const void *context);
static axis2_char_t*
c14n_normalize_attribute(
axis2_char_t *attval,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_char_t*
c14n_normalize_text(
axis2_char_t *text,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static void
c14n_apply_on_namespace(
const void *ns,
- const void *ctx
-);
+ const void *ctx);
static axis2_bool_t
c14n_need_to_declare_ns(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_bool_t
c14n_ns_visibly_utilized(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axis2_bool_t
c14n_no_output_ancestor_uses_prefix(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static axiom_node_t*
c14n_get_root_node(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-);
+ const c14n_ctx_t *ctx);
static c14n_algo_t
c14n_get_algorithm(
- const axis2_char_t* algo
-);
+ const axis2_char_t* algo);
/*static axis2_bool_t
c14n_in_nodeset(
@@ -396,12 +360,10 @@
/* Implementations */
-static void
-c14n_ctx_free(
- c14n_ctx_t *ctx
-)
+static void c14n_ctx_free(
+ c14n_ctx_t *ctx)
{
- if (ctx)
+ if(ctx)
{
c14n_ns_stack_free(ctx);
}
@@ -419,12 +381,10 @@
const axis2_bool_t exclusive,
const axutil_array_list_t *ns_prefixes,
const axis2_bool_t use_stream,
- const axiom_node_t *node
-)
+ const axiom_node_t *node)
{
- c14n_ctx_t *ctx = (c14n_ctx_t *)(AXIS2_MALLOC(env->allocator,
- sizeof(c14n_ctx_t)));
- if (ctx)
+ c14n_ctx_t *ctx = (c14n_ctx_t *) (AXIS2_MALLOC(env->allocator,
sizeof(c14n_ctx_t)));
+ if(ctx)
{
ctx->env = env;
ctx->doc = doc;
@@ -434,7 +394,7 @@
ctx->ns_prefixes = ns_prefixes;
ctx->use_stream = use_stream;
ctx->node = node;
- if (use_stream)
+ if(use_stream)
ctx->outstream = stream;
/*this should come after ctx->env=env*/
@@ -459,36 +419,33 @@
static axiom_node_t*
c14n_get_root_node(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
const axiom_node_t *parent = NULL;
const axiom_node_t *prv_parent = NULL;
parent = node;
- while (parent)
+ while(parent)
{
prv_parent = parent;
- parent = axiom_node_get_parent((axiom_node_t *)parent, ctx->env);
+ parent = axiom_node_get_parent((axiom_node_t *) parent, ctx->env);
}
- return (axiom_node_t *)prv_parent;
+ return (axiom_node_t *) prv_parent;
}
-static c14n_algo_t
-c14n_get_algorithm(
- const axis2_char_t* algo
-)
+static c14n_algo_t c14n_get_algorithm(
+ const axis2_char_t* algo)
{
- if (axutil_strcmp(algo, OXS_HREF_XML_C14N) == 0)
+ if(axutil_strcmp(algo, OXS_HREF_XML_C14N) == 0)
return C14N_XML_C14N;
- if (axutil_strcmp(algo, OXS_HREF_XML_C14N_WITH_COMMENTS) == 0)
+ if(axutil_strcmp(algo, OXS_HREF_XML_C14N_WITH_COMMENTS) == 0)
return C14N_XML_C14N_WITH_COMMENTS;
- if (axutil_strcmp(algo, OXS_HREF_XML_EXC_C14N) == 0)
+ if(axutil_strcmp(algo, OXS_HREF_XML_EXC_C14N) == 0)
return C14N_XML_EXC_C14N;
- if (axutil_strcmp(algo, OXS_HREF_XML_EXC_C14N_WITH_COMMENTS) == 0)
+ if(axutil_strcmp(algo, OXS_HREF_XML_EXC_C14N_WITH_COMMENTS) == 0)
return C14N_XML_EXC_C14N_WITH_COMMENTS;
return 0; /*c14n_algo_t enum starts with 1*/
@@ -501,26 +458,25 @@
axutil_stream_t *stream,
const axutil_array_list_t *ns_prefixes,
const axiom_node_t *node,
- const axis2_char_t* algo
-)
+ const axis2_char_t* algo)
{
- switch (c14n_get_algorithm(algo))
+ switch(c14n_get_algorithm(algo))
{
- case C14N_XML_C14N:
- return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream,
AXIS2_FALSE,
- ns_prefixes, node);
- case C14N_XML_C14N_WITH_COMMENTS:
- return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream, AXIS2_FALSE,
- ns_prefixes, node);
- case C14N_XML_EXC_C14N:
- return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream, AXIS2_TRUE,
- ns_prefixes, node);
- case C14N_XML_EXC_C14N_WITH_COMMENTS:
- return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream, AXIS2_TRUE,
- ns_prefixes, node);
- default:
- /*TODO: set the error*/
- return AXIS2_FAILURE;
+ case C14N_XML_C14N:
+ return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream,
AXIS2_FALSE, ns_prefixes,
+ node);
+ case C14N_XML_C14N_WITH_COMMENTS:
+ return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream,
AXIS2_FALSE, ns_prefixes,
+ node);
+ case C14N_XML_EXC_C14N:
+ return oxs_c14n_apply_stream(env, doc, AXIS2_FALSE, stream,
AXIS2_TRUE, ns_prefixes,
+ node);
+ case C14N_XML_EXC_C14N_WITH_COMMENTS:
+ return oxs_c14n_apply_stream(env, doc, AXIS2_TRUE, stream,
AXIS2_TRUE, ns_prefixes,
+ node);
+ default:
+ /*TODO: set the error*/
+ return AXIS2_FAILURE;
}
}
@@ -531,26 +487,21 @@
axis2_char_t **outbuf,
const axutil_array_list_t *ns_prefixes,
const axiom_node_t *node,
- const axis2_char_t *algo
-)
+ const axis2_char_t *algo)
{
- switch (c14n_get_algorithm(algo))
+ switch(c14n_get_algorithm(algo))
{
- case C14N_XML_C14N:
- return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_FALSE,
- ns_prefixes, node);
- case C14N_XML_C14N_WITH_COMMENTS:
- return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_FALSE,
- ns_prefixes, node);
- case C14N_XML_EXC_C14N:
- return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_TRUE,
- ns_prefixes, node);
- case C14N_XML_EXC_C14N_WITH_COMMENTS:
- return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_TRUE,
- ns_prefixes, node);
- default:
- /*TODO:set the error*/
- return AXIS2_FAILURE;
+ case C14N_XML_C14N:
+ return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_FALSE,
ns_prefixes, node);
+ case C14N_XML_C14N_WITH_COMMENTS:
+ return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_FALSE,
ns_prefixes, node);
+ case C14N_XML_EXC_C14N:
+ return oxs_c14n_apply(env, doc, AXIS2_FALSE, outbuf, AXIS2_TRUE,
ns_prefixes, node);
+ case C14N_XML_EXC_C14N_WITH_COMMENTS:
+ return oxs_c14n_apply(env, doc, AXIS2_TRUE, outbuf, AXIS2_TRUE,
ns_prefixes, node);
+ default:
+ /*TODO:set the error*/
+ return AXIS2_FAILURE;
}
}
@@ -562,8 +513,7 @@
axutil_stream_t *stream,
const axis2_bool_t exclusive,
const axutil_array_list_t *ns_prefixes,
- const axiom_node_t *node
-)
+ const axiom_node_t *node)
{
c14n_ctx_t *ctx = NULL;
axiom_node_t *root_node = NULL;
@@ -572,21 +522,21 @@
/*axiom_children_iterator_t *child_itr = NULL;*/
axutil_stream_t *outstream = NULL;
- ctx = c14n_init(env, doc, comments, NULL, stream, exclusive, ns_prefixes,
- AXIS2_TRUE, node);
+ ctx = c14n_init(env, doc, comments, NULL, stream, exclusive, ns_prefixes,
AXIS2_TRUE, node);
- if (ctx && ctx->outstream)
+ if(ctx && ctx->outstream)
{
root_node = C14N_GET_ROOT_NODE_FROM_DOC_OR_NODE(doc, node, ctx);
/*root_node = axiom_document_get_root_element((axiom_document_t *)doc,
- ctx->env); */
+ ctx->env); */
/* shouldn't the called method's document be const?*/
root_ele = axiom_node_get_data_element(root_node, env);
- status = c14n_apply_on_node((node ? node : root_node), ctx);
+ status = c14n_apply_on_node((node ? node
+ : root_node), ctx);
- if (!status)
+ if(!status)
{
axutil_stream_free(ctx->outstream, env);
ctx->outstream = NULL;
@@ -612,7 +562,7 @@
{
ns1 = ctx->ns_stack->stack[i];
printf("%s:%s\n", axiom_namespace_get_prefix(ns1, env),
- axiom_namespace_get_uri(ns1, env));
+ axiom_namespace_get_uri(ns1, env));
}
printf("%d\n", ctx->ns_stack->size);
@@ -632,7 +582,7 @@
{
AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- if (ctx)
+ if(ctx)
{
c14n_ctx_free(ctx);
ctx = NULL;
@@ -641,11 +591,6 @@
}
return status;
-
- /*if (status)
- return outstream;
- else
- return NULL;*/
}
@@ -657,26 +602,24 @@
axis2_char_t **outbuf,
const axis2_bool_t exclusive,
const axutil_array_list_t *ns_prefixes,
- const axiom_node_t *node
-)
+ const axiom_node_t *node)
{
axutil_stream_t *stream = axutil_stream_create_basic(env);
- axis2_status_t ret = oxs_c14n_apply_stream(env, doc, comments,
- stream, exclusive, ns_prefixes, node);
+ axis2_status_t ret = oxs_c14n_apply_stream(env, doc, comments, stream,
exclusive, ns_prefixes,
+ node);
*outbuf = NULL;
- if (!ret)
+ if(!ret)
{
return AXIS2_FAILURE;
}
else
{
- int len = axutil_stream_get_len(stream, env)+1;
- if (len>0)
+ int len = axutil_stream_get_len(stream, env) + 1;
+ if(len > 0)
{
- *outbuf = (axis2_char_t *)(AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t)*len));
+ *outbuf = (axis2_char_t *) (AXIS2_MALLOC(env->allocator,
sizeof(axis2_char_t) * len));
axutil_stream_read(stream, env, *outbuf, len);
axutil_stream_free(stream, env);
stream = NULL;
@@ -691,27 +634,25 @@
}
}
-static axis2_status_t
-c14n_apply_on_text (
+static axis2_status_t c14n_apply_on_text(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axiom_text_t *text = NULL;
- text = (axiom_text_t *)axiom_node_get_data_element((axiom_node_t *)node,
- ctx->env);
+ text = (axiom_text_t *) axiom_node_get_data_element((axiom_node_t *) node,
ctx->env);
- if (text)
+ if(text)
{
- axis2_char_t *textval = (axis2_char_t*)axiom_text_get_text(text,
ctx->env);
+ axis2_char_t *textval = (axis2_char_t*) axiom_text_get_text(text,
ctx->env);
- if (textval)
+ if(textval)
textval = c14n_normalize_text(textval, ctx);
- else /*should never occur*/
+ else
+ /*should never occur*/
return AXIS2_FAILURE;
c14n_output(textval, ctx);
- if (textval)
+ if(textval)
{
AXIS2_FREE(ctx->env->allocator, textval);
textval = NULL;
@@ -721,55 +662,48 @@
return AXIS2_SUCCESS;
}
-static axis2_status_t
-c14n_apply_on_node (
+static axis2_status_t c14n_apply_on_node(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
/* printf("%d %d %d\n", axiom_node_get_node_type((axiom_node_t *)node,
ctx->env), AXIOM_COMMENT, AXIOM_ELEMENT); */
- switch (axiom_node_get_node_type((axiom_node_t *)node, ctx->env))
+ switch(axiom_node_get_node_type((axiom_node_t *) node, ctx->env))
{
- case AXIOM_ELEMENT:
- c14n_apply_on_element(node, ctx);
- break;
- case AXIOM_TEXT:
- c14n_apply_on_text(node, ctx);
- break;
- case AXIOM_COMMENT:
- if (ctx->comments)
- {
- c14n_apply_on_comment(node, ctx);
+ case AXIOM_ELEMENT:
+ c14n_apply_on_element(node, ctx);
break;
- }
- case AXIOM_DOCTYPE:
- case AXIOM_PROCESSING_INSTRUCTION:
- default:
- ;
+ case AXIOM_TEXT:
+ c14n_apply_on_text(node, ctx);
+ break;
+ case AXIOM_COMMENT:
+ if(ctx->comments)
+ {
+ c14n_apply_on_comment(node, ctx);
+ break;
+ }
+ case AXIOM_DOCTYPE:
+ case AXIOM_PROCESSING_INSTRUCTION:
+ default:
+ ;
}
return AXIS2_SUCCESS;
}
-static void
-c14n_apply_on_comment (
+static void c14n_apply_on_comment(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
/*TODO: HACK*/
c14n_output("<!--", ctx);
- c14n_output(axiom_comment_get_value(
- (axiom_comment_t*)axiom_node_get_data_element(
- (axiom_node_t*)node, ctx->env),ctx->env), ctx);
+ c14n_output(axiom_comment_get_value((axiom_comment_t*)
axiom_node_get_data_element(
+ (axiom_node_t*) node, ctx->env), ctx->env), ctx);
c14n_output("-->", ctx);
}
-static axis2_status_t
-c14n_apply_on_element(
+static axis2_status_t c14n_apply_on_element(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axis2_status_t res = AXIS2_SUCCESS;
axiom_element_t *ele = NULL;
@@ -778,12 +712,12 @@
c14n_ns_stack_t *save_stack = NULL;
axiom_node_t *child_node = NULL;
- ele = (axiom_element_t *)axiom_node_get_data_element((axiom_node_t *)node,
- ctx->env);
+ ele = (axiom_element_t *) axiom_node_get_data_element((axiom_node_t *)
node, ctx->env);
- if (!ele) return AXIS2_FAILURE; /*should it be failure?*/
+ if(!ele)
+ return AXIS2_FAILURE; /*should it be failure?*/
- ns = axiom_element_get_namespace(ele, ctx->env, (axiom_node_t *)node);
+ ns = axiom_element_get_namespace(ele, ctx->env, (axiom_node_t *) node);
save_stack = c14n_ns_stack_create(ctx);
c14n_ns_stack_push(save_stack, ctx); /*save current ns stack*/
@@ -791,11 +725,11 @@
/*print qname*/
c14n_output("<", ctx);
- if (ns)
+ if(ns)
{
axis2_char_t *prefix = axiom_namespace_get_prefix(ns, ctx->env);
- if (axutil_strlen(prefix) > 0)
+ if(axutil_strlen(prefix) > 0)
{
c14n_output(prefix, ctx);
c14n_output(":", ctx);
@@ -803,7 +737,7 @@
}
c14n_output(axiom_element_get_localname(ele, ctx->env), ctx);
- if (ctx->exclusive)
+ if(ctx->exclusive)
res = c14n_apply_on_namespace_axis_exclusive(ele, node, ctx);
else
res = c14n_apply_on_namespace_axis(ele, node, ctx);
@@ -813,11 +747,13 @@
* have to be careful here!
*/
- if (!res) return res;
+ if(!res)
+ return res;
res = c14n_apply_on_attribute_axis(ele, ctx);
- if (!res) return res;
+ if(!res)
+ return res;
c14n_output(">", ctx);
@@ -827,9 +763,9 @@
/*process child elements*/
- child_node = axiom_node_get_first_child((axiom_node_t *)node, ctx->env);
+ child_node = axiom_node_get_first_child((axiom_node_t *) node, ctx->env);
- while (child_node)
+ while(child_node)
{
c14n_apply_on_node(child_node, ctx);
child_node = axiom_node_get_next_sibling(child_node, ctx->env);
@@ -838,30 +774,29 @@
/*process child elements*/
/*child_itr = AXIOM_ELEMENT_GET_CHILDREN(ele, ctx->env,
(axiom_node_t*)node);
- if (child_itr)
- {
-
- while(axiom_children_iterator_has_next(child_itr, ctx->env))
- {
- axiom_node_t *child_node = NULL;
- child_node = axiom_children_iterator_next(child_itr, ctx->env);
-
- if (child_node)
- {
- c14n_apply_on_node(child_node, ctx);
- }
- }
- }*/
+ if (child_itr)
+ {
+ while(axiom_children_iterator_has_next(child_itr, ctx->env))
+ {
+ axiom_node_t *child_node = NULL;
+ child_node = axiom_children_iterator_next(child_itr, ctx->env);
+
+ if (child_node)
+ {
+ c14n_apply_on_node(child_node, ctx);
+ }
+ }
+ }*/
/*print qname*/
c14n_output("</", ctx);
- if (ns)
+ if(ns)
{
axis2_char_t *prefix = axiom_namespace_get_prefix(ns, ctx->env);
- if (axutil_strlen(prefix) > 0)
+ if(axutil_strlen(prefix) > 0)
{
c14n_output(prefix, ctx);
c14n_output(":", ctx);
@@ -887,101 +822,93 @@
return res;
}
-static int
-ns_uri_compare(
+static int ns_uri_compare(
const void *ns1,
const void *ns2,
- const void *context
-)
+ const void *context)
{
- c14n_ctx_t *ctx = (c14n_ctx_t *)context;
+ c14n_ctx_t *ctx = (c14n_ctx_t *) context;
- if (ns1 == ns2) return 0;
- if (!ns1) return -1;
- if (!ns2) return 1;
-
- return (axutil_strcmp(
- (const axis2_char_t *)axiom_namespace_get_uri(
- (axiom_namespace_t *)ns1, ctx->env),
- (const axis2_char_t *)axiom_namespace_get_uri(
- (axiom_namespace_t *)ns2, ctx->env)));
+ if(ns1 == ns2)
+ return 0;
+ if(!ns1)
+ return -1;
+ if(!ns2)
+ return 1;
+
+ return (axutil_strcmp((const axis2_char_t *)
axiom_namespace_get_uri((axiom_namespace_t *) ns1,
+ ctx->env), (const axis2_char_t *)
axiom_namespace_get_uri((axiom_namespace_t *) ns2,
+ ctx->env)));
}
-static int
-ns_prefix_compare(
+static int ns_prefix_compare(
const void *ns1,
const void *ns2,
- const void *context
-)
+ const void *context)
{
- c14n_ctx_t *ctx = (c14n_ctx_t *)context;
+ c14n_ctx_t *ctx = (c14n_ctx_t *) context;
- if (ns1 == ns2) return 0;
- if (!ns1) return -1;
- if (!ns2) return 1;
-
- return (axutil_strcmp(
- (const axis2_char_t *)axiom_namespace_get_prefix(
- (axiom_namespace_t *)ns1, ctx->env),
- (const axis2_char_t *)axiom_namespace_get_prefix(
- (axiom_namespace_t *)ns2, ctx->env)));
+ if(ns1 == ns2)
+ return 0;
+ if(!ns1)
+ return -1;
+ if(!ns2)
+ return 1;
+
+ return (axutil_strcmp((const axis2_char_t *) axiom_namespace_get_prefix(
+ (axiom_namespace_t *) ns1, ctx->env), (const axis2_char_t *)
axiom_namespace_get_prefix(
+ (axiom_namespace_t *) ns2, ctx->env)));
}
-static int
-attr_compare(
+static int attr_compare(
const void *a1,
const void *a2,
- const void *context
-)
+ const void *context)
{
- c14n_ctx_t *ctx = (c14n_ctx_t *)context;
+ c14n_ctx_t *ctx = (c14n_ctx_t *) context;
axiom_attribute_t *attr1 = NULL;
axiom_attribute_t *attr2 = NULL;
axiom_namespace_t *ns1 = NULL;
axiom_namespace_t *ns2 = NULL;
int res;
- if (a1 == a2) return 0;
- if (!a1) return -1;
- if (!a2) return 1;
-
- attr1 = (axiom_attribute_t *)a1;
- attr2 = (axiom_attribute_t *)a2;
- ns1 = axiom_attribute_get_namespace((axiom_attribute_t *)a1, ctx->env);
- ns2 = axiom_attribute_get_namespace((axiom_attribute_t *)a2, ctx->env);
+ if(a1 == a2)
+ return 0;
+ if(!a1)
+ return -1;
+ if(!a2)
+ return 1;
+
+ attr1 = (axiom_attribute_t *) a1;
+ attr2 = (axiom_attribute_t *) a2;
+ ns1 = axiom_attribute_get_namespace((axiom_attribute_t *) a1, ctx->env);
+ ns2 = axiom_attribute_get_namespace((axiom_attribute_t *) a2, ctx->env);
- if (ns1 == ns2)
+ if(ns1 == ns2)
return axutil_strcmp(
- (const axis2_char_t *)axiom_attribute_get_localname(
- (axiom_attribute_t *)a1, ctx->env),
- (const axis2_char_t *)axiom_attribute_get_localname(
- (axiom_attribute_t *)a2, ctx->env));
-
- if (!ns1) return -1;
- if (!ns2) return 1;
-
- res = axutil_strcmp(
- axiom_namespace_get_uri(ns1, ctx->env),
- axiom_namespace_get_uri(ns2, ctx->env));
+ (const axis2_char_t *)
axiom_attribute_get_localname((axiom_attribute_t *) a1, ctx->env),
+ (const axis2_char_t *)
axiom_attribute_get_localname((axiom_attribute_t *) a2, ctx->env));
+
+ if(!ns1)
+ return -1;
+ if(!ns2)
+ return 1;
- if (res == 0)
+ res = axutil_strcmp(axiom_namespace_get_uri(ns1, ctx->env),
axiom_namespace_get_uri(ns2,
+ ctx->env));
+
+ if(res == 0)
return axutil_strcmp(
- (const axis2_char_t *)axiom_attribute_get_localname(
- (axiom_attribute_t *)a1, ctx->env),
- (const axis2_char_t *)axiom_attribute_get_localname(
- (axiom_attribute_t *)a2, ctx->env));
+ (const axis2_char_t *)
axiom_attribute_get_localname((axiom_attribute_t *) a1, ctx->env),
+ (const axis2_char_t *)
axiom_attribute_get_localname((axiom_attribute_t *) a2, ctx->env));
else
return res;
}
-
-
-static void
-c14n_apply_on_attribute(
+static void c14n_apply_on_attribute(
const void *attribute,
- const void *context
-)
+ const void *context)
{
c14n_ctx_t *ctx = (c14n_ctx_t *) context;
axiom_attribute_t *attr = (axiom_attribute_t *) attribute;
@@ -989,11 +916,11 @@
axis2_char_t *attvalue = NULL;
c14n_output(" ", ctx);
- if (ns)
+ if(ns)
{
axis2_char_t *prefix = axiom_namespace_get_prefix(ns, ctx->env);
- if (axutil_strlen(prefix) > 0)
+ if(axutil_strlen(prefix) > 0)
{
c14n_output(prefix, ctx);
c14n_output(":", ctx);
@@ -1004,49 +931,43 @@
/* TODO:DONE Normalize the text before output */
attvalue = axiom_attribute_get_value(attr, ctx->env);
- attvalue = c14n_normalize_attribute(attvalue, (c14n_ctx_t const *)context);
+ attvalue = c14n_normalize_attribute(attvalue, (c14n_ctx_t const *)
context);
c14n_output(attvalue, ctx);
c14n_output("\"", ctx);
- if (attvalue)
+ if(attvalue)
{
AXIS2_FREE(ctx->env->allocator, attvalue);
attvalue = NULL;
}
}
-static axis2_status_t
-c14n_apply_on_attribute_axis(
+static axis2_status_t c14n_apply_on_attribute_axis(
const axiom_element_t *ele,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axutil_hash_t *attr_ht = NULL;
axutil_hash_index_t *hi = NULL;
c14n_sorted_list_t *attr_list = c14n_sorted_list_create(ctx->env);
- attr_ht = axiom_element_get_all_attributes((axiom_element_t *)ele,
- ctx->env);
+ attr_ht = axiom_element_get_all_attributes((axiom_element_t *) ele,
ctx->env);
if(attr_ht)
{
- for (hi = axutil_hash_first(attr_ht, ctx->env); hi;
- hi = axutil_hash_next(ctx->env, hi))
+ for(hi = axutil_hash_first(attr_ht, ctx->env); hi; hi =
axutil_hash_next(ctx->env, hi))
{
void *v = NULL;
axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
+ if(v)
{
- C14N_SORTED_LIST_INSERT(&attr_list, v, ctx, attr_compare,
- ctx->env);
+ C14N_SORTED_LIST_INSERT(&attr_list, v, ctx, attr_compare,
ctx->env);
}
}
- C14N_SORTED_LIST_ITERATE(attr_list, ctx, c14n_apply_on_attribute,
- ctx->env);
+ C14N_SORTED_LIST_ITERATE(attr_list, ctx, c14n_apply_on_attribute,
ctx->env);
}
/*TODO:DONE C14N_SORTED_LIST_FREE();*/
@@ -1074,11 +995,11 @@
/* TODO:DONE a better buffer implementation */
buf = (axis2_char_t *)(AXIS2_MALLOC(ctx->env->allocator,
- (sizeof(axis2_char_t) * bufsz) + 10));
+ (sizeof(axis2_char_t) * bufsz) + 10));
if (!buf)
{
AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
return buf;
}
@@ -1093,12 +1014,12 @@
{
int size = bufsz * 2;
axis2_char_t *temp_buf = (axis2_char_t *)(AXIS2_MALLOC(
- ctx->env->allocator,
sizeof(axis2_char_t) * size + 10));
+ ctx->env->allocator, sizeof(axis2_char_t) * size + 10));
if (!temp_buf)
{
AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_FAILURE);
return buf;
}
@@ -1114,33 +1035,33 @@
switch (*old)
{
- case '&':
+ case '&':
*p++ = '&';
*p++ = 'a';
*p++ = 'm';
*p++ = 'p';
*p++ = ';';
break;
- case '>':
+ case '>':
*p++ = '&';
*p++ = 'g';
*p++ = 't';
*p++ = ';';
break;
- case '<':
+ case '<':
*p++ = '&';
*p++ = 'l';
*p++ = 't';
*p++ = ';';
break;
- case '\x0D':
+ case '\x0D':
*p++ = '&';
*p++ = '#';
*p++ = 'x';
*p++ = 'D';
*p++ = ';';
break;
- default:
+ default:
*p++ = *old;
}
old ++;
@@ -1170,7 +1091,7 @@
if(bufsz < original_size * 1.5)
bufsz = original_size * 1.5;
- buf = (axis2_char_t *)AXIS2_MALLOC(ctx->env->allocator,
(sizeof(axis2_char_t) * bufsz));
+ buf = (axis2_char_t *) AXIS2_MALLOC(ctx->env->allocator,
(sizeof(axis2_char_t) * bufsz));
if(!buf)
{
AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -1182,7 +1103,7 @@
size_t i = 0;
/* scan buffer until the next special character (&, <, >, \x0D) these
need to be escaped,
* otherwise XML will not be valid*/
- axis2_char_t *pos = (axis2_char_t*)strpbrk(text, "&<>\x0D");
+ axis2_char_t *pos = (axis2_char_t*) strpbrk(text, "&<>\x0D");
if(pos)
{
i = pos - text;
@@ -1203,8 +1124,8 @@
axis2_char_t *temp_buf = NULL;
bufsz *= 2;
- temp_buf = (axis2_char_t *)AXIS2_MALLOC(ctx->env->allocator,
- sizeof(axis2_char_t) * bufsz);
+ temp_buf = (axis2_char_t *) AXIS2_MALLOC(ctx->env->allocator,
sizeof(axis2_char_t)
+ * bufsz);
if(!temp_buf)
{
AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
AXIS2_FAILURE);
@@ -1269,8 +1190,7 @@
static axis2_char_t*
c14n_normalize_attribute(
axis2_char_t *attval,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axis2_char_t *buf = NULL;
axis2_char_t *endpivot = NULL;
@@ -1279,12 +1199,11 @@
int bufsz = INIT_BUFFER_SIZE;
/* TODO:DONE a better buffer implementation */
- buf = (axis2_char_t *)(AXIS2_MALLOC(ctx->env->allocator,
- sizeof(axis2_char_t) *
INIT_BUFFER_SIZE + 10));
- if (!buf)
+ buf = (axis2_char_t *) (AXIS2_MALLOC(ctx->env->allocator,
sizeof(axis2_char_t)
+ * INIT_BUFFER_SIZE + 10));
+ if(!buf)
{
- AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
return buf;
}
@@ -1293,18 +1212,17 @@
old = attval;
- while (*old !='\0')
+ while(*old != '\0')
{
- if (p > endpivot)
+ if(p > endpivot)
{
int size = bufsz * 2;
- axis2_char_t *temp_buf = (axis2_char_t *)(AXIS2_MALLOC(
- ctx->env->allocator,
sizeof(axis2_char_t) * size + 10));
+ axis2_char_t *temp_buf = (axis2_char_t *)
(AXIS2_MALLOC(ctx->env->allocator,
+ sizeof(axis2_char_t) * size + 10));
- if (!temp_buf)
+ if(!temp_buf)
{
- AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
- AXIS2_FAILURE);
+ AXIS2_ERROR_SET(ctx->env->error, AXIS2_ERROR_NO_MEMORY,
AXIS2_FAILURE);
return buf;
}
@@ -1318,129 +1236,123 @@
endpivot = buf + bufsz;
}
- switch (*old)
+ switch(*old)
{
- case '&':
- *p++ = '&';
- *p++ = 'a';
- *p++ = 'm';
- *p++ = 'p';
- *p++ = ';';
- break;
- case '<':
- *p++ = '&';
- *p++ = 'l';
- *p++ = 't';
- *p++ = ';';
- break;
- case '"':
- *p++ = '&';
- *p++ = 'q';
- *p++ = 'u';
- *p++ = 'o';
- *p++ = 't';
- *p++ = ';';
- break;
- case '\x09':
- *p++ = '&';
- *p++ = '#';
- *p++ = 'x';
- *p++ = '9';
- *p++ = ';';
- break;
- case '\x0A':
- *p++ = '&';
- *p++ = '#';
- *p++ = 'x';
- *p++ = 'A';
- *p++ = ';';
- break;
- case '\x0D':
- *p++ = '&';
- *p++ = '#';
- *p++ = 'x';
- *p++ = 'D';
- *p++ = ';';
- break;
- default:
- *p++ = *old;
+ case '&':
+ *p++ = '&';
+ *p++ = 'a';
+ *p++ = 'm';
+ *p++ = 'p';
+ *p++ = ';';
+ break;
+ case '<':
+ *p++ = '&';
+ *p++ = 'l';
+ *p++ = 't';
+ *p++ = ';';
+ break;
+ case '"':
+ *p++ = '&';
+ *p++ = 'q';
+ *p++ = 'u';
+ *p++ = 'o';
+ *p++ = 't';
+ *p++ = ';';
+ break;
+ case '\x09':
+ *p++ = '&';
+ *p++ = '#';
+ *p++ = 'x';
+ *p++ = '9';
+ *p++ = ';';
+ break;
+ case '\x0A':
+ *p++ = '&';
+ *p++ = '#';
+ *p++ = 'x';
+ *p++ = 'A';
+ *p++ = ';';
+ break;
+ case '\x0D':
+ *p++ = '&';
+ *p++ = '#';
+ *p++ = 'x';
+ *p++ = 'D';
+ *p++ = ';';
+ break;
+ default:
+ *p++ = *old;
}
- old ++;
+ old++;
}
*p++ = '\0';
return buf;
}
-
-static axis2_status_t
-c14n_apply_on_namespace_axis(
+static axis2_status_t c14n_apply_on_namespace_axis(
const axiom_element_t *ele,
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axutil_hash_t *ns_ht = NULL;
axutil_hash_index_t *hi = NULL;
c14n_sorted_list_t *out_list = c14n_sorted_list_create(ctx->env);
-
- ns_ht = axiom_element_get_namespaces((axiom_element_t *)ele, ctx->env);
+ ns_ht = axiom_element_get_namespaces((axiom_element_t *) ele, ctx->env);
if(ns_ht)
{
- for (hi = axutil_hash_first(ns_ht, ctx->env); hi;
- hi = axutil_hash_next(ctx->env, hi))
+ for(hi = axutil_hash_first(ns_ht, ctx->env); hi; hi =
axutil_hash_next(ctx->env, hi))
{
void *v = NULL;
axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
+ if(v)
{
axiom_namespace_t *ns = (axiom_namespace_t *) v;
axis2_char_t *pfx = axiom_namespace_get_prefix(ns, ctx->env);
axis2_char_t *uri = axiom_namespace_get_uri(ns, ctx->env);
- if (axutil_strlen(pfx) == 0)
+ if(axutil_strlen(pfx) == 0)
{
/*process for default namespace*/
/*int nsc =
ns_prefix_compare(c14n_ns_stack_get_default(ctx), ns, ctx);
- int len = axutil_strlen(uri);*/
+ int len = axutil_strlen(uri);*/
- if (axutil_strlen(uri) == 0)
+ if(axutil_strlen(uri) == 0)
{
- if (c14n_ns_stack_get_default(ctx)!=NULL)
+ if(c14n_ns_stack_get_default(ctx) != NULL)
{
c14n_ns_stack_set_default(ns, ctx);
- C14N_SORTED_LIST_INSERT(&out_list, (void *)ns, ctx,
- ns_prefix_compare,
ctx->env);
+ C14N_SORTED_LIST_INSERT(&out_list, (void *) ns,
ctx, ns_prefix_compare,
+ ctx->env);
}
}
else
{
- axiom_namespace_t *prev_def =
- c14n_ns_stack_get_default(ctx);
+ axiom_namespace_t *prev_def =
c14n_ns_stack_get_default(ctx);
- axis2_char_t *prev_def_uri = ((prev_def) ?
-
axiom_namespace_get_uri(prev_def, ctx->env) : NULL);
+ axis2_char_t *prev_def_uri = ((prev_def) ?
axiom_namespace_get_uri(
+ prev_def, ctx->env)
+ : NULL);
-
- if (!prev_def_uri || axutil_strcmp(prev_def_uri, uri)
!= 0)
+ if(!prev_def_uri || axutil_strcmp(prev_def_uri, uri)
!= 0)
{
c14n_ns_stack_set_default(ns, ctx);
- C14N_SORTED_LIST_INSERT(&out_list, (void *)ns, ctx,
- ns_prefix_compare,
ctx->env);
+ C14N_SORTED_LIST_INSERT(&out_list, (void *) ns,
ctx, ns_prefix_compare,
+ ctx->env);
}
}
}
- else if (!c14n_ns_stack_find(ns, ctx))
+ else if(!c14n_ns_stack_find(ns, ctx))
{
/*non-default namespace*/
c14n_ns_stack_add(ns, ctx);
- C14N_SORTED_LIST_INSERT(&out_list, (void *)ns, ctx,
- ns_prefix_compare, ctx->env);
+ C14N_SORTED_LIST_INSERT(&out_list, (void *) ns, ctx,
ns_prefix_compare,
+ ctx->env);
}
}
}
@@ -1454,12 +1366,10 @@
return AXIS2_SUCCESS;
}
-static axis2_status_t
-c14n_apply_on_namespace_axis_exclusive(
+static axis2_status_t c14n_apply_on_namespace_axis_exclusive(
const axiom_element_t *ele,
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axutil_hash_t *ns_ht = NULL;
axutil_hash_index_t *hi = NULL;
@@ -1469,47 +1379,44 @@
c14n_sorted_list_t *out_list = c14n_sorted_list_create(ctx->env);
- pele = (axiom_element_t *)ele;
- pnode = (axiom_node_t *)node;
+ pele = (axiom_element_t *) ele;
+ pnode = (axiom_node_t *) node;
/*treat the default namespace specially*/
- ns = axiom_element_get_namespace(pele, ctx->env,
- pnode);
+ ns = axiom_element_get_namespace(pele, ctx->env, pnode);
- if (ns)
+ if(ns)
{
- if (axutil_strlen(axiom_namespace_get_prefix((axiom_namespace_t *)ns,
- ctx->env)) == 0)
+ if(axutil_strlen(axiom_namespace_get_prefix((axiom_namespace_t *) ns,
ctx->env)) == 0)
{
axiom_namespace_t *def_ns = c14n_ns_stack_get_default(ctx);
- if (def_ns || axutil_strlen(axiom_namespace_get_uri(
- (axiom_namespace_t *)ns,
ctx->env)) != 0)
+ if(def_ns ||
axutil_strlen(axiom_namespace_get_uri((axiom_namespace_t *) ns, ctx->env))
+ != 0)
{
- if (ns_uri_compare(ns, def_ns, ctx) != 0)
+ if(ns_uri_compare(ns, def_ns, ctx) != 0)
{
c14n_ns_stack_set_default(ns, ctx);
- C14N_SORTED_LIST_INSERT(&out_list, (void *)ns,
- ctx, ns_prefix_compare, ctx->env);
+ C14N_SORTED_LIST_INSERT(&out_list, (void *) ns, ctx,
ns_prefix_compare,
+ ctx->env);
}
}
}
}
- while (pnode)
+ while(pnode)
{
- pele = axiom_node_get_data_element((axiom_node_t *)pnode, ctx->env);
- ns_ht = axiom_element_get_namespaces((axiom_element_t *)pele,
ctx->env);
+ pele = axiom_node_get_data_element((axiom_node_t *) pnode, ctx->env);
+ ns_ht = axiom_element_get_namespaces((axiom_element_t *) pele,
ctx->env);
- if (ns_ht)
+ if(ns_ht)
{
- for (hi = axutil_hash_first(ns_ht, ctx->env); hi;
- hi = axutil_hash_next(ctx->env, hi))
+ for(hi = axutil_hash_first(ns_ht, ctx->env); hi; hi =
axutil_hash_next(ctx->env, hi))
{
void *v = NULL;
axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
+ if(v)
{
axis2_char_t *pfx = NULL;
ns = (axiom_namespace_t *) v;
@@ -1517,29 +1424,29 @@
pfx = axiom_namespace_get_prefix(ns, ctx->env);
/*axis2_char_t *uri = axiom_namespace_get_uri(ns,
ctx->env);*/
- if (axutil_strlen(pfx) == 0)
+ if(axutil_strlen(pfx) == 0)
{
/* process for default namespace.
* NOTE: This part was taken out of here due to the
* search thruogh parent-axis
* */
}
- else if (!c14n_ns_stack_find(ns, ctx))
+ else if(!c14n_ns_stack_find(ns, ctx))
{
/*non-default namespace*/
- if (c14n_need_to_declare_ns(ele, node, ns, ctx))
+ if(c14n_need_to_declare_ns(ele, node, ns, ctx))
{
c14n_ns_stack_add(ns, ctx);
- C14N_SORTED_LIST_INSERT(&out_list, (void *)ns, ctx,
- ns_prefix_compare,
ctx->env);
+ C14N_SORTED_LIST_INSERT(&out_list, (void *) ns,
ctx, ns_prefix_compare,
+ ctx->env);
}
}
}
}
}
- pnode = axiom_node_get_parent((axiom_node_t *)pnode, ctx->env);
+ pnode = axiom_node_get_parent((axiom_node_t *) pnode, ctx->env);
} /*while*/
- C14N_SORTED_LIST_ITERATE(out_list, ctx, c14n_apply_on_namespace ,
ctx->env);
+ C14N_SORTED_LIST_ITERATE(out_list, ctx, c14n_apply_on_namespace, ctx->env);
C14N_SORTED_LIST_FREE_CONTAINER(out_list, ctx->env);
@@ -1547,23 +1454,21 @@
return AXIS2_SUCCESS;
}
-static void
-c14n_apply_on_namespace(
+static void c14n_apply_on_namespace(
const void *namespace,
- const void *context
-)
+ const void *context)
{
- axiom_namespace_t *ns = (axiom_namespace_t *)namespace;
- c14n_ctx_t *ctx = (c14n_ctx_t *)context;
+ axiom_namespace_t *ns = (axiom_namespace_t *) namespace;
+ c14n_ctx_t *ctx = (c14n_ctx_t *) context;
axis2_char_t *pfx = axiom_namespace_get_prefix(ns, ctx->env);
axis2_char_t *uri = axiom_namespace_get_uri(ns, ctx->env);
/*c14n_output(" *", ctx);
- c14n_output(axiom_namespace_to_string(ns, ctx->env), ctx);
- c14n_output("*", ctx);*/
+ c14n_output(axiom_namespace_to_string(ns, ctx->env), ctx);
+ c14n_output("*", ctx);*/
- if (axutil_strlen(pfx) > 0)
+ if(axutil_strlen(pfx) > 0)
{
c14n_output(" xmlns:", ctx);
c14n_output(pfx, ctx);
@@ -1573,105 +1478,92 @@
c14n_output("=\"", ctx);
- if (axutil_strlen(uri) > 0)
+ if(axutil_strlen(uri) > 0)
c14n_output(uri, ctx);
c14n_output("\"", ctx);
}
-static void
-c14n_output(
+static void c14n_output(
const axis2_char_t *str,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
#ifdef C14N_DEBUG
printf("%s", str);
#else
- if (ctx->use_stream)
+ if(ctx->use_stream)
{
- axutil_stream_write(ctx->outstream, ctx->env, str,
- axutil_strlen(str)*sizeof(axis2_char_t));
+ axutil_stream_write(ctx->outstream, ctx->env, str, axutil_strlen(str)
+ * sizeof(axis2_char_t));
}
#endif
}
-static axis2_bool_t
-c14n_need_to_declare_ns(
+static axis2_bool_t c14n_need_to_declare_ns(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axis2_bool_t vu = c14n_ns_visibly_utilized(ele, node, ns, ctx);
- if (vu || (ctx->ns_prefixes && axutil_array_list_contains(
- (axutil_array_list_t*)(ctx->ns_prefixes), ctx->env,
- (void*)(axiom_namespace_get_prefix((axiom_namespace_t*)ns,
- ctx->env)))))
+ if(vu || (ctx->ns_prefixes && axutil_array_list_contains(
+ (axutil_array_list_t*) (ctx->ns_prefixes), ctx->env, (void*)
(axiom_namespace_get_prefix(
+ (axiom_namespace_t*) ns, ctx->env)))))
return c14n_no_output_ancestor_uses_prefix(ele, node, ns, ctx);
return AXIS2_FALSE;
}
-static axis2_bool_t
-c14n_ns_visibly_utilized(
+static axis2_bool_t c14n_ns_visibly_utilized(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axis2_bool_t vu = AXIS2_FALSE;
axiom_namespace_t *ns_ele = NULL;
- axis2_char_t *pfx = axiom_namespace_get_prefix((axiom_namespace_t*)ns,
- ctx->env);
- axis2_char_t *uri = axiom_namespace_get_uri((axiom_namespace_t *)ns,
- ctx->env);
+ axis2_char_t *pfx = axiom_namespace_get_prefix((axiom_namespace_t*) ns,
ctx->env);
+ axis2_char_t *uri = axiom_namespace_get_uri((axiom_namespace_t *) ns,
ctx->env);
axis2_char_t *pfx_ele = NULL;
axis2_char_t *uri_ele = NULL;
- ns_ele = axiom_element_get_namespace((axiom_element_t*)ele, ctx->env,
- (axiom_node_t *)node);
+ ns_ele = axiom_element_get_namespace((axiom_element_t*) ele, ctx->env,
(axiom_node_t *) node);
- if (ns_ele) /* return AXIS2_FALSE; TODO:check */
+ if(ns_ele) /* return AXIS2_FALSE; TODO:check */
{
pfx_ele = axiom_namespace_get_prefix(ns_ele, ctx->env);
uri_ele = axiom_namespace_get_uri(ns_ele, ctx->env);
}
- if ((axutil_strcmp(pfx, pfx_ele) == 0) && (axutil_strcmp(uri, uri_ele) ==
0))
+ if((axutil_strcmp(pfx, pfx_ele) == 0) && (axutil_strcmp(uri, uri_ele) ==
0))
vu = AXIS2_TRUE;
else
{
- axutil_hash_t *attr_ht = axiom_element_get_all_attributes(
- (axiom_element_t *)ele, ctx->env);
+ axutil_hash_t *attr_ht =
+ axiom_element_get_all_attributes((axiom_element_t *) ele,
ctx->env);
axutil_hash_index_t *hi = NULL;
- if (attr_ht)
+ if(attr_ht)
{
- for (hi = axutil_hash_first(attr_ht, ctx->env); hi;
- hi = axutil_hash_next(ctx->env, hi))
+ for(hi = axutil_hash_first(attr_ht, ctx->env); hi; hi =
axutil_hash_next(ctx->env, hi))
{
void *v = NULL;
axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
+ if(v)
{
- axiom_attribute_t *attr = (axiom_attribute_t*)v;
- axiom_namespace_t *ns_attr = axiom_attribute_get_namespace(
- attr, ctx->env);
+ axiom_attribute_t *attr = (axiom_attribute_t*) v;
+ axiom_namespace_t *ns_attr =
axiom_attribute_get_namespace(attr, ctx->env);
axis2_char_t *attr_pfx = NULL;
/*if in_nodelist(attr) {*/
- if (ns_attr)
- attr_pfx = axiom_namespace_get_prefix(
- ns_attr, ctx->env);
+ if(ns_attr)
+ attr_pfx = axiom_namespace_get_prefix(ns_attr,
ctx->env);
- if (axutil_strcmp(attr_pfx, pfx) == 0)
+ if(axutil_strcmp(attr_pfx, pfx) == 0)
{
vu = AXIS2_TRUE;
- if (ctx->env)
-
AXIS2_FREE(ctx->env->allocator, hi);
+ if(ctx->env)
+ AXIS2_FREE(ctx->env->allocator, hi);
break;
}
/*}*/
@@ -1684,46 +1576,40 @@
return vu;
}
-static axis2_bool_t
-in_nodeset(
+static axis2_bool_t in_nodeset(
const axiom_node_t *node,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
axiom_node_t *pnode = NULL;
- pnode = axiom_node_get_parent((axiom_node_t *)node, ctx->env);
+ pnode = axiom_node_get_parent((axiom_node_t *) node, ctx->env);
- while (pnode)
+ while(pnode)
{
- if (ctx->node == pnode) return AXIS2_TRUE;
- pnode = axiom_node_get_parent((axiom_node_t *)pnode, ctx->env);
+ if(ctx->node == pnode)
+ return AXIS2_TRUE;
+ pnode = axiom_node_get_parent((axiom_node_t *) pnode, ctx->env);
}
return AXIS2_FALSE;
}
-static axis2_bool_t
-c14n_no_output_ancestor_uses_prefix(
+static axis2_bool_t c14n_no_output_ancestor_uses_prefix(
const axiom_element_t *ele,
const axiom_node_t *node,
const axiom_namespace_t *ns,
- const c14n_ctx_t *ctx
-)
+ const c14n_ctx_t *ctx)
{
- axis2_char_t *pfx = axiom_namespace_get_prefix((axiom_namespace_t*)ns,
- ctx->env);
- axis2_char_t *uri = axiom_namespace_get_uri((axiom_namespace_t *)ns,
- ctx->env);
+ axis2_char_t *pfx = axiom_namespace_get_prefix((axiom_namespace_t*) ns,
ctx->env);
+ axis2_char_t *uri = axiom_namespace_get_uri((axiom_namespace_t *) ns,
ctx->env);
- axiom_node_t *parent_node = axiom_node_get_parent((axiom_node_t *)node,
- ctx->env);
+ axiom_node_t *parent_node = axiom_node_get_parent((axiom_node_t *) node,
ctx->env);
axiom_element_t *parent_element = NULL;
axiom_namespace_t *parent_ns = NULL;
axis2_char_t *parent_pfx = NULL;
axis2_char_t *parent_uri = NULL;
/* assuming the parent of an element is always an element node in AXIOM*/
- while (parent_node)
+ while(parent_node)
{
axutil_hash_index_t *hi = NULL;
axutil_hash_t *attr_ht = NULL;
@@ -1733,7 +1619,7 @@
* the following hack should work instead of a more
* general in_nodest()*/
- if (!in_nodeset(parent_node, ctx))
+ if(!in_nodeset(parent_node, ctx))
{
/*we reached a node beyond the nodeset,
* so the prefix is not used*/
@@ -1741,49 +1627,41 @@
}
/* if (in_nodeset(parent)){*/
- parent_element = axiom_node_get_data_element(
- (axiom_node_t *)parent_node, ctx->env);
- parent_ns = axiom_element_get_namespace((axiom_element_t *)
- parent_element, ctx->env,
(axiom_node_t *)parent_node);
-
- if (parent_ns)
- {
- parent_pfx = axiom_namespace_get_prefix((axiom_namespace_t
*)parent_ns,
- ctx->env);
- if (axutil_strcmp(pfx, parent_pfx) == 0)
+ parent_element = axiom_node_get_data_element((axiom_node_t *)
parent_node, ctx->env);
+ parent_ns = axiom_element_get_namespace((axiom_element_t *)
parent_element, ctx->env,
+ (axiom_node_t *) parent_node);
+
+ if(parent_ns)
+ {
+ parent_pfx = axiom_namespace_get_prefix((axiom_namespace_t *)
parent_ns, ctx->env);
+ if(axutil_strcmp(pfx, parent_pfx) == 0)
{
- parent_uri =
axiom_namespace_get_uri((axiom_namespace_t*)parent_ns,
- ctx->env);
+ parent_uri = axiom_namespace_get_uri((axiom_namespace_t*)
parent_ns, ctx->env);
return (!(axutil_strcmp(uri, parent_uri) == 0));
}
}
- attr_ht = axiom_element_get_all_attributes(
- (axiom_element_t *)parent_element, ctx->env);
- if (attr_ht)
+ attr_ht = axiom_element_get_all_attributes((axiom_element_t *)
parent_element, ctx->env);
+ if(attr_ht)
{
- for (hi = axutil_hash_first(attr_ht, ctx->env); hi;
- hi = axutil_hash_next(ctx->env, hi))
+ for(hi = axutil_hash_first(attr_ht, ctx->env); hi; hi =
axutil_hash_next(ctx->env, hi))
{
void *v = NULL;
axutil_hash_this(hi, NULL, NULL, &v);
- if (v)
+ if(v)
{
- axiom_attribute_t *attr = (axiom_attribute_t*)v;
- axiom_namespace_t *attr_ns = axiom_attribute_get_namespace(
- attr, ctx->env);
+ axiom_attribute_t *attr = (axiom_attribute_t*) v;
+ axiom_namespace_t *attr_ns =
axiom_attribute_get_namespace(attr, ctx->env);
axis2_char_t *attr_pfx = NULL;
axis2_char_t *attr_uri = NULL;
- if (attr_ns)
+ if(attr_ns)
{
- attr_pfx = axiom_namespace_get_prefix(
- attr_ns, ctx->env);
- attr_uri = axiom_namespace_get_uri(attr_ns,
- ctx->env);
+ attr_pfx = axiom_namespace_get_prefix(attr_ns,
ctx->env);
+ attr_uri = axiom_namespace_get_uri(attr_ns, ctx->env);
- if (axutil_strcmp(attr_pfx, pfx) == 0)
+ if(axutil_strcmp(attr_pfx, pfx) == 0)
return (!(axutil_strcmp(attr_uri, uri) == 0));
/*test for this case*/
}
@@ -1791,8 +1669,7 @@
}
}
/*}*/
- parent_node = axiom_node_get_parent((axiom_node_t *)parent_node,
- ctx->env);
+ parent_node = axiom_node_get_parent((axiom_node_t *) parent_node,
ctx->env);
}
return AXIS2_TRUE;