libUPnP  1.6.17
service_table.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * Copyright (c) 2000-2003 Intel Corporation
4  * All rights reserved.
5  * Copyright (c) 2012 France Telecom All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * - Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  * - Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  * - Neither name of Intel Corporation nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
27  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  ******************************************************************************/
32 
33 #ifndef SERVICE_TABLE_H
34 #define SERVICE_TABLE_H
35 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #include "config.h"
45 #include "uri.h"
46 #include "ixml.h"
47 #include "upnp.h"
48 #include "upnpdebug.h"
49 
50 #include <stdio.h>
51 #include <time.h>
52 
53 #define SID_SIZE (size_t)41
54 
55 #ifdef INCLUDE_DEVICE_APIS
56 
57 typedef struct SUBSCRIPTION {
58  Upnp_SID sid;
59  int eventKey;
60  int ToSendEventKey;
61  time_t expireTime;
62  int active;
63  URL_list DeliveryURLs;
64  struct SUBSCRIPTION *next;
65 } subscription;
66 
67 typedef struct SERVICE_INFO {
68  DOMString serviceType;
69  DOMString serviceId;
70  char *SCPDURL ;
71  char *controlURL;
72  char *eventURL;
73  DOMString UDN;
74  int active;
75  int TotalSubscriptions;
76  subscription *subscriptionList;
77  struct SERVICE_INFO *next;
78 } service_info;
79 
80 typedef struct SERVICE_TABLE {
81  DOMString URLBase;
82  service_info *serviceList;
83  service_info *endServiceList;
85 
86 /* Functions for Subscriptions */
87 
93 int copy_subscription(
95  subscription *in,
97  subscription *out);
98 
99 /*
100  * \brief Remove the subscription represented by the const Upnp_SID sid parameter
101  * from the service table and update the service table.
102  */
103 void RemoveSubscriptionSID(
105  Upnp_SID sid,
107  service_info *service);
108 
115 subscription *GetSubscriptionSID(
117  const Upnp_SID sid,
119  service_info *service);
120 
126 subscription *GetFirstSubscription(
128  service_info *service);
129 
135 subscription *GetNextSubscription(
137  service_info *service,
139  subscription *current);
140 
144 void freeSubscription(
146  subscription *sub);
147 
151 void freeSubscriptionList(
153  subscription * head);
154 
161 service_info *FindServiceId(
163  service_table *table,
166  const char *serviceId,
169  const char *UDN);
170 
178 service_info *FindServiceEventURLPath(
180  service_table *table,
182  char *eventURLPath);
183 
191 service_info * FindServiceControlURLPath(
193  service_table *table,
195  const char *controlURLPath);
196 
201 #ifdef DEBUG
202 void printService(
204  service_info *service,
206  Upnp_LogLevel level,
208  Dbg_Module module);
209 #else
210 static UPNP_INLINE void printService(
211  service_info *service,
212  Upnp_LogLevel level,
213  Dbg_Module module)
214 {
215  return;
216  service = service;
217  level = level;
218  module = module;
219 }
220 #endif
221 
226 #ifdef DEBUG
227 void printServiceList(
229  service_info *service,
231  Upnp_LogLevel level,
233  Dbg_Module module);
234 #else
235 static UPNP_INLINE void printServiceList(
236  service_info *service,
237  Upnp_LogLevel level,
238  Dbg_Module module)
239 {
240  return;
241  service = service;
242  level = level;
243  module = module;
244 }
245 #endif
246 
251 #ifdef DEBUG
252 void printServiceTable(
254  service_table *table,
256  Upnp_LogLevel level,
258  Dbg_Module module);
259 #else
260 static UPNP_INLINE void printServiceTable(
261  service_table *table,
262  Upnp_LogLevel level,
263  Dbg_Module module)
264 {
265  return;
266  table = table;
267  level = level;
268  module = module;
269 }
270 #endif
271 
276 void freeService(
278  service_info *in);
279 
284 void freeServiceList(
286  service_info *head);
287 
292 void freeServiceTable(
294  service_table *table);
295 
304 int removeServiceTable(
306  IXML_Node *node,
308  service_table *in);
309 
313 int addServiceTable(
315  IXML_Node *node,
317  service_table *in,
320  const char *DefaultURLBase);
321 
327 int getServiceTable(
329  IXML_Node *node,
331  service_table *out,
333  const char *DefaultURLBase);
334 
335 /* Misc helper functions */
336 
344 DOMString getElementValue(
346  IXML_Node *node);
347 
356 int getSubElement(
358  const char *element_name,
360  IXML_Node *node,
362  IXML_Node **out);
363 
364 #endif /* INCLUDE_DEVICE_APIS */
365 
366 #ifdef __cplusplus
367 }
368 #endif
369 
370 #endif /* SERVICE_TABLE */
371