libUPnP  1.6.17
sample_util.h
Go to the documentation of this file.
1 #ifndef SAMPLE_UTIL_H
2 #define SAMPLE_UTIL_H
3 
4 /*******************************************************************************
5  *
6  * Copyright (c) 2000-2003 Intel Corporation
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * - Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  * - Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  * - Neither name of Intel Corporation nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
29  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  ******************************************************************************/
34 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 #include "ithread.h"
48 #include "ixml.h" /* for IXML_Document, IXML_Element */
49 #include "upnp.h" /* for Upnp_EventType */
50 #include "upnptools.h"
51 
52 #include <stdlib.h>
53 #include <string.h>
54 
55 #ifdef SAMPLE_UTIL_C
56 
57  const char *TvServiceType[] = {
58  "urn:schemas-upnp-org:service:tvcontrol:1",
59  "urn:schemas-upnp-org:service:tvpicture:1"
60  };
61 #else /* SAMPLE_UTIL_C */
62  extern const char *TvServiceType[];
63 #endif /* SAMPLE_UTIL_C */
64 
65 /* mutex to control displaying of events */
66 extern ithread_mutex_t display_mutex;
67 
68 typedef enum {
69  STATE_UPDATE = 0,
70  DEVICE_ADDED = 1,
71  DEVICE_REMOVED = 2,
72  GET_VAR_COMPLETE = 3
73 } eventType;
74 
84  IXML_Element *element);
85 
97  IXML_Document *doc);
98 
106  IXML_Document *doc,
108  const char *item);
109 
117  IXML_Element *element,
119  const char *item);
120 
126  Upnp_EventType S);
127 
133  Upnp_EventType EventType,
135  void *Event);
136 
145  IXML_Document *DescDoc,
147  const char *location,
149  const char *serviceType,
151  char **serviceId,
153  char **eventURL,
155  char **controlURL);
156 
162 typedef void (*print_string)(
164  const char *string,
166  ...)
167 #if (__GNUC__ >= 3)
168  /* This enables printf like format checking by the compiler */
169  __attribute__((format (__printf__, 1, 2)))
170 #endif
171 ;
172 
174 extern print_string gPrintFun;
175 
179 typedef void (*state_update)(
181  const char *varName,
183  const char *varValue,
185  const char *UDN,
187  eventType type);
188 
191 
198  print_string print_function);
199 
203 int SampleUtil_Finish();
204 
216 int SampleUtil_Print(
218  const char *fmt,
220  ...)
221 #if (__GNUC__ >= 3)
222  /* This enables printf like format checking by the compiler */
223  __attribute__((format (__printf__, 1, 2)))
224 #endif
225 ;
226 
232  state_update update_function);
233 
239  const char *varName,
241  const char *varValue,
243  const char *UDN,
245  eventType type);
246 
250 void linux_print(const char *format, ...)
251 #if (__GNUC__ >= 3)
252  /* This enables printf like format checking by the compiler */
253  __attribute__((format (__printf__, 1, 2)))
254 #endif
255 ;
256 
257 #ifdef __cplusplus
258 };
259 #endif /* __cplusplus */
260 
261 #ifdef WIN32
262  #define snprintf _snprintf
263  #define strcasecmp stricmp
264 #endif
265 
268 #endif /* SAMPLE_UTIL_H */
269