diff options
Diffstat (limited to 'source4/lib/replace/replace.h')
-rw-r--r-- | source4/lib/replace/replace.h | 98 |
1 files changed, 60 insertions, 38 deletions
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index 06173bd84b..26e39ac603 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -1,15 +1,16 @@ -/* +/* Unix SMB/CIFS implementation. macros to go along with the lib/replace/ portability layer code Copyright (C) Andrew Tridgell 2005 Copyright (C) Jelmer Vernooij 2006 + Copyright (C) Jeremy Allison 2007. ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -44,13 +45,6 @@ #include "win32_replace.h" #endif -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif #ifdef HAVE_STDINT_H #include <stdint.h> @@ -78,29 +72,6 @@ #include <stddef.h> #endif -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) - -/** Type-safe version of discard_const */ -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) - #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -168,7 +139,7 @@ int setenv(const char *name, const char *value, int overwrite); #ifndef HAVE_UNSETENV #define unsetenv rep_unsetenv -int rep_unsetenv(const char *name); +int rep_unsetenv(const char *name); #endif #ifndef HAVE_SETEUID @@ -192,7 +163,7 @@ char *rep_strcasestr(const char *haystack, const char *needle); #endif #ifndef HAVE_STRTOK_R -#define strtok_r rep_strtok_r +#define strtok_r rep_strtok_r char *rep_strtok_r(char *s, const char *delim, char **save_ptr); #endif @@ -359,10 +330,25 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif +#ifndef HAVE_INET_PTON +int rep_inet_pton(int af, const char *src, void *dst); +#define inet_pton rep_inet_pton +#endif + +#ifndef HAVE_INET_NTOP +#include "system/network.h" +const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size); +#define inet_ntop rep_inet_ntop +#endif + #ifdef HAVE_LIMITS_H #include <limits.h> #endif +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + /* The extra casts work around common compiler bugs. */ #define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. @@ -375,6 +361,14 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) #define HOST_NAME_MAX 64 #endif +/* + * Some older systems seem not to have MAXHOSTNAMELEN + * defined. + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN HOST_NAME_MAX +#endif + #ifndef UINT16_MAX #define UINT16_MAX 65535 #endif @@ -450,9 +444,6 @@ typedef int bool; #endif #endif -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -462,11 +453,34 @@ typedef int bool; #define MAX(a,b) ((a)>(b)?(a):(b)) #endif +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) + +/** Type-safe version of discard_const */ +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + #ifndef __STRING #define __STRING(x) #x #endif -#ifndef _STRINGSTRING +#ifndef __STRINGSTRING #define __STRINGSTRING(x) __STRING(x) #endif @@ -511,4 +525,12 @@ typedef int bool; #undef HAVE_MMAP #endif +#ifdef __COMPAR_FN_T +#define QSORT_CAST (__compar_fn_t) +#endif + +#ifndef QSORT_CAST +#define QSORT_CAST (int (*)(const void *, const void *)) +#endif + #endif /* _LIBREPLACE_REPLACE_H */ |