/** * Base class implementation of destructor. * * @param _this This instance */ void CDlpObject_Destructor(CDlpObject* _this) { SWord* lpWord; hnode_t* hn; hscan_t hs; DEBUGMSG(-1,"CDlpObject_Destructor for '%s'",_this->m_lpInstanceName,0,0); /* Detach external instances */ hash_scan_begin(&hs,_this->m_lpDictionary); while ((hn = hash_scan_next(&hs))!=NULL) { DLPASSERT((lpWord = (SWord*)hnode_get(hn))!=NULL); /* NULL entry in dictionary */ if ( lpWord->nWordType == WL_TYPE_FIELD && lpWord->ex.fld.nType == T_INSTANCE ) { CHECK_IPTR(*(CDlpObject**)lpWord->lpData,lpWord->ex.fld.nISerialNum); if (CDlpObject_GetParent(*(CDlpObject**)lpWord->lpData)!=_this) *(CDlpObject**)lpWord->lpData = NULL; } } #ifndef __NORTTI /* Clear words */ if(NOK(CDlpObject_UnregisterAllWords(_this)) ) IERROR(_this,ERR_DESTROY," Error while UnregisterAllWords of instance %s !", _this->m_lpInstanceName,0); /* Clear operators */ if(NOK(CDlpObject_UnregisterAllOperators(_this)) ) IERROR(_this,ERR_DESTROY," Error while UnregisterAllOperators of instance %s !", _this->m_lpInstanceName,0); #endif /* Destroy dictionaries */ if(!hash_isempty(_this->m_lpObsIds)) IERROR(_this,ERR_DESTROY, " Destructor of instance '%s': hash 'ObsIds' not empty !", _this->m_lpInstanceName,0); if(!hash_isempty(_this->m_lpDictionary)) IERROR(_this,ERR_DESTROY, " Destructor of instance '%s': hash 'Dictionary' not empty !", _this->m_lpInstanceName,0); if(!hash_isempty(_this->m_lpOpDict)) IERROR(_this,ERR_DESTROY, " Destructor of instance '%s': hash 'OpDict' not empty !", _this->m_lpInstanceName,0); hash_destroy(_this->m_lpObsIds ); hash_destroy(_this->m_lpDictionary); hash_destroy(_this->m_lpOpDict); #ifdef __cplusplus /* Unregister */ dlp_xalloc_unregister_object(_this); #endif }
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); }
void hash_destroy(hash_t *hash) { assert (hash_val_t_bit != 0); assert (hash_isempty(hash)); free(hash->table); free(hash); }
hash_t * wsman_get_selectors_from_epr(WsContextH cntx, WsXmlNodeH epr_node) { WsXmlNodeH selector, node, epr; selector_entry *sentry; int index = 0; hash_t *h = hash_create2(HASHCOUNT_T_MAX, 0, 0); node = ws_xml_get_child(epr_node, 0, XML_NS_WS_MAN, WSM_SELECTOR_SET); if (!node) { debug("no SelectorSet defined"); hash_destroy(h); return NULL; } while ((selector = ws_xml_get_child(node, index++, XML_NS_WS_MAN, WSM_SELECTOR))) { 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 && !hash_lookup(h, attrVal)) { sentry = u_malloc(sizeof(*sentry)); epr = ws_xml_get_child(selector, 0, XML_NS_ADDRESSING, WSA_EPR); if (epr) { debug("epr: %s", attrVal); sentry->type = 1; sentry->entry.eprp = epr_deserialize(selector, XML_NS_ADDRESSING, WSA_EPR, 1); if (!hash_alloc_insert(h, attrVal, sentry)) { error("hash_alloc_insert failed"); } } else { debug("text: %s", attrVal); sentry->type = 0; sentry->entry.text = ws_xml_get_node_text(selector); if (!hash_alloc_insert(h, attrVal, sentry)) { error("hash_alloc_insert failed"); } } } } if (!hash_isempty(h)) return h; hash_destroy(h); return NULL; }
CP_HIDDEN void cpi_free_context(cp_context_t *context) { assert(context != NULL); // Free environment if this is the client program context if (context->plugin == NULL && context->env != NULL) { free_plugin_env(context->env); } // Destroy symbol lists if (context->resolved_symbols != NULL) { assert(hash_isempty(context->resolved_symbols)); hash_destroy(context->resolved_symbols); } if (context->symbol_providers != NULL) { assert(hash_isempty(context->symbol_providers)); hash_destroy(context->symbol_providers); } // Free context free(context); }
CP_C_API cp_status_t cp_register_ploader(cp_context_t *ctx, cp_plugin_loader_t *loader) { cp_status_t status = CP_OK; hash_t *loader_plugins = NULL; CHECK_NOT_NULL(ctx); CHECK_NOT_NULL(loader); cpi_lock_context(ctx); cpi_check_invocation(ctx, CPI_CF_ANY, __func__); do { if ((loader_plugins = hash_create(HASHCOUNT_T_MAX, (int (*)(const void *, const void *)) strcmp, NULL)) == NULL) { status = CP_ERR_RESOURCE; break; } if (!hash_alloc_insert(ctx->env->loaders_to_plugins, loader, loader_plugins)) { status = CP_ERR_RESOURCE; break; } } while (0); // Report error or success if (status != CP_OK) { cpi_errorf(ctx, N_("The plug-in loader %p could not be registered due to insufficient memory."), (void *) loader); } else { cpi_debugf(ctx, N_("The plug-in loader %p was registered."), (void *) loader); } cpi_unlock_context(ctx); // Release resources if (status != CP_OK) { if (loader_plugins != NULL) { assert(hash_isempty(loader_plugins)); hash_destroy(loader_plugins); } } return status; }
static void free_plugin_env(cp_plugin_env_t *env) { assert(env != NULL); // Free environment data if (env->plugin_listeners != NULL) { cpi_unregister_plisteners(env->plugin_listeners, NULL); list_destroy(env->plugin_listeners); env->plugin_listeners = NULL; } if (env->loggers != NULL) { cpi_unregister_loggers(env->loggers, NULL); list_destroy(env->loggers); env->loggers = NULL; } if (env->local_loader != NULL) { cp_destroy_local_ploader(env->local_loader); env->local_loader = NULL; } if (env->loaders_to_plugins != NULL) { assert(hash_isempty(env->loaders_to_plugins)); hash_destroy(env->loaders_to_plugins); env->loaders_to_plugins = NULL; } if (env->infos != NULL) { assert(hash_isempty(env->infos)); hash_destroy(env->infos); env->infos = NULL; } if (env->plugins != NULL) { assert(hash_isempty(env->plugins)); hash_destroy(env->plugins); env->plugins = NULL; } if (env->started_plugins != NULL) { assert(list_isempty(env->started_plugins)); list_destroy(env->started_plugins); env->started_plugins = NULL; } if (env->ext_points != NULL) { assert(hash_isempty(env->ext_points)); hash_destroy(env->ext_points); } if (env->extensions != NULL) { assert(hash_isempty(env->extensions)); hash_destroy(env->extensions); } if (env->run_funcs != NULL) { assert(list_isempty(env->run_funcs)); list_destroy(env->run_funcs); } // Destroy mutex #ifdef CP_THREADS if (env->mutex != NULL) { cpi_destroy_mutex(env->mutex); } #endif // Free environment free(env); }
hash_t * wsman_get_method_args(WsContextH cntx, const char *resource_uri) { char *input = NULL; WsXmlDocH doc = cntx->indoc; hash_t *h = hash_create(HASHCOUNT_T_MAX, 0, 0); hash_set_allocator(h, NULL, wsman_free_method_hnode, NULL); if (doc) { WsXmlNodeH in_node; WsXmlNodeH body = ws_xml_get_soap_body(doc); char *mn = wsman_get_method_name(cntx); input = u_strdup_printf("%s_INPUT", mn); in_node = ws_xml_get_child(body, 0, resource_uri, input); if (!in_node) { char *xsd = u_strdup_printf("%s.xsd", resource_uri); in_node = ws_xml_get_child(body, 0, xsd, input); u_free(xsd); } if (in_node) { WsXmlNodeH arg, epr; int index = 0; list_t *arglist = list_create(LISTCOUNT_T_MAX); lnode_t *argnode; while ((arg = ws_xml_get_child(in_node, index++, NULL, NULL))) { char *key = ws_xml_get_node_local_name(arg); selector_entry *sentry = u_malloc(sizeof(*sentry)); methodarglist_t *nodeval = u_malloc(sizeof(methodarglist_t)); epr = ws_xml_get_child(arg, 0, XML_NS_ADDRESSING, WSA_REFERENCE_PARAMETERS); nodeval->key = u_strdup(key); nodeval->arraycount = 0; argnode = lnode_create(nodeval); if (epr) { debug("epr: %s", key); sentry->type = 1; sentry->entry.eprp = epr_deserialize(arg, NULL, NULL, 1); //wsman_get_epr(cntx, arg, key, XML_NS_CIM_CLASS); } else { debug("text: %s", key); sentry->type = 0; sentry->entry.text = u_strdup(ws_xml_get_node_text(arg)); } nodeval->data = sentry; list_append(arglist, argnode); } if (!hash_alloc_insert(h, METHOD_ARGS_KEY, arglist)) { error("hash_alloc_insert failed"); wsman_free_method_list(arglist); } } u_free(mn); u_free(input); } else { error("error: xml document is NULL"); } if (!hash_isempty(h)) return h; hash_destroy(h); return NULL; }