libUPnP 1.14.19
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#define GEMD_OUT_OF_MEMORY -1
44#define EVENT_TIMEDOUT -2
45#define EVENT_TERMINATE -3
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
55void linecopy(
57 char dest[LINE_SIZE],
59 const char *src);
60
65void namecopy(
67 char dest[NAME_SIZE],
69 const char *src);
70
79void linecopylen(
81 char dest[LINE_SIZE],
83 const char *src,
85 size_t srclen);
86
87#ifdef __cplusplus
88}
89#endif
90
91/* Size of the errorBuffer variable, passed to the strerror_r() function */
92#define ERROR_BUFFER_LEN (size_t)256
93
94/* C specific */
95/* VC needs these in C++ mode too (do other compilers?) */
96#if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
97 #ifdef _WIN32
98 #ifndef S_ISREG
99 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
100 #endif
101 #ifndef S_ISDIR
102 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
103 #endif
104 #ifndef EADDRINUSE /* VS2010 has this defined */
105 #define EADDRINUSE WSAEADDRINUSE
106 #endif
107 #define sleep(a) Sleep((a)*1000)
108 #define usleep(a) Sleep((a) / 1000)
109 #define strerror_r(a, b, c) (strerror_s((b), (c), (a)))
110 #else
111 #define max(a, b) (((a) > (b)) ? (a) : (b))
112 #define min(a, b) (((a) < (b)) ? (a) : (b))
113 #endif /* _WIN32 */
114#endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
115
116#endif /* UTIL_H */
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:62
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:55
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:48