libarchive-static 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/ext/Makefile +6 -0
  2. data/ext/extconf.rb +61 -0
  3. data/ext/libarchive-0.1.1/COPYING.libarchive +60 -0
  4. data/ext/libarchive-0.1.1/LICENSE.libbzip2 +42 -0
  5. data/ext/libarchive-0.1.1/README.txt +143 -0
  6. data/ext/libarchive-0.1.1/ext/Makefile.in +0 -0
  7. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.c +31 -0
  8. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.h +6 -0
  9. data/ext/libarchive-0.1.1/ext/archive_read_support_format.c +32 -0
  10. data/ext/libarchive-0.1.1/ext/archive_read_support_format.h +6 -0
  11. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.c +29 -0
  12. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.h +6 -0
  13. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.c +32 -0
  14. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.h +6 -0
  15. data/ext/libarchive-0.1.1/ext/config.h.in +22 -0
  16. data/ext/libarchive-0.1.1/ext/configure +3904 -0
  17. data/ext/libarchive-0.1.1/ext/configure.in +11 -0
  18. data/ext/libarchive-0.1.1/ext/depend +19 -0
  19. data/ext/libarchive-0.1.1/ext/extconf.rb +6 -0
  20. data/ext/libarchive-0.1.1/ext/install-sh +250 -0
  21. data/ext/libarchive-0.1.1/ext/libarchive.c +89 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_archive.c +84 -0
  23. data/ext/libarchive-0.1.1/ext/libarchive_entry.c +1015 -0
  24. data/ext/libarchive-0.1.1/ext/libarchive_internal.h +155 -0
  25. data/ext/libarchive-0.1.1/ext/libarchive_reader.c +328 -0
  26. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +52 -0
  27. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +246 -0
  28. data/ext/libarchive-0.1.1/libarchive.c +1762 -0
  29. data/ext/libarchive-2.8.4/Makefile.in +7076 -0
  30. data/ext/libarchive-2.8.4/build/autoconf/check_stdcall_func.m4 +51 -0
  31. data/ext/libarchive-2.8.4/build/autoconf/compile +143 -0
  32. data/ext/libarchive-2.8.4/build/autoconf/config.guess +1502 -0
  33. data/ext/libarchive-2.8.4/build/autoconf/config.sub +1708 -0
  34. data/ext/libarchive-2.8.4/build/autoconf/depcomp +630 -0
  35. data/ext/libarchive-2.8.4/build/autoconf/install-sh +291 -0
  36. data/ext/libarchive-2.8.4/build/autoconf/la_uid_t.m4 +20 -0
  37. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +8406 -0
  38. data/ext/libarchive-2.8.4/build/autoconf/missing +376 -0
  39. data/ext/libarchive-2.8.4/build/pkgconfig/libarchive.pc.in +10 -0
  40. data/ext/libarchive-2.8.4/config.h.in +772 -0
  41. data/ext/libarchive-2.8.4/configure +17916 -0
  42. data/ext/libarchive-2.8.4/libarchive/archive.h +741 -0
  43. data/ext/libarchive-2.8.4/libarchive/archive_check_magic.c +134 -0
  44. data/ext/libarchive-2.8.4/libarchive/archive_crc32.h +66 -0
  45. data/ext/libarchive-2.8.4/libarchive/archive_endian.h +162 -0
  46. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +2202 -0
  47. data/ext/libarchive-2.8.4/libarchive/archive_entry.h +524 -0
  48. data/ext/libarchive-2.8.4/libarchive/archive_entry_copy_bhfi.c +74 -0
  49. data/ext/libarchive-2.8.4/libarchive/archive_entry_copy_stat.c +77 -0
  50. data/ext/libarchive-2.8.4/libarchive/archive_entry_link_resolver.c +405 -0
  51. data/ext/libarchive-2.8.4/libarchive/archive_entry_private.h +184 -0
  52. data/ext/libarchive-2.8.4/libarchive/archive_entry_stat.c +118 -0
  53. data/ext/libarchive-2.8.4/libarchive/archive_entry_strmode.c +87 -0
  54. data/ext/libarchive-2.8.4/libarchive/archive_entry_xattr.c +158 -0
  55. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +281 -0
  56. data/ext/libarchive-2.8.4/libarchive/archive_platform.h +165 -0
  57. data/ext/libarchive-2.8.4/libarchive/archive_private.h +124 -0
  58. data/ext/libarchive-2.8.4/libarchive/archive_read.c +1249 -0
  59. data/ext/libarchive-2.8.4/libarchive/archive_read_data_into_fd.c +93 -0
  60. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +198 -0
  61. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +570 -0
  62. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_private.h +62 -0
  63. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_set_standard_lookup.c +303 -0
  64. data/ext/libarchive-2.8.4/libarchive/archive_read_extract.c +182 -0
  65. data/ext/libarchive-2.8.4/libarchive/archive_read_open_fd.c +190 -0
  66. data/ext/libarchive-2.8.4/libarchive/archive_read_open_file.c +165 -0
  67. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +272 -0
  68. data/ext/libarchive-2.8.4/libarchive/archive_read_open_memory.c +156 -0
  69. data/ext/libarchive-2.8.4/libarchive/archive_read_private.h +199 -0
  70. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_all.c +60 -0
  71. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_bzip2.c +353 -0
  72. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_compress.c +444 -0
  73. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_gzip.c +465 -0
  74. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_none.c +40 -0
  75. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_program.c +459 -0
  76. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_rpm.c +287 -0
  77. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_uu.c +627 -0
  78. data/ext/libarchive-2.8.4/libarchive/archive_read_support_compression_xz.c +708 -0
  79. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_all.c +43 -0
  80. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_ar.c +584 -0
  81. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +777 -0
  82. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_empty.c +93 -0
  83. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_iso9660.c +2830 -0
  84. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +1304 -0
  85. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_raw.c +185 -0
  86. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_tar.c +2418 -0
  87. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_xar.c +3151 -0
  88. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +903 -0
  89. data/ext/libarchive-2.8.4/libarchive/archive_string.c +453 -0
  90. data/ext/libarchive-2.8.4/libarchive/archive_string.h +148 -0
  91. data/ext/libarchive-2.8.4/libarchive/archive_string_sprintf.c +164 -0
  92. data/ext/libarchive-2.8.4/libarchive/archive_util.c +391 -0
  93. data/ext/libarchive-2.8.4/libarchive/archive_virtual.c +94 -0
  94. data/ext/libarchive-2.8.4/libarchive/archive_windows.c +1236 -0
  95. data/ext/libarchive-2.8.4/libarchive/archive_windows.h +347 -0
  96. data/ext/libarchive-2.8.4/libarchive/archive_write.c +466 -0
  97. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +2628 -0
  98. data/ext/libarchive-2.8.4/libarchive/archive_write_disk_private.h +38 -0
  99. data/ext/libarchive-2.8.4/libarchive/archive_write_disk_set_standard_lookup.c +262 -0
  100. data/ext/libarchive-2.8.4/libarchive/archive_write_open_fd.c +141 -0
  101. data/ext/libarchive-2.8.4/libarchive/archive_write_open_file.c +105 -0
  102. data/ext/libarchive-2.8.4/libarchive/archive_write_open_filename.c +162 -0
  103. data/ext/libarchive-2.8.4/libarchive/archive_write_open_memory.c +126 -0
  104. data/ext/libarchive-2.8.4/libarchive/archive_write_private.h +122 -0
  105. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +408 -0
  106. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_compress.c +492 -0
  107. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +477 -0
  108. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +257 -0
  109. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +347 -0
  110. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +438 -0
  111. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format.c +72 -0
  112. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_ar.c +550 -0
  113. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_by_name.c +76 -0
  114. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +344 -0
  115. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +295 -0
  116. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +1050 -0
  117. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_pax.c +1386 -0
  118. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_shar.c +626 -0
  119. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_ustar.c +587 -0
  120. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +667 -0
  121. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +154 -0
  122. data/ext/libarchive-2.8.4/libarchive/filter_fork.c +161 -0
  123. data/ext/libarchive-2.8.4/libarchive/filter_fork.h +41 -0
  124. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +113 -0
  125. data/ext/libarchive-static-makefile +80 -0
  126. data/ext/libarchive-static-wrapper-makefile +22 -0
  127. data/ext/zlib-1.2.5/Makefile.in +257 -0
  128. data/ext/zlib-1.2.5/adler32.c +169 -0
  129. data/ext/zlib-1.2.5/compress.c +80 -0
  130. data/ext/zlib-1.2.5/configure +596 -0
  131. data/ext/zlib-1.2.5/crc32.c +442 -0
  132. data/ext/zlib-1.2.5/crc32.h +441 -0
  133. data/ext/zlib-1.2.5/deflate.c +1834 -0
  134. data/ext/zlib-1.2.5/deflate.h +342 -0
  135. data/ext/zlib-1.2.5/example.c +565 -0
  136. data/ext/zlib-1.2.5/gzclose.c +25 -0
  137. data/ext/zlib-1.2.5/gzguts.h +132 -0
  138. data/ext/zlib-1.2.5/gzlib.c +537 -0
  139. data/ext/zlib-1.2.5/gzread.c +653 -0
  140. data/ext/zlib-1.2.5/gzwrite.c +531 -0
  141. data/ext/zlib-1.2.5/infback.c +632 -0
  142. data/ext/zlib-1.2.5/inffast.c +340 -0
  143. data/ext/zlib-1.2.5/inffast.h +11 -0
  144. data/ext/zlib-1.2.5/inffixed.h +94 -0
  145. data/ext/zlib-1.2.5/inflate.c +1480 -0
  146. data/ext/zlib-1.2.5/inflate.h +122 -0
  147. data/ext/zlib-1.2.5/inftrees.c +330 -0
  148. data/ext/zlib-1.2.5/inftrees.h +62 -0
  149. data/ext/zlib-1.2.5/minigzip.c +440 -0
  150. data/ext/zlib-1.2.5/trees.c +1244 -0
  151. data/ext/zlib-1.2.5/trees.h +128 -0
  152. data/ext/zlib-1.2.5/uncompr.c +59 -0
  153. data/ext/zlib-1.2.5/zconf.h +428 -0
  154. data/ext/zlib-1.2.5/zlib.h +1613 -0
  155. data/ext/zlib-1.2.5/zutil.c +318 -0
  156. data/ext/zlib-1.2.5/zutil.h +274 -0
  157. metadata +211 -0
@@ -0,0 +1,164 @@
1
+ /*-
2
+ * Copyright (c) 2003-2007 Tim Kientzle
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
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_string_sprintf.c 189435 2009-03-06 05:14:55Z kientzle $");
28
+
29
+ /*
30
+ * The use of printf()-family functions can be troublesome
31
+ * for space-constrained applications. In addition, correctly
32
+ * implementing this function in terms of vsnprintf() requires
33
+ * two calls (one to determine the size, another to format the
34
+ * result), which in turn requires duplicating the argument list
35
+ * using va_copy, which isn't yet universally available. <sigh>
36
+ *
37
+ * So, I've implemented a bare minimum of printf()-like capability
38
+ * here. This is only used to format error messages, so doesn't
39
+ * require any floating-point support or field-width handling.
40
+ */
41
+
42
+ #include <stdio.h>
43
+
44
+ #include "archive_string.h"
45
+ #include "archive_private.h"
46
+
47
+ /*
48
+ * Utility functions to format signed/unsigned integers and append
49
+ * them to an archive_string.
50
+ */
51
+ static void
52
+ append_uint(struct archive_string *as, uintmax_t d, unsigned base)
53
+ {
54
+ static const char *digits = "0123456789abcdef";
55
+ if (d >= base)
56
+ append_uint(as, d/base, base);
57
+ archive_strappend_char(as, digits[d % base]);
58
+ }
59
+
60
+ static void
61
+ append_int(struct archive_string *as, intmax_t d, unsigned base)
62
+ {
63
+ if (d < 0) {
64
+ archive_strappend_char(as, '-');
65
+ d = -d;
66
+ }
67
+ append_uint(as, d, base);
68
+ }
69
+
70
+
71
+ void
72
+ __archive_string_sprintf(struct archive_string *as, const char *fmt, ...)
73
+ {
74
+ va_list ap;
75
+
76
+ va_start(ap, fmt);
77
+ archive_string_vsprintf(as, fmt, ap);
78
+ va_end(ap);
79
+ }
80
+
81
+ /*
82
+ * Like 'vsprintf', but ensures the target is big enough, resizing if
83
+ * necessary.
84
+ */
85
+ void
86
+ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
87
+ va_list ap)
88
+ {
89
+ char long_flag;
90
+ intmax_t s; /* Signed integer temp. */
91
+ uintmax_t u; /* Unsigned integer temp. */
92
+ const char *p, *p2;
93
+
94
+ if (__archive_string_ensure(as, 64) == NULL)
95
+ __archive_errx(1, "Out of memory");
96
+
97
+ if (fmt == NULL) {
98
+ as->s[0] = 0;
99
+ return;
100
+ }
101
+
102
+ for (p = fmt; *p != '\0'; p++) {
103
+ const char *saved_p = p;
104
+
105
+ if (*p != '%') {
106
+ archive_strappend_char(as, *p);
107
+ continue;
108
+ }
109
+
110
+ p++;
111
+
112
+ long_flag = '\0';
113
+ switch(*p) {
114
+ case 'j':
115
+ long_flag = 'j';
116
+ p++;
117
+ break;
118
+ case 'l':
119
+ long_flag = 'l';
120
+ p++;
121
+ break;
122
+ }
123
+
124
+ switch (*p) {
125
+ case '%':
126
+ __archive_strappend_char(as, '%');
127
+ break;
128
+ case 'c':
129
+ s = va_arg(ap, int);
130
+ __archive_strappend_char(as, s);
131
+ break;
132
+ case 'd':
133
+ switch(long_flag) {
134
+ case 'j': s = va_arg(ap, intmax_t); break;
135
+ case 'l': s = va_arg(ap, long); break;
136
+ default: s = va_arg(ap, int); break;
137
+ }
138
+ append_int(as, s, 10);
139
+ break;
140
+ case 's':
141
+ p2 = va_arg(ap, char *);
142
+ archive_strcat(as, p2);
143
+ break;
144
+ case 'o': case 'u': case 'x': case 'X':
145
+ /* Common handling for unsigned integer formats. */
146
+ switch(long_flag) {
147
+ case 'j': u = va_arg(ap, uintmax_t); break;
148
+ case 'l': u = va_arg(ap, unsigned long); break;
149
+ default: u = va_arg(ap, unsigned int); break;
150
+ }
151
+ /* Format it in the correct base. */
152
+ switch (*p) {
153
+ case 'o': append_uint(as, u, 8); break;
154
+ case 'u': append_uint(as, u, 10); break;
155
+ default: append_uint(as, u, 16); break;
156
+ }
157
+ break;
158
+ default:
159
+ /* Rewind and print the initial '%' literally. */
160
+ p = saved_p;
161
+ archive_strappend_char(as, *p);
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,391 @@
1
+ /*-
2
+ * Copyright (c) 2009 Michihiro NAKAJIMA
3
+ * Copyright (c) 2003-2007 Tim Kientzle
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ #include "archive_platform.h"
28
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:14Z kientzle $");
29
+
30
+ #ifdef HAVE_SYS_TYPES_H
31
+ #include <sys/types.h>
32
+ #endif
33
+ #ifdef HAVE_STDLIB_H
34
+ #include <stdlib.h>
35
+ #endif
36
+ #ifdef HAVE_STRING_H
37
+ #include <string.h>
38
+ #endif
39
+
40
+ #include "archive.h"
41
+ #include "archive_private.h"
42
+ #include "archive_string.h"
43
+
44
+ #if ARCHIVE_VERSION_NUMBER < 3000000
45
+ /* These disappear in libarchive 3.0 */
46
+ /* Deprecated. */
47
+ int
48
+ archive_api_feature(void)
49
+ {
50
+ return (ARCHIVE_API_FEATURE);
51
+ }
52
+
53
+ /* Deprecated. */
54
+ int
55
+ archive_api_version(void)
56
+ {
57
+ return (ARCHIVE_API_VERSION);
58
+ }
59
+
60
+ /* Deprecated synonym for archive_version_number() */
61
+ int
62
+ archive_version_stamp(void)
63
+ {
64
+ return (archive_version_number());
65
+ }
66
+
67
+ /* Deprecated synonym for archive_version_string() */
68
+ const char *
69
+ archive_version(void)
70
+ {
71
+ return (archive_version_string());
72
+ }
73
+ #endif
74
+
75
+ int
76
+ archive_version_number(void)
77
+ {
78
+ return (ARCHIVE_VERSION_NUMBER);
79
+ }
80
+
81
+ const char *
82
+ archive_version_string(void)
83
+ {
84
+ return (ARCHIVE_VERSION_STRING);
85
+ }
86
+
87
+ int
88
+ archive_errno(struct archive *a)
89
+ {
90
+ return (a->archive_error_number);
91
+ }
92
+
93
+ const char *
94
+ archive_error_string(struct archive *a)
95
+ {
96
+
97
+ if (a->error != NULL && *a->error != '\0')
98
+ return (a->error);
99
+ else
100
+ return ("(Empty error message)");
101
+ }
102
+
103
+ int
104
+ archive_file_count(struct archive *a)
105
+ {
106
+ return (a->file_count);
107
+ }
108
+
109
+ int
110
+ archive_format(struct archive *a)
111
+ {
112
+ return (a->archive_format);
113
+ }
114
+
115
+ const char *
116
+ archive_format_name(struct archive *a)
117
+ {
118
+ return (a->archive_format_name);
119
+ }
120
+
121
+
122
+ int
123
+ archive_compression(struct archive *a)
124
+ {
125
+ return (a->compression_code);
126
+ }
127
+
128
+ const char *
129
+ archive_compression_name(struct archive *a)
130
+ {
131
+ return (a->compression_name);
132
+ }
133
+
134
+
135
+ /*
136
+ * Return a count of the number of compressed bytes processed.
137
+ */
138
+ int64_t
139
+ archive_position_compressed(struct archive *a)
140
+ {
141
+ return (a->raw_position);
142
+ }
143
+
144
+ /*
145
+ * Return a count of the number of uncompressed bytes processed.
146
+ */
147
+ int64_t
148
+ archive_position_uncompressed(struct archive *a)
149
+ {
150
+ return (a->file_position);
151
+ }
152
+
153
+ void
154
+ archive_clear_error(struct archive *a)
155
+ {
156
+ archive_string_empty(&a->error_string);
157
+ a->error = NULL;
158
+ }
159
+
160
+ void
161
+ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
162
+ {
163
+ va_list ap;
164
+
165
+ a->archive_error_number = error_number;
166
+ if (fmt == NULL) {
167
+ a->error = NULL;
168
+ return;
169
+ }
170
+
171
+ va_start(ap, fmt);
172
+ archive_string_vsprintf(&(a->error_string), fmt, ap);
173
+ va_end(ap);
174
+ a->error = a->error_string.s;
175
+ }
176
+
177
+ void
178
+ archive_copy_error(struct archive *dest, struct archive *src)
179
+ {
180
+ dest->archive_error_number = src->archive_error_number;
181
+
182
+ archive_string_copy(&dest->error_string, &src->error_string);
183
+ dest->error = dest->error_string.s;
184
+ }
185
+
186
+ void
187
+ __archive_errx(int retvalue, const char *msg)
188
+ {
189
+ static const char *msg1 = "Fatal Internal Error in libarchive: ";
190
+ size_t s;
191
+
192
+ s = write(2, msg1, strlen(msg1));
193
+ (void)s; /* UNUSED */
194
+ s = write(2, msg, strlen(msg));
195
+ (void)s; /* UNUSED */
196
+ s = write(2, "\n", 1);
197
+ (void)s; /* UNUSED */
198
+ exit(retvalue);
199
+ }
200
+
201
+ /*
202
+ * Parse option strings
203
+ * Detail of option format.
204
+ * - The option can accept:
205
+ * "opt-name", "!opt-name", "opt-name=value".
206
+ *
207
+ * - The option entries are separated by comma.
208
+ * e.g "compression=9,opt=XXX,opt-b=ZZZ"
209
+ *
210
+ * - The name of option string consist of '-' and alphabet
211
+ * but character '-' cannot be used for the first character.
212
+ * (Regular expression is [a-z][-a-z]+)
213
+ *
214
+ * - For a specfic format/filter, using the format name with ':'.
215
+ * e.g "zip:compression=9"
216
+ * (This "compression=9" option entry is for "zip" format only)
217
+ *
218
+ * If another entries follow it, those are not for
219
+ * the specfic format/filter.
220
+ * e.g handle "zip:compression=9,opt=XXX,opt-b=ZZZ"
221
+ * "zip" format/filter handler will get "compression=9"
222
+ * all format/filter handler will get "opt=XXX"
223
+ * all format/filter handler will get "opt-b=ZZZ"
224
+ *
225
+ * - Whitespace and tab are bypassed.
226
+ *
227
+ */
228
+ int
229
+ __archive_parse_options(const char *p, const char *fn, int keysize, char *key,
230
+ int valsize, char *val)
231
+ {
232
+ const char *p_org;
233
+ int apply;
234
+ int kidx, vidx;
235
+ int negative;
236
+ enum {
237
+ /* Requested for initialization. */
238
+ INIT,
239
+ /* Finding format/filter-name and option-name. */
240
+ F_BOTH,
241
+ /* Finding option-name only.
242
+ * (already detected format/filter-name) */
243
+ F_NAME,
244
+ /* Getting option-value. */
245
+ G_VALUE,
246
+ } state;
247
+
248
+ p_org = p;
249
+ state = INIT;
250
+ kidx = vidx = negative = 0;
251
+ apply = 1;
252
+ while (*p) {
253
+ switch (state) {
254
+ case INIT:
255
+ kidx = vidx = 0;
256
+ negative = 0;
257
+ apply = 1;
258
+ state = F_BOTH;
259
+ break;
260
+ case F_BOTH:
261
+ case F_NAME:
262
+ if ((*p >= 'a' && *p <= 'z') ||
263
+ (*p >= '0' && *p <= '9') || *p == '-') {
264
+ if (kidx == 0 && !(*p >= 'a' && *p <= 'z'))
265
+ /* Illegal sequence. */
266
+ return (-1);
267
+ if (kidx >= keysize -1)
268
+ /* Too many characters. */
269
+ return (-1);
270
+ key[kidx++] = *p++;
271
+ } else if (*p == '!') {
272
+ if (kidx != 0)
273
+ /* Illegal sequence. */
274
+ return (-1);
275
+ negative = 1;
276
+ ++p;
277
+ } else if (*p == ',') {
278
+ if (kidx == 0)
279
+ /* Illegal sequence. */
280
+ return (-1);
281
+ if (!negative)
282
+ val[vidx++] = '1';
283
+ /* We have got boolean option data. */
284
+ ++p;
285
+ if (apply)
286
+ goto complete;
287
+ else
288
+ /* This option does not apply to the
289
+ * format which the fn variable
290
+ * indicate. */
291
+ state = INIT;
292
+ } else if (*p == ':') {
293
+ /* obuf data is format name */
294
+ if (state == F_NAME)
295
+ /* We already found it. */
296
+ return (-1);
297
+ if (kidx == 0)
298
+ /* Illegal sequence. */
299
+ return (-1);
300
+ if (negative)
301
+ /* We cannot accept "!format-name:". */
302
+ return (-1);
303
+ key[kidx] = '\0';
304
+ if (strcmp(fn, key) != 0)
305
+ /* This option does not apply to the
306
+ * format which the fn variable
307
+ * indicate. */
308
+ apply = 0;
309
+ kidx = 0;
310
+ ++p;
311
+ state = F_NAME;
312
+ } else if (*p == '=') {
313
+ if (kidx == 0)
314
+ /* Illegal sequence. */
315
+ return (-1);
316
+ if (negative)
317
+ /* We cannot accept "!opt-name=value". */
318
+ return (-1);
319
+ ++p;
320
+ state = G_VALUE;
321
+ } else if (*p == ' ') {
322
+ /* Pass the space character */
323
+ ++p;
324
+ } else {
325
+ /* Illegal character. */
326
+ return (-1);
327
+ }
328
+ break;
329
+ case G_VALUE:
330
+ if (*p == ',') {
331
+ if (vidx == 0)
332
+ /* Illegal sequence. */
333
+ return (-1);
334
+ /* We have got option data. */
335
+ ++p;
336
+ if (apply)
337
+ goto complete;
338
+ else
339
+ /* This option does not apply to the
340
+ * format which the fn variable
341
+ * indicate. */
342
+ state = INIT;
343
+ } else if (*p == ' ') {
344
+ /* Pass the space character */
345
+ ++p;
346
+ } else {
347
+ if (vidx >= valsize -1)
348
+ /* Too many characters. */
349
+ return (-1);
350
+ val[vidx++] = *p++;
351
+ }
352
+ break;
353
+ }
354
+ }
355
+
356
+ switch (state) {
357
+ case F_BOTH:
358
+ case F_NAME:
359
+ if (kidx != 0) {
360
+ if (!negative)
361
+ val[vidx++] = '1';
362
+ /* We have got boolean option. */
363
+ if (apply)
364
+ /* This option apply to the format which the
365
+ * fn variable indicate. */
366
+ goto complete;
367
+ }
368
+ break;
369
+ case G_VALUE:
370
+ if (vidx == 0)
371
+ /* Illegal sequence. */
372
+ return (-1);
373
+ /* We have got option value. */
374
+ if (apply)
375
+ /* This option apply to the format which the fn
376
+ * variable indicate. */
377
+ goto complete;
378
+ break;
379
+ case INIT:/* nothing */
380
+ break;
381
+ }
382
+
383
+ /* End of Option string. */
384
+ return (0);
385
+
386
+ complete:
387
+ key[kidx] = '\0';
388
+ val[vidx] = '\0';
389
+ /* Return a size which we've consumed for detecting option */
390
+ return ((int)(p - p_org));
391
+ }
@@ -0,0 +1,94 @@
1
+ /*-
2
+ * Copyright (c) 2003-2007 Tim Kientzle
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
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_virtual.c 201098 2009-12-28 02:58:14Z kientzle $");
28
+
29
+ #include "archive.h"
30
+ #include "archive_entry.h"
31
+ #include "archive_private.h"
32
+
33
+ int
34
+ archive_write_close(struct archive *a)
35
+ {
36
+ return ((a->vtable->archive_close)(a));
37
+ }
38
+
39
+ int
40
+ archive_read_close(struct archive *a)
41
+ {
42
+ return ((a->vtable->archive_close)(a));
43
+ }
44
+
45
+ #if ARCHIVE_API_VERSION > 1
46
+ int
47
+ archive_write_finish(struct archive *a)
48
+ {
49
+ return ((a->vtable->archive_finish)(a));
50
+ }
51
+ #else
52
+ /* Temporarily allow library to compile with either 1.x or 2.0 API. */
53
+ void
54
+ archive_write_finish(struct archive *a)
55
+ {
56
+ (void)(a->vtable->archive_finish)(a);
57
+ }
58
+ #endif
59
+
60
+ int
61
+ archive_read_finish(struct archive *a)
62
+ {
63
+ return ((a->vtable->archive_finish)(a));
64
+ }
65
+
66
+ int
67
+ archive_write_header(struct archive *a, struct archive_entry *entry)
68
+ {
69
+ ++a->file_count;
70
+ return ((a->vtable->archive_write_header)(a, entry));
71
+ }
72
+
73
+ int
74
+ archive_write_finish_entry(struct archive *a)
75
+ {
76
+ return ((a->vtable->archive_write_finish_entry)(a));
77
+ }
78
+
79
+ #if ARCHIVE_API_VERSION > 1
80
+ ssize_t
81
+ #else
82
+ /* Temporarily allow library to compile with either 1.x or 2.0 API. */
83
+ int
84
+ #endif
85
+ archive_write_data(struct archive *a, const void *buff, size_t s)
86
+ {
87
+ return ((a->vtable->archive_write_data)(a, buff, s));
88
+ }
89
+
90
+ ssize_t
91
+ archive_write_data_block(struct archive *a, const void *buff, size_t s, off_t o)
92
+ {
93
+ return ((a->vtable->archive_write_data_block)(a, buff, s, o));
94
+ }