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,344 @@
1
+ /* listhash/libtar_hash.c. Generated from hash.c.in by configure. */
2
+
3
+ /*
4
+ ** Copyright 1998-2002 University of Illinois Board of Trustees
5
+ ** Copyright 1998-2002 Mark D. Roth
6
+ ** All rights reserved.
7
+ **
8
+ ** libtar_hash.c - hash table routines
9
+ **
10
+ ** Mark D. Roth <roth@uiuc.edu>
11
+ ** Campus Information Technologies and Educational Services
12
+ ** University of Illinois at Urbana-Champaign
13
+ */
14
+
15
+ #include <config.h>
16
+ #include <compat.h>
17
+
18
+ #include <libtar_listhash.h>
19
+
20
+ #include <stdio.h>
21
+ #include <errno.h>
22
+
23
+ #ifdef STDC_HEADERS
24
+ # include <stdlib.h>
25
+ #endif
26
+
27
+
28
+ /*
29
+ ** libtar_hashptr_reset() - reset a hash pointer
30
+ */
31
+ void
32
+ libtar_hashptr_reset(libtar_hashptr_t *hp)
33
+ {
34
+ libtar_listptr_reset(&(hp->node));
35
+ hp->bucket = -1;
36
+ }
37
+
38
+
39
+ /*
40
+ ** libtar_hashptr_data() - retrieve the data being pointed to
41
+ */
42
+ void *
43
+ libtar_hashptr_data(libtar_hashptr_t *hp)
44
+ {
45
+ return libtar_listptr_data(&(hp->node));
46
+ }
47
+
48
+
49
+ /*
50
+ ** libtar_str_hashfunc() - default hash function, optimized for
51
+ ** 7-bit strings
52
+ */
53
+ unsigned int
54
+ libtar_str_hashfunc(char *key, unsigned int num_buckets)
55
+ {
56
+ #if 0
57
+ register unsigned result = 0;
58
+ register int i;
59
+
60
+ if (key == NULL)
61
+ return 0;
62
+
63
+ for (i = 0; *key != '\0' && i < 32; i++)
64
+ result = result * 33U + *key++;
65
+
66
+ return (result % num_buckets);
67
+ #else
68
+ if (key == NULL)
69
+ return 0;
70
+
71
+ return (key[0] % num_buckets);
72
+ #endif
73
+ }
74
+
75
+
76
+ /*
77
+ ** libtar_hash_nents() - return number of elements from hash
78
+ */
79
+ unsigned int
80
+ libtar_hash_nents(libtar_hash_t *h)
81
+ {
82
+ return h->nents;
83
+ }
84
+
85
+
86
+ /*
87
+ ** libtar_hash_new() - create a new hash
88
+ */
89
+ libtar_hash_t *
90
+ libtar_hash_new(int num, libtar_hashfunc_t hashfunc)
91
+ {
92
+ libtar_hash_t *hash;
93
+
94
+ hash = (libtar_hash_t *)calloc(1, sizeof(libtar_hash_t));
95
+ if (hash == NULL)
96
+ return NULL;
97
+ hash->numbuckets = num;
98
+ if (hashfunc != NULL)
99
+ hash->hashfunc = hashfunc;
100
+ else
101
+ hash->hashfunc = (libtar_hashfunc_t)libtar_str_hashfunc;
102
+
103
+ hash->table = (libtar_list_t **)calloc(num, sizeof(libtar_list_t *));
104
+ if (hash->table == NULL)
105
+ {
106
+ free(hash);
107
+ return NULL;
108
+ }
109
+
110
+ return hash;
111
+ }
112
+
113
+
114
+ /*
115
+ ** libtar_hash_next() - get next element in hash
116
+ ** returns:
117
+ ** 1 data found
118
+ ** 0 end of list
119
+ */
120
+ int
121
+ libtar_hash_next(libtar_hash_t *h,
122
+ libtar_hashptr_t *hp)
123
+ {
124
+ #ifdef DS_DEBUG
125
+ printf("==> libtar_hash_next(h=0x%lx, hp={%d,0x%lx})\n",
126
+ h, hp->bucket, hp->node);
127
+ #endif
128
+
129
+ if (hp->bucket >= 0 && hp->node != NULL &&
130
+ libtar_list_next(h->table[hp->bucket], &(hp->node)) != 0)
131
+ {
132
+ #ifdef DS_DEBUG
133
+ printf(" libtar_hash_next(): found additional "
134
+ "data in current bucket (%d), returing 1\n",
135
+ hp->bucket);
136
+ #endif
137
+ return 1;
138
+ }
139
+
140
+ #ifdef DS_DEBUG
141
+ printf(" libtar_hash_next(): done with bucket %d\n",
142
+ hp->bucket);
143
+ #endif
144
+
145
+ for (hp->bucket++; hp->bucket < h->numbuckets; hp->bucket++)
146
+ {
147
+ #ifdef DS_DEBUG
148
+ printf(" libtar_hash_next(): "
149
+ "checking bucket %d\n", hp->bucket);
150
+ #endif
151
+ hp->node = NULL;
152
+ if (h->table[hp->bucket] != NULL &&
153
+ libtar_list_next(h->table[hp->bucket],
154
+ &(hp->node)) != 0)
155
+ {
156
+ #ifdef DS_DEBUG
157
+ printf(" libtar_hash_next(): "
158
+ "found data in bucket %d, returing 1\n",
159
+ hp->bucket);
160
+ #endif
161
+ return 1;
162
+ }
163
+ }
164
+
165
+ if (hp->bucket == h->numbuckets)
166
+ {
167
+ #ifdef DS_DEBUG
168
+ printf(" libtar_hash_next(): hash pointer "
169
+ "wrapped to 0\n");
170
+ #endif
171
+ hp->bucket = -1;
172
+ hp->node = NULL;
173
+ }
174
+
175
+ #ifdef DS_DEBUG
176
+ printf("<== libtar_hash_next(): no more data, "
177
+ "returning 0\n");
178
+ #endif
179
+ return 0;
180
+ }
181
+
182
+
183
+ /*
184
+ ** libtar_hash_del() - delete an entry from the hash
185
+ ** returns:
186
+ ** 0 success
187
+ ** -1 (and sets errno) failure
188
+ */
189
+ int
190
+ libtar_hash_del(libtar_hash_t *h,
191
+ libtar_hashptr_t *hp)
192
+ {
193
+ if (hp->bucket < 0
194
+ || hp->bucket >= h->numbuckets
195
+ || h->table[hp->bucket] == NULL
196
+ || hp->node == NULL)
197
+ {
198
+ errno = EINVAL;
199
+ return -1;
200
+ }
201
+
202
+ libtar_list_del(h->table[hp->bucket], &(hp->node));
203
+ h->nents--;
204
+ return 0;
205
+ }
206
+
207
+
208
+ /*
209
+ ** libtar_hash_empty() - empty the hash
210
+ */
211
+ void
212
+ libtar_hash_empty(libtar_hash_t *h, libtar_freefunc_t freefunc)
213
+ {
214
+ int i;
215
+
216
+ for (i = 0; i < h->numbuckets; i++)
217
+ if (h->table[i] != NULL)
218
+ libtar_list_empty(h->table[i], freefunc);
219
+
220
+ h->nents = 0;
221
+ }
222
+
223
+
224
+ /*
225
+ ** libtar_hash_free() - delete all of the nodes in the hash
226
+ */
227
+ void
228
+ libtar_hash_free(libtar_hash_t *h, libtar_freefunc_t freefunc)
229
+ {
230
+ int i;
231
+
232
+ for (i = 0; i < h->numbuckets; i++)
233
+ if (h->table[i] != NULL)
234
+ libtar_list_free(h->table[i], freefunc);
235
+
236
+ free(h->table);
237
+ free(h);
238
+ }
239
+
240
+
241
+ /*
242
+ ** libtar_hash_search() - iterative search for an element in a hash
243
+ ** returns:
244
+ ** 1 match found
245
+ ** 0 no match
246
+ */
247
+ int
248
+ libtar_hash_search(libtar_hash_t *h,
249
+ libtar_hashptr_t *hp, void *data,
250
+ libtar_matchfunc_t matchfunc)
251
+ {
252
+ while (libtar_hash_next(h, hp) != 0)
253
+ if ((*matchfunc)(data, libtar_listptr_data(&(hp->node))) != 0)
254
+ return 1;
255
+
256
+ return 0;
257
+ }
258
+
259
+
260
+ /*
261
+ ** libtar_hash_getkey() - hash-based search for an element in a hash
262
+ ** returns:
263
+ ** 1 match found
264
+ ** 0 no match
265
+ */
266
+ int
267
+ libtar_hash_getkey(libtar_hash_t *h,
268
+ libtar_hashptr_t *hp, void *key,
269
+ libtar_matchfunc_t matchfunc)
270
+ {
271
+ #ifdef DS_DEBUG
272
+ printf("==> libtar_hash_getkey(h=0x%lx, hp={%d,0x%lx}, "
273
+ "key=0x%lx, matchfunc=0x%lx)\n",
274
+ h, hp->bucket, hp->node, key, matchfunc);
275
+ #endif
276
+
277
+ if (hp->bucket == -1)
278
+ {
279
+ hp->bucket = (*(h->hashfunc))(key, h->numbuckets);
280
+ #ifdef DS_DEBUG
281
+ printf(" libtar_hash_getkey(): hp->bucket "
282
+ "set to %d\n", hp->bucket);
283
+ #endif
284
+ }
285
+
286
+ if (h->table[hp->bucket] == NULL)
287
+ {
288
+ #ifdef DS_DEBUG
289
+ printf(" libtar_hash_getkey(): no list "
290
+ "for bucket %d, returning 0\n", hp->bucket);
291
+ #endif
292
+ hp->bucket = -1;
293
+ return 0;
294
+ }
295
+
296
+ #ifdef DS_DEBUG
297
+ printf("<== libtar_hash_getkey(): "
298
+ "returning libtar_list_search()\n");
299
+ #endif
300
+ return libtar_list_search(h->table[hp->bucket], &(hp->node),
301
+ key, matchfunc);
302
+ }
303
+
304
+
305
+ /*
306
+ ** libtar_hash_add() - add an element to the hash
307
+ ** returns:
308
+ ** 0 success
309
+ ** -1 (and sets errno) failure
310
+ */
311
+ int
312
+ libtar_hash_add(libtar_hash_t *h, void *data)
313
+ {
314
+ int bucket, i;
315
+
316
+ #ifdef DS_DEBUG
317
+ printf("==> libtar_hash_add(h=0x%lx, data=0x%lx)\n",
318
+ h, data);
319
+ #endif
320
+
321
+ bucket = (*(h->hashfunc))(data, h->numbuckets);
322
+ #ifdef DS_DEBUG
323
+ printf(" libtar_hash_add(): inserting in bucket %d\n",
324
+ bucket);
325
+ #endif
326
+ if (h->table[bucket] == NULL)
327
+ {
328
+ #ifdef DS_DEBUG
329
+ printf(" libtar_hash_add(): creating new list\n");
330
+ #endif
331
+ h->table[bucket] = libtar_list_new(LIST_QUEUE, NULL);
332
+ }
333
+
334
+ #ifdef DS_DEBUG
335
+ printf("<== libtar_hash_add(): "
336
+ "returning libtar_list_add()\n");
337
+ #endif
338
+ i = libtar_list_add(h->table[bucket], data);
339
+ if (i == 0)
340
+ h->nents++;
341
+ return i;
342
+ }
343
+
344
+