idioms that configure uses.
- Use "#if" (not "#ifdef") for configure-defined macros.
- Use "#if !" (not "#ifndef") for configure-defined macros.
/* The default RSYNC_RSH is always set in config.h. */
/* The default RSYNC_RSH is always set in config.h. */
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stddef.h>
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
-#if defined(HAVE_MALLOC_H) && (defined(HAVE_MALLINFO) || !defined(HAVE_STDLIB_H))
+#if HAVE_MALLOC_H && (HAVE_MALLINFO || !HAVE_STDLIB_H)
#include <malloc.h>
#endif
#include <malloc.h>
#endif
-#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <sys/socket.h>
#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
#include <sys/time.h>
#include <time.h>
#else
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include <sys/fcntl.h>
#endif
#endif
#include <sys/fcntl.h>
#endif
#endif
-#include <sys/stat.h>
-
-#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#include <sys/ioctl.h>
#endif
#include <sys/filio.h>
#endif
#include <signal.h>
#include <sys/filio.h>
#endif
#include <signal.h>
#include <sys/wait.h>
#endif
#include <sys/wait.h>
#endif
#include <ctype.h>
#endif
#include <ctype.h>
#endif
#include <grp.h>
#endif
#include <errno.h>
#include <grp.h>
#endif
#include <errno.h>
#include <utime.h>
#endif
#include <utime.h>
#endif
-#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <sys/select.h>
#endif
/* apparently AIX needs this for S_ISLNK */
#ifndef S_ISLNK
#include <sys/mode.h>
#endif
#endif
/* apparently AIX needs this for S_ISLNK */
#ifndef S_ISLNK
#include <sys/mode.h>
#endif
#endif
#include <sys/sysmacros.h>
#endif
#include <sys/sysmacros.h>
#endif
#include <compat.h>
#endif
#include <compat.h>
#endif
#include "proto.h"
/* We have replacement versions of these if they're missing. */
#include "proto.h"
/* We have replacement versions of these if they're missing. */
int asprintf(char **ptr, const char *format, ...);
#endif
int asprintf(char **ptr, const char *format, ...);
#endif
int vasprintf(char **ptr, const char *format, va_list ap);
#endif
int vasprintf(char **ptr, const char *format, va_list ap);
#endif
-#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+#if !HAVE_VSNPRINTF || !HAVE_C99_VSNPRINTF
#define vsnprintf rsync_vsnprintf
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
#define vsnprintf rsync_vsnprintf
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
-#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+#if !HAVE_SNPRINTF || !HAVE_C99_VSNPRINTF
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#define strerror(i) sys_errlist[i]
#endif
#define strerror(i) sys_errlist[i]
#endif
# define strchr index
# define strrchr rindex
#endif
# define strchr index
# define strrchr rindex
#endif
__attribute__((format (printf, 3, 4)))
;
__attribute__((format (printf, 3, 4)))
;
-#ifdef REPLACE_INET_NTOA
#define inet_ntoa rep_inet_ntoa
#endif
#define inet_ntoa rep_inet_ntoa
#endif
#define O_BINARY 0
#endif
#define O_BINARY 0
#endif
size_t strlcpy(char *d, const char *s, size_t bufsize);
#endif
size_t strlcpy(char *d, const char *s, size_t bufsize);
#endif
size_t strlcat(char *d, const char *s, size_t bufsize);
#endif
size_t strlcat(char *d, const char *s, size_t bufsize);
#endif
#define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
#define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
#define MY_UID() geteuid()
#else
#define MY_UID() getuid()
#endif
#define MY_UID() geteuid()
#else
#define MY_UID() getuid()
#endif
#define MY_GID() getegid()
#else
#define MY_GID() getgid()
#define MY_GID() getegid()
#else
#define MY_GID() getgid()
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#endif /* !HAVE_INET_NTOP */
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#endif /* !HAVE_INET_NTOP */
int inet_pton(int af, const char *src, void *dst);
#endif
int inet_pton(int af, const char *src, void *dst);
#endif