libUPnP  1.6.17
service_table.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2000-2003 Intel Corporation 
00004  * All rights reserved. 
00005  * Copyright (c) 2012 France Telecom All rights reserved. 
00006  *
00007  * Redistribution and use in source and binary forms, with or without 
00008  * modification, are permitted provided that the following conditions are met: 
00009  *
00010  * - Redistributions of source code must retain the above copyright notice, 
00011  * this list of conditions and the following disclaimer. 
00012  * - Redistributions in binary form must reproduce the above copyright notice, 
00013  * this list of conditions and the following disclaimer in the documentation 
00014  * and/or other materials provided with the distribution. 
00015  * - Neither name of Intel Corporation nor the names of its contributors 
00016  * may be used to endorse or promote products derived from this software 
00017  * without specific prior written permission.
00018  * 
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 
00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
00027  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  ******************************************************************************/
00032 
00033 #ifndef SERVICE_TABLE_H
00034 #define SERVICE_TABLE_H
00035 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 #include "config.h"
00045 #include "uri.h"
00046 #include "ixml.h"
00047 #include "upnp.h"
00048 #include "upnpdebug.h"
00049 
00050 #include <stdio.h>
00051 #include <time.h>
00052 
00053 #define SID_SIZE  (size_t)41
00054 
00055 #ifdef INCLUDE_DEVICE_APIS
00056 
00057 typedef struct SUBSCRIPTION {
00058         Upnp_SID sid;
00059         int eventKey;
00060         int ToSendEventKey;
00061         time_t expireTime;
00062         int active;
00063         URL_list DeliveryURLs;
00064         struct SUBSCRIPTION *next;
00065 } subscription;
00066 
00067 typedef struct SERVICE_INFO {
00068         DOMString       serviceType;
00069         DOMString       serviceId;
00070         char            *SCPDURL ;
00071         char            *controlURL;
00072         char            *eventURL;
00073         DOMString       UDN;
00074         int             active;
00075         int             TotalSubscriptions;
00076         subscription    *subscriptionList;
00077         struct SERVICE_INFO      *next;
00078 } service_info;
00079 
00080 typedef struct SERVICE_TABLE {
00081         DOMString URLBase;
00082         service_info *serviceList;
00083         service_info *endServiceList;
00084 } service_table;
00085 
00086 /* Functions for Subscriptions */
00087 
00093 int copy_subscription(
00095         subscription *in,
00097         subscription *out);
00098 
00099 /*
00100  * \brief Remove the subscription represented by the const Upnp_SID sid parameter
00101  * from the service table and update the service table.
00102  */
00103 void RemoveSubscriptionSID(
00105         Upnp_SID sid,
00107         service_info *service);
00108 
00115 subscription *GetSubscriptionSID(
00117         const Upnp_SID sid,
00119         service_info *service); 
00120 
00126 subscription *GetFirstSubscription(
00128         service_info *service);
00129 
00135 subscription *GetNextSubscription(
00137         service_info *service,
00139         subscription *current);
00140 
00144 void freeSubscription(
00146         subscription *sub);
00147 
00151 void freeSubscriptionList(
00153         subscription * head);
00154 
00161 service_info *FindServiceId(
00163         service_table *table, 
00166         const char *serviceId,
00169         const char *UDN);
00170 
00178 service_info *FindServiceEventURLPath(
00180         service_table *table,
00182         char *eventURLPath);
00183 
00191 service_info * FindServiceControlURLPath(
00193         service_table *table,
00195         const char *controlURLPath);
00196 
00201 #ifdef DEBUG
00202 void printService(
00204         service_info *service,
00206         Upnp_LogLevel level,
00208         Dbg_Module module);
00209 #else
00210 static UPNP_INLINE void printService(
00211         service_info *service,
00212         Upnp_LogLevel level,
00213         Dbg_Module module)
00214 {
00215         return;
00216         service = service;
00217         level = level;
00218         module = module;
00219 }
00220 #endif
00221 
00226 #ifdef DEBUG
00227 void printServiceList(
00229         service_info *service,
00231         Upnp_LogLevel level,
00233         Dbg_Module module);
00234 #else
00235 static UPNP_INLINE void printServiceList(
00236         service_info *service,
00237         Upnp_LogLevel level,
00238         Dbg_Module module)
00239 {
00240         return;
00241         service = service;
00242         level = level;
00243         module = module;
00244 }
00245 #endif
00246 
00251 #ifdef DEBUG
00252 void printServiceTable(
00254         service_table *table,
00256         Upnp_LogLevel level,
00258         Dbg_Module module);
00259 #else
00260 static UPNP_INLINE void printServiceTable(
00261         service_table *table,
00262         Upnp_LogLevel level,
00263         Dbg_Module module)
00264 {
00265         return;
00266         table = table;
00267         level = level;
00268         module = module;
00269 }
00270 #endif
00271 
00276 void freeService(
00278         service_info *in);
00279 
00284 void freeServiceList(
00286         service_info *head);
00287 
00292 void freeServiceTable(
00294         service_table *table);
00295 
00304 int removeServiceTable(
00306         IXML_Node *node,
00308         service_table *in);
00309 
00313 int addServiceTable(
00315         IXML_Node *node,
00317         service_table *in,
00320         const char *DefaultURLBase);
00321 
00327 int getServiceTable(
00329         IXML_Node *node,
00331         service_table *out,
00333         const char *DefaultURLBase);
00334 
00335 /*      Misc helper functions   */
00336 
00344 DOMString getElementValue(
00346         IXML_Node *node);
00347 
00356 int getSubElement(
00358         const char *element_name,
00360         IXML_Node *node, 
00362         IXML_Node **out);
00363 
00364 #endif /* INCLUDE_DEVICE_APIS */
00365 
00366 #ifdef __cplusplus
00367 }
00368 #endif
00369 
00370 #endif /* SERVICE_TABLE */
00371