예제 #1
0
void xmldb_deleteMetaInfo(IXML_Element* doc)
{
    IXML_NodeList* list = ixmlElement_getElementsByTagName(doc, OBIX_META);
    if (list == NULL)
    {
        log_debug("oBIX object doesn't contain any meta information.");
        return;
    }

    int length = ixmlNodeList_length(list);

    IXML_Node* node;
    int error;
    int i;

    for (i = 0; i < length; i++)
    {
        node = ixmlNodeList_item(list, i);
        error = ixmlNode_removeChild(ixmlNode_getParentNode(node), node, &node);
        if (error != IXML_SUCCESS)
        {
            log_warning("Unable to clean the oBIX object from meta information "
                        "(error %d).", error);
            ixmlNodeList_free(list);
            return;
        }
        ixmlNode_free(node);
    }

    ixmlNodeList_free(list);
}
예제 #2
0
IXML_Element* xmldb_getMetaInfo(IXML_Element* doc)
{
    IXML_NodeList* list = ixmlElement_getElementsByTagName(doc, OBIX_META);
    if (list == NULL)
    {
        return NULL;
    }

    int length = ixmlNodeList_length(list);
    int i;
    IXML_Node* result = NULL;

    for (i = 0; i < length; i++)
    {
        result = ixmlNodeList_item(list, i);
        // check that we have found meta of exactly this tag but not of
        // meta of it's child
        if (ixmlNode_getParentNode(result) == ixmlElement_getNode(doc))
        {
            ixmlNodeList_free(list);
            return ixmlNode_convertToElement(result);
        }
    }

    // We did not find anything
    ixmlNodeList_free(list);
    return NULL;
}
예제 #3
0
int xmldb_deleteMetaVariable(IXML_Node* meta)
{
    IXML_Node* metaItem = ixmlElement_getNode(
                              ixmlAttr_getOwnerElement(
                                  ixmlNode_convertToAttr(meta)));

    int error = ixmlNode_removeChild(
                    ixmlNode_getParentNode(metaItem), metaItem, &metaItem);
    if (error != IXML_SUCCESS)
    {
        log_error("Unable to delete meta data: ixmlNode_removeChild() "
                  "returned %d", error);
        return -1;
    }

    ixmlNode_free(metaItem);
    return 0;
}
예제 #4
0
int xmldb_delete(const char* href)
{
    IXML_Node* node = getNodeByHref(_storage, href, NULL);
    if (node == NULL)
    {
        log_warning("Unable to delete data. Provided URI (%s) doesn't "
                    "exist.", href);
        return -1;
    }

    int error = ixmlNode_removeChild(ixmlNode_getParentNode(node), node, &node);
    if (error != IXML_SUCCESS)
    {
        log_warning("Error occurred when deleting data (error %d).", error);
        return -1;
    }

    ixmlNode_free(node);
    return 0;
}
예제 #5
0
	if (!strcmp(name, "main_log")) glLog.main = debug2level(val);
	if (!strcmp(name, "sq2mr_log")) glLog.sq2mr = debug2level(val);
	if (!strcmp(name, "base_mac"))  sscanf(val,"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
								   &glMac[0],&glMac[1],&glMac[2],&glMac[3],&glMac[4],&glMac[5]);
	if (!strcmp(name, "upnp_scan_interval")) gluPNPScanInterval = atol(val);
	if (!strcmp(name, "upnp_scan_timeout")) gluPNPScanTimeout = atol(val);
 }


/*----------------------------------------------------------------------------*/
void *FindMRConfig(void *ref, char *UDN)
{
	IXML_Element *elm;
	IXML_Node	*device = NULL;
	IXML_NodeList *l1_node_list;
	IXML_Document *doc = (IXML_Document*) ref;
	char *v;
	unsigned i;

	elm = ixmlDocument_getElementById(doc, "squeeze2upnp");
	l1_node_list = ixmlDocument_getElementsByTagName((IXML_Document*) elm, "udn");
	for (i = 0; i < ixmlNodeList_length(l1_node_list); i++) {
		IXML_Node *l1_node, *l1_1_node;
		l1_node = ixmlNodeList_item(l1_node_list, i);
예제 #6
0
파일: rtpxml.c 프로젝트: layerfsd/cifssmb
RTPXML_Node* rtpxmlNode_getParentNode(RTPXML_Node *nodeptr)
{
	return ixmlNode_getParentNode((IXML_Node *)nodeptr);
}
예제 #7
0
파일: Convert.c 프로젝트: jamesyan84/zbase
void processInsertEncode(IXML_Document * persXmlDoc,U32 * InserID)
{
    int  i, numPending;
    IXML_NodeList  *nodeList;
    char  *xmlBuff;
    char * xmlBuff2;
    IXML_Node  *node;
    U32  tempId;
    char  persFile[128];
    INSERT_PENDING sInsertP;/* for InsertPending table */
    ENC_PENDING    sEncodeP;

    U32  affectedDiscId = 0;
    U32  prevDiscId;
    int  b_updated = 0;

    sprintf(persFile, ZRIP_OLD_TASKFILE);

    /* first test if have rip interupt */
    if ((nodeList = ixmlDocument_getElementsByTagName(persXmlDoc, "WavPending")) != NULL){
        if ((numPending = ixmlNodeList_length(nodeList)) != 0){
            if (numPending != 1){
                goto    funcOut;
            }

            if ((node = ixmlNodeList_item(nodeList, 0)) != NULL){
                if ((xmlBuff = ixmlElement_getAttribute((IXML_Element *)node, "discId")) != NULL){
                    sscanf(xmlBuff,"%x",&affectedDiscId);
                    xmlBuff2=ixmlElement_getAttribute((IXML_Element *)node, TOTAL_FRMTAG);
                    if(xmlBuff2)
                    {
                        sInsertP.uCDID = affectedDiscId;
                        sInsertP.ptrFrames = strdup(xmlBuff2);
                        InsertPendingTask(INSERTPENDING, &sInsertP);
                        ZFREE(sInsertP.ptrFrames);
                        /* Insert in to database */
                    }

                    if (ixmlNode_removeChild(ixmlNode_getParentNode(node), node, NULL) != IXML_SUCCESS){
                        ZError(DBG_ZRIP, "Failed to remove <WavPending>");
                    }
                    else{
                        b_updated = 1;
                    }
                }
            }
        }
        ixmlNodeList_free(nodeList);
    }

    /* second test if have EncPending */
    if ((nodeList = ixmlDocument_getElementsByTagName(persXmlDoc, "EncPending")) == NULL){
        goto funcOut;
    }

    if ((numPending = ixmlNodeList_length(nodeList)) == 0){
        ixmlNodeList_free(nodeList);
        goto funcOut;
    }

    prevDiscId = 0;
    node = NULL;

    for (i = 0; i < numPending; i++){
        if ((node = ixmlNodeList_item(nodeList, i)) == NULL){
            continue;
        }
        xmlBuff = ixmlElement_getAttribute((IXML_Element *)node, "discId");

        if (!xmlBuff){
            continue;
        }

        sscanf(xmlBuff,"%x",&tempId);
        if (affectedDiscId == tempId){
            continue;
        }

        /* getAudioFormat */
        xmlBuff = NULL;
        xmlBuff = ixmlElement_getAttribute((IXML_Element *)node, "AudioFormat");
        if (!xmlBuff){
            continue;
        }
        else{
            sEncodeP.ptrAudioFormat = strdup(xmlBuff);
		}
		if(strncasecmp(xmlBuff, AUDIO_MP3_TYPE, 3) == 0)
		{
			sEncodeP.ptrFormatCfg = strdup("128");
		}
		else
			sEncodeP.ptrFormatCfg = strdup("0");

        /* getpbject */
        xmlBuff = NULL;
        xmlBuff = ixmlElement_getAttribute((IXML_Element *)node, "objid");
        if (!xmlBuff){
            ZFREE(sEncodeP.ptrAudioFormat);
			ZFREE(sEncodeP.ptrFormatCfg);
            continue;
        }
        else{
            sEncodeP.objID = strdup(xmlBuff);
        }
	
		InsertPendingTask(ENCPENDING,&sEncodeP);	
        ZFREE(sEncodeP.ptrAudioFormat);
		ZFREE(sEncodeP.ptrFormatCfg);
        ZFREE(sEncodeP.objID);
        /* insert database */
    }

    for (i = 0; i < numPending; i++){
        if ((node = ixmlNodeList_item(nodeList, i)) == NULL){
            continue;
        }
        if (ixmlNode_removeChild(ixmlNode_getParentNode(node), node, NULL) != IXML_SUCCESS){
            ZError(DBG_ZRIP, "Failed to remove <WavPending>");
        }
    }
    /* remove all child */
    b_updated = 1;
    ixmlNodeList_free(nodeList);
funcOut:
    if ( affectedDiscId){
        /* delete no use  */
		*InserID = affectedDiscId;
    }
    if ( b_updated && ixmlUpdateDocument(persXmlDoc, persFile) == -1){
        dprintf("Unable to write file path->%s", persFile);
    }
    return;
}
예제 #8
0
파일: Convert.c 프로젝트: jamesyan84/zbase
void processCDDBUp(IXML_Document * persXmlDoc,U32 InserID)
{
    IXML_NodeList   *nodeList = NULL;
    IXML_Node       *node;
    int             i;
    int             numPending;
    char            *xmlBuff;
    char            * xmlBuff2=NULL;
    char            tempStr[1024];
    int             bUpdated = 0;
    CDDB_PENDING    sCddbP;

    sprintf(tempStr,ZRIP_OLD_TASKFILE);

    if ((nodeList = ixmlDocument_getElementsByTagName(persXmlDoc, "CDDBPending")) == NULL)
    {
        dprintf( "Can't find <CDDBPending> node in the %s file",
                tempStr);
        goto funcOut;
    }

    if ((numPending = ixmlNodeList_length(nodeList)) == 0)
    {
        dprintf( "Can't find any <CDDBPending> nodes in the %s file",
                tempStr);
        goto funcOut;
    }

    for (i = 0; i < numPending; i++)
    {
        if ((node = ixmlNodeList_item(nodeList, i)) == NULL)
        {
            continue;
        }
        xmlBuff = ixmlElement_getAttribute((IXML_Element *)node, "discId");
        if (!xmlBuff)
            continue;

        sscanf(xmlBuff,"%x",&sCddbP.uCDID);
		if(sCddbP.uCDID == InserID)
			continue;

        xmlBuff = ixmlGetFirstElementItem( (IXML_Element *)node, "playsecs" );
        if ( xmlBuff == NULL )
        {
            continue;
        }
        else
        {
            sCddbP.nPlaySecs = atoi(xmlBuff);
        }

        xmlBuff = ixmlGetFirstElementItem( (IXML_Element *)node, "tracks" );
        if ( xmlBuff == NULL )
        {
            continue;
        }
        else
        {
            sCddbP.uTotalTracks = atoi(xmlBuff);
        }

        xmlBuff2=ixmlGetFirstElementItem( (IXML_Element *)node, "frames" );

        if ( !xmlBuff2)
            continue;
        else{
            sCddbP.ptrFrames = strdup(xmlBuff2);
            ZFREE(xmlBuff2);
        }
        /* insert into database and free the memory */
        InsertPendingTask(CDDBPENDING,&sCddbP);
        ZFREE(sCddbP.ptrFrames);
    }

    /* free the xml */
    for (i = 0; i < numPending; i++)
    {
        if ((node = ixmlNodeList_item(nodeList, i)) == NULL)
        {
            continue;
        }
        if (ixmlNode_removeChild(ixmlNode_getParentNode(node), node, NULL) != IXML_SUCCESS){
            dprintf("Failed to remove <cddbPending>");
        }
    }
    bUpdated = 1;

funcOut:
    if ( nodeList )
        ixmlNodeList_free(nodeList);

    if (bUpdated && ixmlUpdateDocument(persXmlDoc, tempStr) == -1)
    {
        /* free it odirect */
        dprintf( "Unable to write file path->%s", tempStr);
    }

    return;
}
예제 #9
0
/******************************************************************************
 * DIDLObject_Create
 *****************************************************************************/
DIDLObject*
DIDLObject_Create (void* talloc_context,
		   IN IXML_Element* elem, 
		   IN bool is_container) 
{
	if (elem == NULL) {
		Log_Printf (LOG_ERROR, 
			    "DIDLObject can't create from NULL XML Element");
		return NULL; // ---------->
	}

	DIDLObject* o = talloc (talloc_context, DIDLObject);
	if (o) {
		*o = (DIDLObject) { 
			.is_container = is_container
		};

		IXML_Node* node = NULL;
		/* Steal the node from its parent (instead of copying it, given
		 * that the parent document is going to be deallocated anyway)
		 */
		ixmlNode_removeChild (ixmlNode_getParentNode (XML_E2N (elem)), 
				      XML_E2N (elem), &node);
		o->element = (IXML_Element*) node;

		// TBD need to copy ??
		o->id = talloc_strdup (o, ixmlElement_getAttribute
				       (o->element, "id"));
		if (o->id == NULL || o->id[0] == NUL) {
			char* s = DIDLObject_GetElementString (o, NULL);
			Log_Printf (LOG_ERROR, 
				    "DIDLObject can't create with NULL "
				    "or empty id, XML = %s", s);
			talloc_free (s);
			talloc_free (o);
			return NULL; // ---------->
		}

		o->title = XMLUtil_FindFirstElementValue (node, "dc:title", 
							  false, true);
		if (o->title == NULL)
			o->title = "";

		o->basename = String_CleanFileName (o, o->title);
		if (o->basename[0] == NUL) {
			char* s = DIDLObject_GetElementString (o, NULL);
			Log_Printf (LOG_WARNING, 
				    "DIDLObject NULL or empty <dc:title>, "
				    "XML = %s", s);
			talloc_free (s);
			talloc_free (o->basename);
			o->basename = talloc_asprintf (o, "-id-%s", o->id);
		} else if (o->basename[0] == '.' || o->basename[0] == '_') {
			o->basename[0] = '-';
		}
		
		o->cds_class = String_StripSpaces 
			(o, XMLUtil_FindFirstElementValue (node, "upnp:class",
							   false, true));
		if (o->cds_class == NULL)
			o->cds_class = "";

		char* s = ixmlElement_getAttribute (o->element, "searchable");
		o->searchable = String_ToBoolean (s, false);

		Log_Printf (LOG_DEBUG,
			    "new DIDLObject : %s : id='%s' "
			    "title='%s' class='%s'",
			    (is_container ? "container" : "item"), 
			    o->id, o->title, o->cds_class);
		
		// Register destructor
		talloc_set_destructor (o, DestroyObject);
	}
	return o;
}