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