void wsmc_add_selector_from_uri(WsXmlDocH doc, const char *resource_uri) { u_uri_t *uri; WsXmlNodeH header = ws_xml_get_soap_header(doc); hash_t *query; hnode_t *hn; hscan_t hs; if (resource_uri != NULL) { if (u_uri_parse((const char *) resource_uri, &uri) != 0) return; else if (!uri->query) goto cleanup; } query = u_parse_query(uri->query); hash_scan_begin(&hs, query); while ((hn = hash_scan_next(&hs))) { wsman_add_selector(header, (char *) hnode_getkey(hn), (char *) hnode_get(hn)); debug("key=%s value=%s", (char *) hnode_getkey(hn), (char *) hnode_get(hn)); } hash_free_nodes(query); hash_destroy(query); cleanup: if (uri) { u_uri_free(uri); } }
CP_C_API void cp_unregister_ploaders(cp_context_t *ctx) { int found; CHECK_NOT_NULL(ctx); cpi_lock_context(ctx); cpi_check_invocation(ctx, CPI_CF_ANY, __func__); do { hscan_t hscan; hnode_t *hnode; hash_scan_begin(&hscan, ctx->env->loaders_to_plugins); do { hnode = hash_scan_next(&hscan); } while (hnode != NULL && hnode_getkey(hnode) == ctx->env->local_loader); if (hnode != NULL) { cp_plugin_loader_t *loader = (cp_plugin_loader_t *) hnode_getkey(hnode); cp_unregister_ploader(ctx, loader); found = 1; } else { found = 0; } } while (found); cpi_unlock_context(ctx); }
static list_t * set_vendor_namespaces(void) { hscan_t hs; hnode_t *hn; int i; list_t *l = list_create(LISTCOUNT_T_MAX); for (i = 0; CimResource_Namespaces[i].ns != NULL; i++) { WsSupportedNamespaces *ns = (WsSupportedNamespaces *)u_malloc(sizeof(WsSupportedNamespaces)); ns->class_prefix = CimResource_Namespaces[i].class_prefix; ns->ns = (char*) CimResource_Namespaces[i].ns; lnode_t *node = lnode_create(ns); list_append(l, node); } if (vendor_namespaces && hash_count(vendor_namespaces) > 0 ) { hash_scan_begin(&hs, vendor_namespaces); while ((hn = hash_scan_next(&hs))) { WsSupportedNamespaces *ns = (WsSupportedNamespaces *)u_malloc(sizeof(WsSupportedNamespaces)); ns->class_prefix = (char*)hnode_getkey(hn); ns->ns = (char*) hnode_get(hn); lnode_t *node = lnode_create(ns); list_append(l, node); } } return l; }
CP_C_API void cp_unregister_ploader(cp_context_t *ctx, cp_plugin_loader_t *loader) { hnode_t *hnode; CHECK_NOT_NULL(ctx); CHECK_NOT_NULL(loader); cpi_lock_context(ctx); cpi_check_invocation(ctx, CPI_CF_ANY, __func__); hnode = hash_lookup(ctx->env->loaders_to_plugins, loader); if (hnode != NULL) { hash_t *loader_plugins = hnode_get(hnode); // Uninstall all plug-ins loaded by the loader while (!hash_isempty(loader_plugins)) { hscan_t hscan; hnode_t *hnode2; cp_status_t status; hash_scan_begin(&hscan, loader_plugins); hnode2 = hash_scan_next(&hscan); assert(hnode2 != NULL); status = cp_uninstall_plugin(ctx, hnode_getkey(hnode2)); assert(status == CP_OK); } hash_delete_free(ctx->env->loaders_to_plugins, hnode); assert(hash_isempty(loader_plugins)); hash_destroy(loader_plugins); cpi_debugf(ctx, N_("The plug-in loader %p was unregistered."), (void *) loader); } cpi_unlock_context(ctx); }
epr_t *epr_from_string(const char* str) { char *p; char *uri; hash_t *selectors; hash_t *selectors_new; hnode_t *hn; hscan_t hs; selector_entry *entry; epr_t *epr; p = strchr(str, '?'); uri = u_strndup(str, p - str); selectors = u_parse_query(p + 1); selectors_new = hash_create2(HASHCOUNT_T_MAX, 0, 0); hash_scan_begin(&hs, selectors); while ((hn = hash_scan_next(&hs))) { entry = u_malloc(sizeof(selector_entry)); entry->type = 0; entry->entry.text = (char *)hnode_get(hn); hash_alloc_insert(selectors_new, hnode_getkey(hn), entry); } epr = epr_create(uri, selectors_new, NULL); hash_free(selectors_new); hash_free(selectors); u_free(uri); return epr; }
static void wsmc_set_put_prop(WsXmlDocH get_response, WsXmlDocH put_request, client_opt_t *options) { WsXmlNodeH resource_node; char *ns_uri; hscan_t hs; hnode_t *hn; WsXmlNodeH get_body = ws_xml_get_soap_body(get_response); WsXmlNodeH put_body = ws_xml_get_soap_body(put_request); ws_xml_copy_node(ws_xml_get_child(get_body, 0, NULL, NULL), put_body); resource_node = ws_xml_get_child(put_body, 0, NULL, NULL); ns_uri = ws_xml_get_node_name_ns_uri(resource_node); if (!options->properties) { return; } hash_scan_begin(&hs, options->properties); while ((hn = hash_scan_next(&hs))) { WsXmlNodeH n = ws_xml_get_child(resource_node, 0, ns_uri, (char *) hnode_getkey(hn)); ws_xml_set_node_text(n, (char *) hnode_get(hn)); } }
void wsmc_add_selector_from_options(WsXmlDocH doc, client_opt_t *options) { WsXmlNodeH header; hnode_t *hn; hscan_t hs; if (!options->selectors || hash_count(options->selectors) == 0) return; header = ws_xml_get_soap_header(doc); hash_scan_begin(&hs, options->selectors); while ((hn = hash_scan_next(&hs))) { wsman_add_selector(header, (char *) hnode_getkey(hn), (char *) hnode_get(hn)); debug("key = %s value=%s", (char *) hnode_getkey(hn), (char *) hnode_get(hn)); } }
static void req_free_hash(hnode_t *node, void *notused) { (void)notused; bstrListDestroy((struct bstrList *)hnode_get(node)); bdestroy((bstring)hnode_getkey(node)); free(node); }
static void wsman_free_method_hnode(hnode_t * n, void *dummy) { if (strcmp(METHOD_ARGS_KEY, (char *)hnode_getkey(n)) == 0) { wsman_free_method_list((list_t *)hnode_get(n)); } u_free(n); }
epr_t *epr_create(const char *uri, hash_t * selectors, const char *address) { epr_t *epr = NULL; epr = u_malloc(sizeof(epr_t)); if (address == NULL) epr->address = u_strdup(WSA_TO_ANONYMOUS); else epr->address = u_strdup(address); epr->refparams.uri = u_strdup(uri); if (selectors) { hnode_t *hn; hscan_t hs; Selector *p; selector_entry *entry; epr->refparams.selectorset.count = hash_count(selectors); epr->refparams.selectorset.selectors = u_malloc(sizeof(Selector)* epr->refparams.selectorset.count); p = epr->refparams.selectorset.selectors; hash_scan_begin(&hs, selectors); while ((hn = hash_scan_next(&hs))) { p->name = u_strdup((char *)hnode_getkey(hn)); entry = (selector_entry *)hnode_get(hn); if(entry->type == 0) { p->type = 0; p->value = u_strdup(entry->entry.text); debug("key = %s value=%s", (char *) hnode_getkey(hn), p->value); } else { p->type = 1; p->value = (char *)epr_copy(entry->entry.eprp); debug("key = %s value=%p(nested epr)", (char *) hnode_getkey(hn), p->value); } p++; } } else { epr->refparams.selectorset.count = 0; epr->refparams.selectorset.selectors = NULL; } return epr; }
static void printhash( hash_t *hash ){ hscan_t hs; hnode_t *hn; hash_scan_begin(&hs, hash); while ((hn = hash_scan_next(&hs))) printf("%s\t%s\n", (char*) hnode_getkey(hn), (char*) hnode_get(hn)); }
/* convert openwsman hash_t* to hash VALUE (string pairs) */ static VALUE hash2value( hash_t *hash ) { VALUE v; hnode_t *node; hscan_t ptr; if (!hash) return Qnil; hash_scan_begin( &ptr, hash ); v = rb_hash_new(); while ((node = hash_scan_next( &ptr )) ) { rb_hash_aset( v, makestring( hnode_getkey( node ) ), makestring( hnode_get( node ) ) ); } return v; }
void camconfig_dest( CamConfig *ccfg ){ hscan_t hs; hnode_t *node; hash_scan_begin( &hs, ccfg->mainhash ); while( (node = hash_scan_next( &hs ))) { char *key; CamConfigSection *val; key = hnode_getkey( node ); val = hnode_get( node ); hash_scan_delete( ccfg->mainhash, node ); ccfg->mainhash->freenode( node, ccfg->mainhash->context ); free( key ); section_dest( val ); } hash_destroy( ccfg->mainhash ); free( ccfg ); }
static void section_dest( CamConfigSection *section ){ hscan_t hs; hnode_t *node; hash_scan_begin( &hs, section->entryhash ); while( (node = hash_scan_next( &hs ))) { char *key, *val; key = hnode_getkey( node ); val = hnode_get( node ); hash_scan_delete( section->entryhash, node ); section->entryhash->freenode( node, section->entryhash->context ); free( key ); free( val ); } hash_destroy( section->entryhash ); free( section ); }
void ekhtml_parser_destroy(ekhtml_parser_t *ekparser){ hnode_t *hn; hscan_t hs; hash_scan_begin(&hs, ekparser->startendcb); while((hn = hash_scan_next(&hs))){ ekhtml_string_t *key = (ekhtml_string_t *)hnode_getkey(hn); ekhtml_tag_container *cont = hnode_get(hn); hash_scan_delfree(ekparser->startendcb, hn); free((char *)key->str); free(key); free(cont); } hash_destroy(ekparser->startendcb); ekhtml_parser_starttag_cleanup(ekparser); free(ekparser->buf); free(ekparser); }
static char * get_cim_indication_namespace(WsSubscribeInfo *subsInfo, char *classname) { hscan_t hs; hnode_t *hn; char *sub; if (strstr(subsInfo->uri, XML_NS_CIM_CLASS) != NULL) { return u_strdup(subsInfo->uri); } hash_t *namespaces = subsInfo->vendor_namespaces; if (namespaces) { hash_scan_begin(&hs, namespaces); while ((hn = hash_scan_next(&hs))) { debug("namespace=%s", (char *) hnode_get(hn)); if ((sub = strstr(classname, (char *) hnode_getkey(hn)))) { return u_strdup((char *)hnode_get(hn)); } } } return NULL; }
/// Breaks up the aggregation and uploads each piece separately. /// Audit groups do not nest. Therefore, when we see an aggregating /// cmd while already within an audit group, the "outer" group becomes /// invalid. This method traverses an audit group, publishes each of /// its audits individually, and destroys the group, thus clearing /// the way for the "inner" group to take over. /// @param[in] ldr the leader object pointer /// @param[in] process a function pointer to the publishing callback void ca_disband(ca_o ldr, void (*process) (ca_o)) { hnode_t *hnp; ck_o ck; ca_o sub; hscan_t hscan; _ca_verbosity_ag(ldr, "DISBANDING", NULL); hash_scan_begin(&hscan, ldr->ca_group_hash); for (hnp = hash_scan_next(&hscan); hnp; hnp = hash_scan_next(&hscan)) { ck = (ck_o)hnode_getkey(hnp); sub = (ca_o)hnode_get(hnp); if (ca_get_closed(sub)) { _ca_verbosity_ag(sub, "PROCESSING", NULL); ca_coalesce(sub); process(sub); } else { _ca_verbosity_ag(sub, "RELEASING", NULL); } ca_set_leader(sub, NULL); hash_scan_delete(ldr->ca_group_hash, hnp); hnode_destroy(hnp); ck_destroy(ck); } if (ca_get_closed(ldr)) { _ca_verbosity_ag(ldr, "PROCESSING", NULL); ca_coalesce(ldr); process(ldr); } else { _ca_verbosity_ag(ldr, "RELEASING", NULL); } hash_destroy(ldr->ca_group_hash); ldr->ca_group_hash = NULL; ca_set_leader(ldr, NULL); }
/// Finish off the CA by formatting it and sending it off. /// @param[in] ca the object pointer /// @param[in] process a function pointer to the publishing callback void ca_publish(ca_o ca, void (*process) (ca_o)) { _ca_verbosity_ag(ca, "BUNDLING", NULL); // Combine the textual command lines of the subcommands for record keeping. if (ca->ca_group_hash) { hscan_t hscan; hnode_t *hnp; ck_o ck; ca_o sub; hash_scan_begin(&hscan, ca->ca_group_hash); for (hnp = hash_scan_next(&hscan); hnp; hnp = hash_scan_next(&hscan)) { ck = (ck_o)hnode_getkey(hnp); sub = (ca_o)hnode_get(hnp); if (sub != ca) { _ca_verbosity_ag(sub, "MERGING", NULL); ca_merge(ca, sub); ca_set_processed(sub, 1); } hash_scan_delete(ca->ca_group_hash, hnp); hnode_destroy(hnp); ck_destroy(ck); } hash_destroy(ca->ca_group_hash); ca->ca_group_hash = NULL; } // Merge all PAs in subcommands in with the PA set of the leader. // Must be done before serializing for upload but after subcmds // are merged in. ca_coalesce(ca); // The sub CAs have now been sucked dry. Publish the fully merged leader. process(ca); }