Escape hyphens that should be minus signs in man pages.
[libtar.git] / compat / compat.h
blob366667c46e9e701a6eca3e916bca872b966aee61
1 /* prototypes for borrowed "compatibility" code */
3 #include <config.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
8 #ifdef STDC_HEADERS
9 # include <stdarg.h>
10 # include <stddef.h>
11 #else
12 # include <varargs.h>
13 #endif
15 #ifdef HAVE_LIBGEN_H
16 # include <libgen.h>
17 #endif
20 #if defined(NEED_BASENAME) && !defined(HAVE_BASENAME)
22 # ifdef basename
23 # undef basename /* fix glibc brokenness */
24 # endif
26 char *openbsd_basename(const char *);
27 # define basename openbsd_basename
29 #endif /* NEED_BASENAME && ! HAVE_BASENAME */
32 #if defined(NEED_DIRNAME) && !defined(HAVE_DIRNAME)
34 char *openbsd_dirname(const char *);
35 # define dirname openbsd_dirname
37 #endif /* NEED_DIRNAME && ! HAVE_DIRNAME */
40 #ifdef NEED_FNMATCH
41 # ifndef HAVE_FNMATCH
43 # define FNM_NOMATCH 1 /* Match failed. */
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. */
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
54 int openbsd_fnmatch(const char *, const char *, int);
55 # define fnmatch openbsd_fnmatch
57 # else /* HAVE_FNMATCH */
59 # ifdef HAVE_FNMATCH_H
60 # include <fnmatch.h>
61 # endif
63 # endif /* ! HAVE_FNMATCH */
64 #endif /* NEED_FNMATCH */
67 #ifdef NEED_GETHOSTBYNAME_R
69 # include <netdb.h>
71 # if GETHOSTBYNAME_R_NUM_ARGS != 6
73 int compat_gethostbyname_r(const char *, struct hostent *,
74 char *, size_t, struct hostent **, int *);
76 # define gethostbyname_r compat_gethostbyname_r
78 # endif /* GETHOSTBYNAME_R_NUM_ARGS != 6 */
80 #endif /* NEED_GETHOSTBYNAME_R */
83 #if defined(NEED_GETHOSTNAME) && !defined(HAVE_GETHOSTNAME)
85 int gethostname(char *, size_t);
87 #endif /* NEED_GETHOSTNAME && ! HAVE_GETHOSTNAME */
90 #ifdef NEED_GETSERVBYNAME_R
92 # include <netdb.h>
94 # if GETSERVBYNAME_R_NUM_ARGS != 6
96 int compat_getservbyname_r(const char *, const char *, struct servent *,
97 char *, size_t, struct servent **);
99 # define getservbyname_r compat_getservbyname_r
101 # endif /* GETSERVBYNAME_R_NUM_ARGS != 6 */
103 #endif /* NEED_GETSERVBYNAME_R */
107 #ifdef NEED_GLOB
108 # ifndef HAVE_GLOB
110 typedef 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);
120 * Alternate filesystem access methods for glob; replacement
121 * versions of closedir(3), readdir(3), opendir(3), stat(2)
122 * and lstat(2).
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;
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. */
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. */
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
154 int openbsd_glob(const char *, int, int (*)(const char *, int), glob_t *);
155 void openbsd_globfree(glob_t *);
156 # define glob openbsd_glob
157 # define globfree openbsd_globfree
159 # else /* HAVE_GLOB */
161 # ifdef HAVE_GLOB_H
162 # include <glob.h>
163 # endif
165 # endif /* ! HAVE_GLOB */
166 #endif /* NEED_GLOB */
169 #if defined(NEED_INET_ATON) && !defined(HAVE_INET_ATON)
171 int inet_aton(const char *, struct in_addr *);
173 #endif /* NEED_INET_ATON && ! HAVE_INET_ATON */
176 #ifdef NEED_MAKEDEV
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
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.
193 # ifdef MAKEDEV_THREE_ARGS
194 # define compat_makedev(maj, min) makedev(0, maj, min)
195 # else
196 # define compat_makedev makedev
197 # endif
199 #endif /* NEED_MAKEDEV */
202 #if defined(NEED_SNPRINTF) && !defined(HAVE_SNPRINTF)
204 int mutt_snprintf(char *, size_t, const char *, ...);
205 int mutt_vsnprintf(char *, size_t, const char *, va_list);
206 #define snprintf mutt_snprintf
207 #define vsnprintf mutt_vsnprintf
209 #endif /* NEED_SNPRINTF && ! HAVE_SNPRINTF */
212 #if defined(NEED_STRLCAT) && !defined(HAVE_STRLCAT)
214 size_t strlcat(char *, const char *, size_t);
216 #endif /* NEED_STRLCAT && ! HAVE_STRLCAT */
219 #if defined(NEED_STRLCPY) && !defined(HAVE_STRLCPY)
221 size_t strlcpy(char *, const char *, size_t);
223 #endif /* NEED_STRLCPY && ! HAVE_STRLCPY */
226 #if defined(NEED_STRDUP) && !defined(HAVE_STRDUP)
228 char *openbsd_strdup(const char *);
229 # define strdup openbsd_strdup
231 #endif /* NEED_STRDUP && ! HAVE_STRDUP */
234 #if defined(NEED_STRMODE) && !defined(HAVE_STRMODE)
236 void strmode(register mode_t, register char *);
238 #endif /* NEED_STRMODE && ! HAVE_STRMODE */
241 #if defined(NEED_STRRSTR) && !defined(HAVE_STRRSTR)
243 char *strrstr(char *, char *);
245 #endif /* NEED_STRRSTR && ! HAVE_STRRSTR */
248 #ifdef NEED_STRSEP
250 # ifdef HAVE_STRSEP
251 # define _LINUX_SOURCE_COMPAT /* needed on AIX 4.3.3 */
252 # else
254 char *strsep(register char **, register const char *);
256 # endif
258 #endif /* NEED_STRSEP */