version 1.1.2.2, 2010/09/27 18:19:57
|
version 1.1.2.4, 2010/09/28 11:37:04
|
Line 26 int
|
Line 26 int
|
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
char ch, *ctx, str[STRSIZ], szName[MAXPATHLEN], m = 0; |
char ch, *ctx, str[STRSIZ], szName[MAXPATHLEN], m = 0; |
int ctxlen, ret = 0; | int ctxlen, n, ret = 0; |
axlDoc *doc = NULL; |
axlDoc *doc = NULL; |
axlError *err = NULL; |
axlError *err = NULL; |
axlNode *node = NULL; |
axlNode *node = NULL; |
Line 99 main(int argc, char **argv)
|
Line 99 main(int argc, char **argv)
|
} |
} |
|
|
switch (m) { |
switch (m) { |
case 's': |
|
break; |
|
case 'g': |
case 'g': |
if (!xr.xml_namespace.vallen) { |
if (!xr.xml_namespace.vallen) { |
if (!(node = axl_doc_find_called(doc, xr.xml_container.value))) { | if (ret == 32) { |
printf("GET:: node %s - not found!\n", xr.xml_container.value); | if (!(ctx = (char*) axl_doc_get_content_at(doc, xr.xml_node.path.value, &ctxlen))) { |
ret = 1; | printf("GET:: path %s - not found!\n", xr.xml_node.path.value); |
goto end; | ret = 1; |
| goto end; |
| } |
| } else { |
| if (!(node = axl_doc_find_called(doc, xr.xml_node.container.value))) { |
| printf("GET:: node %s - not found!\n", xr.xml_node.container.value); |
| ret = 1; |
| goto end; |
| } |
} |
} |
} else { |
} else { |
strlcpy(str, xr.xml_namespace.value, sizeof str); |
strlcpy(str, xr.xml_namespace.value, sizeof str); |
strlcat(str, ":", sizeof str); |
strlcat(str, ":", sizeof str); |
strlcat(str, xr.xml_container.value, sizeof str); | strlcat(str, xr.xml_node.container.value, sizeof str); |
if (!(node = axl_doc_find_called(doc, str))) { | if (ret == 32) { |
printf("GET:: node %s:%s - not found!\n", xr.xml_namespace.value, | if (!(ctx = (char*) axl_doc_get_content_at(doc, str, &ctxlen))) { |
xr.xml_container.value); | printf("GET:: path %s:%s - not found!\n", xr.xml_namespace.value, |
ret = 1; | xr.xml_node.path.value); |
goto end; | ret = 1; |
| goto end; |
| } |
| } else { |
| if (!(node = axl_doc_find_called(doc, str))) { |
| printf("GET:: node %s:%s - not found!\n", xr.xml_namespace.value, |
| xr.xml_node.container.value); |
| ret = 1; |
| goto end; |
| } |
} |
} |
} |
} |
|
|
if (xr.xml_data.vallen) { | if (!(ret & 32) && xr.xml_data.vallen) { |
if (!(ctx = (char*) axl_node_get_content(node, &ctxlen))) { |
if (!(ctx = (char*) axl_node_get_content(node, &ctxlen))) { |
axl_node_free(node); |
|
printf("GET:: data %s for node %s - not found!\n", |
printf("GET:: data %s for node %s - not found!\n", |
xr.xml_data.value, xr.xml_attribute.value); | xr.xml_data.value, xr.xml_node.container.value); |
ret = 1; |
ret = 1; |
goto end; |
goto end; |
} else |
} else |
VERB(3) printf("Verbose(3):: Returned bytes %d\n", ctxlen); |
VERB(3) printf("Verbose(3):: Returned bytes %d\n", ctxlen); |
|
|
VERB(1) printf("\n"); |
VERB(1) printf("\n"); |
if (!(ret = strcmp(ctx, xr.xml_data.value))) | if (!strcmp(ctx, xr.xml_data.value)) |
printf("DATA::1\n"); |
printf("DATA::1\n"); |
else |
else |
printf("DATA::0\n"); |
printf("DATA::0\n"); |
} |
} |
|
|
if (xr.xml_attribute.vallen) { | if (!(ret & 32) && xr.xml_attribute.vallen) { |
if ((ret = axl_node_num_attributes(node)) < 1) { | if ((n = axl_node_num_attributes(node)) < 1) { |
axl_node_free(node); | |
printf("GET:: attribute %s for node %s - not found!\n", |
printf("GET:: attribute %s for node %s - not found!\n", |
xr.xml_container.value, xr.xml_attribute.value); | xr.xml_attribute.value, xr.xml_node.container.value); |
ret = 1; |
ret = 1; |
goto end; |
goto end; |
} else { |
} else { |
VERB(1) printf("Verbose:: node have %d attributes\n", ret); | VERB(1) printf("Verbose:: node have %d attributes\n", n); |
|
|
if (!(ctx = (char*) axl_node_get_attribute_value(node, xr.xml_attribute.value))) { |
if (!(ctx = (char*) axl_node_get_attribute_value(node, xr.xml_attribute.value))) { |
axl_node_free(node); |
|
printf("GET:: attribute %s for node %s - not found!\n", |
printf("GET:: attribute %s for node %s - not found!\n", |
xr.xml_container.value, xr.xml_attribute.value); | xr.xml_attribute.value, xr.xml_node.container.value); |
ret = 1; |
ret = 1; |
goto end; |
goto end; |
} |
} |
|
|
if (xr.xml_value.vallen) { |
if (xr.xml_value.vallen) { |
if (!(ret = strcmp(ctx, xr.xml_value.value))) | if (!strcmp(ctx, xr.xml_value.value)) |
ctx = "VALUE::1"; |
ctx = "VALUE::1"; |
else |
else |
ctx = "VALUE::0"; |
ctx = "VALUE::0"; |
} |
} |
} |
} |
} else { |
} else { |
axl_node_dump_pretty(node, &ctx, &ctxlen, 4); | if (!(ret & 32) && !(ctx = (char*) axl_node_get_content(node, &ctxlen))) { |
VERB(1) printf("Verbose:: Node length=%d\n", ctxlen); | printf("GET:: data for node %s - not found!\n", xr.xml_node.container.value); |
| ret = 1; |
| goto end; |
| } else |
| VERB(3) printf("Verbose(3):: Returned bytes %d\n", ctxlen); |
} |
} |
|
|
VERB(1) printf("\n"); |
VERB(1) printf("\n"); |
printf("%s\n", ctx); |
printf("%s\n", ctx); |
axl_node_free(node); |
|
ret = 0; |
ret = 0; |
break; |
break; |
|
case 's': |
|
if (!xr.xml_namespace.vallen) { |
|
if (ret == 32) { |
|
// insert new |
|
} else { |
|
// update old |
|
if (!(node = axl_doc_find_called(doc, xr.xml_node.container.value))) { |
|
printf("SET:: node %s - not found!\n", xr.xml_node.container.value); |
|
ret = 1; |
|
goto end; |
|
} |
|
} |
|
} else { |
|
strlcpy(str, xr.xml_namespace.value, sizeof str); |
|
strlcat(str, ":", sizeof str); |
|
strlcat(str, xr.xml_node.container.value, sizeof str); |
|
if (ret == 32) { |
|
// insert new |
|
} else { |
|
// update old |
|
if (!(node = axl_doc_find_called(doc, str))) { |
|
printf("SET:: node %s:%s - not found!\n", xr.xml_namespace.value, |
|
xr.xml_node.container.value); |
|
ret = 1; |
|
goto end; |
|
} |
|
} |
|
} |
|
|
|
if (!(ret & 32) && xr.xml_data.vallen) { |
|
axl_node_set_is_empty(node, 1); |
|
axl_node_set_content(node, xr.xml_data.value, xr.xml_data.vallen); |
|
} |
|
if (!(ret & 32) && xr.xml_attribute.vallen) { |
|
axl_node_remove_attribute(node, xr.xml_attribute.value); |
|
axl_node_set_attribute(node, xr.xml_attribute.value, xr.xml_value.value); |
|
} |
|
|
|
xr.xml_data = xr.xml_node.container; |
|
ret = 0; |
default: |
default: |
axl_doc_dump_pretty(doc, &ctx, &ctxlen, 4); | if (xr.xml_data.vallen) { |
VERB(1) printf("Verbose:: Document length=%d\n", ctxlen); | if (!(node = axl_doc_find_called(doc, xr.xml_data.value))) { |
| printf("GET:: node %s - not found!\n", xr.xml_data.value); |
| ret = 1; |
| goto end; |
| } |
| axl_node_dump_pretty(node, &ctx, &ctxlen, 4); |
| VERB(1) printf("Verbose:: Node length=%d\n", ctxlen); |
| } else { |
| axl_doc_dump_pretty(doc, &ctx, &ctxlen, 4); |
| VERB(1) printf("Verbose:: Document length=%d\n", ctxlen); |
| } |
|
|
VERB(1) printf("\n"); |
VERB(1) printf("\n"); |
printf("%s\n", ctx); |
printf("%s\n", ctx); |
free(ctx); | if (ctx) |
| free(ctx); |
} |
} |
end: |
end: |
axl_doc_free(doc); |
axl_doc_free(doc); |