📄 upnpapi.c
字号:
} /****************** End of UpnpSendAdvertisement *********************/#endif // INCLUDE_DEVICE_APIS#endif#if EXCLUDE_SSDP == 0#ifdef INCLUDE_CLIENT_APISint UpnpSearchAsync(IN UpnpClient_Handle Hnd, IN int Mx, IN const char *Target_const, IN const void *Cookie_const ){ struct Handle_Info * SInfo=NULL; char *Target = (char *)Target_const; DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Inside UpnpSearchAsync \n");) HandleLock(); if(GetHandleInfo(Hnd, &SInfo) != HND_CLIENT) { HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if( Mx < 1) Mx = DEFAULT_MX; if (Target == NULL ) { HandleUnlock(); return UPNP_E_INVALID_PARAM; } SearchByTarget(Mx, Target, (void*) Cookie_const); HandleUnlock(); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpSearchAsync \n");) return UPNP_E_SUCCESS;} /****************** End of UpnpSearchAsync *********************/#endif // INCLUDE_CLIENT_APIS#endif//-----------------------------------------------------------------------------//// GENA interface ////-----------------------------------------------------------------------------#if EXCLUDE_GENA == 0#ifdef INCLUDE_DEVICE_APISint UpnpSetMaxSubscriptions( IN UpnpDevice_Handle Hnd, /** The handle of the device for which the maximum subscriptions is being set. */ IN int MaxSubscriptions /** The maximum number of subscriptions to be allowed per service. */ ){ struct Handle_Info * SInfo=NULL; 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_APISint UpnpSetMaxSubscriptionTimeOut( 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. */ ){ struct Handle_Info * SInfo=NULL; 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_APISint UpnpSubscribeAsync(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; 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_URL; } 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; tpool_Schedule( (void *)UpnpThreadDistribution , Param); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpSubscribeAsync \n");) return UPNP_E_SUCCESS;} /****************** End of UpnpSubscribeAsync *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APISint UpnpSubscribe (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; 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_URL; } 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_APISint UpnpUnSubscribe (IN UpnpClient_Handle Hnd, IN Upnp_SID SubsId){ struct Handle_Info * SInfo=NULL; int RetVal; 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_SID; } 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_APISint UpnpUnSubscribeAsync(IN UpnpClient_Handle Hnd, IN Upnp_SID SubsId, IN Upnp_FunPtr Fun, IN const void * Cookie_const ){ struct Handle_Info * SInfo=NULL; struct UpnpNonblockParam * Param; 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_SID; } 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; tpool_Schedule((void *) UpnpThreadDistribution, Param); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpUnSubscribeAsync \n");) return UPNP_E_SUCCESS;} /****************** End of UpnpUnSubscribeAsync *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APISint UpnpRenewSubscription (IN UpnpClient_Handle Hnd, INOUT int *TimeOut, IN Upnp_SID SubsId){ struct Handle_Info * SInfo=NULL; int RetVal; DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Inside UpnpRenewSubscription \n");) HandleLock(); if(GetHandleInfo(Hnd, &SInfo) != HND_CLIENT) { HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if (TimeOut == NULL) { HandleUnlock(); return UPNP_E_INVALID_PARAM; } if (SubsId == NULL) { HandleUnlock(); return UPNP_E_INVALID_SID; } HandleUnlock(); RetVal = genaRenewSubscription(Hnd, SubsId, TimeOut); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpRenewSubscription \n");) return RetVal;} /****************** End of UpnpRenewSubscription *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_CLIENT_APISint UpnpRenewSubscriptionAsync(IN UpnpClient_Handle Hnd, INOUT int TimeOut, IN Upnp_SID SubsId, IN Upnp_FunPtr Fun, IN const void * Cookie_const ){ struct Handle_Info * SInfo=NULL; struct UpnpNonblockParam * Param; DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Inside UpnpRenewSubscriptionAsync \n");) if(GetHandleInfo(Hnd, &SInfo) != HND_CLIENT) { HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if (TimeOut!=UPNP_INFINITE && TimeOut < 1) { HandleUnlock(); return UPNP_E_INVALID_PARAM; } if (SubsId == NULL) { HandleUnlock(); return UPNP_E_INVALID_SID; } 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 = RENEW; Param->Handle = Hnd; strcpy(Param->SubsId,SubsId); Param->Fun = Fun; Param->Cookie = (void*) Cookie_const; Param->TimeOut = TimeOut; tpool_Schedule((void *) UpnpThreadDistribution, Param); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpRenewSubscriptionAsync \n");) return UPNP_E_SUCCESS;} /****************** End of UpnpRenewSubscriptionAsync *********************/#endif // INCLUDE_CLIENT_APIS#ifdef INCLUDE_DEVICE_APISint UpnpNotify(IN UpnpDevice_Handle Hnd , IN const char *DevID_const, IN const char *ServName_const, IN const char ** VarName_const, IN const char ** NewVal_const, IN int cVariables){ struct Handle_Info *SInfo=NULL; int retVal; char *DevID = (char *)DevID_const; char *ServName = (char *)ServName_const; char **VarName = (char **)VarName_const; char **NewVal = (char **)NewVal_const; DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Inside UpnpNotify \n");) HandleLock(); if(GetHandleInfo(Hnd, &SInfo) != HND_DEVICE) { HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if (DevID == NULL) { HandleUnlock(); return UPNP_E_INVALID_SERVICE; } if (ServName == NULL) { HandleUnlock(); return UPNP_E_INVALID_SERVICE; } if (VarName == NULL || NewVal == NULL || cVariables < 0) { HandleUnlock(); return UPNP_E_INVALID_PARAM; } HandleUnlock(); retVal = genaNotifyAll (Hnd,DevID,ServName, VarName, NewVal, cVariables); DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Exiting UpnpNotify \n");) return retVal;} /****************** End of UpnpNotify *********************/int UpnpNotifyExt(IN UpnpDevice_Handle Hnd, IN const char *DevID_const, IN const char *ServName_const, IN Upnp_Document PropSet){ struct Handle_Info *SInfo=NULL; int retVal; char *DevID = (char *)DevID_const; char *ServName = (char *)ServName_const; DBGONLY(UpnpPrintf(UPNP_ALL,API,__FILE__,__LINE__,"Inside UpnpNotify \n");) HandleLock(); if(GetHandleInfo(Hnd, &SInfo) != HND_DEVICE) { HandleUnlock(); return UPNP_E_INVALID_HANDLE; } if (DevID == NULL) { HandleUnlock(); return UPNP_E_INVALID_SERVICE; } if (ServName == NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -