Fix return type of readlink().
[kai/samba.git] / lib / replace / replace.h
index c69ea6cdac4d8ae873db163b4ceb6c1cbf73f792..c1444cd5ee5c36ee2ff20657ed63c047013d66b6 100644 (file)
    which causes a warning storm on irix */
 #undef HAVE_INTTYPES_H
 #elif HAVE_INTTYPES_H
+#define __STDC_FORMAT_MACROS
 #include <inttypes.h>
 #endif
 
+#ifndef __PRI64_PREFIX
+# if __WORDSIZE == 64
+#  define __PRI64_PREFIX       "l"
+# else
+#  define __PRI64_PREFIX       "ll"
+# endif
+#endif
+
+/* Decimal notation.  */
+#ifndef PRId8
+# define PRId8         "d"
+#endif
+#ifndef PRId16
+# define PRId16                "d"
+#endif
+#ifndef PRId32
+# define PRId32                "d"
+#endif
+#ifndef PRId64
+# define PRId64                __PRI64_PREFIX "d"
+#endif
+
+#ifndef PRIi8
+# define PRIi8         "i"
+#endif
+#ifndef PRIi8
+# define PRIi16                "i"
+#endif
+#ifndef PRIi8
+# define PRIi32                "i"
+#endif
+#ifndef PRIi8
+# define PRIi64                __PRI64_PREFIX "i"
+#endif
+
+#ifndef PRIu8
+# define PRIu8         "u"
+#endif
+#ifndef PRIu16
+# define PRIu16                "u"
+#endif
+#ifndef PRIu32
+# define PRIu32                "u"
+#endif
+#ifndef PRIu64
+# define PRIu64                __PRI64_PREFIX "u"
+#endif
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -133,6 +182,15 @@ char *rep_strndup(const char *s, size_t n);
 size_t rep_strnlen(const char *s, size_t n);
 #endif
 
+#if !HAVE_DECL_ENVIRON
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+extern char **environ;
+#endif
+#endif
+
 #ifndef HAVE_SETENV
 #define setenv rep_setenv
 int rep_setenv(const char *name, const char *value, int overwrite);
@@ -157,6 +215,41 @@ int rep_seteuid(uid_t);
 int rep_setegid(gid_t);
 #endif
 
+#ifndef HAVE_CHOWN
+#define chown rep_chown
+int rep_chown(const char *path, uid_t uid, gid_t gid);
+#endif
+
+#ifndef HAVE_CHROOT
+#define chroot rep_chroot
+int rep_chroot(const char *dirname);
+#endif
+
+#ifndef HAVE_LINK
+#define link rep_link
+int rep_link(const char *oldpath, const char *newpath);
+#endif
+
+#ifndef HAVE_READLINK
+#define readlink rep_readlink
+ssize_t rep_readlink(const char *path, char *buf, size_t bufsize);
+#endif
+
+#ifndef HAVE_SYMLINK
+#define symlink rep_symlink
+int rep_symlink(const char *oldpath, const char *newpath);
+#endif
+
+#ifndef HAVE_REALPATH
+#define realpath rep_realpath
+char *rep_realpath(const char *path, char *resolved_path);
+#endif
+
+#ifndef HAVE_LCHOWN
+#define lchown rep_lchown
+int rep_lchown(const char *fname,uid_t uid,gid_t gid);
+#endif
+
 #ifndef HAVE_SETLINEBUF
 #define setlinebuf rep_setlinebuf
 void rep_setlinebuf(FILE *);
@@ -300,6 +393,11 @@ struct tm;
 char *rep_strptime(const char *buf, const char *format, struct tm *tm);
 #endif
 
+#ifndef HAVE_DUP2
+#define dup2 rep_dup2
+int rep_dup2(int oldfd, int newfd);
+#endif
+
 /* Load header file for dynamic linking stuff */
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
@@ -579,4 +677,13 @@ typedef int bool;
 #define MAX_DNS_NAME_LENGTH 256 /* Actually 255 but +1 for terminating null. */
 #endif
 
+#ifndef HAVE_CRYPT
+char *ufc_crypt(const char *key, const char *salt);
+#define crypt ufc_crypt
+#else
+#ifdef HAVE_CRYPT_H
+#include <crypt.h>
+#endif
+#endif
+
 #endif /* _LIBREPLACE_REPLACE_H */