libUPnP  1.6.17
upnputil.h
Go to the documentation of this file.
1 #ifndef UTIL_H
2 #define UTIL_H
3 
4 /*******************************************************************************
5  *
6  * Copyright (c) 2000-2003 Intel Corporation
7  * All rights reserved.
8  * Copyright (c) 2012 France Telecom All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * - Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * - Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * - Neither name of Intel Corporation nor the names of its contributors
19  * may be used to endorse or promote products derived from this software
20  * without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  ******************************************************************************/
35 
40 #include "upnp.h"
41 
42 /* usually used to specify direction of parameters in functions */
43 #ifndef IN
44  #define IN
45 #endif
46 
47 #ifndef OUT
48  #define OUT
49 #endif
50 
51 #ifndef INOUT
52  #define INOUT
53 #endif
54 
55 
56 #define GEMD_OUT_OF_MEMORY -1
57 #define EVENT_TIMEDOUT -2
58 #define EVENT_TERMINATE -3
59 
61 #ifndef TRUE
62  #define TRUE 1
63 #endif
64 #ifndef FALSE
65  #define FALSE 0
66 #endif
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
76 void linecopy(
78  char dest[LINE_SIZE],
80  const char *src);
81 
86 void namecopy(
88  char dest[NAME_SIZE],
90  const char *src);
91 
100 void linecopylen(
102  char dest[LINE_SIZE],
104  const char *src,
106  size_t srclen);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 /* Size of the errorBuffer variable, passed to the strerror_r() function */
113 #define ERROR_BUFFER_LEN (size_t)256
114 
115 /* C specific */
116 /* VC needs these in C++ mode too (do other compilers?) */
117 #if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
118  #ifdef WIN32
119  #ifndef S_ISREG
120  #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
121  #endif
122  #ifndef S_ISDIR
123  #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
124  #endif
125  #define EADDRINUSE WSAEADDRINUSE
126  #define strcasecmp stricmp
127  #define strncasecmp strnicmp
128  #define sleep(a) Sleep((a)*1000)
129  #define usleep(a) Sleep((a)/1000)
130  #define strerror_r(a,b,c) (strerror_s((b),(c),(a)))
131  #else
132  #define max(a, b) (((a)>(b))? (a):(b))
133  #define min(a, b) (((a)<(b))? (a):(b))
134  #endif /* WIN32 */
135 #endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
136 
137 #endif /* UTIL_H */
138