2 Unix SMB/CIFS implementation.
4 macros to go along with the lib/replace/ portability layer code
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #if defined(_MSC_VER) || defined(__MINGW32__)
27 #include "lib/replace/win32/replace.h"
31 #define QSORT_CAST (__compar_fn_t)
35 #define QSORT_CAST (int (*)(const void *, const void *))
39 extern char *sys_errlist[];
40 #define strerror(i) sys_errlist[i]
43 #ifndef HAVE_ERRNO_DECL
48 char *strdup(const char *s);
52 void *memmove(void *dest,const void *src,int size);
56 time_t mktime(struct tm *t);
60 size_t strlcpy(char *d, const char *s, size_t bufsize);
64 size_t strlcat(char *d, const char *s, size_t bufsize);
68 char *strndup(const char *s, size_t n);
72 size_t strnlen(const char *s, size_t n);
76 unsigned long strtoul(const char *nptr, char **endptr, int base);
80 int setenv(const char *name, const char *value, int overwrite);
84 int rename(const char *zfrom, const char *zto);
87 #ifndef HAVE_STRCASESTR
88 char *strcasestr(const char *haystack, const char *needle);
91 #ifndef HAVE_FTRUNCATE
92 int ftruncate(int f,long l);
95 #ifndef HAVE_VASPRINTF_DECL
96 int vasprintf(char **ptr, const char *format, va_list ap);
99 #if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
100 #define bzero(a,b) memset((a),'\0',(b))
103 /* add varargs prototypes with printf checking */
104 #ifndef HAVE_SNPRINTF_DECL
105 int snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
107 #ifndef HAVE_ASPRINTF_DECL
108 int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
112 /* we used to use these fns, but now we have good replacements
113 for snprintf and vsnprintf */
114 #define slprintf snprintf
118 #define VA_COPY(dest, src) va_copy(dest, src)
119 #elif defined(HAVE___VA_COPY)
120 #define VA_COPY(dest, src) __va_copy(dest, src)
122 #define VA_COPY(dest, src) (dest) = (src)
125 #if defined(HAVE_VOLATILE)
126 #define VOLATILE volatile
131 #ifndef HAVE_COMPARISON_FN_T
132 typedef int (*comparison_fn_t)(const void *, const void *);
135 /* Load header file for dynamic linking stuff */
144 #ifndef HAVE_SECURE_MKSTEMP
145 #define mkstemp(path) rep_mkstemp(path)
146 int rep_mkstemp(char *temp);
153 #ifndef HOST_NAME_MAX
154 #define HOST_NAME_MAX 64
158 #define UINT16_MAX 65535
162 #define UINT32_MAX (4294967295U)
166 #define UINT64_MAX ((uint64_t)-1)