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); } }
void hash_free(hash_t *hash) { #ifdef KAZLIB_OBSOLESCENT_DEBUG assert ("call to obsolescent function hash_free()" && 0); #endif hash_free_nodes(hash); hash_destroy(hash); }
void Request_destroy(Request *req) { if(req) { Request_nuke_parts(req); hash_free_nodes(req->headers); hash_destroy(req->headers); free(req); } }
void Request_start(Request *req) { assert(req && "NULL pointer error."); http_parser_init(&(req->parser)); Request_nuke_parts(req); if(req->headers) { hash_free_nodes(req->headers); } }
static int check_for_duplicate_selectors(op_t * op) { WsXmlNodeH header, node, selector; int retval = 0, index = 0; hash_t *h; header = wsman_get_soap_header_element( op->in_doc, NULL, NULL); if ((node = ws_xml_get_child(header, 0, XML_NS_WS_MAN, WSM_SELECTOR_SET)) == NULL) { // No selectors return 0; } h = hash_create(HASHCOUNT_T_MAX, 0, 0); if (h == NULL) { generate_op_fault(op, WSMAN_INTERNAL_ERROR, OWSMAN_NO_DETAILS); error("could not create hash"); return 1; } while ((selector = ws_xml_get_child(node, index++, XML_NS_WS_MAN, WSM_SELECTOR))) { char *attrVal = ws_xml_find_attr_value(selector, NULL, WSM_NAME); if (!attrVal) continue; if (hash_lookup(h, attrVal)) { generate_op_fault(op, WSMAN_INVALID_SELECTORS, WSMAN_DETAIL_DUPLICATE_SELECTORS); debug("Selector %s duplicated", attrVal); retval = 1; break; } if (!hash_alloc_insert(h, attrVal, ws_xml_get_node_text(selector))) { generate_op_fault(op, WSMAN_INTERNAL_ERROR, OWSMAN_NO_DETAILS); retval = 1; error("hash_alloc_insert failed"); break; } } hash_free_nodes(h); hash_destroy(h); return retval; }
/** * Deletes auxiliary components created by CFst_Cps_AddSdAux from the state table. * * @param _this Pointer to automaton instance * @see Cps_AddSdAux CFst_Cps_AddSdAux * @see Cps_SetSdAux CFst_Cps_SetSdAux * @see Cps_FindState CFst_Cps_FindState */ void CGEN_PRIVATE CFst_Cps_DelSdAux(CFst* _this) { INT32 i = 0; /* Destroy composed state hash map */ /* NOTE: MUST be done before deleting auxiliary state components! */ hash_free_nodes((hash_t*)_this->m_lpCpsHash); hash_destroy((hash_t*)_this->m_lpCpsHash); _this->m_lpCpsHash = NULL; /* Destroy hash node pool */ if (_this->m_lpCpsHnpool) for (i=0; i<(INT32)(dlp_size(_this->m_lpCpsHnpool)/sizeof(hnode_t*)); i++) dlp_free(_this->m_lpCpsHnpool[i]); dlp_free(_this->m_lpCpsHnpool); _this->m_lpCpsHnpool = NULL; _this->m_nCpsHnpoolSize = 0; /* Delete auxiliary components from state table */ CData_DeleteComps(AS(CData,_this->sd),_this->m_nIcSdAux,3); _this->m_nIcSdAux = -1; }
int Upload_stream(Connection *conn, Handler *handler, int content_len) { char *data = NULL; int avail = 0; int offset = 0; int first_chunk = 1; int rc; hash_t *altheaders = NULL; bstring offsetstr; debug("max content length: %d, content_len: %d", MAX_CONTENT_LENGTH, content_len); IOBuf_resize(conn->iob, MAX_CONTENT_LENGTH); // give us a good buffer size while(content_len > 0) { if(first_chunk) { // read whatever's there data = IOBuf_read_some(conn->iob, &avail); } else if(conn->sendCredits > 0) { // read up to credits data = IOBuf_read(conn->iob, conn->sendCredits < content_len ? conn->sendCredits : content_len, &avail); conn->sendCredits -= avail; } else { // sleep until we have credits tasksleep(&conn->uploadRendez); continue; } check(!IOBuf_closed(conn->iob), "Closed while reading from IOBuf."); content_len -= avail; offsetstr = bformat("%d", offset); if(first_chunk) { Request_set(conn->req, &UPLOAD_STREAM, offsetstr, 1); if(content_len == 0) { Request_set(conn->req, &UPLOAD_STREAM_DONE, bfromcstr("1"), 1); } } else { altheaders = hash_create(2, (hash_comp_t)bstrcmp, bstr_hash_fun); add_to_hash(altheaders, &UPLOAD_STREAM, offsetstr); if(content_len == 0) { add_to_hash(altheaders, &UPLOAD_STREAM_DONE, bfromcstr("1")); } } rc = Connection_send_to_handler(conn, handler, data, avail, altheaders); check_debug(rc == 0, "Failed to deliver to the handler."); if(altheaders != NULL) { hash_free_nodes(altheaders); hash_destroy(altheaders); altheaders = NULL; } check(IOBuf_read_commit(conn->iob, avail) != -1, "Commit failed while streaming."); first_chunk = 0; offset += avail; } check(content_len == 0, "Failed to write everything to the large upload tmpfile."); return 0; error: return -1; }