diff options
author | Klaus Kämpf <kkaempf@suse.de> | 2011-09-08 09:05:16 +0200 |
---|---|---|
committer | Klaus Kämpf <kkaempf@suse.de> | 2011-09-08 09:05:16 +0200 |
commit | 69ddc10b31d158e5ceeab9d2e0fc78b9b1a4c244 (patch) | |
tree | acc489cd3d2cc067dd54191bab4b6813f3e77606 | |
parent | 503c6951b881b4d10704136dfd57174d5f6d4c59 (diff) | |
download | wsmancli-69ddc10b31d158e5ceeab9d2e0fc78b9b1a4c244.tar.gz wsmancli-69ddc10b31d158e5ceeab9d2e0fc78b9b1a4c244.tar.xz wsmancli-69ddc10b31d158e5ceeab9d2e0fc78b9b1a4c244.zip |
wsmancli allow debugging of invalid response XML
sing wsmancli, when the response XML is invalid (such as due to
invalid characters) an error is displayed with only a partial view of
the XML and no other information that could tell us where exactly the
problem is.
In debug mode (using -d option), it would be useful if the tool could
dump the raw XML for further analysis before it could be interpreted
by libxml functions.
Patch by Chris Poblete
-rw-r--r-- | src/wsman.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/wsman.c b/src/wsman.c index 4c34e78..8a70481 100644 --- a/src/wsman.c +++ b/src/wsman.c @@ -48,7 +48,7 @@ #include <errno.h> #include <time.h> -#include <wsman-client-api.h> +#include <wsman-client.h> #include <wsman-client-transport.h> #include <wsman-debug.h> @@ -407,12 +407,11 @@ static char wsman_parse_options(int argc, char **argv) } - - static void wsman_output(WsManClient * cl, WsXmlDocH doc) { FILE *f = stdout; const char *filename = output_file; + const char *badxml = NULL; WS_LASTERR_Code err; err = wsmc_get_last_error(cl); @@ -421,19 +420,28 @@ static void wsman_output(WsManClient * cl, WsXmlDocH doc) } if (!doc) { error("doc with NULL content"); - return; + badxml = (char*)u_buf_ptr(cl->connection->response); + if ((-1 == debug_level) || (NULL == badxml)) { + goto error1; + } } if (filename) { f = fopen(filename, "w"); if (f == NULL) { error("Could not open file for writing"); - return; + goto error1; } } - ws_xml_dump_node_tree(f, ws_xml_get_doc_root(doc)); + if (NULL != badxml) { + fprintf(f, "%s", badxml); // on debug mode, output the bad xml + } else { + ws_xml_dump_node_tree(f, ws_xml_get_doc_root(doc)); + } if (f != stdout) { fclose(f); } + +error1: return; } |