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

📄 service_table.c

📁 UPnP的SDK源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Copyright (c) 2000 Intel Corporation// All rights reserved.//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are met://// * Redistributions of source code must retain the above copyright notice,// this list of conditions and the following disclaimer.// * Redistributions in binary form must reproduce the above copyright notice,// this list of conditions and the following disclaimer in the documentation// and/or other materials provided with the distribution.// * Neither name of Intel Corporation nor the names of its contributors// may be used to endorse or promote products derived from this software// without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.///////////////////////////////////////////////////////////////////////////////// $Revision: 1.1.1.5 $// $Date: 2001/06/15 00:21:55 $//     #include "../../inc/tools/config.h"#if EXCLUDE_DOM == 0#include "./genlib/service_table/service_table.h"DEVICEONLY(int copy_subscription(subscription *in, subscription *out){  int return_code=HTTP_SUCCESS;  memcpy(out->sid,in->sid,SID_SIZE);  out->sid[SID_SIZE]=0;  out->eventKey=in->eventKey;  out->ToSendEventKey=in->ToSendEventKey;  out->expireTime=in->expireTime;  out->active=in->active;  if ( (return_code=copy_URL_list(&in->DeliveryURLs,&out->DeliveryURLs))!=HTTP_SUCCESS)    return return_code;  out->next=NULL;   return HTTP_SUCCESS; }void RemoveSubscriptionSID(Upnp_SID sid, service_info * service){  subscription * finger=service->subscriptionList;  subscription * previous=NULL;    while (finger)    {      if ( !(strcmp(sid,finger->sid)))	{	  if (previous)	    previous->next=finger->next;	  else	    service->subscriptionList=finger->next;	  finger->next=NULL;	  freeSubscriptionList(finger);	  finger=NULL;	  service->TotalSubscriptions--;	}      else	{ previous=finger;	  finger=finger->next;	}    }  }subscription * GetSubscriptionSID(Upnp_SID sid,service_info * service){  subscription * next =service->subscriptionList;  subscription * previous =NULL;  subscription * found=NULL;  time_t current_time;  while ( (next) && (found==NULL))    {      if ( ! strcmp(next->sid,sid))	    found=next;      else 	{	  previous=next;	  next=next->next;	}    }   if (found)    {       //get the current_time      time(&current_time);      if ( (found->expireTime!=0) && (found->expireTime<current_time) )	{	  if (previous)	    previous->next=found->next;	  else 	    service->subscriptionList=found->next;	  found->next=NULL;	  freeSubscriptionList(found);	  found=NULL;	  service->TotalSubscriptions--;	}    }  return found;}subscription * GetNextSubscription(service_info * service, subscription *current){  time_t current_time;  subscription * next=NULL;  subscription * previous=NULL;  int notDone =1;  //get the current_time  time(&current_time);  while ( (notDone) && (current))    {      previous=current;      current=current->next;      if (current==NULL)	{	  notDone=0;	  next=current;	}      else	if ( (current->expireTime!=0) && (current->expireTime<current_time) )	  {	    previous->next=current->next;	    current->next=NULL;	    freeSubscriptionList(current);	    current=previous;	    service->TotalSubscriptions--;	  }	    else	  if (current->active)	    {	      notDone=0;	      next=current;	    }    }  return next;}subscription * GetFirstSubscription(service_info *service){  subscription temp;   subscription * next=NULL;  temp.next=service->subscriptionList;  next=GetNextSubscription(service, &temp);  service->subscriptionList=temp.next;  //  service->subscriptionList=next;  return next;}service_info * FindServiceId(service_table *table, const char * serviceId, const char * UDN){  service_info * finger=NULL;  if (table)    {      finger=table->serviceList;      while(finger)	{	  if (  ( !strcmp(serviceId,finger->serviceId)) && 		( !strcmp(UDN,finger->UDN)))	    {	      return finger;	    }	  finger=finger->next;	}    }  return NULL;}service_info * FindServiceEventURLPath(service_table *table, 				       char * eventURLPath){  service_info * finger=NULL;  uri_type parsed_url;  uri_type parsed_url_in;  if ( (table) && (parse_uri(eventURLPath,strlen(eventURLPath),&parsed_url_in)))    {           finger=table->serviceList;      while (finger)	{  	  if (finger->eventURL)	  if ( (parse_uri(finger->eventURL,strlen(finger->eventURL),			  &parsed_url)))	    {	     	      if (!token_cmp(&parsed_url.pathquery,&parsed_url_in.pathquery))		return finger;	      	    }	  finger=finger->next;	}    }    return NULL;}service_info * FindServiceControlURLPath(service_table * table, char * controlURLPath){  service_info * finger=NULL;  uri_type parsed_url;  uri_type parsed_url_in;  if ( (table) && (parse_uri(controlURLPath,strlen(controlURLPath),&parsed_url_in)))    {      finger=table->serviceList;      while (finger)	{	  if (finger->controlURL)	  if ( (parse_uri(finger->controlURL,strlen(finger->controlURL),			  &parsed_url)))	    {	      if (!token_cmp(&parsed_url.pathquery,&parsed_url_in.pathquery))		return finger;	    }	  finger=finger->next;	}    }  return NULL;  }DBGONLY(void printService(service_info *service, Dbg_Level level,		  Dbg_Module module){  if (service)    {      if (service->serviceType)	UpnpPrintf(level,module,__FILE__,__LINE__,"serviceType: %s\n",service->serviceType);      if (service->serviceId)	UpnpPrintf(level,module,__FILE__,__LINE__,"serviceId: %s\n",service->serviceId);      if (service->SCPDURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"SCPDURL: %s\n",service->SCPDURL);      if (service->controlURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"controlURL: %s\n",service->controlURL);      if (service->eventURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"eventURL: %s\n",service->eventURL);            if (service->UDN)	UpnpPrintf(level,module,__FILE__,__LINE__,"UDN: %s\n\n",service->UDN);      if (service->active)	UpnpPrintf(level,module,__FILE__,__LINE__,"Service is active\n");      else	UpnpPrintf(level,module,__FILE__,__LINE__,"Service is inactive\n");    }})DBGONLY(void printServiceList(service_info *service,Dbg_Level level,		      Dbg_Module module){  while (service)    {      if (service->serviceType)	UpnpPrintf(level,module,__FILE__,__LINE__,"serviceType: %s\n",service->serviceType);      if (service->serviceId)	UpnpPrintf(level,module,__FILE__,__LINE__,"serviceId: %s\n",service->serviceId);      if (service->SCPDURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"SCPDURL: %s\n",service->SCPDURL);      if (service->controlURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"controlURL: %s\n",service->controlURL);      if (service->eventURL)	UpnpPrintf(level,module,__FILE__,__LINE__,"eventURL: %s\n",service->eventURL);            if (service->UDN)	UpnpPrintf(level,module,__FILE__,__LINE__,"UDN: %s\n\n",service->UDN);      if (service->active)	UpnpPrintf(level,module,__FILE__,__LINE__,"Service is active\n");      else	UpnpPrintf(level,module,__FILE__,__LINE__,"Service is inactive\n");      service=service->next;    }})DBGONLY(void printServiceTable(service_table * table,Dbg_Level level,  Dbg_Module module){  UpnpPrintf(level,module,__FILE__,__LINE__,"URL_BASE: %s\n",table->URLBase);  UpnpPrintf(level,module,__FILE__,__LINE__,"Services: \n");  printServiceList(table->serviceList,level,module);})void freeSubscription(subscription * sub){  if (sub)    {      free_URL_list(&sub->DeliveryURLs);    }}void freeSubscriptionList(subscription * head){  subscription * next=NULL;  while (head)

⌨️ 快捷键说明

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