libUPnP 1.8.4
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#include <errno.h>
42
43/* usually used to specify direction of parameters in functions */
44#ifndef IN
45 #define IN
46#endif
47
48#ifndef OUT
49 #define OUT
50#endif
51
52#ifndef INOUT
53 #define INOUT
54#endif
55
56
57#define GEMD_OUT_OF_MEMORY -1
58#define EVENT_TIMEDOUT -2
59#define EVENT_TERMINATE -3
60
62#ifndef TRUE
63 #define TRUE 1
64#endif
65#ifndef FALSE
66 #define FALSE 0
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
77void linecopy(
79 char dest[LINE_SIZE],
81 const char *src);
82
87void namecopy(
89 char dest[NAME_SIZE],
91 const char *src);
92
101void linecopylen(
103 char dest[LINE_SIZE],
105 const char *src,
107 size_t srclen);
108
109#ifdef __cplusplus
110}
111#endif
112
113/* Size of the errorBuffer variable, passed to the strerror_r() function */
114#define ERROR_BUFFER_LEN (size_t)256
115
116/* C specific */
117/* VC needs these in C++ mode too (do other compilers?) */
118#if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
119 #ifdef _WIN32
120 #ifndef S_ISREG
121 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
122 #endif
123 #ifndef S_ISDIR
124 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
125 #endif
126 #ifndef EADDRINUSE /* VS2010 has this defined */
127 #define EADDRINUSE WSAEADDRINUSE
128 #endif
129 #define strcasecmp stricmp
130 #define strncasecmp strnicmp
131 #define sleep(a) Sleep((a)*1000)
132 #define usleep(a) Sleep((a)/1000)
133 #define strerror_r(a,b,c) (strerror_s((b),(c),(a)))
134 #else
135 #define max(a, b) (((a)>(b))? (a):(b))
136 #define min(a, b) (((a)<(b))? (a):(b))
137 #endif /* _WIN32 */
138#endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
139
140#endif /* UTIL_H */
141
void linecopylen(char dest[LINE_SIZE], const char *src, size_t srclen)
Determine if the srclen passed in paramter is less than the permitted LINE_SIZE. If it is use the pas...
Definition util.c:60
void namecopy(char dest[NAME_SIZE], const char *src)
Copy no of bytes spcified by the NAME_SIZE constant, from the source buffer. Null terminate the desti...
Definition util.c:53
void linecopy(char dest[LINE_SIZE], const char *src)
Copy no of bytes spcified by the LINE_SIZE constant, from the source buffer. Null terminate the desti...
Definition util.c:46