diff options
author | Anas Nashif <nashif@intel.com> | 2007-04-06 02:44:43 +0000 |
---|---|---|
committer | Anas Nashif <nashif@intel.com> | 2007-04-06 02:44:43 +0000 |
commit | 33a2d581d9b498ebb345cd2dcf2e093851dcc2cb (patch) | |
tree | a6d4b56b25b6d6bef93af5e217b5b18e73abb2d4 /examples | |
parent | d551bb117f7639384594f40295192493d9a67b23 (diff) | |
download | wsmancli-33a2d581d9b498ebb345cd2dcf2e093851dcc2cb.tar.gz wsmancli-33a2d581d9b498ebb345cd2dcf2e093851dcc2cb.tar.xz wsmancli-33a2d581d9b498ebb345cd2dcf2e093851dcc2cb.zip |
rename files
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 24 | ||||
-rw-r--r-- | examples/serialize.c | 1643 | ||||
-rw-r--r-- | examples/session_api_transfer_create.c (renamed from examples/new_api_transfer_create.c) | 0 | ||||
-rw-r--r-- | examples/session_example.c (renamed from examples/new_api_example.c) | 0 | ||||
-rw-r--r-- | examples/session_invoke.c (renamed from examples/new_api_invoke.c) | 0 | ||||
-rw-r--r-- | examples/session_transfer_get_put.c (renamed from examples/new_api_transfer_get_put.c) | 0 |
6 files changed, 859 insertions, 808 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 4adda7f..51247c5 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -21,17 +21,17 @@ serialize_SOURCES = serialize.c create_resource_SOURCES = \ create_resource.c -new_api_example_SOURCES = \ - new_api_example.c +session_example_SOURCES = \ + session_example.c -new_api_transfer_create_SOURCES = \ - new_api_transfer_create.c +session_transfer_create_SOURCES = \ + session_transfer_create.c -new_api_invoke_SOURCES = \ - new_api_invoke.c +session_invoke_SOURCES = \ + session_invoke.c -new_api_transfer_get_put_SOURCES = \ - new_api_transfer_get_put.c +session_transfer_get_put_SOURCES = \ + session_transfer_get_put.c noinst_PROGRAMS = \ wsmid_identify \ @@ -39,9 +39,9 @@ noinst_PROGRAMS = \ enum_epr \ create_resource \ serialize \ - new_api_example \ - new_api_transfer_create \ - new_api_invoke \ - new_api_transfer_get_put + session_example \ + session_transfer_create \ + session_invoke \ + session_transfer_get_put diff --git a/examples/serialize.c b/examples/serialize.c index 610288a..d31f141 100644 --- a/examples/serialize.c +++ b/examples/serialize.c @@ -50,868 +50,919 @@ -static void -example1() +static void example1() { #define EX1_NS "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem" -struct __Sample_Servie -{ - XML_TYPE_BOOL AcceptPause; - XML_TYPE_BOOL AcceptStop; - XML_TYPE_STR Caption; - XML_TYPE_UINT32 CheckPoint; - XML_TYPE_STR CreationClassName; - XML_TYPE_STR Description; - XML_TYPE_BOOL DesktopInteract; - XML_TYPE_STR DisplayName; - XML_TYPE_STR ErrorControl; - XML_TYPE_UINT32 ExitCode; - XML_TYPE_STR InstallDate; - XML_TYPE_STR Name; - XML_TYPE_STR PathName; - XML_TYPE_UINT32 ProcessId; - XML_TYPE_UINT32 ServiceSpecificExitCode; - XML_TYPE_STR ServiceType; - XML_TYPE_BOOL Started; - XML_TYPE_STR StartMode; - XML_TYPE_STR StartName; - XML_TYPE_STR State; - XML_TYPE_STR Status; - XML_TYPE_STR SystemCreationClassName; - XML_TYPE_STR SystemName; - XML_TYPE_UINT32 TagId; - XML_TYPE_UINT32 WaitHint; -}; -typedef struct __Sample_Servie Sample_Servie; - -Sample_Servie servie = { - 0, - 1, - "Caption", - 30, - "CreationClassName", - "Description", - 1, - "DisplayName", - "ErrorControl", - 50, - "InstallDate", - "Name", - "PathName", - 60, - 70, - "ServiceType", - 0, - "StartMode", - "StartName", - "State", - "Status", - "SystemCreationClassName", - "SystemName", - 90, - 100 -}; - -SER_START_ITEMS(Sample_Servie) -SER_BOOL("AcceptPause", 1), -SER_BOOL("AcceptStop", 1), -SER_STR("Caption", 1), -SER_UINT32("CheckPoint", 1), -SER_STR("CreationClassName", 1), -SER_STR("Description", 1), -SER_BOOL("DesktopInteract", 1), -SER_NS_STR(EX1_NS, "DisplayName", 1), -SER_STR("ErrorControl", 1), -SER_UINT32("ExitCode", 1), -SER_STR("InstallDate", 1), -SER_STR("Name", 1), -SER_STR("PathName", 1), -SER_UINT32("ProcessId", 1), -SER_UINT32("ServiceSpecificExitCode", 1), -SER_STR("ServiceType", 1), -SER_BOOL("Started", 1), -SER_STR("StartMode", 1), -SER_STR("StartName", 1), -SER_STR("State", 1), -SER_STR("Status", 1), -SER_STR("SystemCreationClassName", 1), -SER_STR("SystemName", 1), -SER_UINT32("TagId", 1), -SER_UINT32("WaitHint", 1), -SER_END_ITEMS(Sample_Servie); - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example1. Basic types ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &servie, Sample_Servie_TypeInfo, - CLASSNAME, - NULL, NULL, - 0); - printf("ws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - node = ws_xml_get_doc_root(doc); - Sample_Servie *cs = (Sample_Servie *)ws_deserialize(cntx, - node, - Sample_Servie_TypeInfo, - CLASSNAME, - NULL, NULL, - 0, 0); - if (cs == NULL) { - printf("Error ws_serialize\n"); - return; - } - retval = memcmp(cs, &servie, sizeof (&servie)); - if (retval) { - printf("Not compared (%d) - FAILED\n", retval); - printf("%d : %d\n", servie.AcceptPause, cs->AcceptPause); - printf("%d : %d\n", servie.AcceptStop, cs->AcceptStop); - printf("%s : %s\n", servie.Caption, cs->Caption); - } + XML_TYPE_UINT16 myshorts[] = { 5, 11, 14, 19, 27, 36 }; + SER_TYPEINFO_UINT16; + struct __Sample_Servie { + XML_TYPE_BOOL AcceptPause; + XML_TYPE_BOOL AcceptStop; + XML_TYPE_STR Caption; + XML_TYPE_UINT32 CheckPoint; + XML_TYPE_STR CreationClassName; + XML_TYPE_STR Description; + XML_TYPE_BOOL DesktopInteract; + XML_TYPE_STR DisplayName; + XML_TYPE_STR ErrorControl; + XML_TYPE_UINT32 ExitCode; + XML_TYPE_STR InstallDate; + XML_TYPE_STR Name; + XML_TYPE_STR PathName; + XML_TYPE_UINT32 ProcessId; + XML_TYPE_UINT32 ServiceSpecificExitCode; + XML_TYPE_STR ServiceType; + XML_TYPE_BOOL Started; + XML_TYPE_STR StartMode; + XML_TYPE_STR StartName; + XML_TYPE_STR State; + XML_TYPE_STR Status; + XML_TYPE_STR SystemCreationClassName; + XML_TYPE_STR SystemName; + XML_TYPE_UINT32 TagId; + XML_TYPE_UINT32 WaitHint; + XML_TYPE_UINT64 Uint64; + XML_TYPE_DYN_ARRAY shorts; + }; + typedef struct __Sample_Servie Sample_Servie; + + Sample_Servie servie = { + 0, + 1, + "Caption", + 30, + "CreationClassName", + "Description", + 1, + "DisplayName", + "ErrorControl", + 50, + "InstallDate", + "Name", + "PathName", + 60, + 70, + "ServiceType", + 0, + "StartMode", + "StartName", + "State", + "Status", + "SystemCreationClassName", + "SystemName", + 90, + 100, + 1000000, + {6, myshorts } + }; + + SER_START_ITEMS(Sample_Servie) + SER_BOOL("AcceptPause", 1), + SER_BOOL("AcceptStop", 1), + SER_STR("Caption", 1), + SER_UINT32("CheckPoint", 1), + SER_STR("CreationClassName", 1), + SER_STR("Description", 1), + SER_BOOL("DesktopInteract", 1), + SER_NS_STR(EX1_NS, "DisplayName", 1), + SER_STR("ErrorControl", 1), + SER_UINT32("ExitCode", 1), + SER_STR("InstallDate", 1), + SER_STR("Name", 1), + SER_STR("PathName", 1), + SER_UINT32("ProcessId", 1), + SER_UINT32("ServiceSpecificExitCode", 1), + SER_STR("ServiceType", 1), + SER_BOOL("Started", 1), + SER_STR("StartMode", 1), + SER_STR("StartName", 1), + SER_STR("State", 1), + SER_STR("Status", 1), + SER_STR("SystemCreationClassName", 1), + SER_STR("SystemName", 1), + SER_UINT32("TagId", 1), + SER_UINT32("WaitHint", 1), + SER_UINT64("Uint64", 1), + SER_DYN_ARRAY("shorts", 0, 1000, uint16), + SER_END_ITEMS(Sample_Servie); + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf("\n\n ******** example1. Basic types ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &servie, Sample_Servie_TypeInfo, + CLASSNAME, NULL, NULL, 0); + printf("ws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + node = ws_xml_get_doc_root(doc); + + WsXmlDocH xx = ws_xml_read_file( ws_context_get_runtime(cntx), "./test.xml", "UTF-8", 0 ); + node = ws_xml_get_doc_root(xx); + Sample_Servie *cs = (Sample_Servie *) ws_deserialize(cntx, + node, + Sample_Servie_TypeInfo, + CLASSNAME, + NULL, NULL, + 0, 0); + if (cs == NULL) { + printf("Error in ws_serialize\n"); + return; + } + + printf("%d\n", cs->ExitCode ); + + retval = memcmp(cs, &servie, sizeof(&servie)); + if (retval) { + printf("Not compared (%d) - FAILED\n", retval); + printf("%d : %d\n", servie.AcceptPause, cs->AcceptPause); + printf("%d : %d\n", servie.AcceptStop, cs->AcceptStop); + printf("%s : %s\n", servie.Caption, cs->Caption); + } } -static void -example2() +static void example2() { -typedef struct { - XML_TYPE_UINT8 byte1; - XML_TYPE_UINT32 int1; - XML_TYPE_UINT8 byte2; -} Foo; - -typedef struct { - XML_TYPE_UINT8 byte1; - XML_TYPE_UINT16 short1; - XML_TYPE_UINT32 int1; - char *string1; - Foo foo; -} Sample; - - -Sample sample = { 1, 2, 4, "string", {5, 196, 8} }; - -SER_START_ITEMS(Foo) - SER_UINT8("FOOBYTE1", 1), - SER_UINT32("FOOINT32", 1), - SER_UINT8("FOOBYTE2", 1), -SER_END_ITEMS(Foo); - - -SER_START_ITEMS(Sample) - SER_UINT8("BYTE", 1), - SER_UINT16("SHORT", 1), - SER_UINT32("INT32", 1), - SER_STR("STRING", 1), - SER_STRUCT("FOO", 1, Foo), -SER_END_ITEMS(Sample); - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example2. Structure with pads. ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, - CLASSNAME, NULL, NULL, 0); - printf("ws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - - node = ws_xml_get_doc_root(doc); - Sample *cs = (Sample *)ws_deserialize(cntx, - node, - Sample_TypeInfo, - CLASSNAME, NULL, NULL, - 0, 0); - if (cs == NULL) { - printf("Errror ws_deserialize\n"); - return; - } - - printf("\n initial and deserialized structures\n"); - printf(" byte1 = %d : %d\n", sample.byte1, cs->byte1); - printf(" short1 = %d : %d\n", sample.short1, cs->short1); - printf(" int1 = %d : %d\n", sample.int1, cs->int1); - printf(" string1 = <%s> : <%s>\n", sample.string1, cs->string1); - printf(" foo :\n"); - printf(" byte1 = %d : %d\n", sample.foo.byte1, cs->foo.byte1); - printf(" int1 = %d : %d\n", sample.foo.int1, cs->foo.int1); - printf(" byte2 = %d : %d\n", sample.foo.byte2, cs->foo.byte2); + typedef struct { + XML_TYPE_UINT8 byte1; + XML_TYPE_UINT32 int1; + XML_TYPE_UINT8 byte2; + } Foo; + + typedef struct { + XML_TYPE_UINT8 byte1; + XML_TYPE_UINT16 short1; + XML_TYPE_UINT32 int1; + char *string1; + Foo foo; + } Sample; + + + Sample sample = { 1, 2, 4, "string", {5, 196, 8} }; + + SER_START_ITEMS(Foo) + SER_UINT8("FOOBYTE1", 1), + SER_UINT32("FOOINT32", 1), + SER_UINT8("FOOBYTE2", 1), SER_END_ITEMS(Foo); + + + SER_START_ITEMS(Sample) + SER_UINT8("BYTE", 1), + SER_UINT16("SHORT", 1), + SER_UINT32("INT32", 1), + SER_STR("STRING", 1), + SER_STRUCT("FOO", 1, Foo), SER_END_ITEMS(Sample); + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf + ("\n\n ******** example2. Structure with pads. ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, + CLASSNAME, NULL, NULL, 0); + printf("ws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + + node = ws_xml_get_doc_root(doc); + Sample *cs = (Sample *) ws_deserialize(cntx, + node, + Sample_TypeInfo, + CLASSNAME, NULL, NULL, + 0, 0); + if (cs == NULL) { + printf("Errror ws_deserialize\n"); + return; + } + + printf("\n initial and deserialized structures\n"); + printf(" byte1 = %d : %d\n", sample.byte1, cs->byte1); + printf(" short1 = %d : %d\n", sample.short1, cs->short1); + printf(" int1 = %d : %d\n", sample.int1, cs->int1); + printf(" string1 = <%s> : <%s>\n", sample.string1, + cs->string1); + printf(" foo :\n"); + printf(" byte1 = %d : %d\n", sample.foo.byte1, + cs->foo.byte1); + printf(" int1 = %d : %d\n", sample.foo.int1, + cs->foo.int1); + printf(" byte2 = %d : %d\n", sample.foo.byte2, + cs->foo.byte2); } -static void -example3() +static void example3() { -typedef struct { - XML_TYPE_UINT8 a; - XML_TYPE_UINT8 b; - XML_TYPE_UINT8 c; - XML_TYPE_UINT8 pad; - XML_TYPE_STR string; -} Sample; - - - -SER_START_ITEMS(Sample) -SER_UINT8("a", 1), -SER_UINT8("b", 1), -SER_UINT8("c", 1), -SER_IN_UINT8("pad", 1), -SER_STR("string", 1), -SER_END_ITEMS(Sample); - -Sample sample = {'a', 'b', 'c', 'x', "simple string"}; -Sample *p = NULL; - - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example3. Skip elements. ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, - CLASSNAME, NULL, NULL, 0); - printf("ws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - - printf("\n\nws_deserialize (prints original : result):\n"); - - node = ws_xml_get_doc_root(doc); - Sample *cs = (Sample *)ws_deserialize(cntx, - node, - Sample_TypeInfo, - CLASSNAME, NULL, NULL, - 0, 0); - if (cs == NULL) { - printf("Errror ws_serialize\n"); - return; - } - - printf("a = %c : %c\n", sample.a, cs->a); - printf("b = %c : %c\n", sample.b, cs->b); - printf("c = %c : %c\n", sample.c, cs->c); - printf("pad = %c(%d) : %c(%d)\n", sample.pad, sample.pad, - cs->pad, cs->pad); - printf("string = <%s> : <%s>\n", sample.string, cs->string); + typedef struct { + XML_TYPE_UINT8 a; + XML_TYPE_UINT8 b; + XML_TYPE_UINT8 c; + XML_TYPE_UINT8 pad; + XML_TYPE_STR string; + } Sample; + + + + SER_START_ITEMS(Sample) + SER_UINT8("a", 1), + SER_UINT8("b", 1), + SER_UINT8("c", 1), + SER_IN_UINT8("pad", 1), + SER_STR("string", 1), SER_END_ITEMS(Sample); + + Sample sample = { 'a', 'b', 'c', 'x', "simple string" }; + Sample *p = NULL; + + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf("\n\n ******** example3. Skip elements. ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, + CLASSNAME, NULL, NULL, 0); + printf("ws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + + printf("\n\nws_deserialize (prints original : result):\n"); + + node = ws_xml_get_doc_root(doc); + Sample *cs = (Sample *) ws_deserialize(cntx, + node, + Sample_TypeInfo, + CLASSNAME, NULL, NULL, + 0, 0); + if (cs == NULL) { + printf("Errror ws_serialize\n"); + return; + } + + printf("a = %c : %c\n", sample.a, cs->a); + printf("b = %c : %c\n", sample.b, cs->b); + printf("c = %c : %c\n", sample.c, cs->c); + printf("pad = %c(%d) : %c(%d)\n", sample.pad, sample.pad, + cs->pad, cs->pad); + printf("string = <%s> : <%s>\n", sample.string, cs->string); } -static void -example4() +static void example4() { -typedef struct { - XML_TYPE_BOOL a; - XML_TYPE_STR string; - XML_TYPE_BOOL b; -} Embed; - -typedef struct { - XML_TYPE_UINT32 A; - Embed EMBED[2]; - XML_TYPE_STR STRING; -} Sample; - - -Sample sample = { - 10, - {{1, "string 1", 0}, {0, "string 2", 1},}, - "STRING", -}; - -SER_START_ITEMS(Embed) -SER_BOOL("a", 1), -SER_STR("string", 1), -SER_BOOL("b", 1), -SER_END_ITEMS(Embed); - -SER_START_ITEMS(Sample) -SER_UINT32("A", 1), -SER_STRUCT("EMBED", 2, Embed), -SER_STR("STRING", 1), -SER_END_ITEMS(Sample); - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example4. Static structure array ********\n"); - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, - CLASSNAME, NULL, NULL, 0); - printf("ws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); + typedef struct { + XML_TYPE_BOOL a; + XML_TYPE_STR string; + XML_TYPE_BOOL b; + } Embed; + + typedef struct { + XML_TYPE_UINT32 A; + Embed EMBED[2]; + XML_TYPE_STR STRING; + } Sample; + + + Sample sample = { + 10, + {{1, "string 1", 0}, {0, "string 2", 1},}, + "STRING", + }; + + SER_START_ITEMS(Embed) + SER_BOOL("a", 1), + SER_STR("string", 1), SER_BOOL("b", 1), SER_END_ITEMS(Embed); + + SER_START_ITEMS(Sample) + SER_UINT32("A", 1), + SER_STRUCT("EMBED", 2, Embed), + SER_STR("STRING", 1), SER_END_ITEMS(Sample); + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf + ("\n\n ******** example4. Static structure array ********\n"); + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, + CLASSNAME, NULL, NULL, 0); + printf("ws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); } -static void -example5() +static void example5() { -typedef struct { - XML_TYPE_BOOL AcceptPause; - XML_TYPE_STR Caption; -} Foo; - -Foo foos[] = { - {1, "Caption 1"}, - {0, "Caption 2"}, - {1, "Caption 1",}, - {0, "Caption 2",},}; - - -SER_START_ITEMS(Foo) -SER_BOOL("AcceptPause", 1), -SER_STR("Caption", 1), -SER_END_ITEMS(Foo); - -XML_TYPE_UINT16 myshorts[] = {5, 11, 14,19, 27, 36}; -SER_TYPEINFO_UINT16; - -typedef struct { - XML_TYPE_STR city; - XML_TYPE_DYN_ARRAY shorts; - XML_TYPE_DYN_ARRAY foos; - XML_TYPE_UINT16 tag; -} Sample; - -Sample sample = { "Moscow", {6, myshorts}, {2, foos}, 99}; - - - - -SER_START_ITEMS(Sample) -SER_STR("city", 1), -SER_DYN_ARRAY("shorts", 0, 1000, uint16), -SER_DYN_ARRAY("foos", 0, 1000, Foo), -SER_UINT16("tag", 1), -SER_END_ITEMS(Sample); - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example5. Dynamic arrays ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, - CLASSNAME, NULL, NULL, 0); - printf("\n\nws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - - node = ws_xml_get_doc_root(doc); - - printf("\n\nws_deserialize:\n"); - Sample *cs = (Sample *)ws_deserialize(cntx, - node, - Sample_TypeInfo, - CLASSNAME, NULL, NULL, - 0, 0); - if (cs == NULL) { - printf("Errror ws_deserialize\n"); - return; - } - int i; - printf("shorts count = %d\n", cs->shorts.count); - printf("foos count = %d\n", cs->foos.count); - printf("\n"); - printf(" city = <%s>\n", cs->city); - if (cs->shorts.data == NULL) { - printf("No uint16 objects\n"); - goto AFTER_SHORTS; - } - unsigned short *newuints = (unsigned short *)cs->shorts.data; - printf(" shorts = {"); - for (i = 0; i < cs->shorts.count; i++) { - printf("%u, ", *newuints); - newuints++; - } - printf("}\n"); -AFTER_SHORTS: - if (cs->foos.data == NULL) { - printf("No foo objects\n"); - goto AFTER_FOOS; - } - Foo *newfoos = cs->foos.data; - for (i = 0; i < cs->foos.count; i++) { - printf(" ==== Foo %d =====\n", i); - printf(" AcceptPause = %d\n", newfoos->AcceptPause); - printf(" Caption = <%s>\n", newfoos->Caption); - printf(" ==== End of Foo %d =====\n", i); - newfoos++; - } -AFTER_FOOS: - printf(" tag = %d\n", cs->tag); + typedef struct { + XML_TYPE_BOOL AcceptPause; + XML_TYPE_STR Caption; + } Foo; + + Foo foos[] = { + {1, "Caption 1"}, + {0, "Caption 2"}, + {1, "Caption 1",}, + {0, "Caption 2",}, + }; + + + SER_START_ITEMS(Foo) + SER_BOOL("AcceptPause", 1), + SER_STR("Caption", 1), SER_END_ITEMS(Foo); + + XML_TYPE_UINT16 myshorts[] = { 5, 11, 14, 19, 27, 36 }; + SER_TYPEINFO_UINT16; + + typedef struct { + XML_TYPE_STR city; + XML_TYPE_DYN_ARRAY shorts; + XML_TYPE_DYN_ARRAY foos; + XML_TYPE_UINT16 tag; + } Sample; + + Sample sample = { "Moscow", {6, myshorts}, {2, foos}, 99 }; + + SER_START_ITEMS(Sample) + SER_STR("city", 1), + SER_DYN_ARRAY("shorts", 0, 1000, uint16), + SER_DYN_ARRAY("foos", 0, 1000, Foo), + SER_UINT16("tag", 1), SER_END_ITEMS(Sample); + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf("\n\n ******** example 5: Dynamic arrays ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, + CLASSNAME, NULL, NULL, 0); + printf("\n\nws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + + node = ws_xml_get_doc_root(doc); + + printf("\n\nws_deserialize:\n"); + Sample *cs = (Sample *) ws_deserialize(cntx, + node, + Sample_TypeInfo, + CLASSNAME, NULL, NULL, + 0, 0); + if (cs == NULL) { + printf("Error ws_deserialize\n"); + return; + } + int i; + printf("shorts count = %d\n", cs->shorts.count); + printf("foos count = %d\n", cs->foos.count); + printf("\n"); + printf(" city = <%s>\n", cs->city); + if (cs->shorts.data == NULL) { + printf("No uint16 objects\n"); + goto AFTER_SHORTS; + } + unsigned short *newuints = (unsigned short *) cs->shorts.data; + printf(" shorts = {"); + for (i = 0; i < cs->shorts.count; i++) { + printf("%u, ", *newuints); + newuints++; + } + printf("}\n"); + AFTER_SHORTS: + if (cs->foos.data == NULL) { + printf("No foo objects\n"); + goto AFTER_FOOS; + } + Foo *newfoos = cs->foos.data; + for (i = 0; i < cs->foos.count; i++) { + printf(" ==== Foo %d =====\n", i); + printf(" AcceptPause = %d\n", newfoos->AcceptPause); + printf(" Caption = <%s>\n", newfoos->Caption); + printf(" ==== End of Foo %d =====\n", i); + newfoos++; + } + AFTER_FOOS: + printf(" tag = %d\n", cs->tag); } -static void -example6() +static void example6() { - typedef struct { - struct {XML_TYPE_UINT8 body; XML_NODE_ATTR *attrs;} uint8_with_attrs; - struct {XML_TYPE_UINT16 body; XML_NODE_ATTR *attrs;} uint16_with_attrs; - struct {XML_TYPE_UINT32 body; XML_NODE_ATTR *attrs;} uint32_with_attrs; - struct {XML_TYPE_BOOL body; XML_NODE_ATTR *attrs;} bool_with_attrs; - struct {XML_TYPE_STR body; XML_NODE_ATTR *attrs;} str_with_attrs; - } Dummy; - - typedef struct { - struct {Dummy body; XML_NODE_ATTR *attrs;} struct_with_attrs; - } Sample; - - XML_NODE_ATTR attrs[] = { - {NULL, NULL, "Uint8AttrName1", "Uint8AttrValue1"}, - {NULL, NULL, "Uint16AttrName1", "Uint16AttrValue1"}, - {NULL, NULL, "Uint32AttrName1", "Uint32AttrValue1"}, - {NULL, NULL, "BoolAttrName1", "BoolAttrValue1"}, - {NULL, NULL, "StringAttrName1", "StringAttrValue1"}, - }; - XML_NODE_ATTR str_attrs[3] = { - {NULL, NULL, "AttrName1", "AttrValue1"}, - {NULL, NULL, "AttrName2", "AttrValue2"}, - {NULL, XML_NS_ADDRESSING, "AttrQName", "AttrValue3"}, - }; - Sample sample = { - { - { - {8, &attrs[0]}, - {16, &attrs[1]}, - {32, &attrs[2]}, - {0, &attrs[3]}, - {"string", &attrs[4]}, - }, - &str_attrs[0] - } - }; - str_attrs[0].next = &str_attrs[1]; - str_attrs[1].next = &str_attrs[2]; - - SER_START_ITEMS(Dummy) - SER_ATTR_NS_UINT8_FLAGS(NULL, "UINT8", 1, 0), - SER_ATTR_NS_UINT16_FLAGS(NULL, "UINT16", 1, 0), - SER_ATTR_NS_UINT32_FLAGS(NULL, "UINT32", 1, 0), - SER_ATTR_NS_BOOL_FLAGS(NULL, "BOOL", 1, 0), - SER_ATTR_NS_STR_FLAGS(NULL, "STRING", 1, 0), - SER_END_ITEMS(Dummy); - - SER_START_ITEMS(Sample) - SER_ATTR_NS_STRUCT_FLAGS(XML_NS_WS_MAN, "STRUCT", 1, 0, Dummy), - SER_END_ITEMS(Sample); - - WsContextH cntx; - WsXmlDocH doc; - WsXmlNodeH node; - int retval; - - printf("\n\n ******** example5. Nodes with attributes ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, - CLASSNAME, XML_NS_WS_MAN, NULL, 0); - printf("\n\nws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - - Sample *news; - printf("\n\nws_deserialize:\n"); - news = (Sample *)ws_deserialize(cntx, - node, - Sample_TypeInfo, - CLASSNAME, - XML_NS_ADDRESSING, - NULL, 0, 0); - if (news == NULL) { - printf("Errror ws_deserialize\n"); - return; - } - - XML_NODE_ATTR *nattrs; - Dummy *dm = &(news->struct_with_attrs.body); - printf("**** Deserialized document %p *****\n", news); - printf("struct_with_attrs.body ("); - nattrs = news->struct_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n"); - - printf(" uint8_with_attrs = %d (", dm->uint8_with_attrs.body); - nattrs = dm->uint8_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n"); - - printf(" uint16_with_attrs = %d (", dm->uint16_with_attrs.body); - nattrs = dm->uint16_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n"); - - printf(" uint32_with_attrs = %d (", dm->uint32_with_attrs.body); - nattrs = dm->uint32_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n"); - - printf(" bool_with_attrs = %d (", dm->bool_with_attrs.body); - nattrs = dm->bool_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n"); - - printf(" str_with_attrs = %s (", dm->str_with_attrs.body); - nattrs = dm->str_with_attrs.attrs; - while (nattrs) { - printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, nattrs->value); - nattrs = nattrs->next; - } - printf(")\n");} - - - - -static void -example7() + typedef struct { + struct { + XML_TYPE_UINT8 body; + XML_NODE_ATTR *attrs; + } uint8_with_attrs; + struct { + XML_TYPE_UINT16 body; + XML_NODE_ATTR *attrs; + } uint16_with_attrs; + struct { + XML_TYPE_UINT32 body; + XML_NODE_ATTR *attrs; + } uint32_with_attrs; + struct { + XML_TYPE_BOOL body; + XML_NODE_ATTR *attrs; + } bool_with_attrs; + struct { + XML_TYPE_STR body; + XML_NODE_ATTR *attrs; + } str_with_attrs; + } Dummy; + + typedef struct { + struct { + Dummy body; + XML_NODE_ATTR *attrs; + } struct_with_attrs; + } Sample; + + XML_NODE_ATTR attrs[] = { + {NULL, NULL, "Uint8AttrName1", "Uint8AttrValue1"}, + {NULL, NULL, "Uint16AttrName1", "Uint16AttrValue1"}, + {NULL, NULL, "Uint32AttrName1", "Uint32AttrValue1"}, + {NULL, NULL, "BoolAttrName1", "BoolAttrValue1"}, + {NULL, NULL, "StringAttrName1", "StringAttrValue1"}, + }; + XML_NODE_ATTR str_attrs[3] = { + {NULL, NULL, "AttrName1", "AttrValue1"}, + {NULL, NULL, "AttrName2", "AttrValue2"}, + {NULL, XML_NS_ADDRESSING, "AttrQName", "AttrValue3"}, + }; + Sample sample = { + { + { + {8, &attrs[0]}, + {16, &attrs[1]}, + {32, &attrs[2]}, + {0, &attrs[3]}, + {"string", &attrs[4]}, + }, + &str_attrs[0] + } + }; + str_attrs[0].next = &str_attrs[1]; + str_attrs[1].next = &str_attrs[2]; + + SER_START_ITEMS(Dummy) + SER_ATTR_NS_UINT8_FLAGS(NULL, "UINT8", 1, 0), + SER_ATTR_NS_UINT16_FLAGS(NULL, "UINT16", 1, 0), + SER_ATTR_NS_UINT32_FLAGS(NULL, "UINT32", 1, 0), + SER_ATTR_NS_BOOL_FLAGS(NULL, "BOOL", 1, 0), + SER_ATTR_NS_STR_FLAGS(NULL, "STRING", 1, 0), + SER_END_ITEMS(Dummy); + + SER_START_ITEMS(Sample) + SER_ATTR_NS_STRUCT_FLAGS(XML_NS_WS_MAN, "STRUCT", 1, 0, Dummy), + SER_END_ITEMS(Sample); + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf + ("\n\n ******** example 6. Nodes with attributes ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &sample, Sample_TypeInfo, + CLASSNAME, XML_NS_WS_MAN, NULL, 0); + printf("\n\nws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + + Sample *news; + printf("\n\nws_deserialize:\n"); + news = (Sample *) ws_deserialize(cntx, + node, + Sample_TypeInfo, + CLASSNAME, + XML_NS_ADDRESSING, NULL, 0, 0); + if (news == NULL) { + printf("Errror ws_deserialize\n"); + return; + } + + XML_NODE_ATTR *nattrs; + Dummy *dm = &(news->struct_with_attrs.body); + printf("**** Deserialized document %p *****\n", news); + printf("struct_with_attrs.body ("); + nattrs = news->struct_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); + + printf(" uint8_with_attrs = %d (", dm->uint8_with_attrs.body); + nattrs = dm->uint8_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); + + printf(" uint16_with_attrs = %d (", dm->uint16_with_attrs.body); + nattrs = dm->uint16_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); + + printf(" uint32_with_attrs = %d (", dm->uint32_with_attrs.body); + nattrs = dm->uint32_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); + + printf(" bool_with_attrs = %d (", dm->bool_with_attrs.body); + nattrs = dm->bool_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); + + printf(" str_with_attrs = %s (", dm->str_with_attrs.body); + nattrs = dm->str_with_attrs.attrs; + while (nattrs) { + printf("%s:%s=\"%s\" ", nattrs->ns, nattrs->name, + nattrs->value); + nattrs = nattrs->next; + } + printf(")\n"); +} + + + + +static void example7() { - typedef struct { - XML_TYPE_STR value; - XML_NODE_ATTR *attrs; - } Selector; - - SER_TYPEINFO_STRING_ATTR; - - - typedef struct { - XML_TYPE_DYN_ARRAY selectors; - } SelectorSet; - - SER_START_ITEMS(SelectorSet) - SER_NS_DYN_ARRAY(XML_NS_WS_MAN, WSM_SELECTOR, 0, 1000, string_attr), - SER_END_ITEMS(SelectorSet); - - - typedef struct { - XML_TYPE_STR uri; - SelectorSet selectorset; - } ReferenceParameters; - - SER_START_ITEMS(ReferenceParameters) - SER_NS_STR(XML_NS_WS_MAN, WSM_RESOURCE_URI, 1), - SER_NS_STRUCT(XML_NS_WS_MAN, WSM_SELECTOR_SET, 1, SelectorSet), - SER_END_ITEMS(ReferenceParameters); - - typedef struct { - XML_TYPE_STR address; - ReferenceParameters refparams; - } EPR; - - SER_START_ITEMS(EPR) - SER_NS_STR(XML_NS_ADDRESSING, WSA_ADDRESS, 1), - SER_NS_STRUCT(XML_NS_ADDRESSING, WSA_REFERENCE_PARAMETERS, 1, ReferenceParameters), - SER_END_ITEMS(EPR); - - XML_NODE_ATTR attrs[3] = { - {NULL, NULL, "Name", "SelName1"}, - {NULL, NULL, "Name", "SelName2"}, - {NULL, NULL, "Name", "SelName3"}, - }; - Selector selectors[] = { - {"selector1", &attrs[0]}, - {"selector2", &attrs[1]}, - {"selector3", &attrs[2]} - }; - EPR Epr = { - "http://localhost:8889/wsman", - {"http://acme.org/hardware/2005/02/storage/physDisk", - { {3, selectors}} - } - }; - -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example7. Endpoint Reference ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - - retval = ws_serialize(cntx, node, &Epr, EPR_TypeInfo, - "EndpointReference", XML_NS_ADDRESSING, NULL, 0); - printf("\n\nws_serialize: %d\n", retval); - ws_xml_dump_node_tree(stdout, node); - - EPR *newEPR; - node = ws_xml_get_doc_root(doc); - - printf("\n\nws_deserialize:\n"); - newEPR = (EPR *)ws_deserialize(cntx, - node, - EPR_TypeInfo, - "EndpointReference", - XML_NS_ADDRESSING, - NULL, 0, 0); - if (newEPR == NULL) { - printf("Errror ws_deserialize\n"); - return; - } - - printf("**** Deserialized document *****\n"); - printf("address = %s\n", newEPR->address); - printf("refparams.uri = %s\n", newEPR->refparams.uri); - int i; - Selector *ss = (Selector *)newEPR->refparams.selectorset.selectors.data; - if (ss == NULL) { - printf(" !!!! newEPR->refparams.selectors.data == NULL\n"); - return; - } - for (i = 0; i < newEPR->refparams.selectorset.selectors.count; i++) { - Selector *s; - s = ss + i; - printf(" Selector("); - XML_NODE_ATTR *a = s->attrs; - while (a) { - printf("%s:%s=%s", - a->ns ? a->ns : "", a->name, a->value); - a = a->next; - } - printf(") = %s\n", s->value); - } + typedef struct { + XML_TYPE_STR value; + XML_NODE_ATTR *attrs; + } Selector; + + SER_TYPEINFO_STRING_ATTR; + + + typedef struct { + XML_TYPE_DYN_ARRAY selectors; + } SelectorSet; + + SER_START_ITEMS(SelectorSet) + SER_NS_DYN_ARRAY(XML_NS_WS_MAN, WSM_SELECTOR, 0, 1000, + string_attr), SER_END_ITEMS(SelectorSet); + + + typedef struct { + XML_TYPE_STR uri; + SelectorSet selectorset; + } ReferenceParameters; + + SER_START_ITEMS(ReferenceParameters) + SER_NS_STR(XML_NS_WS_MAN, WSM_RESOURCE_URI, 1), + SER_NS_STRUCT(XML_NS_WS_MAN, WSM_SELECTOR_SET, 1, SelectorSet), + SER_END_ITEMS(ReferenceParameters); + + typedef struct { + XML_TYPE_STR address; + ReferenceParameters refparams; + } EPR; + + SER_START_ITEMS(EPR) + SER_NS_STR(XML_NS_ADDRESSING, WSA_ADDRESS, 1), + SER_NS_STRUCT(XML_NS_ADDRESSING, WSA_REFERENCE_PARAMETERS, 1, + ReferenceParameters), SER_END_ITEMS(EPR); + + XML_NODE_ATTR attrs[3] = { + {NULL, NULL, "Name", "SelName1"}, + {NULL, NULL, "Name", "SelName2"}, + {NULL, NULL, "Name", "SelName3"}, + }; + Selector selectors[] = { + {"selector1", &attrs[0]}, + {"selector2", &attrs[1]}, + {"selector3", &attrs[2]} + }; + EPR Epr = { + "http://localhost:8889/wsman", + {"http://acme.org/hardware/2005/02/storage/physDisk", + {{3, selectors}} + } + }; + + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf + ("\n\n ******** example7. Endpoint Reference ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + + retval = ws_serialize(cntx, node, &Epr, EPR_TypeInfo, + "EndpointReference", XML_NS_ADDRESSING, NULL, + 0); + printf("\n\nws_serialize: %d\n", retval); + ws_xml_dump_node_tree(stdout, node); + + EPR *newEPR; + node = ws_xml_get_doc_root(doc); + + printf("\n\nws_deserialize:\n"); + newEPR = (EPR *) ws_deserialize(cntx, + node, + EPR_TypeInfo, + "EndpointReference", + XML_NS_ADDRESSING, NULL, 0, 0); + if (newEPR == NULL) { + printf("Errror ws_deserialize\n"); + return; + } + + printf("**** Deserialized document *****\n"); + printf("address = %s\n", newEPR->address); + printf("refparams.uri = %s\n", newEPR->refparams.uri); + int i; + Selector *ss = + (Selector *) newEPR->refparams.selectorset.selectors.data; + if (ss == NULL) { + printf + (" !!!! newEPR->refparams.selectors.data == NULL\n"); + return; + } + for (i = 0; i < newEPR->refparams.selectorset.selectors.count; i++) { + Selector *s; + s = ss + i; + printf(" Selector("); + XML_NODE_ATTR *a = s->attrs; + while (a) { + printf("%s:%s=%s", + a->ns ? a->ns : "", a->name, a->value); + a = a->next; + } + printf(") = %s\n", s->value); + } } -static void -example50() +static void example50() { - printf("\n\n ******** example50. XML datetime deserialization ********\n"); + printf + ("\n\n ******** example50. XML datetime deserialization ********\n"); - char xml_dttm[] = "2007-02-13T12:39:14-03:30"; - XML_DATETIME dttm; + char xml_dttm[] = "2007-02-13T12:39:14-03:30"; + XML_DATETIME dttm; - if (ws_deserialize_datetime(xml_dttm, &dttm)) { - printf("deserialization failed\n"); - return; - } - printf("XML datetime = %s\n", xml_dttm); - printf("deserialed = %u-%u-%uT%u:%u:%u %i\n", dttm.tm.tm_year, - dttm.tm.tm_mon, dttm.tm.tm_mday, dttm.tm.tm_hour, - dttm.tm.tm_min, dttm.tm.tm_sec, dttm.tz_min); + if (ws_deserialize_datetime(xml_dttm, &dttm)) { + printf("deserialization failed\n"); + return; + } + printf("XML datetime = %s\n", xml_dttm); + printf("deserialed = %u-%u-%uT%u:%u:%u %i\n", dttm.tm.tm_year, + dttm.tm.tm_mon, dttm.tm.tm_mday, dttm.tm.tm_hour, + dttm.tm.tm_min, dttm.tm.tm_sec, dttm.tz_min); } - // No serialization examples(shttpd_0) +// No serialization examples(shttpd_0) -static void -example106() +static void example106() { -char *data = "<dummy><qq>This is qq body</qq><pp>This is pp</pp></dummy>"; -// WsXmlDocH response; - WsManClient *cl = wsman_create_client("mstevbakrov.ims.intel.com", - 8889, - "/wsman", - "http", - "wsman", - "secret"); - - actionOptions *options = initialize_action_options(); - - WsXmlDocH request = wsman_client_create_request(cl, - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - options, - WSMAN_ACTION_TRANSFER_CREATE, NULL, NULL); - WsXmlDocH d = wsman_client_read_memory(cl, data, strlen(data), NULL, 0); -ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(d)); -// WsXmlNodeH n = ws_xml_get_doc_root(d); - - ws_xml_duplicate_tree(ws_xml_get_soap_body(request), ws_xml_get_doc_root(d)); - ws_xml_destroy_doc(d); -// ws_xml_copy_node(ws_xml_get_doc_root(d), ws_xml_get_soap_body(request)); - ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(request)); - wsman_release_client(cl); - ws_xml_destroy_doc(request); + char *data = + "<dummy><qq>This is qq body</qq><pp>This is pp</pp></dummy>"; + // WsXmlDocH response; + WsManClient *cl = wsman_create_client("mstevbakrov.ims.intel.com", + 8889, + "/wsman", + "http", + "wsman", + "secret"); + + actionOptions *options = initialize_action_options(); + + WsXmlDocH request = wsman_client_create_request(cl, + "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", + options, + WSMAN_ACTION_TRANSFER_CREATE, + NULL, NULL); + WsXmlDocH d = + wsman_client_read_memory(cl, data, strlen(data), NULL, 0); + ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(d)); + // WsXmlNodeH n = ws_xml_get_doc_root(d); + + ws_xml_duplicate_tree(ws_xml_get_soap_body(request), + ws_xml_get_doc_root(d)); + ws_xml_destroy_doc(d); + // ws_xml_copy_node(ws_xml_get_doc_root(d), ws_xml_get_soap_body(request)); + ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(request)); + wsman_release_client(cl); + ws_xml_destroy_doc(request); } -static void -example107() +static void example107() { -WsContextH cntx; -WsXmlDocH doc; -WsXmlNodeH node; -int retval; - - printf("\n\n ******** example7. Endpoint Reference ********\n"); - - cntx = wsman_create_runtime(); - if (cntx == NULL) { - printf("Error ws_create_runtime\n"); - return; - } - doc = wsman_create_doc(cntx, "example"); - node = ws_xml_get_doc_root(doc); - WsXmlAttrH attr; - attr = ws_xml_add_node_attr(node, NULL, "Name", "Attribute"); - attr = ws_xml_add_node_attr(node, NULL, "Name", "Attribute"); + WsContextH cntx; + WsXmlDocH doc; + WsXmlNodeH node; + int retval; + + printf + ("\n\n ******** example7. Endpoint Reference ********\n"); + + cntx = wsman_create_runtime(); + if (cntx == NULL) { + printf("Error ws_create_runtime\n"); + return; + } + doc = wsman_create_doc(cntx, "example"); + node = ws_xml_get_doc_root(doc); + WsXmlAttrH attr; + attr = ws_xml_add_node_attr(node, NULL, "Name", "Attribute"); + attr = ws_xml_add_node_attr(node, NULL, "Name", "Attribute"); } -static void -initialize_logging(void) +static void initialize_logging(void) { - debug_add_handler(wsman_debug_message_handler, DEBUG_LEVEL_ALWAYS, NULL); + debug_add_handler(wsman_debug_message_handler, DEBUG_LEVEL_ALWAYS, + NULL); } int debug_level = 0; -int -main(int argc, char **argv) +int main(int argc, char **argv) { - int num; - int i; - actionOptions options; - char retval = 0; - u_error_t *error = NULL; - u_option_entry_t opt[] = { - { "debug", 'd', U_OPTION_ARG_INT, &debug_level, - "Set the verbosity of debugging output.", "1-6" } - }; - u_option_context_t *opt_ctx; - opt_ctx = u_option_context_new(""); - u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); - u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify"); - retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); - - u_option_context_free(opt_ctx); - - if (error) { - if (error->message) - printf ("%s\n", error->message); - u_error_free(error); - return 1; - } - u_error_free(error); - - if (debug_level) { - initialize_logging(); - wsman_debug_set_level(debug_level); - } - - if (argc == 1) { - // execute all - example1(); - example2(); - example3(); - example4(); - example6(); - example7(); - return 0; - } - - for (i = 1; i < argc; i++) { - num = atoi(argv[i]); - switch (num) { - case 1: example1(); break; - case 2: example2(); break; - case 3: example3(); break; - case 4: example4(); break; -// case 5: example5(); break; - case 6: example6(); break; - case 7: example7(); break; - case 50: example50(); break; - case 106: example106(); break; - case 107: example107(); break; - default: - printf("\n No example%d()\n", num); - break; - } - } - return 0; + int num; + int i; + actionOptions options; + char retval = 0; + u_error_t *error = NULL; + u_option_entry_t opt[] = { + {"debug", 'd', U_OPTION_ARG_INT, &debug_level, + "Set the verbosity of debugging output.", "1-6"} + }; + u_option_context_t *opt_ctx; + opt_ctx = u_option_context_new(""); + u_option_context_set_ignore_unknown_options(opt_ctx, FALSE); + u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify"); + retval = u_option_context_parse(opt_ctx, &argc, &argv, &error); + + u_option_context_free(opt_ctx); + + if (error) { + if (error->message) + printf("%s\n", error->message); + u_error_free(error); + return 1; + } + u_error_free(error); + + if (debug_level) { + initialize_logging(); + wsman_debug_set_level(debug_level); + } + + if (argc == 1) { + // execute all + example1(); + example2(); + example3(); + example4(); + example5(); + example6(); + example7(); + return 0; + } + + for (i = 1; i < argc; i++) { + num = atoi(argv[i]); + switch (num) { + case 1: + example1(); + break; + case 2: + example2(); + break; + case 3: + example3(); + break; + case 4: + example4(); + break; + case 5: + example5(); + break; + case 6: + example6(); + break; + case 7: + example7(); + break; + case 50: + example50(); + break; + case 106: + example106(); + break; + case 107: + example107(); + break; + default: + printf("\n No example%d()\n", num); + break; + } + } + return 0; } diff --git a/examples/new_api_transfer_create.c b/examples/session_api_transfer_create.c index a46593d..a46593d 100644 --- a/examples/new_api_transfer_create.c +++ b/examples/session_api_transfer_create.c diff --git a/examples/new_api_example.c b/examples/session_example.c index da4bb08..da4bb08 100644 --- a/examples/new_api_example.c +++ b/examples/session_example.c diff --git a/examples/new_api_invoke.c b/examples/session_invoke.c index ff7ebc1..ff7ebc1 100644 --- a/examples/new_api_invoke.c +++ b/examples/session_invoke.c diff --git a/examples/new_api_transfer_get_put.c b/examples/session_transfer_get_put.c index 0cedd13..0cedd13 100644 --- a/examples/new_api_transfer_get_put.c +++ b/examples/session_transfer_get_put.c |