⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upnptools.c

📁 原来由英特尔制定的UPnP SDK的
💻 C
📖 第 1 页 / 共 2 页
字号:
    if( ActionDoc == NULL ) {        return NULL;    }    if( NumArg > 0 ) {        //va_start(ArgList, Arg);        ArgName = Arg;        for ( ; ; ) {            ArgValue = va_arg( ArgList, const char * );            if( ArgName != NULL ) {                node = ixmlNode_getFirstChild( ( IXML_Node * ) ActionDoc );                Ele = ixmlDocument_createElement( ActionDoc, ArgName );                if( ArgValue ) {                    Txt =                        ixmlDocument_createTextNode( ActionDoc, ArgValue );                    ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );                }                ixmlNode_appendChild( node, ( IXML_Node * ) Ele );            }            if (++Idx < NumArg) {                ArgName = va_arg( ArgList, const char * );            } else {                break;            }        }        //va_end(ArgList);    }    return ActionDoc;}/************************************************************************* Function : UpnpMakeAction** Parameters:*	IN char * ActionName: Name of the action request or response*	IN char * ServType: Service type*	IN int NumArg :Number of arguments in the action request or response*	IN char * Arg : pointer to the first argument*	IN ... : variable argument list*	IN va_list ArgList: Argument list** Description:*	This function creates the action request from the argument* list. Its a wrapper function that calls makeAction function to create* the action request.** Returns: IXML_Document **	returns action request document if successful *	else returns NULL***************************************************************************/IXML_Document *UpnpMakeAction( const char *ActionName,                const char *ServType,                int NumArg,                const char *Arg,                ... ){    va_list ArgList;    IXML_Document *out = NULL;    va_start( ArgList, Arg );    out = makeAction( 0, ActionName, ServType, NumArg, Arg, ArgList );    va_end( ArgList );    return out;}/************************************************************************* Function : UpnpMakeActionResponse** Parameters:*	IN char * ActionName: Name of the action request or response*	IN char * ServType: Service type*	IN int NumArg :Number of arguments in the action request or response*	IN char * Arg : pointer to the first argument*	IN ... : variable argument list*	IN va_list ArgList: Argument list** Description:*	This function creates the action response from the argument* list. Its a wrapper function that calls makeAction function to create* the action response.** Returns: IXML_Document **	returns action response document if successful*	else returns NULL***************************************************************************/IXML_Document *UpnpMakeActionResponse( const char *ActionName,                        const char *ServType,                        int NumArg,                        const char *Arg,                        ... ){    va_list ArgList;    IXML_Document *out = NULL;    va_start( ArgList, Arg );    out = makeAction( 1, ActionName, ServType, NumArg, Arg, ArgList );    va_end( ArgList );    return out;}/************************************************************************* Function : UpnpAddToActionResponse** Parameters:*	INOUT IXML_Document **ActionResponse: action response document*	IN char * ActionName: Name of the action request or response*	IN char * ServType: Service type*	IN int ArgName :Name of argument to be added in the action response*	IN char * ArgValue : value of the argument** Description:*	This function adds the argument in the action response. Its a wrapper* function that calls addToAction function to add the argument in the* action response.** Returns: int*	returns UPNP_E_SUCCESS if successful*	else returns appropriate error***************************************************************************/intUpnpAddToActionResponse( INOUT IXML_Document ** ActionResponse,                         IN const char *ActionName,                         IN const char *ServType,                         IN const char *ArgName,                         IN const char *ArgValue ){    return addToAction( 1, ActionResponse, ActionName, ServType, ArgName,                        ArgValue );}/************************************************************************* Function : UpnpAddToAction** Parameters:*	INOUT IXML_Document **ActionDoc: action request document*	IN char * ActionName: Name of the action request or response*	IN char * ServType: Service type*	IN int ArgName :Name of argument to be added in the action response*	IN char * ArgValue : value of the argument** Description:*	This function adds the argument in the action request. Its a wrapper* function that calls addToAction function to add the argument in the* action request.** Returns: int*	returns UPNP_E_SUCCESS if successful*	else returns appropriate error***************************************************************************/intUpnpAddToAction( IXML_Document ** ActionDoc,                 const char *ActionName,                 const char *ServType,                 const char *ArgName,                 const char *ArgValue ){    return addToAction( 0, ActionDoc, ActionName, ServType, ArgName,                        ArgValue );}/************************************************************************* Function : UpnpAddToPropertySet** Parameters:*	INOUT IXML_Document **PropSet: propertyset document*	IN char *ArgName: Name of the argument*	IN char *ArgValue: value of the argument** Description:*	This function adds the argument in the propertyset node** Returns: int*	returns UPNP_E_SUCCESS if successful else returns appropriate error***************************************************************************/intUpnpAddToPropertySet( INOUT IXML_Document ** PropSet,                      IN const char *ArgName,                      IN const char *ArgValue ){    char BlankDoc[] = "<e:propertyset xmlns:e=\"urn:schemas"        "-upnp-org:event-1-0\"></e:propertyset>";    IXML_Node *node;    IXML_Element *Ele;    IXML_Element *Ele1;    IXML_Node *Txt;    int rc;    if( ArgName == NULL ) {        return UPNP_E_INVALID_PARAM;    }    if( *PropSet == NULL ) {        rc = ixmlParseBufferEx( BlankDoc, PropSet );        if( rc != IXML_SUCCESS ) {            return UPNP_E_OUTOF_MEMORY;        }    }    node = ixmlNode_getFirstChild( ( IXML_Node * ) * PropSet );    Ele1 = ixmlDocument_createElement( *PropSet, "e:property" );    Ele = ixmlDocument_createElement( *PropSet, ArgName );    if( ArgValue ) {        Txt = ixmlDocument_createTextNode( *PropSet, ArgValue );        ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );    }    ixmlNode_appendChild( ( IXML_Node * ) Ele1, ( IXML_Node * ) Ele );    ixmlNode_appendChild( node, ( IXML_Node * ) Ele1 );    return UPNP_E_SUCCESS;}/************************************************************************* Function : UpnpCreatePropertySet** Parameters:*	IN int NumArg: Number of argument that will go in the propertyset node*	IN char * Args: argument strings** Description:*	This function creates a propertyset node and put all the input*	parameters in the node as elements** Returns: IXML_Document **	returns the document containing propertyset node.***************************************************************************/IXML_Document *UpnpCreatePropertySet( IN int NumArg,                       IN const char *Arg,                       ... ){    va_list ArgList;    int Idx = 0;    char BlankDoc[] = "<e:propertyset xmlns:e=\"urn:schemas-"        "upnp-org:event-1-0\"></e:propertyset>";    const char *ArgName,     *ArgValue;    IXML_Node *node;    IXML_Element *Ele;    IXML_Element *Ele1;    IXML_Node *Txt;    IXML_Document *PropSet;    if( ixmlParseBufferEx( BlankDoc, &PropSet ) != IXML_SUCCESS ) {        return NULL;    }    if( NumArg < 1 ) {        return NULL;    }    va_start( ArgList, Arg );    ArgName = Arg;    while( Idx++ != NumArg ) {        ArgValue = va_arg( ArgList, const char * );        if( ArgName != NULL /*&& ArgValue != NULL */  ) {            node = ixmlNode_getFirstChild( ( IXML_Node * ) PropSet );            Ele1 = ixmlDocument_createElement( PropSet, "e:property" );            Ele = ixmlDocument_createElement( PropSet, ArgName );            if( ArgValue ) {                Txt = ixmlDocument_createTextNode( PropSet, ArgValue );                ixmlNode_appendChild( ( IXML_Node * ) Ele, Txt );            }            ixmlNode_appendChild( ( IXML_Node * ) Ele1,                                  ( IXML_Node * ) Ele );            ixmlNode_appendChild( node, ( IXML_Node * ) Ele1 );        }        ArgName = va_arg( ArgList, const char * );    }    va_end( ArgList );    return PropSet;}#endif // EXCLUDE_DOM == 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -