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

📄 upnpapi.c

📁 Upnp开发包文件
💻 C
📖 第 1 页 / 共 5 页
字号:
UpnpSetMaxSubscriptions( IN UpnpDevice_Handle Hnd,                         IN int MaxSubscriptions ){    struct Handle_Info *SInfo = NULL;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpSetMaxSubscriptions \n" );         )        HandleLock(  );    if( ( ( MaxSubscriptions != UPNP_INFINITE )          && ( MaxSubscriptions < 0 ) )        || ( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    SInfo->MaxSubscriptions = MaxSubscriptions;    HandleUnlock(  );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpSetMaxSubscriptions \n" );         )        return UPNP_E_SUCCESS;}  /***************** End of UpnpSetMaxSubscriptions ********************/#endif // INCLUDE_DEVICE_APIS#ifdef INCLUDE_DEVICE_APIS/************************************************************************** * Function: UpnpSetMaxSubscriptionTimeOut  * *  Parameters:	 *		IN UpnpDevice_Handle Hnd: The handle of the device for which the *								maximum subscription time-out is being set. *		IN int MaxSubscriptionTimeOut:The maximum subscription time-out  *									to be accepted * *  Description: *      This function sets the maximum subscription timer. Control points *	will require to send the subscription request before timeout. * *  Return Values: int *      UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/intUpnpSetMaxSubscriptionTimeOut( IN UpnpDevice_Handle Hnd,                               IN int MaxSubscriptionTimeOut ){    struct Handle_Info *SInfo = NULL;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpSetMaxSubscriptionTimeOut \n" );         )        HandleLock(  );    if( ( ( MaxSubscriptionTimeOut != UPNP_INFINITE )          && ( MaxSubscriptionTimeOut < 0 ) )        || ( GetHandleInfo( Hnd, &SInfo ) != HND_DEVICE ) ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    SInfo->MaxSubscriptionTimeOut = MaxSubscriptionTimeOut;    HandleUnlock(  );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpSetMaxSubscriptionTimeOut \n" );         )        return UPNP_E_SUCCESS;}  /****************** End of UpnpSetMaxSubscriptionTimeOut ******************/#endif // INCLUDE_DEVICE_APIS#ifdef INCLUDE_CLIENT_APIS/************************************************************************** * Function: UpnpSubscribeAsync  * *  Parameters:	 *		IN UpnpClient_Handle Hnd: The handle of the control point for which  *								the subscription request is to be sent. *		IN const char * EvtUrl_const: URL that control point wants to  *								subscribe *		IN int TimeOut: The requested subscription time.  Upon  *                      return, it contains the actual subscription time  *						returned from the service *		IN Upnp_FunPtr Fun : callback function to tell result of the  *							subscription request *		IN const void * Cookie_const: cookie passed by client to give back  *				in the callback function. * *  Description: *      This function performs the same operation as UpnpSubscribeAsync *	but returns immediately and calls the registered callback function  *	when the operation is complete. * *  Return Values: int *      UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/intUpnpSubscribeAsync( IN UpnpClient_Handle Hnd,                    IN const char *EvtUrl_const,                    IN int TimeOut,                    IN Upnp_FunPtr Fun,                    IN const void *Cookie_const ){    struct Handle_Info *SInfo = NULL;    struct UpnpNonblockParam *Param;    char *EvtUrl = ( char * )EvtUrl_const;    ThreadPoolJob job;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpSubscribeAsync \n" );         )        HandleLock(  );    if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    if( EvtUrl == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    if( TimeOut != UPNP_INFINITE && TimeOut < 1 ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    if( Fun == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    Param =        ( struct UpnpNonblockParam * )        malloc( sizeof( struct UpnpNonblockParam ) );    if( Param == NULL ) {        HandleUnlock(  );        return UPNP_E_OUTOF_MEMORY;    }    HandleUnlock(  );    Param->FunName = SUBSCRIBE;    Param->Handle = Hnd;    strcpy( Param->Url, EvtUrl );    Param->TimeOut = TimeOut;    Param->Fun = Fun;    Param->Cookie = ( void * )Cookie_const;    TPJobInit( &job, ( start_routine ) UpnpThreadDistribution, Param );    TPJobSetFreeFunction( &job, ( free_routine ) free );    TPJobSetPriority( &job, MED_PRIORITY );    ThreadPoolAdd( &gSendThreadPool, &job, NULL );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpSubscribeAsync \n" );         )        return UPNP_E_SUCCESS;}  /****************** End of UpnpSubscribeAsync *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APIS/************************************************************************** * Function: UpnpSubscribe  * *  Parameters:	 *		IN UpnpClient_Handle Hnd: The handle of the control point. *		IN const char *PublisherUrl: The URL of the service to subscribe to. *		INOUT int *TimeOut: Pointer to a variable containing the requested  *					subscription time.  Upon return, it contains the *					actual subscription time returned from the service. *		OUT Upnp_SID SubsId: Pointer to a variable to receive the  *							subscription ID (SID).  * *  Description: *      This function registers a control point to receive event *  notifications from another device.  This operation is synchronous * *  Return Values: int *      UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/intUpnpSubscribe( IN UpnpClient_Handle Hnd,               IN const char *EvtUrl_const,               INOUT int *TimeOut,               OUT Upnp_SID SubsId ){    struct Handle_Info *SInfo = NULL;    int RetVal;    char *EvtUrl = ( char * )EvtUrl_const;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpSubscribe \n" );         )        HandleLock(  );    if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    if( EvtUrl == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    if( TimeOut == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    if( SubsId == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    HandleUnlock(  );    RetVal = genaSubscribe( Hnd, EvtUrl, TimeOut, SubsId );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpSubscribe \n" );         )        return RetVal;}  /****************** End of UpnpSubscribe  *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APIS/************************************************************************** * Function: UpnpUnSubscribe  * *  Parameters:	 *		IN UpnpClient_Handle Hnd: The handle of the control point. *		IN Upnp_SID SubsId: The ID returned when the control point  *                                 subscribed to the service. * *  Description: *      This function removes the subscription of  a control point from a  *  service previously subscribed to using UpnpSubscribe or  *  UpnpSubscribeAsync. This is a synchronous call. * *  Return Values: int *      UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/intUpnpUnSubscribe( IN UpnpClient_Handle Hnd,                 IN Upnp_SID SubsId ){    struct Handle_Info *SInfo = NULL;    int RetVal;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpUnSubscribe \n" );         )        HandleLock(  );    if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    if( SubsId == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    HandleUnlock(  );    RetVal = genaUnSubscribe( Hnd, SubsId );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpUnSubscribe \n" );         )        return RetVal;}  /****************** End of UpnpUnSubscribe  *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APIS/************************************************************************** * Function: UpnpUnSubscribeAsync  * *  Parameters:	 *		IN UpnpClient_Handle Hnd: The handle of the subscribed control  *                                point.  *		IN Upnp_SID SubsId:	The ID returned when the control point  *                           subscribed to the service. *		IN Upnp_FunPtr Fun:Pointer to a callback function to be called *                          when the operation is complete.  *		IN const void *Cookie:Pointer to user data to pass to the                              callback function when invoked. * *  Description: *      This function removes a subscription of a control point *  from a service previously subscribed to using UpnpSubscribe or *	UpnpSubscribeAsync,generating a callback when the operation is complete. * *  Return Values: int *      UPNP_E_SUCCESS if successful else sends appropriate error. ***************************************************************************/intUpnpUnSubscribeAsync( IN UpnpClient_Handle Hnd,                      IN Upnp_SID SubsId,                      IN Upnp_FunPtr Fun,                      IN const void *Cookie_const ){    ThreadPoolJob job;    struct Handle_Info *SInfo = NULL;    struct UpnpNonblockParam *Param;    if( UpnpSdkInit != 1 ) {        return UPNP_E_FINISH;    }    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Inside UpnpUnSubscribeAsync \n" );         )        HandleLock(  );    if( GetHandleInfo( Hnd, &SInfo ) != HND_CLIENT ) {        HandleUnlock(  );        return UPNP_E_INVALID_HANDLE;    }    if( SubsId == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    if( Fun == NULL ) {        HandleUnlock(  );        return UPNP_E_INVALID_PARAM;    }    HandleUnlock(  );    Param =        ( struct UpnpNonblockParam * )        malloc( sizeof( struct UpnpNonblockParam ) );    if( Param == NULL )        return UPNP_E_OUTOF_MEMORY;    Param->FunName = UNSUBSCRIBE;    Param->Handle = Hnd;    strcpy( Param->SubsId, SubsId );    Param->Fun = Fun;    Param->Cookie = ( void * )Cookie_const;    TPJobInit( &job, ( start_routine ) UpnpThreadDistribution, Param );    TPJobSetFreeFunction( &job, ( free_routine ) free );    TPJobSetPriority( &job, MED_PRIORITY );    ThreadPoolAdd( &gSendThreadPool, &job, NULL );    DBGONLY( UpnpPrintf( UPNP_ALL, API, __FILE__, __LINE__,                         "Exiting UpnpUnSubscribeAsync \n" );         )        return UPNP_E_SUCCESS;}  /****************** End of UpnpUnSubscribeAsync  *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APIS/************************************************************************** * Function: UpnpRenewSubscription  * *  Parameters:	 *		IN UpnpClient_Handle Hnd: The handle of the control point that  *                                is renewing the subscription. *		INOUT int *TimeOut: Pointer to a variable containing the  *                          requested subscription time.  Upon return,  *                          it contains the actual renewal time.  *		IN Upnp_SID SubsId: The 

⌨️ 快捷键说明

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