tarruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +99 -0
- data/ext/extconf.rb +19 -0
- data/ext/libtar/COPYRIGHT +35 -0
- data/ext/libtar/ChangeLog +243 -0
- data/ext/libtar/ChangeLog-1.0.x +141 -0
- data/ext/libtar/INSTALL +183 -0
- data/ext/libtar/Makefile.in +51 -0
- data/ext/libtar/README +121 -0
- data/ext/libtar/TODO +10 -0
- data/ext/libtar/autoconf/ac_path_generic.m4 +136 -0
- data/ext/libtar/autoconf/aclocal.m4 +199 -0
- data/ext/libtar/autoconf/encap.m4 +133 -0
- data/ext/libtar/autoconf/install-sh +251 -0
- data/ext/libtar/autom4te.cache/output.0 +8102 -0
- data/ext/libtar/autom4te.cache/requests +112 -0
- data/ext/libtar/autom4te.cache/traces.0 +382 -0
- data/ext/libtar/compat/ChangeLog +31 -0
- data/ext/libtar/compat/README +12 -0
- data/ext/libtar/compat/TODO +4 -0
- data/ext/libtar/compat/basename.c +91 -0
- data/ext/libtar/compat/compat.h +260 -0
- data/ext/libtar/compat/dirname.c +96 -0
- data/ext/libtar/compat/fnmatch.c +237 -0
- data/ext/libtar/compat/gethostbyname_r.c +41 -0
- data/ext/libtar/compat/gethostname.c +36 -0
- data/ext/libtar/compat/getservbyname_r.c +41 -0
- data/ext/libtar/compat/glob.c +898 -0
- data/ext/libtar/compat/inet_aton.c +27 -0
- data/ext/libtar/compat/module.ac +591 -0
- data/ext/libtar/compat/snprintf.c +788 -0
- data/ext/libtar/compat/strdup.c +62 -0
- data/ext/libtar/compat/strlcat.c +72 -0
- data/ext/libtar/compat/strlcpy.c +68 -0
- data/ext/libtar/compat/strmode.c +199 -0
- data/ext/libtar/compat/strrstr.c +40 -0
- data/ext/libtar/compat/strsep.c +87 -0
- data/ext/libtar/config.h.in +187 -0
- data/ext/libtar/configure +8102 -0
- data/ext/libtar/configure.ac +114 -0
- data/ext/libtar/doc/Makefile.in +152 -0
- data/ext/libtar/doc/tar_append_file.3 +50 -0
- data/ext/libtar/doc/tar_block_read.3 +24 -0
- data/ext/libtar/doc/tar_extract_all.3 +43 -0
- data/ext/libtar/doc/tar_extract_file.3 +84 -0
- data/ext/libtar/doc/tar_open.3 +97 -0
- data/ext/libtar/doc/th_get_pathname.3 +63 -0
- data/ext/libtar/doc/th_print_long_ls.3 +22 -0
- data/ext/libtar/doc/th_read.3 +34 -0
- data/ext/libtar/doc/th_set_from_stat.3 +45 -0
- data/ext/libtar/lib/Makefile.in +92 -0
- data/ext/libtar/lib/append.c +272 -0
- data/ext/libtar/lib/block.c +384 -0
- data/ext/libtar/lib/decode.c +130 -0
- data/ext/libtar/lib/encode.c +237 -0
- data/ext/libtar/lib/extract.c +656 -0
- data/ext/libtar/lib/handle.c +150 -0
- data/ext/libtar/lib/internal.h +46 -0
- data/ext/libtar/lib/libtar.h +311 -0
- data/ext/libtar/lib/output.c +146 -0
- data/ext/libtar/lib/util.c +153 -0
- data/ext/libtar/lib/wrapper.c +175 -0
- data/ext/libtar/libtar/Makefile.in +73 -0
- data/ext/libtar/libtar/libtar.c +363 -0
- data/ext/libtar/listhash/ChangeLog +15 -0
- data/ext/libtar/listhash/TODO +21 -0
- data/ext/libtar/listhash/hash.c.in +344 -0
- data/ext/libtar/listhash/hash_new.3.in +74 -0
- data/ext/libtar/listhash/list.c.in +458 -0
- data/ext/libtar/listhash/list_new.3.in +86 -0
- data/ext/libtar/listhash/listhash.h.in +196 -0
- data/ext/libtar/listhash/module.ac +21 -0
- data/ext/libtar/win32/config.h +190 -0
- data/ext/libtar/win32/dirent.c +115 -0
- data/ext/libtar/win32/dirent.h +24 -0
- data/ext/libtar/win32/grp.h +4 -0
- data/ext/libtar/win32/listhash/libtar_hash.c +344 -0
- data/ext/libtar/win32/listhash/libtar_list.c +458 -0
- data/ext/libtar/win32/listhash/libtar_listhash.h +196 -0
- data/ext/libtar/win32/pwd.h +4 -0
- data/ext/libtar/win32/sys/param.h +8 -0
- data/ext/libtar/win32/tar.h +35 -0
- data/ext/libtar/win32/utime.h +6 -0
- data/ext/libtar/win32/win32/types.h +10 -0
- data/ext/tarruby.c +648 -0
- metadata +150 -0
@@ -0,0 +1,260 @@
|
|
1
|
+
/* prototypes for borrowed "compatibility" code */
|
2
|
+
|
3
|
+
#include <config.h>
|
4
|
+
|
5
|
+
#include <sys/types.h>
|
6
|
+
#include <sys/stat.h>
|
7
|
+
|
8
|
+
#ifdef STDC_HEADERS
|
9
|
+
# include <stdarg.h>
|
10
|
+
# include <stddef.h>
|
11
|
+
#else
|
12
|
+
# include <varargs.h>
|
13
|
+
#endif
|
14
|
+
|
15
|
+
#ifdef HAVE_LIBGEN_H
|
16
|
+
# include <libgen.h>
|
17
|
+
#endif
|
18
|
+
|
19
|
+
|
20
|
+
#if defined(NEED_BASENAME) && !defined(HAVE_BASENAME)
|
21
|
+
|
22
|
+
# ifdef basename
|
23
|
+
# undef basename /* fix glibc brokenness */
|
24
|
+
# endif
|
25
|
+
|
26
|
+
char *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
|
+
|
34
|
+
char *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
|
+
|
54
|
+
int 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
|
+
|
73
|
+
int 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
|
+
|
85
|
+
int 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
|
+
|
96
|
+
int 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
|
+
|
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);
|
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
|
+
|
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
|
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
|
+
|
171
|
+
int 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
|
+
|
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
|
208
|
+
|
209
|
+
#endif /* NEED_SNPRINTF && ! HAVE_SNPRINTF */
|
210
|
+
|
211
|
+
|
212
|
+
#if defined(NEED_STRLCAT) && !defined(HAVE_STRLCAT)
|
213
|
+
|
214
|
+
size_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
|
+
|
221
|
+
size_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
|
+
|
228
|
+
char *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
|
+
|
236
|
+
void strmode(register mode_t, register char *);
|
237
|
+
|
238
|
+
#endif /* NEED_STRMODE && ! HAVE_STRMODE */
|
239
|
+
|
240
|
+
|
241
|
+
#if defined(NEED_STRRSTR) && !defined(HAVE_STRRSTR)
|
242
|
+
|
243
|
+
char *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
|
+
|
254
|
+
char *strsep(register char **, register const char *);
|
255
|
+
|
256
|
+
# endif
|
257
|
+
|
258
|
+
#endif /* NEED_STRSEP */
|
259
|
+
|
260
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/* $OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
|
5
|
+
* All rights reserved.
|
6
|
+
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
8
|
+
* modification, are permitted provided that the following conditions
|
9
|
+
* are met:
|
10
|
+
* 1. Redistributions of source code must retain the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
* notice, this list of conditions and the following disclaimer in the
|
14
|
+
* documentation and/or other materials provided with the distribution.
|
15
|
+
* 3. The name of the author may not be used to endorse or promote products
|
16
|
+
* derived from this software without specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
+
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
21
|
+
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
22
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
23
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
24
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
25
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
26
|
+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
27
|
+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
*/
|
29
|
+
|
30
|
+
#ifndef lint
|
31
|
+
static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
|
32
|
+
#endif /* not lint */
|
33
|
+
|
34
|
+
#include <errno.h>
|
35
|
+
#include <string.h>
|
36
|
+
#include <sys/param.h>
|
37
|
+
|
38
|
+
char *
|
39
|
+
openbsd_dirname(path)
|
40
|
+
const char *path;
|
41
|
+
{
|
42
|
+
static char bname[MAXPATHLEN];
|
43
|
+
register const char *endp;
|
44
|
+
|
45
|
+
/* Empty or NULL string gets treated as "." */
|
46
|
+
if (path == NULL || *path == '\0') {
|
47
|
+
(void)strcpy(bname, ".");
|
48
|
+
return(bname);
|
49
|
+
}
|
50
|
+
|
51
|
+
/* Strip trailing slashes */
|
52
|
+
endp = path + strlen(path) - 1;
|
53
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
54
|
+
while (endp > path && *endp == '/')
|
55
|
+
endp--;
|
56
|
+
#else
|
57
|
+
while (endp > path && (*endp == '/' || *endp == '\\')) {
|
58
|
+
endp--;
|
59
|
+
}
|
60
|
+
#endif
|
61
|
+
|
62
|
+
/* Find the start of the dir */
|
63
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
64
|
+
while (endp > path && *endp != '/')
|
65
|
+
endp--;
|
66
|
+
#else
|
67
|
+
while (endp > path && !(*endp == '/' || *endp == '\\')) {
|
68
|
+
endp--;
|
69
|
+
}
|
70
|
+
#endif
|
71
|
+
|
72
|
+
/* Either the dir is "/" or there are no slashes */
|
73
|
+
if (endp == path) {
|
74
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
75
|
+
(void)strcpy(bname, *endp == '/' ? "/" : ".");
|
76
|
+
#else
|
77
|
+
(void)strcpy(bname, (*endp == '/' || *endp == '\\') ? "/" : ".");
|
78
|
+
#endif
|
79
|
+
return(bname);
|
80
|
+
} else {
|
81
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
82
|
+
do {
|
83
|
+
endp--;
|
84
|
+
} while (endp > path && *endp == '/');
|
85
|
+
#else
|
86
|
+
#endif
|
87
|
+
}
|
88
|
+
|
89
|
+
if (endp - path + 1 > sizeof(bname)) {
|
90
|
+
errno = ENAMETOOLONG;
|
91
|
+
return(NULL);
|
92
|
+
}
|
93
|
+
(void)strncpy(bname, path, endp - path + 1);
|
94
|
+
bname[endp - path + 1] = '\0';
|
95
|
+
return(bname);
|
96
|
+
}
|
@@ -0,0 +1,237 @@
|
|
1
|
+
/* $OpenBSD: fnmatch.c,v 1.6 1998/03/19 00:29:59 millert Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1989, 1993, 1994
|
5
|
+
* The Regents of the University of California. All rights reserved.
|
6
|
+
*
|
7
|
+
* This code is derived from software contributed to Berkeley by
|
8
|
+
* Guido van Rossum.
|
9
|
+
*
|
10
|
+
* Redistribution and use in source and binary forms, with or without
|
11
|
+
* modification, are permitted provided that the following conditions
|
12
|
+
* are met:
|
13
|
+
* 1. Redistributions of source code must retain the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer.
|
15
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
+
* notice, this list of conditions and the following disclaimer in the
|
17
|
+
* documentation and/or other materials provided with the distribution.
|
18
|
+
* 3. All advertising materials mentioning features or use of this software
|
19
|
+
* must display the following acknowledgement:
|
20
|
+
* This product includes software developed by the University of
|
21
|
+
* California, Berkeley and its contributors.
|
22
|
+
* 4. Neither the name of the University nor the names of its contributors
|
23
|
+
* may be used to endorse or promote products derived from this software
|
24
|
+
* without specific prior written permission.
|
25
|
+
*
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
27
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
28
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
29
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
30
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
31
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
32
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
33
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
34
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
35
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
36
|
+
* SUCH DAMAGE.
|
37
|
+
*/
|
38
|
+
|
39
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
40
|
+
#if 0
|
41
|
+
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
|
42
|
+
#else
|
43
|
+
static char rcsid[] = "$OpenBSD: fnmatch.c,v 1.6 1998/03/19 00:29:59 millert Exp $";
|
44
|
+
#endif
|
45
|
+
#endif /* LIBC_SCCS and not lint */
|
46
|
+
|
47
|
+
/*
|
48
|
+
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
|
49
|
+
* Compares a filename or pathname to a pattern.
|
50
|
+
*/
|
51
|
+
|
52
|
+
#include <config.h>
|
53
|
+
|
54
|
+
#include <stdio.h>
|
55
|
+
|
56
|
+
#ifdef STDC_HEADERS
|
57
|
+
# include <string.h>
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#ifdef HAVE_CTYPE_H
|
61
|
+
# include <ctype.h>
|
62
|
+
#endif
|
63
|
+
|
64
|
+
#include <compat.h>
|
65
|
+
|
66
|
+
|
67
|
+
#define EOS '\0'
|
68
|
+
|
69
|
+
#define RANGE_MATCH 1
|
70
|
+
#define RANGE_NOMATCH 0
|
71
|
+
#define RANGE_ERROR (-1)
|
72
|
+
|
73
|
+
#ifdef NO_IBM_COMPILER_HORKAGE
|
74
|
+
static int rangematch (const char *, char, int, char **);
|
75
|
+
#else
|
76
|
+
static int rangematch ();
|
77
|
+
#endif
|
78
|
+
|
79
|
+
int
|
80
|
+
fnmatch(pattern, string, flags)
|
81
|
+
const char *pattern, *string;
|
82
|
+
int flags;
|
83
|
+
{
|
84
|
+
const char *stringstart;
|
85
|
+
char *newp;
|
86
|
+
char c, test;
|
87
|
+
|
88
|
+
for (stringstart = string;;)
|
89
|
+
switch (c = *pattern++) {
|
90
|
+
case EOS:
|
91
|
+
if ((flags & FNM_LEADING_DIR) && *string == '/')
|
92
|
+
return (0);
|
93
|
+
return (*string == EOS ? 0 : FNM_NOMATCH);
|
94
|
+
case '?':
|
95
|
+
if (*string == EOS)
|
96
|
+
return (FNM_NOMATCH);
|
97
|
+
if (*string == '/' && (flags & FNM_PATHNAME))
|
98
|
+
return (FNM_NOMATCH);
|
99
|
+
if (*string == '.' && (flags & FNM_PERIOD) &&
|
100
|
+
(string == stringstart ||
|
101
|
+
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
|
102
|
+
return (FNM_NOMATCH);
|
103
|
+
++string;
|
104
|
+
break;
|
105
|
+
case '*':
|
106
|
+
c = *pattern;
|
107
|
+
/* Collapse multiple stars. */
|
108
|
+
while (c == '*')
|
109
|
+
c = *++pattern;
|
110
|
+
|
111
|
+
if (*string == '.' && (flags & FNM_PERIOD) &&
|
112
|
+
(string == stringstart ||
|
113
|
+
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
|
114
|
+
return (FNM_NOMATCH);
|
115
|
+
|
116
|
+
/* Optimize for pattern with * at end or before /. */
|
117
|
+
if (c == EOS) {
|
118
|
+
if (flags & FNM_PATHNAME)
|
119
|
+
return ((flags & FNM_LEADING_DIR) ||
|
120
|
+
strchr(string, '/') == NULL ?
|
121
|
+
0 : FNM_NOMATCH);
|
122
|
+
else
|
123
|
+
return (0);
|
124
|
+
} else if (c == '/' && (flags & FNM_PATHNAME)) {
|
125
|
+
if ((string = strchr(string, '/')) == NULL)
|
126
|
+
return (FNM_NOMATCH);
|
127
|
+
break;
|
128
|
+
}
|
129
|
+
|
130
|
+
/* General case, use recursion. */
|
131
|
+
while ((test = *string) != EOS) {
|
132
|
+
if (!fnmatch(pattern, string, flags & ~FNM_PERIOD))
|
133
|
+
return (0);
|
134
|
+
if (test == '/' && (flags & FNM_PATHNAME))
|
135
|
+
break;
|
136
|
+
++string;
|
137
|
+
}
|
138
|
+
return (FNM_NOMATCH);
|
139
|
+
case '[':
|
140
|
+
if (*string == EOS)
|
141
|
+
return (FNM_NOMATCH);
|
142
|
+
if (*string == '/' && (flags & FNM_PATHNAME))
|
143
|
+
return (FNM_NOMATCH);
|
144
|
+
if (*string == '.' && (flags & FNM_PERIOD) &&
|
145
|
+
(string == stringstart ||
|
146
|
+
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
|
147
|
+
return (FNM_NOMATCH);
|
148
|
+
|
149
|
+
switch (rangematch(pattern, *string, flags, &newp)) {
|
150
|
+
case RANGE_ERROR:
|
151
|
+
/* not a good range, treat as normal text */
|
152
|
+
goto normal;
|
153
|
+
case RANGE_MATCH:
|
154
|
+
pattern = newp;
|
155
|
+
break;
|
156
|
+
case RANGE_NOMATCH:
|
157
|
+
return (FNM_NOMATCH);
|
158
|
+
}
|
159
|
+
++string;
|
160
|
+
break;
|
161
|
+
case '\\':
|
162
|
+
if (!(flags & FNM_NOESCAPE)) {
|
163
|
+
if ((c = *pattern++) == EOS) {
|
164
|
+
c = '\\';
|
165
|
+
--pattern;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
/* FALLTHROUGH */
|
169
|
+
default:
|
170
|
+
normal:
|
171
|
+
if (c != *string && !((flags & FNM_CASEFOLD) &&
|
172
|
+
(tolower((unsigned char)c) ==
|
173
|
+
tolower((unsigned char)*string))))
|
174
|
+
return (FNM_NOMATCH);
|
175
|
+
++string;
|
176
|
+
break;
|
177
|
+
}
|
178
|
+
/* NOTREACHED */
|
179
|
+
}
|
180
|
+
|
181
|
+
static int
|
182
|
+
rangematch(pattern, test, flags, newp)
|
183
|
+
const char *pattern;
|
184
|
+
char test;
|
185
|
+
int flags;
|
186
|
+
char **newp;
|
187
|
+
{
|
188
|
+
int negate, ok;
|
189
|
+
char c, c2;
|
190
|
+
|
191
|
+
/*
|
192
|
+
* A bracket expression starting with an unquoted circumflex
|
193
|
+
* character produces unspecified results (IEEE 1003.2-1992,
|
194
|
+
* 3.13.2). This implementation treats it like '!', for
|
195
|
+
* consistency with the regular expression syntax.
|
196
|
+
* J.T. Conklin (conklin@ngai.kaleida.com)
|
197
|
+
*/
|
198
|
+
if ((negate = (*pattern == '!' || *pattern == '^')))
|
199
|
+
++pattern;
|
200
|
+
|
201
|
+
if (flags & FNM_CASEFOLD)
|
202
|
+
test = tolower((unsigned char)test);
|
203
|
+
|
204
|
+
/*
|
205
|
+
* A right bracket shall lose its special meaning and represent
|
206
|
+
* itself in a bracket expression if it occurs first in the list.
|
207
|
+
* -- POSIX.2 2.8.3.2
|
208
|
+
*/
|
209
|
+
ok = 0;
|
210
|
+
c = *pattern++;
|
211
|
+
do {
|
212
|
+
if (c == '\\' && !(flags & FNM_NOESCAPE))
|
213
|
+
c = *pattern++;
|
214
|
+
if (c == EOS)
|
215
|
+
return (RANGE_ERROR);
|
216
|
+
if (c == '/' && (flags & FNM_PATHNAME))
|
217
|
+
return (RANGE_NOMATCH);
|
218
|
+
if ((flags & FNM_CASEFOLD))
|
219
|
+
c = tolower((unsigned char)c);
|
220
|
+
if (*pattern == '-'
|
221
|
+
&& (c2 = *(pattern+1)) != EOS && c2 != ']') {
|
222
|
+
pattern += 2;
|
223
|
+
if (c2 == '\\' && !(flags & FNM_NOESCAPE))
|
224
|
+
c2 = *pattern++;
|
225
|
+
if (c2 == EOS)
|
226
|
+
return (RANGE_ERROR);
|
227
|
+
if (flags & FNM_CASEFOLD)
|
228
|
+
c2 = tolower((unsigned char)c2);
|
229
|
+
if (c <= test && test <= c2)
|
230
|
+
ok = 1;
|
231
|
+
} else if (c == test)
|
232
|
+
ok = 1;
|
233
|
+
} while ((c = *pattern++) != ']');
|
234
|
+
|
235
|
+
*newp = (char *)pattern;
|
236
|
+
return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
|
237
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
** Copyright 2002 University of Illinois Board of Trustees
|
3
|
+
** Copyright 2002 Mark D. Roth
|
4
|
+
** All rights reserved.
|
5
|
+
**
|
6
|
+
** gethostbyname_r.c - gethostbyname_r() function for compatibility library
|
7
|
+
**
|
8
|
+
** Mark D. Roth <roth@uiuc.edu>
|
9
|
+
** Campus Information Technologies and Educational Services
|
10
|
+
** University of Illinois at Urbana-Champaign
|
11
|
+
*/
|
12
|
+
|
13
|
+
#include <config.h>
|
14
|
+
|
15
|
+
#include <stdio.h>
|
16
|
+
#include <sys/types.h>
|
17
|
+
#include <netdb.h>
|
18
|
+
|
19
|
+
|
20
|
+
int
|
21
|
+
compat_gethostbyname_r(const char *name, struct hostent *hp,
|
22
|
+
char *buf, size_t buflen,
|
23
|
+
struct hostent **hpp, int *herr)
|
24
|
+
{
|
25
|
+
#if GETHOSTBYNAME_R_NUM_ARGS == 5
|
26
|
+
*hpp = gethostbyname_r(name, hp, buf, buflen, herr);
|
27
|
+
|
28
|
+
if (*hpp == NULL)
|
29
|
+
return -1;
|
30
|
+
return 0;
|
31
|
+
#elif GETHOSTBYNAME_R_NUM_ARGS == 3
|
32
|
+
struct hostent_data hdata;
|
33
|
+
|
34
|
+
if (gethostbyname_r(name, hp, &hdata) == -1)
|
35
|
+
return -1;
|
36
|
+
*hpp = hp;
|
37
|
+
return 0;
|
38
|
+
#endif /* GETHOSTBYNAME_R_NUM_ARGS == 5 */
|
39
|
+
}
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/* gethostname.c: minimal substitute for missing gethostname() function
|
2
|
+
* created 2000-Mar-02 jmk
|
3
|
+
* requires SVR4 uname() and -lc
|
4
|
+
*
|
5
|
+
* by Jim Knoble <jmknoble@pobox.com>
|
6
|
+
* Copyright ? 2000 Jim Knoble
|
7
|
+
*
|
8
|
+
* Permission to use, copy, modify, distribute, and sell this software
|
9
|
+
* and its documentation for any purpose is hereby granted without fee,
|
10
|
+
* provided that the above copyright notice appear in all copies and
|
11
|
+
* that both that copyright notice and this permission notice appear in
|
12
|
+
* supporting documentation.
|
13
|
+
*
|
14
|
+
* This software is provided "as is", without warranty of any kind,
|
15
|
+
* express or implied, including but not limited to the warranties of
|
16
|
+
* merchantability, fitness for a particular purpose and
|
17
|
+
* noninfringement. In no event shall the author(s) be liable for any
|
18
|
+
* claim, damages or other liability, whether in an action of contract,
|
19
|
+
* tort or otherwise, arising from, out of or in connection with the
|
20
|
+
* software or the use or other dealings in the software.
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include <string.h>
|
24
|
+
#include <sys/utsname.h>
|
25
|
+
|
26
|
+
int gethostname(char *name, size_t len)
|
27
|
+
{
|
28
|
+
struct utsname u;
|
29
|
+
int status = uname(&u);
|
30
|
+
if (-1 != status) {
|
31
|
+
strncpy(name, u.nodename, len);
|
32
|
+
name[len - 1] = '\0';
|
33
|
+
}
|
34
|
+
return(status);
|
35
|
+
}
|
36
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
** Copyright 2002 University of Illinois Board of Trustees
|
3
|
+
** Copyright 2002 Mark D. Roth
|
4
|
+
** All rights reserved.
|
5
|
+
**
|
6
|
+
** getservbyname_r.c - getservbyname_r() function for compatibility library
|
7
|
+
**
|
8
|
+
** Mark D. Roth <roth@uiuc.edu>
|
9
|
+
** Campus Information Technologies and Educational Services
|
10
|
+
** University of Illinois at Urbana-Champaign
|
11
|
+
*/
|
12
|
+
|
13
|
+
#include <config.h>
|
14
|
+
|
15
|
+
#include <stdio.h>
|
16
|
+
#include <sys/types.h>
|
17
|
+
#include <netdb.h>
|
18
|
+
|
19
|
+
|
20
|
+
int
|
21
|
+
compat_getservbyname_r(const char *name, const char *proto,
|
22
|
+
struct servent *sp, char *buf, size_t buflen,
|
23
|
+
struct servent **spp)
|
24
|
+
{
|
25
|
+
#if GETSERVBYNAME_R_NUM_ARGS == 5
|
26
|
+
*spp = getservbyname_r(name, proto, sp, buf, buflen);
|
27
|
+
|
28
|
+
if (*spp == NULL)
|
29
|
+
return -1;
|
30
|
+
return 0;
|
31
|
+
#elif GETSERVBYNAME_R_NUM_ARGS == 4
|
32
|
+
struct servent_data sdata;
|
33
|
+
|
34
|
+
if (getservbyname_r(name, proto, sp, &sdata) == -1)
|
35
|
+
return -1;
|
36
|
+
*spp = sp;
|
37
|
+
return 0;
|
38
|
+
#endif /* GETSERVBYNAME_R_NUM_ARGS == 5 */
|
39
|
+
}
|
40
|
+
|
41
|
+
|