| 1 | #ifdef HAVE_CONFIG_H |
| 2 | #include "config.h" |
| 3 | #endif |
| 4 | |
| 5 | #if defined (__GLIBC__) && defined(__LCLINT__) |
| 6 | /*@-declundef@*/ |
| 7 | /*@unchecked@*/ |
| 8 | extern __const __int32_t *__ctype_tolower; |
| 9 | /*@unchecked@*/ |
| 10 | extern __const __int32_t *__ctype_toupper; |
| 11 | /*@=declundef@*/ |
| 12 | #endif |
| 13 | |
| 14 | #include <ctype.h> |
| 15 | |
| 16 | #include <errno.h> |
| 17 | #include <fcntl.h> |
| 18 | #include <limits.h> |
| 19 | |
| 20 | #if HAVE_MCHECK_H |
| 21 | #include <mcheck.h> |
| 22 | #endif |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
| 27 | |
| 28 | #if HAVE_UNISTD_H |
| 29 | #include <unistd.h> |
| 30 | #endif |
| 31 | |
| 32 | #ifndef __GNUC__ |
| 33 | #define __attribute__(x) |
| 34 | #endif |
| 35 | |
| 36 | #ifdef __NeXT |
| 37 | /* access macros are not declared in non posix mode in unistd.h - |
| 38 | don't try to use posix on NeXTstep 3.3 ! */ |
| 39 | #include <libc.h> |
| 40 | #endif |
| 41 | |
| 42 | #if defined(__LCLINT__) |
| 43 | /*@-declundef -incondefs @*/ /* LCL: missing annotation */ |
| 44 | /*@only@*/ /*@out@*/ |
| 45 | void * alloca (size_t __size) |
| 46 | /*@ensures MaxSet(result) == (__size - 1) @*/ |
| 47 | /*@*/; |
| 48 | /*@=declundef =incondefs @*/ |
| 49 | #endif |
| 50 | |
| 51 | /* AIX requires this to be the first thing in the file. */ |
| 52 | #ifndef __GNUC__ |
| 53 | # if HAVE_ALLOCA_H |
| 54 | # include <alloca.h> |
| 55 | # else |
| 56 | # ifdef _AIX |
| 57 | #pragma alloca |
| 58 | # else |
| 59 | # ifdef HAVE_ALLOCA |
| 60 | # ifndef alloca /* predefined by HP cc +Olibcalls */ |
| 61 | char *alloca (); |
| 62 | # endif |
| 63 | # else |
| 64 | # ifdef alloca |
| 65 | # undef alloca |
| 66 | # endif |
| 67 | # define alloca(sz) malloc(sz) /* Kludge this for now */ |
| 68 | # endif |
| 69 | # endif |
| 70 | # endif |
| 71 | #elif defined(__GNUC__) && defined(__STRICT_ANSI__) |
| 72 | #define alloca __builtin_alloca |
| 73 | #endif |
| 74 | |
| 75 | /*@-redecl -redef@*/ |
| 76 | /*@mayexit@*/ /*@only@*/ /*@unused@*/ |
| 77 | char * xstrdup (const char *str) |
| 78 | /*@*/; |
| 79 | /*@=redecl =redef@*/ |
| 80 | |
| 81 | #if HAVE_MCHECK_H && defined(__GNUC__) |
| 82 | #define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL) |
| 83 | #define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str))) |
| 84 | #else |
| 85 | #define xstrdup(_str) strdup(_str) |
| 86 | #endif /* HAVE_MCHECK_H && defined(__GNUC__) */ |
| 87 | |
| 88 | #if HAVE___SECURE_GETENV && !defined(__LCLINT__) |
| 89 | #define getenv(_s) __secure_getenv(_s) |
| 90 | #endif |
| 91 | |
| 92 | #ifndef HAVE_STRLCPY |
| 93 | size_t strlcpy(char *d, const char *s, size_t bufsize); |
| 94 | #endif |
| 95 | |
| 96 | #ifndef HAVE_STRLCAT |
| 97 | size_t strlcat(char *d, const char *s, size_t bufsize); |
| 98 | #endif |
| 99 | |
| 100 | #define UNUSED(x) x __attribute__((__unused__)) |
| 101 | |
| 102 | #define PACKAGE "rsync" |
| 103 | |
| 104 | #ifndef DBL_EPSILON |
| 105 | #define DBL_EPSILON 2.2204460492503131e-16 |
| 106 | #endif |
| 107 | |
| 108 | #ifdef _ABS |
| 109 | #undef _ABS |
| 110 | #endif |
| 111 | |
| 112 | #include "popt.h" |