bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* prototypes for borrowed "compatibility" code */ |
| 2 | |
| 3 | #include <config.h> |
| 4 | |
| 5 | #include <sys/types.h> |
| 6 | #include <sys/stat.h> |
| 7 | |
| 8 | #include <stdarg.h> |
| 9 | #include <stddef.h> |
| 10 | |
| 11 | #ifdef HAVE_LIBGEN_H |
| 12 | # include <libgen.h> |
| 13 | #endif |
| 14 | |
bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 15 | |
| 16 | #if defined(NEED_BASENAME) && !defined(HAVE_BASENAME) |
| 17 | |
| 18 | # ifdef basename |
| 19 | # undef basename /* fix glibc brokenness */ |
| 20 | # endif |
| 21 | |
| 22 | char *openbsd_basename(const char *); |
| 23 | # define basename openbsd_basename |
| 24 | |
| 25 | #endif /* NEED_BASENAME && ! HAVE_BASENAME */ |
| 26 | |
| 27 | |
| 28 | #if defined(NEED_DIRNAME) && !defined(HAVE_DIRNAME) |
| 29 | |
| 30 | char *openbsd_dirname(const char *); |
| 31 | # define dirname openbsd_dirname |
| 32 | |
| 33 | #endif /* NEED_DIRNAME && ! HAVE_DIRNAME */ |
| 34 | |
| 35 | |
| 36 | #ifdef NEED_FNMATCH |
| 37 | # ifndef HAVE_FNMATCH |
| 38 | |
| 39 | # define FNM_NOMATCH 1 /* Match failed. */ |
| 40 | |
| 41 | # define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ |
| 42 | # define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ |
| 43 | # define FNM_PERIOD 0x04 /* Period must be matched by period. */ |
| 44 | |
| 45 | # define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */ |
| 46 | # define FNM_CASEFOLD 0x10 /* Case insensitive search. */ |
| 47 | # define FNM_IGNORECASE FNM_CASEFOLD |
| 48 | # define FNM_FILE_NAME FNM_PATHNAME |
| 49 | |
| 50 | int openbsd_fnmatch(const char *, const char *, int); |
| 51 | # define fnmatch openbsd_fnmatch |
| 52 | |
| 53 | # else /* HAVE_FNMATCH */ |
| 54 | |
| 55 | # ifdef HAVE_FNMATCH_H |
| 56 | # include <fnmatch.h> |
| 57 | # endif |
| 58 | |
| 59 | # endif /* ! HAVE_FNMATCH */ |
| 60 | #endif /* NEED_FNMATCH */ |
| 61 | |
| 62 | |
| 63 | #ifdef NEED_GETHOSTBYNAME_R |
| 64 | |
| 65 | # include <netdb.h> |
| 66 | |
| 67 | # if GETHOSTBYNAME_R_NUM_ARGS != 6 |
| 68 | |
| 69 | int compat_gethostbyname_r(const char *, struct hostent *, |
| 70 | char *, size_t, struct hostent **, int *); |
| 71 | |
| 72 | # define gethostbyname_r compat_gethostbyname_r |
| 73 | |
| 74 | # endif /* GETHOSTBYNAME_R_NUM_ARGS != 6 */ |
| 75 | |
| 76 | #endif /* NEED_GETHOSTBYNAME_R */ |
| 77 | |
| 78 | |
| 79 | #if defined(NEED_GETHOSTNAME) && !defined(HAVE_GETHOSTNAME) |
| 80 | |
| 81 | int gethostname(char *, size_t); |
| 82 | |
| 83 | #endif /* NEED_GETHOSTNAME && ! HAVE_GETHOSTNAME */ |
| 84 | |
| 85 | |
| 86 | #ifdef NEED_GETSERVBYNAME_R |
| 87 | |
| 88 | # include <netdb.h> |
| 89 | |
| 90 | # if GETSERVBYNAME_R_NUM_ARGS != 6 |
| 91 | |
| 92 | int compat_getservbyname_r(const char *, const char *, struct servent *, |
| 93 | char *, size_t, struct servent **); |
| 94 | |
| 95 | # define getservbyname_r compat_getservbyname_r |
| 96 | |
| 97 | # endif /* GETSERVBYNAME_R_NUM_ARGS != 6 */ |
| 98 | |
| 99 | #endif /* NEED_GETSERVBYNAME_R */ |
| 100 | |
| 101 | |
| 102 | |
| 103 | #ifdef NEED_GLOB |
| 104 | # ifndef HAVE_GLOB |
| 105 | |
| 106 | typedef struct { |
| 107 | int gl_pathc; /* Count of total paths so far. */ |
| 108 | int gl_matchc; /* Count of paths matching pattern. */ |
| 109 | int gl_offs; /* Reserved at beginning of gl_pathv. */ |
| 110 | int gl_flags; /* Copy of flags parameter to glob. */ |
| 111 | char **gl_pathv; /* List of paths matching pattern. */ |
| 112 | /* Copy of errfunc parameter to glob. */ |
| 113 | int (*gl_errfunc)(const char *, int); |
| 114 | |
| 115 | /* |
| 116 | * Alternate filesystem access methods for glob; replacement |
| 117 | * versions of closedir(3), readdir(3), opendir(3), stat(2) |
| 118 | * and lstat(2). |
| 119 | */ |
| 120 | void (*gl_closedir)(void *); |
| 121 | struct dirent *(*gl_readdir)(void *); |
| 122 | void *(*gl_opendir)(const char *); |
| 123 | int (*gl_lstat)(const char *, struct stat *); |
| 124 | int (*gl_stat)(const char *, struct stat *); |
| 125 | } glob_t; |
| 126 | |
| 127 | /* Flags */ |
| 128 | # define GLOB_APPEND 0x0001 /* Append to output from previous call. */ |
| 129 | # define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ |
| 130 | # define GLOB_ERR 0x0004 /* Return on error. */ |
| 131 | # define GLOB_MARK 0x0008 /* Append / to matching directories. */ |
| 132 | # define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ |
| 133 | # define GLOB_NOSORT 0x0020 /* Don't sort. */ |
| 134 | |
| 135 | # define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ |
| 136 | # define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ |
| 137 | # define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ |
| 138 | # define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ |
| 139 | # define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ |
| 140 | # define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ |
| 141 | # define GLOB_NOESCAPE 0x1000 /* Disable backslash escaping. */ |
| 142 | |
| 143 | /* Error values returned by glob(3) */ |
| 144 | # define GLOB_NOSPACE (-1) /* Malloc call failed. */ |
| 145 | # define GLOB_ABORTED (-2) /* Unignored error. */ |
| 146 | # define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK not set. */ |
| 147 | # define GLOB_NOSYS (-4) /* Function not supported. */ |
| 148 | # define GLOB_ABEND GLOB_ABORTED |
| 149 | |
| 150 | int openbsd_glob(const char *, int, int (*)(const char *, int), glob_t *); |
| 151 | void openbsd_globfree(glob_t *); |
| 152 | # define glob openbsd_glob |
| 153 | # define globfree openbsd_globfree |
| 154 | |
| 155 | # else /* HAVE_GLOB */ |
| 156 | |
| 157 | # ifdef HAVE_GLOB_H |
| 158 | # include <glob.h> |
| 159 | # endif |
| 160 | |
| 161 | # endif /* ! HAVE_GLOB */ |
| 162 | #endif /* NEED_GLOB */ |
| 163 | |
| 164 | |
| 165 | #if defined(NEED_INET_ATON) && !defined(HAVE_INET_ATON) |
| 166 | |
| 167 | int inet_aton(const char *, struct in_addr *); |
| 168 | |
| 169 | #endif /* NEED_INET_ATON && ! HAVE_INET_ATON */ |
| 170 | |
| 171 | |
| 172 | #ifdef NEED_MAKEDEV |
| 173 | |
| 174 | # ifdef MAJOR_IN_MKDEV |
| 175 | # include <sys/mkdev.h> |
| 176 | # else |
| 177 | # ifdef MAJOR_IN_SYSMACROS |
| 178 | # include <sys/sysmacros.h> |
| 179 | # endif |
| 180 | # endif |
| 181 | |
| 182 | /* |
| 183 | ** On most systems makedev() has two args. |
| 184 | ** Some weird systems, like QNX6, have makedev() functions that expect |
| 185 | ** an extra first argument for "node", which can be 0 for a local |
| 186 | ** machine. |
| 187 | */ |
| 188 | |
| 189 | # ifdef MAKEDEV_THREE_ARGS |
| 190 | # define compat_makedev(maj, min) makedev(0, maj, min) |
| 191 | # else |
| 192 | # define compat_makedev makedev |
| 193 | # endif |
| 194 | |
| 195 | #endif /* NEED_MAKEDEV */ |
| 196 | |
| 197 | |
| 198 | #if defined(NEED_SNPRINTF) && !defined(HAVE_SNPRINTF) |
| 199 | |
| 200 | int mutt_snprintf(char *, size_t, const char *, ...); |
| 201 | int mutt_vsnprintf(char *, size_t, const char *, va_list); |
| 202 | #define snprintf mutt_snprintf |
| 203 | #define vsnprintf mutt_vsnprintf |
| 204 | |
| 205 | #endif /* NEED_SNPRINTF && ! HAVE_SNPRINTF */ |
| 206 | |
| 207 | |
| 208 | #if defined(NEED_STRLCAT) && !defined(HAVE_STRLCAT) |
| 209 | |
| 210 | size_t strlcat(char *, const char *, size_t); |
| 211 | |
| 212 | #endif /* NEED_STRLCAT && ! HAVE_STRLCAT */ |
| 213 | |
| 214 | |
| 215 | #if defined(NEED_STRLCPY) && !defined(HAVE_STRLCPY) |
| 216 | |
| 217 | size_t strlcpy(char *, const char *, size_t); |
| 218 | |
| 219 | #endif /* NEED_STRLCPY && ! HAVE_STRLCPY */ |
| 220 | |
| 221 | |
| 222 | #if defined(NEED_STRDUP) && !defined(HAVE_STRDUP) |
| 223 | |
| 224 | char *openbsd_strdup(const char *); |
| 225 | # define strdup openbsd_strdup |
| 226 | |
| 227 | #endif /* NEED_STRDUP && ! HAVE_STRDUP */ |
| 228 | |
| 229 | |
| 230 | #if defined(NEED_STRMODE) && !defined(HAVE_STRMODE) |
| 231 | |
| 232 | void strmode(register mode_t, register char *); |
| 233 | |
| 234 | #endif /* NEED_STRMODE && ! HAVE_STRMODE */ |
| 235 | |
| 236 | |
| 237 | #if defined(NEED_STRRSTR) && !defined(HAVE_STRRSTR) |
| 238 | |
| 239 | char *strrstr(char *, char *); |
| 240 | |
| 241 | #endif /* NEED_STRRSTR && ! HAVE_STRRSTR */ |
| 242 | |
| 243 | |
| 244 | #ifdef NEED_STRSEP |
| 245 | |
| 246 | # ifdef HAVE_STRSEP |
| 247 | # define _LINUX_SOURCE_COMPAT /* needed on AIX 4.3.3 */ |
| 248 | # else |
| 249 | |
| 250 | char *strsep(register char **, register const char *); |
| 251 | |
| 252 | # endif |
| 253 | |
| 254 | #endif /* NEED_STRSEP */ |
| 255 | |
| 256 | |