summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnas Nashif <nashif@intel.com>2008-03-03 19:50:31 +0000
committerAnas Nashif <nashif@intel.com>2008-03-03 19:50:31 +0000
commit6a0fa43a4e637718e923a8e4b3f1b2fe9f5338ce (patch)
tree8bcf998e897592b328543d76bbe8f1f06a6b4d51
parent49996770e4878592a3ceca9c48736a4d9774b873 (diff)
downloadwsmancli-6a0fa43a4e637718e923a8e4b3f1b2fe9f5338ce.tar.gz
wsmancli-6a0fa43a4e637718e923a8e4b3f1b2fe9f5338ce.tar.xz
wsmancli-6a0fa43a4e637718e923a8e4b3f1b2fe9f5338ce.zip
update with new API support complex filters
-rw-r--r--examples/enum_epr.c44
-rw-r--r--examples/win32_service.c2
-rw-r--r--src/wseventmgr.c8
-rw-r--r--src/wsman.c18
-rw-r--r--tests/interop/interop.c8
5 files changed, 42 insertions, 38 deletions
diff --git a/examples/enum_epr.c b/examples/enum_epr.c
index 88805b5..7b94942 100644
--- a/examples/enum_epr.c
+++ b/examples/enum_epr.c
@@ -54,44 +54,44 @@ typedef struct __WsmanEpr WsmanEpr;
static int collect_epr(WsManClient *cl, WsXmlDocH doc, void *data)
{
-
+
if (!doc) {
return 0;
}
list_t *list = (list_t *)data;
WsXmlNodeH resource_uri_node, node1, node2, node3, node4;
-
+
WsmanEpr *epr = (WsmanEpr *)u_zalloc(sizeof(WsmanEpr));
WsXmlNodeH body = ws_xml_get_soap_body(doc);
-
+
if (body != NULL)
node1 = ws_xml_get_child(body, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP);
- else
+ else
return 0;
-
+
if (node1 != NULL )
node2 = ws_xml_get_child(node1, 0, XML_NS_ENUMERATION, WSENUM_ITEMS);
else
return 0;
- if (node2 != NULL)
+ if (node2 != NULL)
node3 = ws_xml_get_child(node2, 0, XML_NS_ADDRESSING, WSA_EPR);
else
return 0;
- if (node3 != NULL)
+ if (node3 != NULL)
node4 = ws_xml_get_child(node3, 0, XML_NS_ADDRESSING, WSA_REFERENCE_PARAMETERS);
else
return 0;
-
- if (node4 != NULL)
+
+ if (node4 != NULL)
resource_uri_node = ws_xml_get_child(node4, 0, XML_NS_WS_MAN, WSM_RESOURCE_URI);
else
return 0;
-
+
if (resource_uri_node != NULL) {
epr->resource_uri = u_strdup(ws_xml_get_node_text(resource_uri_node));
} else {
@@ -108,14 +108,14 @@ static int collect_epr(WsManClient *cl, WsXmlDocH doc, void *data)
char* attrVal = ws_xml_find_attr_value(selector, XML_NS_WS_MAN, WSM_NAME);
if ( attrVal == NULL )
attrVal = ws_xml_find_attr_value(selector, NULL, WSM_NAME);
-
+
if ( attrVal ) {
if (!hash_alloc_insert(epr->selectors, u_strdup(attrVal), u_strdup(ws_xml_get_node_text(selector)))) {
error("hash_alloc_insert failed");
}
}
}
-
+
}
lnode_t *n = lnode_create(epr);
@@ -128,7 +128,7 @@ static int collect_epr(WsManClient *cl, WsXmlDocH doc, void *data)
int main(int argc, char** argv)
{
-
+
WsManClient *cl;
client_opt_t *options;
char retval = 0;
@@ -141,7 +141,7 @@ int main(int argc, char** argv)
{ NULL }
};
- u_option_context_t *opt_ctx;
+ 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, "Win32 Service");
@@ -173,17 +173,17 @@ int main(int argc, char** argv)
uri->path,
uri->scheme,
uri->user,
- uri->pwd);
+ uri->pwd);
wsmc_transport_init(cl, NULL);
options = wsmc_options_init();
wsmc_set_action_option(options, FLAG_ENUMERATION_ENUM_EPR);
-
+
list_t *l = list_create(LISTCOUNT_T_MAX);
- wsmc_action_enumerate_and_pull(cl, argv[1] , options, collect_epr, l );
-
-
+ wsmc_action_enumerate_and_pull(cl, argv[1] , options, NULL, collect_epr, l );
+
+
printf("returned items: %d\n", (int)list_count(l));
lnode_t *node = list_first(l);
while(node) {
@@ -197,14 +197,14 @@ int main(int argc, char** argv)
printf("\t%s = %s\n", (char*) hnode_getkey(hn),
(char*) hnode_get(hn) );
}
-
+
node = list_next (l, node);
- }
+ }
if (uri) {
u_uri_free(uri);
}
-
+
wsmc_options_destroy(options);
wsmc_release(cl);
return 0;
diff --git a/examples/win32_service.c b/examples/win32_service.c
index 5c96e4e..6c37ec7 100644
--- a/examples/win32_service.c
+++ b/examples/win32_service.c
@@ -246,7 +246,7 @@ int main(int argc, char** argv)
if (listall) {
if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST );
- wsmc_action_enumerate_and_pull(cl, RESOURCE_URI, options, list_services, NULL );
+ wsmc_action_enumerate_and_pull(cl, RESOURCE_URI, options, NULL, list_services, NULL );
} else if (start && argv[1]) {
if (dump) wsmc_set_action_option(options,FLAG_DUMP_REQUEST );
wsmc_add_selector(options, "Name", argv[1]);
diff --git a/src/wseventmgr.c b/src/wseventmgr.c
index eb6d920..60dac93 100644
--- a/src/wseventmgr.c
+++ b/src/wseventmgr.c
@@ -411,6 +411,7 @@ int main(int argc, char **argv)
char *event_mode, *delivery_uri;
char *resource_uri = NULL;
char subscontext[512];
+ filter_t *filter = NULL;
if (!wsman_parse_options(argc, argv)) {
exit(EXIT_FAILURE);
}
@@ -485,14 +486,13 @@ int main(int argc, char **argv)
wsmc_set_action_option(options, FLAG_DUMP_REQUEST);
}
if (wsm_filter) {
- options->filter = filter_create_simple(wsm_dialect, wsm_filter );
+ filter = filter_create_simple(wsm_dialect, wsm_filter );
}
options->cim_ns = cim_namespace;
switch (op) {
case WSMAN_ACTION_PULL:
- doc =
- wsmc_action_pull(cl, resource_uri, options,
+ doc = wsmc_action_pull(cl, resource_uri, options, filter,
enum_context);
wsman_output(cl, doc);
if (doc) {
@@ -526,7 +526,7 @@ int main(int argc, char **argv)
*/
if(event_reference_properties)
options->reference = event_reference_properties;
- rqstDoc = wsmc_action_subscribe(cl, resource_uri, options);
+ rqstDoc = wsmc_action_subscribe(cl, resource_uri, options, filter);
wsman_output(cl, rqstDoc);
if (rqstDoc) {
ws_xml_destroy_doc(rqstDoc);
diff --git a/src/wsman.c b/src/wsman.c
index 5ad0d5c..f67350c 100644
--- a/src/wsman.c
+++ b/src/wsman.c
@@ -548,7 +548,12 @@ int main(int argc, char **argv)
char *event_mode, *delivery_uri;
char *resource_uri = NULL;
char subscontext[512];
+ filter_t *filter = NULL;
+
+
filename = (char *) config_file;
+
+
if (filename) {
ini = iniparser_new(filename);
if (ini == NULL) {
@@ -727,9 +732,7 @@ int main(int argc, char **argv)
}
break;
case WSMAN_ACTION_PULL:
- doc =
- wsmc_action_pull(cl, resource_uri, options,
- enum_context);
+ doc = wsmc_action_pull(cl, resource_uri, options, filter, enum_context);
wsman_output(cl, doc);
if (doc) {
ws_xml_destroy_doc(doc);
@@ -754,7 +757,7 @@ int main(int argc, char **argv)
epr_add_selector_text(epr, CIM_NAMESPACE_SELECTOR, options->cim_ns);
}
if (epr) {
- options->filter = filter_create_assoc(epr, (op == WSMAN_ACTION_REFERENCES )?0:1, NULL, NULL, NULL, NULL, NULL, 0 );
+ filter = filter_create_assoc(epr, (op == WSMAN_ACTION_REFERENCES )?0:1, NULL, NULL, NULL, NULL, NULL, 0 );
}
} else {
error("Filter Requied");
@@ -798,7 +801,7 @@ int main(int argc, char **argv)
wsmc_set_action_option(options,
FLAG_ENUMERATION_COUNT_ESTIMATION);
}
- enum_response = wsmc_action_enumerate(cl, resource_uri, options);
+ enum_response = wsmc_action_enumerate(cl, resource_uri, options, filter);
wsman_output(cl, enum_response);
if (enum_response) {
if (!(wsmc_get_response_code(cl) == 200 ||
@@ -817,7 +820,7 @@ int main(int argc, char **argv)
break;
while (enumContext != NULL && enumContext[0] != 0) {
- doc = wsmc_action_pull(cl, resource_uri, options,
+ doc = wsmc_action_pull(cl, resource_uri, options, filter,
enumContext);
wsman_output(cl, doc);
@@ -862,7 +865,7 @@ int main(int argc, char **argv)
*/
if(event_reference_properties)
options->reference = event_reference_properties;
- rqstDoc = wsmc_action_subscribe(cl, resource_uri, options);
+ rqstDoc = wsmc_action_subscribe(cl, resource_uri, options, filter);
wsman_output(cl, rqstDoc);
if (rqstDoc) {
ws_xml_destroy_doc(rqstDoc);
@@ -905,6 +908,7 @@ int main(int argc, char **argv)
}
}
wsmc_options_destroy(options);
+ filter_destroy(filter);
wsmc_transport_fini(cl);
wsmc_release(cl);
if (ini) {
diff --git a/tests/interop/interop.c b/tests/interop/interop.c
index 3402da4..c537091 100644
--- a/tests/interop/interop.c
+++ b/tests/interop/interop.c
@@ -121,14 +121,14 @@ static int run_interop_test (WsManClient *cl, WsXmlNodeH scenario, InteropTest i
WsXmlNodeH input = ws_xml_get_child(scenario, 0, NULL, "Input");
WsXmlNodeH r = ws_xml_get_child(input, 0, NULL, "ResourceURI");
char *resource_uri = ws_xml_get_node_text(r);
- wsmc_action_enumerate_and_pull(cl, resource_uri , options, pull_items, NULL );
+ wsmc_action_enumerate_and_pull(cl, resource_uri , options, NULL, pull_items, NULL );
} else if (id == 9) { // 7.2 Optimized Enumerate
wsmc_set_action_option(options, FLAG_ENUMERATION_OPTIMIZATION);
WsXmlNodeH input = ws_xml_get_child(scenario, 0, NULL, "Input");
WsXmlNodeH r = ws_xml_get_child(input, 0, NULL, "ResourceURI");
char *resource_uri = ws_xml_get_node_text(r);
- wsmc_action_enumerate_and_pull(cl, resource_uri , options, pull_items, NULL );
+ wsmc_action_enumerate_and_pull(cl, resource_uri , options, NULL, pull_items, NULL );
} else if (id == 10) { // 7.3 Enumerate failure
/*
@@ -152,14 +152,14 @@ static int run_interop_test (WsManClient *cl, WsXmlNodeH scenario, InteropTest i
WsXmlNodeH input = ws_xml_get_child(scenario, 0, NULL, "Input");
WsXmlNodeH r = ws_xml_get_child(input, 0, NULL, "ResourceURI");
char *resource_uri = ws_xml_get_node_text(r);
- wsmc_action_enumerate_and_pull(cl, resource_uri , options, pull_items, NULL );
+ wsmc_action_enumerate_and_pull(cl, resource_uri , options, NULL, pull_items, NULL );
}else if (id == 16) { // 7.9 Enumerate Polymorphism
wsmc_set_action_option(options, FLAG_POLYMORPHISM_NONE);
WsXmlNodeH input = ws_xml_get_child(scenario, 0, NULL, "Input");
WsXmlNodeH r = ws_xml_get_child(input, 0, NULL, "ResourceURI");
char *resource_uri = ws_xml_get_node_text(r);
- wsmc_action_enumerate_and_pull(cl, resource_uri , options, pull_items, NULL );
+ wsmc_action_enumerate_and_pull(cl, resource_uri , options, NULL, pull_items, NULL );
}else if (id == 17) { // 8.1 Invoke
WsXmlNodeH input = ws_xml_get_child(scenario, 0, NULL, "Input");