tarruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/README.txt +99 -0
  2. data/ext/extconf.rb +19 -0
  3. data/ext/libtar/COPYRIGHT +35 -0
  4. data/ext/libtar/ChangeLog +243 -0
  5. data/ext/libtar/ChangeLog-1.0.x +141 -0
  6. data/ext/libtar/INSTALL +183 -0
  7. data/ext/libtar/Makefile.in +51 -0
  8. data/ext/libtar/README +121 -0
  9. data/ext/libtar/TODO +10 -0
  10. data/ext/libtar/autoconf/ac_path_generic.m4 +136 -0
  11. data/ext/libtar/autoconf/aclocal.m4 +199 -0
  12. data/ext/libtar/autoconf/encap.m4 +133 -0
  13. data/ext/libtar/autoconf/install-sh +251 -0
  14. data/ext/libtar/autom4te.cache/output.0 +8102 -0
  15. data/ext/libtar/autom4te.cache/requests +112 -0
  16. data/ext/libtar/autom4te.cache/traces.0 +382 -0
  17. data/ext/libtar/compat/ChangeLog +31 -0
  18. data/ext/libtar/compat/README +12 -0
  19. data/ext/libtar/compat/TODO +4 -0
  20. data/ext/libtar/compat/basename.c +91 -0
  21. data/ext/libtar/compat/compat.h +260 -0
  22. data/ext/libtar/compat/dirname.c +96 -0
  23. data/ext/libtar/compat/fnmatch.c +237 -0
  24. data/ext/libtar/compat/gethostbyname_r.c +41 -0
  25. data/ext/libtar/compat/gethostname.c +36 -0
  26. data/ext/libtar/compat/getservbyname_r.c +41 -0
  27. data/ext/libtar/compat/glob.c +898 -0
  28. data/ext/libtar/compat/inet_aton.c +27 -0
  29. data/ext/libtar/compat/module.ac +591 -0
  30. data/ext/libtar/compat/snprintf.c +788 -0
  31. data/ext/libtar/compat/strdup.c +62 -0
  32. data/ext/libtar/compat/strlcat.c +72 -0
  33. data/ext/libtar/compat/strlcpy.c +68 -0
  34. data/ext/libtar/compat/strmode.c +199 -0
  35. data/ext/libtar/compat/strrstr.c +40 -0
  36. data/ext/libtar/compat/strsep.c +87 -0
  37. data/ext/libtar/config.h.in +187 -0
  38. data/ext/libtar/configure +8102 -0
  39. data/ext/libtar/configure.ac +114 -0
  40. data/ext/libtar/doc/Makefile.in +152 -0
  41. data/ext/libtar/doc/tar_append_file.3 +50 -0
  42. data/ext/libtar/doc/tar_block_read.3 +24 -0
  43. data/ext/libtar/doc/tar_extract_all.3 +43 -0
  44. data/ext/libtar/doc/tar_extract_file.3 +84 -0
  45. data/ext/libtar/doc/tar_open.3 +97 -0
  46. data/ext/libtar/doc/th_get_pathname.3 +63 -0
  47. data/ext/libtar/doc/th_print_long_ls.3 +22 -0
  48. data/ext/libtar/doc/th_read.3 +34 -0
  49. data/ext/libtar/doc/th_set_from_stat.3 +45 -0
  50. data/ext/libtar/lib/Makefile.in +92 -0
  51. data/ext/libtar/lib/append.c +272 -0
  52. data/ext/libtar/lib/block.c +384 -0
  53. data/ext/libtar/lib/decode.c +130 -0
  54. data/ext/libtar/lib/encode.c +237 -0
  55. data/ext/libtar/lib/extract.c +656 -0
  56. data/ext/libtar/lib/handle.c +150 -0
  57. data/ext/libtar/lib/internal.h +46 -0
  58. data/ext/libtar/lib/libtar.h +311 -0
  59. data/ext/libtar/lib/output.c +146 -0
  60. data/ext/libtar/lib/util.c +153 -0
  61. data/ext/libtar/lib/wrapper.c +175 -0
  62. data/ext/libtar/libtar/Makefile.in +73 -0
  63. data/ext/libtar/libtar/libtar.c +363 -0
  64. data/ext/libtar/listhash/ChangeLog +15 -0
  65. data/ext/libtar/listhash/TODO +21 -0
  66. data/ext/libtar/listhash/hash.c.in +344 -0
  67. data/ext/libtar/listhash/hash_new.3.in +74 -0
  68. data/ext/libtar/listhash/list.c.in +458 -0
  69. data/ext/libtar/listhash/list_new.3.in +86 -0
  70. data/ext/libtar/listhash/listhash.h.in +196 -0
  71. data/ext/libtar/listhash/module.ac +21 -0
  72. data/ext/libtar/win32/config.h +190 -0
  73. data/ext/libtar/win32/dirent.c +115 -0
  74. data/ext/libtar/win32/dirent.h +24 -0
  75. data/ext/libtar/win32/grp.h +4 -0
  76. data/ext/libtar/win32/listhash/libtar_hash.c +344 -0
  77. data/ext/libtar/win32/listhash/libtar_list.c +458 -0
  78. data/ext/libtar/win32/listhash/libtar_listhash.h +196 -0
  79. data/ext/libtar/win32/pwd.h +4 -0
  80. data/ext/libtar/win32/sys/param.h +8 -0
  81. data/ext/libtar/win32/tar.h +35 -0
  82. data/ext/libtar/win32/utime.h +6 -0
  83. data/ext/libtar/win32/win32/types.h +10 -0
  84. data/ext/tarruby.c +648 -0
  85. metadata +150 -0
@@ -0,0 +1,153 @@
1
+ /*
2
+ ** Copyright 1998-2003 University of Illinois Board of Trustees
3
+ ** Copyright 1998-2003 Mark D. Roth
4
+ ** All rights reserved.
5
+ **
6
+ ** util.c - miscellaneous utility code for libtar
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 <internal.h>
14
+
15
+ #include <stdio.h>
16
+ #include <sys/param.h>
17
+ #include <errno.h>
18
+
19
+ #ifdef STDC_HEADERS
20
+ # include <string.h>
21
+ #endif
22
+
23
+
24
+ /* hashing function for pathnames */
25
+ int
26
+ path_hashfunc(char *key, int numbuckets)
27
+ {
28
+ char buf[MAXPATHLEN];
29
+ char *p;
30
+
31
+ strcpy(buf, key);
32
+ p = basename(buf);
33
+
34
+ return (((unsigned int)p[0]) % numbuckets);
35
+ }
36
+
37
+
38
+ /* matching function for dev_t's */
39
+ int
40
+ dev_match(dev_t *dev1, dev_t *dev2)
41
+ {
42
+ return !memcmp(dev1, dev2, sizeof(dev_t));
43
+ }
44
+
45
+
46
+ /* matching function for ino_t's */
47
+ int
48
+ ino_match(ino_t *ino1, ino_t *ino2)
49
+ {
50
+ return !memcmp(ino1, ino2, sizeof(ino_t));
51
+ }
52
+
53
+
54
+ /* hashing function for dev_t's */
55
+ int
56
+ dev_hash(dev_t *dev)
57
+ {
58
+ return *dev % 16;
59
+ }
60
+
61
+
62
+ /* hashing function for ino_t's */
63
+ int
64
+ ino_hash(ino_t *inode)
65
+ {
66
+ return *inode % 256;
67
+ }
68
+
69
+
70
+ /*
71
+ ** mkdirhier() - create all directories in a given path
72
+ ** returns:
73
+ ** 0 success
74
+ ** 1 all directories already exist
75
+ ** -1 (and sets errno) error
76
+ */
77
+ int
78
+ mkdirhier(char *path)
79
+ {
80
+ char src[MAXPATHLEN], dst[MAXPATHLEN] = "";
81
+ char *dirp, *nextp = src;
82
+ int retval = 1;
83
+
84
+ if (strlcpy(src, path, sizeof(src)) > sizeof(src))
85
+ {
86
+ errno = ENAMETOOLONG;
87
+ return -1;
88
+ }
89
+
90
+ if (path[0] == '/')
91
+ strcpy(dst, "/");
92
+
93
+ while ((dirp = strsep(&nextp, "/")) != NULL)
94
+ {
95
+ if (*dirp == '\0')
96
+ continue;
97
+
98
+ if (dst[0] != '\0')
99
+ strcat(dst, "/");
100
+ strcat(dst, dirp);
101
+
102
+ if (mkdir(dst, 0777) == -1)
103
+ {
104
+ if (errno != EEXIST)
105
+ return -1;
106
+ }
107
+ else
108
+ retval = 0;
109
+ }
110
+
111
+ return retval;
112
+ }
113
+
114
+
115
+ /* calculate header checksum */
116
+ int
117
+ th_crc_calc(TAR *t)
118
+ {
119
+ int i, sum = 0;
120
+
121
+ for (i = 0; i < T_BLOCKSIZE; i++)
122
+ sum += ((unsigned char *)(&(t->th_buf)))[i];
123
+ for (i = 0; i < 8; i++)
124
+ sum += (' ' - (unsigned char)t->th_buf.chksum[i]);
125
+
126
+ return sum;
127
+ }
128
+
129
+
130
+ /* string-octal to integer conversion */
131
+ int
132
+ oct_to_int(char *oct)
133
+ {
134
+ int i;
135
+
136
+ sscanf(oct, "%o", &i);
137
+
138
+ return i;
139
+ }
140
+
141
+
142
+ /* integer to string-octal conversion, no NULL */
143
+ void
144
+ int_to_oct_nonull(int num, char *oct, size_t octlen)
145
+ {
146
+ // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
147
+ //snprintf(oct, octlen, "%*lo", octlen - 1, (unsigned long)num);
148
+ //oct[octlen - 1] = ' ';
149
+ snprintf(oct, octlen, "%0*lo", octlen - 1, (unsigned long)num);
150
+ oct[octlen - 1] = 0;
151
+ }
152
+
153
+
@@ -0,0 +1,175 @@
1
+ /*
2
+ ** Copyright 1998-2003 University of Illinois Board of Trustees
3
+ ** Copyright 1998-2003 Mark D. Roth
4
+ ** All rights reserved.
5
+ **
6
+ ** wrapper.c - libtar high-level wrapper code
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 <internal.h>
14
+
15
+ #include <stdio.h>
16
+ #include <sys/param.h>
17
+ #include <dirent.h>
18
+ #include <errno.h>
19
+
20
+ #ifdef STDC_HEADERS
21
+ # include <string.h>
22
+ #endif
23
+
24
+
25
+ int
26
+ tar_extract_glob(TAR *t, char *globname, char *prefix)
27
+ {
28
+ char *filename;
29
+ char buf[MAXPATHLEN];
30
+ int i;
31
+
32
+ while ((i = th_read(t)) == 0)
33
+ {
34
+ filename = th_get_pathname(t);
35
+ if (fnmatch(globname, filename, FNM_PATHNAME | FNM_PERIOD))
36
+ {
37
+ if (TH_ISREG(t) && tar_skip_regfile(t)){
38
+ free(filename);
39
+ return -1;
40
+ }
41
+ continue;
42
+ }
43
+ if (t->options & TAR_VERBOSE)
44
+ th_print_long_ls(t);
45
+ if (prefix != NULL)
46
+ snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
47
+ else
48
+ strlcpy(buf, filename, sizeof(buf));
49
+ // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
50
+ //if (tar_extract_file(t, filename) != 0)
51
+ if (tar_extract_file(t, buf) != 0) {
52
+ free(filename);
53
+ return -1;
54
+ }
55
+ free(filename);
56
+ }
57
+
58
+ return (i == 1 ? 0 : -1);
59
+ }
60
+
61
+
62
+ int
63
+ tar_extract_all(TAR *t, char *prefix)
64
+ {
65
+ char *filename;
66
+ char buf[MAXPATHLEN];
67
+ int i;
68
+
69
+ #ifdef DEBUG
70
+ printf("==> tar_extract_all(TAR *t, \"%s\")\n",
71
+ (prefix ? prefix : "(null)"));
72
+ #endif
73
+
74
+ while ((i = th_read(t)) == 0)
75
+ {
76
+ #ifdef DEBUG
77
+ puts(" tar_extract_all(): calling th_get_pathname()");
78
+ #endif
79
+ filename = th_get_pathname(t);
80
+ if (t->options & TAR_VERBOSE)
81
+ th_print_long_ls(t);
82
+ if (prefix != NULL)
83
+ snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
84
+ else
85
+ strlcpy(buf, filename, sizeof(buf));
86
+ #ifdef DEBUG
87
+ printf(" tar_extract_all(): calling tar_extract_file(t, "
88
+ "\"%s\")\n", buf);
89
+ #endif
90
+ if (tar_extract_file(t, buf) != 0){
91
+ free(filename);
92
+ return -1;
93
+ }
94
+ free(filename);
95
+ }
96
+
97
+ return (i == 1 ? 0 : -1);
98
+ }
99
+
100
+
101
+ int
102
+ tar_append_tree(TAR *t, char *realdir, char *savedir)
103
+ {
104
+ char realpath[MAXPATHLEN];
105
+ char savepath[MAXPATHLEN];
106
+ struct dirent *dent;
107
+ DIR *dp;
108
+ struct stat s;
109
+ #ifdef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
110
+ int errorp = 0;
111
+ #endif
112
+
113
+ #ifdef DEBUG
114
+ printf("==> tar_append_tree(0x%lx, \"%s\", \"%s\")\n",
115
+ t, realdir, (savedir ? savedir : "[NULL]"));
116
+ #endif
117
+
118
+ if (tar_append_file(t, realdir, savedir) != 0)
119
+ return -1;
120
+
121
+ #ifdef DEBUG
122
+ puts(" tar_append_tree(): done with tar_append_file()...");
123
+ #endif
124
+
125
+ #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
126
+ dp = opendir(realdir);
127
+ #else
128
+ dp = opendir0(realdir, &errorp);
129
+ #endif
130
+ if (dp == NULL)
131
+ {
132
+ #ifndef _WIN32 // modified by SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
133
+ if (errno == ENOTDIR)
134
+ return 0;
135
+ #else
136
+ if (errorp == ENOTDIR) {
137
+ return 0;
138
+ }
139
+ #endif
140
+ return -1;
141
+ }
142
+ while ((dent = readdir(dp)) != NULL)
143
+ {
144
+ if (strcmp(dent->d_name, ".") == 0 ||
145
+ strcmp(dent->d_name, "..") == 0)
146
+ continue;
147
+
148
+ snprintf(realpath, MAXPATHLEN, "%s/%s", realdir,
149
+ dent->d_name);
150
+ if (savedir)
151
+ snprintf(savepath, MAXPATHLEN, "%s/%s", savedir,
152
+ dent->d_name);
153
+
154
+ if (lstat(realpath, &s) != 0)
155
+ return -1;
156
+
157
+ if (S_ISDIR(s.st_mode))
158
+ {
159
+ if (tar_append_tree(t, realpath,
160
+ (savedir ? savepath : NULL)) != 0)
161
+ return -1;
162
+ continue;
163
+ }
164
+
165
+ if (tar_append_file(t, realpath,
166
+ (savedir ? savepath : NULL)) != 0)
167
+ return -1;
168
+ }
169
+
170
+ closedir(dp);
171
+
172
+ return 0;
173
+ }
174
+
175
+
@@ -0,0 +1,73 @@
1
+ # @configure_input@
2
+
3
+ ### Path settings
4
+ srcdir = @srcdir@
5
+ top_srcdir = @top_srcdir@
6
+ prefix = @prefix@
7
+ exec_prefix = @exec_prefix@
8
+ bindir = @bindir@
9
+ libdir = @libdir@
10
+ includedir = @includedir@
11
+
12
+ PACKAGE_NAME = @PACKAGE_NAME@
13
+ PACKAGE_VERSION = @PACKAGE_VERSION@
14
+
15
+ @ENCAP_DEFS@
16
+
17
+ ### Installation programs and flags
18
+ INSTALL = @INSTALL@
19
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s
20
+ INSTALL_DATA = @INSTALL_DATA@
21
+ LN_S = @LN_S@
22
+ MKDIR = @MKDIR@
23
+
24
+ ### Compiler and link options
25
+ CC = @CC@
26
+ CPPFLAGS = -I.. \
27
+ -I../lib \
28
+ -I../listhash \
29
+ -I${top_srcdir}/lib \
30
+ -I${top_srcdir}/compat \
31
+ @CPPFLAGS@
32
+ CFLAGS = @CFLAGS@
33
+ LDFLAGS = @LDFLAGS@
34
+ LIBS = @LIBS@
35
+ LIBOBJS = @LIBOBJS@
36
+ RANLIB = @RANLIB@
37
+ @SET_MAKE@
38
+ VPATH = @srcdir@
39
+
40
+
41
+ ### Makefile rules - no user-servicable parts below
42
+
43
+ LIBTAR_OBJS = libtar.o
44
+ LIBTAR_HDRS = ../config.h \
45
+ ${top_srcdir}/compat/compat.h \
46
+ ${top_srcdir}/lib/libtar.h \
47
+ ../listhash/libtar_listhash.h
48
+ LIBTAR_LIBS = ../lib/libtar.a
49
+ ALL = libtar
50
+
51
+
52
+ all: ${ALL}
53
+
54
+ .PHONY: clean distclean install
55
+
56
+ libtar: ${LIBTAR_OBJS} ${LIBTAR_LIBS} ${LIBTAR_HDRS}
57
+ ${CC} ${CFLAGS} ${LDFLAGS} -o libtar libtar.o ${LIBTAR_LIBS} ${LIBS}
58
+
59
+ ${LIBTAR_OBJS}: ${LIBTAR_HDRS}
60
+
61
+ .c.o:
62
+ ${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
63
+
64
+ clean:
65
+ rm -f *~ *.o ${ALL} core
66
+
67
+ distclean: clean
68
+ rm -f Makefile
69
+
70
+ install: ${ALL}
71
+ ${MKDIR} ${DESTDIR}${bindir}
72
+ ${INSTALL_PROGRAM} libtar ${DESTDIR}${bindir}
73
+