libUPnP  1.6.17
upnputil.h
Go to the documentation of this file.
00001 #ifndef UTIL_H
00002 #define UTIL_H
00003 
00004 /*******************************************************************************
00005  *
00006  * Copyright (c) 2000-2003 Intel Corporation
00007  * All rights reserved.
00008  * Copyright (c) 2012 France Telecom All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions are met:
00012  *
00013  * - Redistributions of source code must retain the above copyright notice,
00014  * this list of conditions and the following disclaimer.
00015  * - Redistributions in binary form must reproduce the above copyright notice,
00016  * this list of conditions and the following disclaimer in the documentation
00017  * and/or other materials provided with the distribution.
00018  * - Neither name of Intel Corporation nor the names of its contributors
00019  * may be used to endorse or promote products derived from this software
00020  * without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
00026  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00030  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  ******************************************************************************/
00035 
00040 #include "upnp.h"
00041 
00042 /* usually used to specify direction of parameters in functions */
00043 #ifndef IN
00044         #define IN
00045 #endif
00046 
00047 #ifndef OUT
00048         #define OUT
00049 #endif
00050 
00051 #ifndef INOUT
00052         #define INOUT
00053 #endif
00054 
00055 
00056 #define GEMD_OUT_OF_MEMORY -1
00057 #define EVENT_TIMEDOUT -2
00058 #define EVENT_TERMINATE -3
00059 
00061 #ifndef TRUE
00062         #define TRUE 1
00063 #endif
00064 #ifndef FALSE
00065         #define FALSE 0
00066 #endif
00067 
00068 #ifdef __cplusplus
00069 extern "C" {
00070 #endif
00071 
00076 void linecopy(
00078         char dest[LINE_SIZE],
00080         const char *src);
00081 
00086 void namecopy(
00088         char dest[NAME_SIZE],
00090         const char *src);
00091 
00100 void linecopylen(
00102         char dest[LINE_SIZE],
00104         const char *src,
00106         size_t srclen);
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 
00112 /* Size of the errorBuffer variable, passed to the strerror_r() function */
00113 #define ERROR_BUFFER_LEN (size_t)256
00114 
00115 /* C specific */
00116 /* VC needs these in C++ mode too (do other compilers?) */
00117 #if !defined(__cplusplus) || defined(UPNP_USE_MSVCPP)
00118         #ifdef WIN32
00119                 #ifndef S_ISREG
00120                         #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
00121                 #endif
00122                 #ifndef S_ISDIR
00123                         #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
00124                 #endif
00125                 #define EADDRINUSE              WSAEADDRINUSE
00126                 #define strcasecmp              stricmp
00127                 #define strncasecmp             strnicmp
00128                 #define sleep(a)                Sleep((a)*1000)
00129                 #define usleep(a)               Sleep((a)/1000)
00130                 #define strerror_r(a,b,c)       (strerror_s((b),(c),(a)))
00131         #else
00132                 #define max(a, b)   (((a)>(b))? (a):(b))
00133                 #define min(a, b)   (((a)<(b))? (a):(b))
00134         #endif /* WIN32 */
00135 #endif /* !defined(__cplusplus) || defined(UPNP_USE_MSVCPP) */
00136 
00137 #endif /* UTIL_H */
00138