libUPnP 1.8.0
service_table.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2000-2003 Intel Corporation 
00004  * All rights reserved. 
00005  *
00006  * Redistribution and use in source and binary forms, with or without 
00007  * modification, are permitted provided that the following conditions are met: 
00008  *
00009  * - Redistributions of source code must retain the above copyright notice, 
00010  * this list of conditions and the following disclaimer. 
00011  * - Redistributions in binary form must reproduce the above copyright notice, 
00012  * this list of conditions and the following disclaimer in the documentation 
00013  * and/or other materials provided with the distribution. 
00014  * - Neither name of Intel Corporation nor the names of its contributors 
00015  * may be used to endorse or promote products derived from this software 
00016  * without specific prior written permission.
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
00026  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  ******************************************************************************/
00031 
00032 
00033 #ifndef SERVICE_TABLE_H
00034 #define SERVICE_TABLE_H
00035 
00036 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 
00047 #include "config.h"
00048 #include "uri.h"
00049 #include "ixml.h"
00050 #include "upnp.h"
00051 #include "upnpdebug.h"
00052 
00053 
00054 #include <stdio.h>
00055 #include <time.h>
00056 
00057 
00058 #define SID_SIZE  41
00059 
00060 
00061 #ifdef INCLUDE_DEVICE_APIS
00062 
00063 
00064 typedef struct SUBSCRIPTION {
00065         Upnp_SID sid;
00066         int eventKey;
00067         int ToSendEventKey;
00068         time_t expireTime;
00069         int active;
00070         URL_list DeliveryURLs;
00071         struct SUBSCRIPTION *next;
00072 } subscription;
00073 
00074 
00075 typedef struct SERVICE_INFO {
00076         DOMString       serviceType;
00077         DOMString       serviceId;
00078         char            *SCPDURL ;
00079         char            *controlURL;
00080         char            *eventURL;
00081         DOMString       UDN;
00082         int             active;
00083         int             TotalSubscriptions;
00084         subscription    *subscriptionList;
00085         struct SERVICE_INFO      *next;
00086 } service_info;
00087 
00088 
00089 typedef struct SERVICE_TABLE {
00090         DOMString URLBase;
00091         service_info *serviceList;
00092         service_info *endServiceList;
00093 } service_table;
00094 
00095 
00096 /* Functions for Subscriptions */
00097 
00098 
00104 int copy_subscription(
00106         subscription *in,
00108         subscription *out);
00109 
00110 
00111 /*
00112  * \brief Remove the subscription represented by the const Upnp_SID sid parameter
00113  * from the service table and update the service table.
00114  */
00115 void RemoveSubscriptionSID(
00117         Upnp_SID sid,
00119         service_info *service);
00120 
00121 
00128 subscription *GetSubscriptionSID(
00130         const Upnp_SID sid,
00132         service_info *service); 
00133   
00134 
00140 subscription *GetFirstSubscription(
00142         service_info *service);
00143 
00144 
00150 subscription *GetNextSubscription(
00152         service_info *service,
00154         subscription *current);
00155 
00156 
00160 void freeSubscription(
00162         subscription *sub);
00163 
00164 
00168 void freeSubscriptionList(
00170         subscription * head);
00171 
00172 
00179 service_info *FindServiceId(
00181         service_table *table, 
00184         const char *serviceId,
00187         const char *UDN);
00188 
00189 
00197 service_info *FindServiceEventURLPath(
00199         service_table *table,
00201         char *eventURLPath);
00202 
00203 
00211 service_info * FindServiceControlURLPath(
00213         service_table *table,
00215         const char *controlURLPath);
00216 
00217 
00222 #ifdef DEBUG
00223 void printService(
00225         service_info *service,
00227         Upnp_LogLevel level,
00229         Dbg_Module module);
00230 #else
00231 static UPNP_INLINE void printService(
00232         service_info *service,
00233         Upnp_LogLevel level,
00234         Dbg_Module module) {}
00235 #endif
00236 
00237 
00242 #ifdef DEBUG
00243 void printServiceList(
00245         service_info *service,
00247         Upnp_LogLevel level,
00249         Dbg_Module module);
00250 #else
00251 static UPNP_INLINE void printServiceList(
00252         service_info *service,
00253         Upnp_LogLevel level,
00254         Dbg_Module module) {}
00255 #endif
00256 
00257 
00262 #ifdef DEBUG
00263 void printServiceTable(
00265         service_table *table,
00267         Upnp_LogLevel level,
00269         Dbg_Module module);
00270 #else
00271 static UPNP_INLINE void printServiceTable(
00272         service_table *table,
00273         Upnp_LogLevel level,
00274         Dbg_Module module) {}
00275 #endif
00276 
00277 
00282 void freeService(
00284         service_info *in);
00285 
00286 
00291 void freeServiceList(
00293         service_info *head);
00294 
00295 
00300 void freeServiceTable(
00302         service_table *table);
00303 
00304 
00313 int removeServiceTable(
00315         IXML_Node *node,
00317         service_table *in);
00318 
00319 
00323 int addServiceTable(
00325         IXML_Node *node,
00327         service_table *in,
00330         const char *DefaultURLBase);
00331 
00332 
00338 int getServiceTable(
00340         IXML_Node *node,
00342         service_table *out,
00344         const char *DefaultURLBase);
00345 
00346 
00347 /*      Misc helper functions   */
00348 
00349 
00357 DOMString getElementValue(
00359         IXML_Node *node);
00360 
00361 
00370 int getSubElement(
00372         const char *element_name,
00374         IXML_Node *node, 
00376         IXML_Node **out);
00377 
00378 
00379 #endif /* INCLUDE_DEVICE_APIS */
00380 
00381 #ifdef __cplusplus
00382 }
00383 #endif
00384 
00385 #endif /* SERVICE_TABLE */
00386