示例#1
0
boxpath *       boxpath_from_string(const char * path)
{
	char * dir = dirname(strdup(path));
	char * file = basename(strdup(path));
	boxpath * bpath = (boxpath*) malloc(sizeof(boxpath));
  
	bpath->dir = xmlHashLookup(allDirs, dir);
	bpath->base = strdup(file);
	bpath->file = (strcmp(path,"/") ? NULL : rootDir);
	bpath->is_dir = (xmlHashLookup(allDirs, path)!=NULL);

	free(dir);
	return bpath; 
}
示例#2
0
/**
 * xsltCopyNamespace:
 * @ctxt:  a transformation context
 * @node:  the target node
 * @cur:  the namespace node
 *
 * Do a copy of an namespace node. If @node is non-NULL the
 * new namespaces are added automatically. This handles namespaces
 * aliases
 *
 * Returns: a new xmlNsPtr, or NULL in case of error.
 */
xmlNsPtr
xsltCopyNamespace(xsltTransformContextPtr ctxt, xmlNodePtr node,
	          xmlNsPtr cur) {
    xmlNsPtr ret = NULL;
    const xmlChar *URI;

    if (cur == NULL)
	return(NULL);
    if (cur->type != XML_NAMESPACE_DECL)
	return(NULL);

    /*
     * One can add namespaces only on element nodes
     */
    if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
	node = NULL;

    if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {
	URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,
					      cur->href);
	if (URI != NULL) {
	    ret = xmlNewNs(node, URI, cur->prefix);
	} else {
	    ret = xmlNewNs(node, cur->href, cur->prefix);
	}
    }
    return(ret);
}
示例#3
0
文件: schema.c 项目: ZoloZiak/reactos
static HRESULT WINAPI schema_cache_get(IXMLDOMSchemaCollection2* iface, BSTR uri,
                                       IXMLDOMNode** node)
{
    schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
    cache_entry* entry;
    xmlChar* name;

    TRACE("(%p)->(%s %p)\n", This, debugstr_w(uri), node);

    if (This->version == MSXML6)
    {
        if (node) *node = NULL;
        return E_NOTIMPL;
    }

    if (!node)
        return E_POINTER;

    *node = NULL;

    name = uri ? xmlchar_from_wchar(uri) : xmlchar_from_wchar(emptyW);
    entry = (cache_entry*) xmlHashLookup(This->cache, name);
    heap_free(name);

    /* TODO: this should be read-only */
    if (entry && entry->doc)
        return get_domdoc_from_xmldoc(entry->doc, (IXMLDOMDocument3**)node);

    return S_OK;
}
示例#4
0
文件: schema.c 项目: ZoloZiak/reactos
static xmlSchemaElementPtr lookup_schema_elemDecl(xmlSchemaPtr schema, xmlNodePtr node)
{
    xmlSchemaElementPtr decl = NULL;
    xmlChar const* nsURI = get_node_nsURI(node);

    TRACE("(%p, %p)\n", schema, node);

    if (xmlStrEqual(nsURI, schema->targetNamespace))
        decl = xmlHashLookup(schema->elemDecl, node->name);

    if (!decl && xmlHashSize(schema->schemasImports) > 1)
    {
        FIXME("declaration not found in main schema - need to check schema imports!\n");
        /*xmlSchemaImportPtr import;
        if (nsURI == NULL)
            import = xmlHashLookup(schema->schemasImports, XML_SCHEMAS_NO_NAMESPACE);
        else
            import = xmlHashLookup(schema->schemasImports, node->ns->href);

        if (import != NULL)
            decl = xmlHashLookup(import->schema->elemDecl, node->name);*/
    }

    return decl;
}
示例#5
0
/*
 * This is called by ??? when reading an annotation is encountered
 * while reading the instance data.
 */
xmlParserErrors instance_annotation_callback(void *handle, xmlNodePtr node)
{
    int i;
    char key[20];
    xmlChar* path;
    xmlDocPtr doc = node->doc;
    xmlXPathContextPtr xpathCtx = xmlXPathNewContext(doc);
    xmlXPathObjectPtr xpathObj;

    sprintf(key, "%p", handle);
    path = (xmlChar*)xmlHashLookup(Handle2Path, (xmlChar*)key);
    assert(path != NULL);

    printf("\noooooooooooo %s: %p\n", __FUNCTION__, handle);
    dump_doc(node->doc, node);
    /* walk_doc_tree(node, 0); */
    printf("\n");
    xpathCtx->node = node;
    xpathObj = xmlXPathEvalExpression(path, xpathCtx);
    if (xpathObj->nodesetval != NULL)
	for (i = 0; i < xpathObj->nodesetval->nodeNr; ++i)
	    printf("xpath(\"%s\") => %s\n", path,
		   xmlNodeGetContent(xpathObj->nodesetval->nodeTab[i]));
    return XML_ERR_OK;
}
示例#6
0
/**
 * xsltGetNamespace:
 * @ctxt:  a transformation context
 * @cur:  the input node
 * @ns:  the namespace
 * @out:  the output node (or its parent)
 *
 * Find a matching (prefix and ns-name) ns-declaration
 * for the requested @ns->prefix and @ns->href in the result tree.
 * If none is found then a new ns-declaration will be
 * added to @resultElem. If, in this case, the given prefix is
 * already in use, then a ns-declaration with a modified ns-prefix
 * be we created.
 *
 * Called by:
 *  - xsltCopyPropList() (*not*  anymore)
 *  - xsltShallowCopyElement()
 *  - xsltCopyTreeInternal() (*not*  anymore)
 *  - xsltApplySequenceConstructor() (*not* in the refactored code),
 *  - xsltElement() (*not* anymore)
 *
 * Returns a namespace declaration or NULL in case of
 *         namespace fixup failures or API or internal errors.
 */
xmlNsPtr
xsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns,
	         xmlNodePtr out)
{

    if (ns == NULL)
	return(NULL);

#ifdef XSLT_REFACTORED
    /*
    * Namespace exclusion and ns-aliasing is performed at
    * compilation-time in the refactored code.
    * Additionally, aliasing is not intended for non Literal
    * Result Elements.
    */
    return(xsltGetSpecialNamespace(ctxt, cur, ns->href, ns->prefix, out));
#else
    {
	xsltStylesheetPtr style;
	const xmlChar *URI = NULL; /* the replacement URI */

	if ((ctxt == NULL) || (cur == NULL) || (out == NULL))
	    return(NULL);

	style = ctxt->style;
	while (style != NULL) {
	    if (style->nsAliases != NULL)
		URI = (const xmlChar *)
		xmlHashLookup(style->nsAliases, ns->href);
	    if (URI != NULL)
		break;

	    style = xsltNextImport(style);
	}


	if (URI == UNDEFINED_DEFAULT_NS) {
	    return(xsltGetSpecialNamespace(ctxt, cur, NULL, NULL, out));
#if 0
	    /*
	    * TODO: Removed, since wrong. If there was no default
	    * namespace in the stylesheet then this must resolve to
	    * the NULL namespace.
	    */
	    xmlNsPtr dflt;
	    dflt = xmlSearchNs(cur->doc, cur, NULL);
	    if (dflt != NULL)
		URI = dflt->href;
	    else
		return NULL;
#endif
	} else if (URI == NULL)
	    URI = ns->href;

	return(xsltGetSpecialNamespace(ctxt, cur, URI, ns->prefix, out));
    }
#endif
}
示例#7
0
文件: schema.c 项目: r6144/wine
HRESULT SchemaCache_validate_tree(IXMLDOMSchemaCollection2* iface, xmlNodePtr tree)
{
    schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
    cache_entry* entry;
    xmlChar const* ns = NULL;
    TRACE("(%p, %p)\n", This, tree);

    if (!tree)
        return E_POINTER;

    if ((xmlNodePtr)tree->doc == tree)
    {
        xmlNodePtr root = xmlDocGetRootElement(tree->doc);
        if (root && root->ns)
            ns = root->ns->href;
    }
    else if (tree->ns)
    {
        ns = tree->ns->href;
    }

    entry = xmlHashLookup(This->cache, ns);
    /* TODO: if the ns is not in the cache, and it's a URL,
     *       do we try to load from that? */
    if (entry)
    {
        if (entry->type == SCHEMA_TYPE_XDR)
        {
            FIXME("partial stub: XDR schema support not implemented\n");
            return S_OK;
        }
        else if (entry->type == SCHEMA_TYPE_XSD)
        {
            xmlSchemaValidCtxtPtr svctx;
            int err;
            /* TODO: if validateOnLoad property is false,
             *       we probably need to validate the schema here. */
            svctx = xmlSchemaNewValidCtxt(entry->schema);
            xmlSchemaSetValidErrors(svctx, validate_error, validate_warning, NULL);
#ifdef HAVE_XMLSCHEMASSETVALIDSTRUCTUREDERRORS
            xmlSchemaSetValidStructuredErrors(svctx, validate_serror, NULL);
#endif

            if ((xmlNodePtr)tree->doc == tree)
                err = xmlSchemaValidateDoc(svctx, (xmlDocPtr)tree);
            else
                err = xmlSchemaValidateOneElement(svctx, tree);

            xmlSchemaFreeValidCtxt(svctx);
            return err? S_FALSE : S_OK;
        }
    }

    return E_FAIL;
}
示例#8
0
文件: schema.c 项目: r6144/wine
static void cache_copy(void* data, void* dest, xmlChar* name)
{
    schema_cache* This = (schema_cache*) dest;
    cache_entry* entry = (cache_entry*) data;

    if (xmlHashLookup(This->cache, name) == NULL)
    {
        cache_entry_add_ref(entry);
        xmlHashAddEntry(This->cache, name, entry);
    }
}
示例#9
0
/**
 * xsltGetKey:
 * @ctxt: an XSLT transformation context
 * @name:  the key name or NULL
 * @nameURI:  the name URI or NULL
 * @value:  the key value to look for
 *
 * Looks up a key of the in current source doc (the document info
 * on @ctxt->document). Computes the key if not already done
 * for the current source doc.
 *
 * Returns the nodeset resulting from the query or NULL
 */
xmlNodeSetPtr
xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name,
	   const xmlChar *nameURI, const xmlChar *value) {
    xmlNodeSetPtr ret;
    xsltKeyTablePtr table;
    int init_table = 0;

    if ((ctxt == NULL) || (name == NULL) || (value == NULL) ||
	(ctxt->document == NULL))
	return(NULL);

#ifdef WITH_XSLT_DEBUG_KEYS
    xsltGenericDebug(xsltGenericDebugContext,
	"Get key %s, value %s\n", name, value);
#endif

    /*
     * keys are computed only on-demand on first key access for a document
     */
    if ((ctxt->document->nbKeysComputed < ctxt->nbKeys) &&
        (ctxt->keyInitLevel == 0)) {
        /*
	 * If non-recursive behaviour, just try to initialize all keys
	 */
	if (xsltInitAllDocKeys(ctxt))
	    return(NULL);
    }

retry:
    table = (xsltKeyTablePtr) ctxt->document->keys;
    while (table != NULL) {
	if (((nameURI != NULL) == (table->nameURI != NULL)) &&
	    xmlStrEqual(table->name, name) &&
	    xmlStrEqual(table->nameURI, nameURI))
	{
	    ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value);
	    return(ret);
	}
	table = table->next;
    }

    if ((ctxt->keyInitLevel != 0) && (init_table == 0)) {
        /*
	 * Apparently one key is recursive and this one is needed,
	 * initialize just it, that time and retry
	 */
        xsltInitDocKeyTable(ctxt, name, nameURI);
	init_table = 1;
	goto retry;
    }

    return(NULL);
}
示例#10
0
/***********************************************************************
 * Function Name : CNTRLXMLGETReqHandler
 * Description   : This function calls the registered callback functions
 				   against the XML file URL
 * Input         : regUrl - XML file URL
 *				   pOutXMLStr - Response XML buffer
 * Output		 : none
 * Return value  : CNTRLXML_SUCCESS, CNTRLXML_FAILURE, CNTRLXML_BADPARAM
 ***********************************************************************/
t_char8
CNTRLXMLGETReqHandler (t_char8 * pInXMLFile, t_void * pAppData,
                     t_char8 ** pOutXMLStr)
{

  XMLTEMPLATE_CALLBACK_HANDLER pCbfun;
  t_int32 retStatus = CNTRLXML_SUCCESS;

  if (!pInXMLFile)
  {
    XML_Error ("pInXMLFile is NULL");
    return CNTRLXML_BADPARAM;
  }

  XML_DebugArg ("Look up for tag = ", pInXMLFile);
  pCbfun = xmlHashLookup (hTable, pInXMLFile);

  if (pCbfun != NULL)
  {
    XML_DebugArg ("Found function for tag =", pInXMLFile);
    retStatus = (*pCbfun) (pInXMLFile, pAppData);
    if (retStatus != CNTRLXML_SUCCESS)
    {
      XML_Error ("GET Request CbkFunction Failed");
      if(pXMLErrorStr)
      {
        *pOutXMLStr = xmlStrdup ((const xmlChar *) pXMLErrorStr);

        XML_DebugArg ("*pOutXMLStr=", *pOutXMLStr);
        XMLBUFFERFREE (pXMLErrorStr);

        pXMLErrorStr = NULL;

        return CNTRLXML_SUCCESS;
      }
      *pOutXMLStr = NULL;
      return CNTRLXML_FAILURE;
    }

    /**pOutXMLStr = (t_char8*) T_malloc(T_strlen(pXMLResultStr)+1);
    of_strcpy(*pOutXMLStr, pXMLResultStr);*/
    *pOutXMLStr = xmlStrdup ((const xmlChar *) pXMLResultStr);

    XML_DebugArg ("*pOutXMLStr=", *pOutXMLStr);
    XMLBUFFERFREE (pXMLResultStr);

    pXMLResultStr = NULL;

    return CNTRLXML_SUCCESS;

  }
  return CNTRLXML_FAILURE;
}
示例#11
0
/**
 * breakPointGet:
 * @url: Non-null, non-empty file name that has been loaded by
 *                    debugger
 * @lineNumber: lineNumber >= 0 and is available in @url
 *
 * Get a break point for the breakpoint collection
 *
 * Returns break point if break point exists at location specified,
 *	   NULL otherwise
*/
breakPointPtr
breakPointGet(const xmlChar * url, long lineNumber)
{
    xmlHashTablePtr breakHash = breakPointGetLineNoHash(lineNumber);
    breakPointPtr breakPtr = NULL;

    if (!breakHash || !url)
        return breakPtr;

    breakPtr = (breakPointPtr)xmlHashLookup(breakHash, url);
    return breakPtr;
}
示例#12
0
/*
 *  session_from_hargs
 *
 *  Return a session from a handler struct session key
 */
struct session* 
session_from_hargs(struct handler_args* hargs, 
    xmlHashTablePtr sessions, struct qz_config* conf){ 

    uint64_t etag_payload;
    unsigned char session_id[9];
    
    struct session* this_session;

    etag_payload = validate_etag(hargs->conf->tagger_socket_path, 
        hargs->session_key);

    if (etag_payload == 0){

        fprintf(hargs->log, "%f %d %s:%d session key not validated\n", 
            gettime(), hargs->request_id, __func__, __LINE__);

        return NULL;
    }

    memcpy(session_id, &etag_payload, 8);
    session_id[8] = '\0';

    this_session = xmlHashLookup(sessions, session_id);

    if (this_session==NULL){

        fprintf(hargs->log, "%f %d %s:%d null session from hash lookup\n", 
            gettime(), hargs->request_id, __func__, __LINE__);
        
        return NULL;
    }
    
    if (this_session->integrity_token != conf->integrity_token){
        // The last 64 bits of the session struct have been 
        // altered.  The session record is corrupted.
        // Clean up the session

        close_session(hargs, this_session);

        fprintf(hargs->log,"%f %d %s:%d session closed for bad integrity token",
            gettime(), hargs->request_id, __func__, __LINE__);
        
        return NULL;
    }

    fprintf(hargs->log, "%f %d %s:%d user=%s\n",
        gettime(), hargs->request_id, __func__, __LINE__,
        this_session->user);

    return this_session;
}
示例#13
0
static xar_file_t xar_link_lookup(xar_t x, dev_t dev, ino_t ino, xar_file_t f) {
	char key[32];
	xar_file_t ret;

	memset(key, 0, sizeof(key));
	snprintf(key, sizeof(key)-1, "%08" DEV_HEXSTRING "%08" INO_HEXSTRING, DEV_CAST dev, INO_CAST ino);
	ret = xmlHashLookup(XAR(x)->ino_hash, BAD_CAST(key));
	if( ret == NULL ) {
		xmlHashAddEntry(XAR(x)->ino_hash, BAD_CAST(key), XAR_FILE(f));
		return NULL;
	}
	return ret;
}
示例#14
0
USER_OBJECT_
R_libxmlTypeTable_lookup(USER_OBJECT_ table, USER_OBJECT_ name, USER_OBJECT_ s_elType)
{
   xmlHashTablePtr t;
   USER_OBJECT_ ans;
   void *p;

   t = R_getExternalRef(table, NULL); /* R_libxmlTypeTableGetRef(table); */
   p = xmlHashLookup(t, CHAR_DEREF(STRING_ELT(name, 0)));
   ans = R_makeRefObject(p, CHAR_DEREF(STRING_ELT(s_elType, 0)));

   return(ans);
}
示例#15
0
文件: keysmngr.c 项目: dnet/pyxmlsec
static void xmlsec_KeyStoreFinalizeMethod(xmlSecKeyStorePtr store) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyStoreFinalizeMethods, store->id->name);

  args = Py_BuildValue((char *) "O", wrap_xmlSecKeyStorePtr(store));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  Py_XDECREF(result);
}
示例#16
0
文件: keysdata.c 项目: dnet/pyxmlsec
static xmlSecKeyDataType xmlsec_KeyDataGetSizeMethod(xmlSecKeyDataPtr data) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataGetSizeMethods, data->id->name);

  args = Py_BuildValue((char *) "O", wrap_xmlSecKeyDataPtr(data));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
示例#17
0
文件: keysdata.c 项目: dnet/pyxmlsec
static const xmlChar* xmlsec_KeyDataGetIdentifierMethod(xmlSecKeyDataPtr data) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataGetIdentifierMethods, data->id->name);

  args = Py_BuildValue((char *) "O", wrap_xmlSecKeyDataPtr(data));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return ((const xmlChar*)PyString_AsString(result));
}
示例#18
0
文件: keysmngr.c 项目: dnet/pyxmlsec
static int xmlsec_KeyStoreInitializeMethod(xmlSecKeyStorePtr store) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyStoreInitializeMethods, store->id->name);

  args = Py_BuildValue((char *) "O", wrap_xmlSecKeyStorePtr(store));

  /* Protect refcount against reentrant manipulation of callback hash */
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
示例#19
0
文件: keysdata.c 项目: dnet/pyxmlsec
static void xmlsec_KeyDataDebugDumpMethod(xmlSecKeyDataPtr data, FILE *output) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataDebugDumpMethods, data->id->name);

  args = Py_BuildValue((char *) "OO", wrap_xmlSecKeyDataPtr(data),
		       PyFile_FromFile(output, NULL, NULL, NULL));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  Py_XDECREF(result);
}
示例#20
0
文件: keysdata.c 项目: dnet/pyxmlsec
static int xmlsec_KeyDataDuplicateMethod(xmlSecKeyDataPtr dst,
					 xmlSecKeyDataPtr src) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataDuplicateMethods, src->id->name);

  args = Py_BuildValue((char *) "OO", wrap_xmlSecKeyDataPtr(dst),
		       wrap_xmlSecKeyDataPtr(src));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
示例#21
0
/***********************************************************************
 * Function Name : CNTRLXMLGetRegHandler
 * Description   : This function retrives registered callback functions
 				   for the given Module name.
 * Input         : pInModule	- Module name
 * Output		 : pOutFunLst	- Registered function list
 * Return value  : CNTRLXML_SUCCESS, CNTRLXML_FAILURE, CNTRLXML_BADPARAM
 ***********************************************************************/
t_char8
CNTRLXMLGetRegHandler (t_char8 * pInModule, t_void ** pOutFunLst)
{

  XML_DebugArg ("Look up for tag = ", pInModule);
  *pOutFunLst = (t_void *) xmlHashLookup (pModSetTable, pInModule);

  if (*pOutFunLst == NULL)
  {
    XML_DebugArg ("Could not find function for tag", pInModule);
    return CNTRLXML_FAILURE;
  }
  XML_DebugArg ("Found function for tag = %s", pInModule);

  return CNTRLXML_SUCCESS;

}
示例#22
0
文件: keysmngr.c 项目: dnet/pyxmlsec
static xmlSecKeyPtr xmlsec_GetKeyCallback(xmlNodePtr keyInfoNode,
					  xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(GetKeyCallbacks,
		       keyInfoCtx->keysMngr->keysStore->id->name);

  args = Py_BuildValue((char *) "OO", wrap_xmlNodePtr(keyInfoNode),
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (xmlSecKeyPtr_get(result));
}
示例#23
0
文件: list.c 项目: DeltaOS/pyxmlsec
static void xmlsec_PtrDestroyItemMethod(xmlSecPtr ptr) {
  xmlSecPtrListPtr list;
  PyObject *args, *result;
  PyObject *func = NULL;

  list = (xmlSecPtrListPtr) ptr;
  func = xmlHashLookup(PtrDestroyItemMethods, list->id->name);

  args = Py_BuildValue((char *) "O", wrap_xmlSecPtr(ptr));

  /* Protect refcount against reentrant manipulation of callback hash */
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  Py_XDECREF(result);
}
示例#24
0
文件: keysdata.c 项目: dnet/pyxmlsec
static int xmlsec_KeyDataXmlWriteMethod(xmlSecKeyDataId id, xmlSecKeyPtr key,
					xmlNodePtr node,
					xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataXmlWriteMethods, id->name);

  args = Py_BuildValue((char *) "OOOO", wrap_xmlSecKeyDataId(id),
		       wrap_xmlSecKeyPtr(key), wrap_xmlNodePtr(node),
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
示例#25
0
文件: list.c 项目: DeltaOS/pyxmlsec
static void xmlsec_PtrDebugXmlDumpItemMethod(xmlSecPtr ptr, FILE *output) {
  xmlSecPtrListPtr list;
  PyObject *args, *result;
  PyObject *func = NULL;

  list = (xmlSecPtrListPtr) ptr;
  func = xmlHashLookup(PtrDebugXmlDumpItemMethods, list->id->name);

  /* FIXME */
  args = Py_BuildValue((char *) "OO", wrap_xmlSecPtr(ptr),
		       PyFile_FromFile(output, NULL, NULL, NULL));

  /* Protect refcount against reentrant manipulation of callback hash */
  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  Py_XDECREF(result);
}
示例#26
0
/**
 * xsltCopyNamespaceList:
 * @ctxt:  a transformation context
 * @node:  the target node
 * @cur:  the first namespace
 *
 * Do a copy of an namespace list. If @node is non-NULL the
 * new namespaces are added automatically. This handles namespaces
 * aliases
 *
 * Returns: a new xmlNsPtr, or NULL in case of error.
 */
xmlNsPtr
xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
	              xmlNsPtr cur) {
    xmlNsPtr ret = NULL;
    xmlNsPtr p = NULL,q;
    const xmlChar *URI;

    if (cur == NULL)
	return(NULL);
    if (cur->type != XML_NAMESPACE_DECL)
	return(NULL);

    /*
     * One can add namespaces only on element nodes
     */
    if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
	node = NULL;

    while (cur != NULL) {
	if (cur->type != XML_NAMESPACE_DECL)
	    break;
	if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {
	    /* TODO apply cascading */
	    URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,
		                                  cur->href);
	    if (URI != NULL) {
		q = xmlNewNs(node, URI, cur->prefix);
	    } else {
		q = xmlNewNs(node, cur->href, cur->prefix);
	    }
	    if (p == NULL) {
		ret = p = q;
	    } else {
		p->next = q;
		p = q;
	    }
	}
	cur = cur->next;
    }
    return(ret);
}
示例#27
0
// Move a dir to another path in the tree,
// recursively updating all the child entries in allDirs
void	boxtree_movedir(const char * from, const char * to)
{
	boxdir * aDir = xmlHashLookup(allDirs, from);
        list_iter it;
        char * newfrom, * newto, *name;
	if(!aDir) {
	  syslog(LOG_ERR, "no such directory %s", from);
	  return;
	}
        for (it=list_get_iter(aDir->folders); it; it = list_iter_next(it)) {
            name = ((boxfile*)list_iter_getval(it))->name;
            newfrom = pathappend(from, name);
            newto   = pathappend(to,   name);
            boxtree_movedir(newfrom, newto);
            free(newfrom); free(newto);
        }
	//LOCKDIR(aDir);
	xmlHashRemoveEntry(allDirs, from, NULL);
	xmlHashAddEntry(allDirs, to, aDir);
	//UNLOCKDIR(aDir);
}
示例#28
0
文件: keysdata.c 项目: dnet/pyxmlsec
static int xmlsec_KeyDataBinReadMethod(xmlSecKeyDataId id,
				      xmlSecKeyPtr key,
				      const xmlSecByte *buf,
				      xmlSecSize bufSize,
				      xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyDataBinReadMethods, id->name);

  args = Py_BuildValue((char *) "OOsiO", wrap_xmlSecKeyDataId(id),
		       wrap_xmlSecKeyPtr(key), buf, bufSize,
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  Py_DECREF(func);
  Py_DECREF(args);

  return (PyInt_AsLong(result));
}
示例#29
0
文件: keysmngr.c 项目: dnet/pyxmlsec
static xmlSecKeyPtr xmlsec_KeyStoreFindKeyMethod(xmlSecKeyStorePtr store,
						 xmlChar *name,
						 xmlSecKeyInfoCtxPtr keyInfoCtx) {
  PyObject *args, *result;
  PyObject *func = NULL;

  func = xmlHashLookup(KeyStoreFindKeyMethods, store->id->name);

  args = Py_BuildValue((char *) "OsO", wrap_xmlSecKeyStorePtr(store), name,
		       wrap_xmlSecKeyInfoCtxPtr(keyInfoCtx));

  Py_INCREF(func);
  result = PyEval_CallObject(func, args);
  if (result == NULL) {
    return (NULL);
  }
  Py_DECREF(func);
  Py_DECREF(args);

  return (xmlSecKeyPtr_get(result));
}
示例#30
0
文件: schema.c 项目: r6144/wine
static HRESULT WINAPI schema_cache_get(IXMLDOMSchemaCollection2* iface, BSTR uri,
                                       IXMLDOMNode** node)
{
    schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
    xmlChar* name;
    cache_entry* entry;
    TRACE("(%p)->(%s, %p)\n", This, wine_dbgstr_w(uri), node);

    if (!node)
        return E_POINTER;

    name = xmlChar_from_wchar(uri);
    entry = (cache_entry*) xmlHashLookup(This->cache, name);
    heap_free(name);

    /* TODO: this should be read-only */
    if (entry)
        return DOMDocument_create_from_xmldoc(entry->doc, (IXMLDOMDocument3**)node);

    *node = NULL;
    return S_OK;
}