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