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,62 @@
|
|
1
|
+
/* $OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1988, 1993
|
5
|
+
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
|
16
|
+
* must display the following acknowledgement:
|
17
|
+
* This product includes software developed by the University of
|
18
|
+
* California, Berkeley and its contributors.
|
19
|
+
* 4. Neither the name of the University nor the names of its contributors
|
20
|
+
* may be used to endorse or promote products derived from this software
|
21
|
+
* without specific prior written permission.
|
22
|
+
*
|
23
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
24
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
27
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
29
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
31
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
32
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
33
|
+
* SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
37
|
+
#if 0
|
38
|
+
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
|
39
|
+
#else
|
40
|
+
static char *rcsid = "$OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $";
|
41
|
+
#endif
|
42
|
+
#endif /* LIBC_SCCS and not lint */
|
43
|
+
|
44
|
+
#include <sys/types.h>
|
45
|
+
|
46
|
+
#include <stddef.h>
|
47
|
+
#include <stdlib.h>
|
48
|
+
#include <string.h>
|
49
|
+
|
50
|
+
char *
|
51
|
+
openbsd_strdup(str)
|
52
|
+
const char *str;
|
53
|
+
{
|
54
|
+
size_t siz;
|
55
|
+
char *copy;
|
56
|
+
|
57
|
+
siz = strlen(str) + 1;
|
58
|
+
if ((copy = malloc(siz)) == NULL)
|
59
|
+
return(NULL);
|
60
|
+
(void)memcpy(copy, str, siz);
|
61
|
+
return(copy);
|
62
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* $OpenBSD: strlcat.c,v 1.5 2001/01/13 16:17:24 millert Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1998 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
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
31
|
+
static char *rcsid = "$OpenBSD: strlcat.c,v 1.5 2001/01/13 16:17:24 millert Exp $";
|
32
|
+
#endif /* LIBC_SCCS and not lint */
|
33
|
+
|
34
|
+
#include <sys/types.h>
|
35
|
+
#include <string.h>
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Appends src to string dst of size siz (unlike strncat, siz is the
|
39
|
+
* full size of dst, not space left). At most siz-1 characters
|
40
|
+
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
41
|
+
* Returns strlen(initial dst) + strlen(src); if retval >= siz,
|
42
|
+
* truncation occurred.
|
43
|
+
*/
|
44
|
+
size_t strlcat(dst, src, siz)
|
45
|
+
char *dst;
|
46
|
+
const char *src;
|
47
|
+
size_t siz;
|
48
|
+
{
|
49
|
+
register char *d = dst;
|
50
|
+
register const char *s = src;
|
51
|
+
register size_t n = siz;
|
52
|
+
size_t dlen;
|
53
|
+
|
54
|
+
/* Find the end of dst and adjust bytes left but don't go past end */
|
55
|
+
while (n-- != 0 && *d != '\0')
|
56
|
+
d++;
|
57
|
+
dlen = d - dst;
|
58
|
+
n = siz - dlen;
|
59
|
+
|
60
|
+
if (n == 0)
|
61
|
+
return(dlen + strlen(s));
|
62
|
+
while (*s != '\0') {
|
63
|
+
if (n != 1) {
|
64
|
+
*d++ = *s;
|
65
|
+
n--;
|
66
|
+
}
|
67
|
+
s++;
|
68
|
+
}
|
69
|
+
*d = '\0';
|
70
|
+
|
71
|
+
return(dlen + (s - src)); /* count does not include NUL */
|
72
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1998 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
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
31
|
+
static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
|
32
|
+
#endif /* LIBC_SCCS and not lint */
|
33
|
+
|
34
|
+
#include <sys/types.h>
|
35
|
+
#include <string.h>
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Copy src to string dst of size siz. At most siz-1 characters
|
39
|
+
* will be copied. Always NUL terminates (unless siz == 0).
|
40
|
+
* Returns strlen(src); if retval >= siz, truncation occurred.
|
41
|
+
*/
|
42
|
+
size_t strlcpy(dst, src, siz)
|
43
|
+
char *dst;
|
44
|
+
const char *src;
|
45
|
+
size_t siz;
|
46
|
+
{
|
47
|
+
register char *d = dst;
|
48
|
+
register const char *s = src;
|
49
|
+
register size_t n = siz;
|
50
|
+
|
51
|
+
/* Copy as many bytes as will fit */
|
52
|
+
if (n != 0 && --n != 0) {
|
53
|
+
do {
|
54
|
+
if ((*d++ = *s++) == 0)
|
55
|
+
break;
|
56
|
+
} while (--n != 0);
|
57
|
+
}
|
58
|
+
|
59
|
+
/* Not enough room in dst, add NUL and traverse rest of src */
|
60
|
+
if (n == 0) {
|
61
|
+
if (siz != 0)
|
62
|
+
*d = '\0'; /* NUL-terminate dst */
|
63
|
+
while (*s++)
|
64
|
+
;
|
65
|
+
}
|
66
|
+
|
67
|
+
return(s - src - 1); /* count does not include NUL */
|
68
|
+
}
|
@@ -0,0 +1,199 @@
|
|
1
|
+
/*-
|
2
|
+
* Copyright (c) 1990 The Regents of the University of California.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. All advertising materials mentioning features or use of this software
|
14
|
+
* must display the following acknowledgement:
|
15
|
+
* This product includes software developed by the University of
|
16
|
+
* California, Berkeley and its contributors.
|
17
|
+
* 4. Neither the name of the University nor the names of its contributors
|
18
|
+
* may be used to endorse or promote products derived from this software
|
19
|
+
* without specific prior written permission.
|
20
|
+
*
|
21
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
22
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
25
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
27
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
28
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
29
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
30
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
31
|
+
* SUCH DAMAGE.
|
32
|
+
*/
|
33
|
+
|
34
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
35
|
+
static char *rcsid = "$OpenBSD: strmode.c,v 1.3 1997/06/13 13:57:20 deraadt Exp $";
|
36
|
+
#endif /* LIBC_SCCS and not lint */
|
37
|
+
|
38
|
+
#include <sys/types.h>
|
39
|
+
#include <sys/stat.h>
|
40
|
+
#include <string.h>
|
41
|
+
|
42
|
+
// modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
43
|
+
#ifdef _WIN32
|
44
|
+
#include "win32/types.h"
|
45
|
+
#endif
|
46
|
+
|
47
|
+
void
|
48
|
+
strmode(mode, p)
|
49
|
+
register mode_t mode;
|
50
|
+
register char *p;
|
51
|
+
{
|
52
|
+
/* print type */
|
53
|
+
switch (mode & S_IFMT) {
|
54
|
+
case S_IFDIR: /* directory */
|
55
|
+
*p++ = 'd';
|
56
|
+
break;
|
57
|
+
case S_IFCHR: /* character special */
|
58
|
+
*p++ = 'c';
|
59
|
+
break;
|
60
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
61
|
+
case S_IFBLK: /* block special */
|
62
|
+
*p++ = 'b';
|
63
|
+
break;
|
64
|
+
#endif
|
65
|
+
case S_IFREG: /* regular */
|
66
|
+
*p++ = '-';
|
67
|
+
break;
|
68
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
69
|
+
case S_IFLNK: /* symbolic link */
|
70
|
+
*p++ = 'l';
|
71
|
+
break;
|
72
|
+
#endif
|
73
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
74
|
+
case S_IFSOCK: /* socket */
|
75
|
+
*p++ = 's';
|
76
|
+
break;
|
77
|
+
#endif
|
78
|
+
#ifdef S_IFIFO
|
79
|
+
case S_IFIFO: /* fifo */
|
80
|
+
*p++ = 'p';
|
81
|
+
break;
|
82
|
+
#endif
|
83
|
+
#ifdef S_IFWHT
|
84
|
+
case S_IFWHT: /* whiteout */
|
85
|
+
*p++ = 'w';
|
86
|
+
break;
|
87
|
+
#endif
|
88
|
+
default: /* unknown */
|
89
|
+
*p++ = '?';
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
/* usr */
|
93
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
94
|
+
if (mode & S_IRUSR)
|
95
|
+
*p++ = 'r';
|
96
|
+
else
|
97
|
+
*p++ = '-';
|
98
|
+
#else
|
99
|
+
*p++ = '-';
|
100
|
+
#endif
|
101
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
102
|
+
if (mode & S_IWUSR)
|
103
|
+
*p++ = 'w';
|
104
|
+
else
|
105
|
+
*p++ = '-';
|
106
|
+
#else
|
107
|
+
*p++ = '-';
|
108
|
+
#endif
|
109
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
110
|
+
switch (mode & (S_IXUSR | S_ISUID)) {
|
111
|
+
case 0:
|
112
|
+
*p++ = '-';
|
113
|
+
break;
|
114
|
+
case S_IXUSR:
|
115
|
+
*p++ = 'x';
|
116
|
+
break;
|
117
|
+
case S_ISUID:
|
118
|
+
*p++ = 'S';
|
119
|
+
break;
|
120
|
+
case S_IXUSR | S_ISUID:
|
121
|
+
*p++ = 's';
|
122
|
+
break;
|
123
|
+
}
|
124
|
+
#else
|
125
|
+
*p++ = '-';
|
126
|
+
#endif
|
127
|
+
/* group */
|
128
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
129
|
+
if (mode & S_IRGRP)
|
130
|
+
*p++ = 'r';
|
131
|
+
else
|
132
|
+
*p++ = '-';
|
133
|
+
#else
|
134
|
+
*p++ = '-';
|
135
|
+
#endif
|
136
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
137
|
+
if (mode & S_IWGRP)
|
138
|
+
*p++ = 'w';
|
139
|
+
else
|
140
|
+
*p++ = '-';
|
141
|
+
#else
|
142
|
+
*p++ = '-';
|
143
|
+
#endif
|
144
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
145
|
+
switch (mode & (S_IXGRP | S_ISGID)) {
|
146
|
+
case 0:
|
147
|
+
*p++ = '-';
|
148
|
+
break;
|
149
|
+
case S_IXGRP:
|
150
|
+
*p++ = 'x';
|
151
|
+
break;
|
152
|
+
case S_ISGID:
|
153
|
+
*p++ = 'S';
|
154
|
+
break;
|
155
|
+
case S_IXGRP | S_ISGID:
|
156
|
+
*p++ = 's';
|
157
|
+
break;
|
158
|
+
}
|
159
|
+
#else
|
160
|
+
*p++ = '-';
|
161
|
+
#endif
|
162
|
+
/* other */
|
163
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
164
|
+
if (mode & S_IROTH)
|
165
|
+
*p++ = 'r';
|
166
|
+
else
|
167
|
+
*p++ = '-';
|
168
|
+
#else
|
169
|
+
*p++ = '-';
|
170
|
+
#endif
|
171
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
172
|
+
if (mode & S_IWOTH)
|
173
|
+
*p++ = 'w';
|
174
|
+
else
|
175
|
+
*p++ = '-';
|
176
|
+
#else
|
177
|
+
*p++ = '-';
|
178
|
+
#endif
|
179
|
+
#ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
180
|
+
switch (mode & (S_IXOTH | S_ISVTX)) {
|
181
|
+
case 0:
|
182
|
+
*p++ = '-';
|
183
|
+
break;
|
184
|
+
case S_IXOTH:
|
185
|
+
*p++ = 'x';
|
186
|
+
break;
|
187
|
+
case S_ISVTX:
|
188
|
+
*p++ = 'T';
|
189
|
+
break;
|
190
|
+
case S_IXOTH | S_ISVTX:
|
191
|
+
*p++ = 't';
|
192
|
+
break;
|
193
|
+
}
|
194
|
+
#else
|
195
|
+
*p++ = '-';
|
196
|
+
#endif
|
197
|
+
*p++ = ' '; /* will be a '+' if ACL's implemented */
|
198
|
+
*p = '\0';
|
199
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/*
|
2
|
+
** Copyright 1998-2002 University of Illinois Board of Trustees
|
3
|
+
** Copyright 1998-2002 Mark D. Roth
|
4
|
+
** All rights reserved.
|
5
|
+
**
|
6
|
+
** strrstr.c - strrstr() 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 <stdio.h>
|
14
|
+
#include <sys/types.h>
|
15
|
+
|
16
|
+
#include <string.h>
|
17
|
+
|
18
|
+
|
19
|
+
/*
|
20
|
+
** find the last occurrance of find in string
|
21
|
+
*/
|
22
|
+
char *
|
23
|
+
strrstr(char *string, char *find)
|
24
|
+
{
|
25
|
+
size_t stringlen, findlen;
|
26
|
+
char *cp;
|
27
|
+
|
28
|
+
findlen = strlen(find);
|
29
|
+
stringlen = strlen(string);
|
30
|
+
if (findlen > stringlen)
|
31
|
+
return NULL;
|
32
|
+
|
33
|
+
for (cp = string + stringlen - findlen; cp >= string; cp--)
|
34
|
+
if (strncmp(cp, find, findlen) == 0)
|
35
|
+
return cp;
|
36
|
+
|
37
|
+
return NULL;
|
38
|
+
}
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
/* $OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $ */
|
2
|
+
|
3
|
+
/*-
|
4
|
+
* Copyright (c) 1990, 1993
|
5
|
+
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
|
16
|
+
* must display the following acknowledgement:
|
17
|
+
* This product includes software developed by the University of
|
18
|
+
* California, Berkeley and its contributors.
|
19
|
+
* 4. Neither the name of the University nor the names of its contributors
|
20
|
+
* may be used to endorse or promote products derived from this software
|
21
|
+
* without specific prior written permission.
|
22
|
+
*
|
23
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
24
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
27
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
29
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
31
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
32
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
33
|
+
* SUCH DAMAGE.
|
34
|
+
*/
|
35
|
+
|
36
|
+
#include <string.h>
|
37
|
+
#include <stdio.h>
|
38
|
+
|
39
|
+
#if defined(LIBC_SCCS) && !defined(lint)
|
40
|
+
#if 0
|
41
|
+
static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
|
42
|
+
#else
|
43
|
+
static char *rcsid = "$OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $";
|
44
|
+
#endif
|
45
|
+
#endif /* LIBC_SCCS and not lint */
|
46
|
+
|
47
|
+
#ifndef HAVE_STRSEP
|
48
|
+
/*
|
49
|
+
* Get next token from string *stringp, where tokens are possibly-empty
|
50
|
+
* strings separated by characters from delim.
|
51
|
+
*
|
52
|
+
* Writes NULs into the string at *stringp to end tokens.
|
53
|
+
* delim need not remain constant from call to call.
|
54
|
+
* On return, *stringp points past the last NUL written (if there might
|
55
|
+
* be further tokens), or is NULL (if there are definitely no more tokens).
|
56
|
+
*
|
57
|
+
* If *stringp is NULL, strsep returns NULL.
|
58
|
+
*/
|
59
|
+
char *
|
60
|
+
strsep(stringp, delim)
|
61
|
+
register char **stringp;
|
62
|
+
register const char *delim;
|
63
|
+
{
|
64
|
+
register char *s;
|
65
|
+
register const char *spanp;
|
66
|
+
register int c, sc;
|
67
|
+
char *tok;
|
68
|
+
|
69
|
+
if ((s = *stringp) == NULL)
|
70
|
+
return (NULL);
|
71
|
+
for (tok = s;;) {
|
72
|
+
c = *s++;
|
73
|
+
spanp = delim;
|
74
|
+
do {
|
75
|
+
if ((sc = *spanp++) == c) {
|
76
|
+
if (c == 0)
|
77
|
+
s = NULL;
|
78
|
+
else
|
79
|
+
s[-1] = 0;
|
80
|
+
*stringp = s;
|
81
|
+
return (tok);
|
82
|
+
}
|
83
|
+
} while (sc != 0);
|
84
|
+
}
|
85
|
+
/* NOTREACHED */
|
86
|
+
}
|
87
|
+
#endif /* ! HAVE_STRSEP */
|