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,134 @@
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_check_magic.c 201089 2009-12-28 02:20:23Z kientzle $");
28
+
29
+ #ifdef HAVE_SYS_TYPES_H
30
+ #include <sys/types.h>
31
+ #endif
32
+
33
+ #include <stdio.h>
34
+ #ifdef HAVE_STDLIB_H
35
+ #include <stdlib.h>
36
+ #endif
37
+ #ifdef HAVE_STRING_H
38
+ #include <string.h>
39
+ #endif
40
+ #ifdef HAVE_UNISTD_H
41
+ #include <unistd.h>
42
+ #endif
43
+ #if defined(_WIN32) && !defined(__CYGWIN__)
44
+ #include <windows.h>
45
+ #include <winbase.h>
46
+ #endif
47
+
48
+ #include "archive_private.h"
49
+
50
+ static void
51
+ errmsg(const char *m)
52
+ {
53
+ size_t s = strlen(m);
54
+ ssize_t written;
55
+
56
+ while (s > 0) {
57
+ written = write(2, m, strlen(m));
58
+ if (written <= 0)
59
+ return;
60
+ m += written;
61
+ s -= written;
62
+ }
63
+ }
64
+
65
+ static void
66
+ diediedie(void)
67
+ {
68
+ #if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
69
+ /* Cause a breakpoint exception */
70
+ DebugBreak();
71
+ #endif
72
+ abort(); /* Terminate the program abnormally. */
73
+ }
74
+
75
+ static const char *
76
+ state_name(unsigned s)
77
+ {
78
+ switch (s) {
79
+ case ARCHIVE_STATE_NEW: return ("new");
80
+ case ARCHIVE_STATE_HEADER: return ("header");
81
+ case ARCHIVE_STATE_DATA: return ("data");
82
+ case ARCHIVE_STATE_EOF: return ("eof");
83
+ case ARCHIVE_STATE_CLOSED: return ("closed");
84
+ case ARCHIVE_STATE_FATAL: return ("fatal");
85
+ default: return ("??");
86
+ }
87
+ }
88
+
89
+
90
+ static void
91
+ write_all_states(unsigned int states)
92
+ {
93
+ unsigned int lowbit;
94
+
95
+ /* A trick for computing the lowest set bit. */
96
+ while ((lowbit = states & (1 + ~states)) != 0) {
97
+ states &= ~lowbit; /* Clear the low bit. */
98
+ errmsg(state_name(lowbit));
99
+ if (states != 0)
100
+ errmsg("/");
101
+ }
102
+ }
103
+
104
+ /*
105
+ * Check magic value and current state; bail if it isn't valid.
106
+ *
107
+ * This is designed to catch serious programming errors that violate
108
+ * the libarchive API.
109
+ */
110
+ void
111
+ __archive_check_magic(struct archive *a, unsigned int magic,
112
+ unsigned int state, const char *function)
113
+ {
114
+ if (a->magic != magic) {
115
+ errmsg("INTERNAL ERROR: Function ");
116
+ errmsg(function);
117
+ errmsg(" invoked with invalid struct archive structure.\n");
118
+ diediedie();
119
+ }
120
+
121
+ if (state == ARCHIVE_STATE_ANY)
122
+ return;
123
+
124
+ if ((a->state & state) == 0) {
125
+ errmsg("INTERNAL ERROR: Function '");
126
+ errmsg(function);
127
+ errmsg("' invoked with archive structure in state '");
128
+ write_all_states(a->state);
129
+ errmsg("', should be in state '");
130
+ write_all_states(state);
131
+ errmsg("'\n");
132
+ diediedie();
133
+ }
134
+ }
@@ -0,0 +1,66 @@
1
+ /*-
2
+ * Copyright (c) 2009 Joerg Sonnenberger
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
+ * $FreeBSD: head/lib/libarchive/archive_crc32.h 201102 2009-12-28 03:11:36Z kientzle $
26
+ */
27
+
28
+ #ifndef __LIBARCHIVE_BUILD
29
+ #error This header is only to be used internally to libarchive.
30
+ #endif
31
+
32
+ /*
33
+ * When zlib is unavailable, we should still be able to validate
34
+ * uncompressed zip archives. That requires us to be able to compute
35
+ * the CRC32 check value. This is a drop-in compatible replacement
36
+ * for crc32() from zlib. It's slower than the zlib implementation,
37
+ * but still pretty fast: This runs about 300MB/s on my 3GHz P4
38
+ * compared to about 800MB/s for the zlib implementation.
39
+ */
40
+ static unsigned long
41
+ crc32(unsigned long crc, const void *_p, size_t len)
42
+ {
43
+ unsigned long crc2, b, i;
44
+ const unsigned char *p = _p;
45
+ static volatile int crc_tbl_inited = 0;
46
+ static unsigned long crc_tbl[256];
47
+
48
+ if (!crc_tbl_inited) {
49
+ for (b = 0; b < 256; ++b) {
50
+ crc2 = b;
51
+ for (i = 8; i > 0; --i) {
52
+ if (crc2 & 1)
53
+ crc2 = (crc2 >> 1) ^ 0xedb88320UL;
54
+ else
55
+ crc2 = (crc2 >> 1);
56
+ }
57
+ crc_tbl[b] = crc2;
58
+ }
59
+ crc_tbl_inited = 1;
60
+ }
61
+
62
+ crc = crc ^ 0xffffffffUL;
63
+ while (len--)
64
+ crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
65
+ return (crc ^ 0xffffffffUL);
66
+ }
@@ -0,0 +1,162 @@
1
+ /*-
2
+ * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
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 AND CONTRIBUTORS ``AS IS'' AND
15
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ * SUCH DAMAGE.
25
+ *
26
+ * $FreeBSD: head/lib/libarchive/archive_endian.h 201085 2009-12-28 02:17:15Z kientzle $
27
+ *
28
+ * Borrowed from FreeBSD's <sys/endian.h>
29
+ */
30
+
31
+ #ifndef __LIBARCHIVE_BUILD
32
+ #error This header is only to be used internally to libarchive.
33
+ #endif
34
+
35
+ /* Note: This is a purely internal header! */
36
+ /* Do not use this outside of libarchive internal code! */
37
+
38
+ #ifndef ARCHIVE_ENDIAN_H_INCLUDED
39
+ #define ARCHIVE_ENDIAN_H_INCLUDED
40
+
41
+
42
+ /*
43
+ * Disabling inline keyword for compilers known to choke on it:
44
+ * - Watcom C++ in C code. (For any version?)
45
+ * - SGI MIPSpro
46
+ * - Microsoft Visual C++ 6.0 (supposedly newer versions too)
47
+ */
48
+ #if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
49
+ #define inline
50
+ #elif defined(_MSC_VER)
51
+ #define inline __inline
52
+ #endif
53
+
54
+ /* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
55
+
56
+ static inline uint16_t
57
+ archive_be16dec(const void *pp)
58
+ {
59
+ unsigned char const *p = (unsigned char const *)pp;
60
+
61
+ return ((p[0] << 8) | p[1]);
62
+ }
63
+
64
+ static inline uint32_t
65
+ archive_be32dec(const void *pp)
66
+ {
67
+ unsigned char const *p = (unsigned char const *)pp;
68
+
69
+ return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
70
+ }
71
+
72
+ static inline uint64_t
73
+ archive_be64dec(const void *pp)
74
+ {
75
+ unsigned char const *p = (unsigned char const *)pp;
76
+
77
+ return (((uint64_t)archive_be32dec(p) << 32) | archive_be32dec(p + 4));
78
+ }
79
+
80
+ static inline uint16_t
81
+ archive_le16dec(const void *pp)
82
+ {
83
+ unsigned char const *p = (unsigned char const *)pp;
84
+
85
+ return ((p[1] << 8) | p[0]);
86
+ }
87
+
88
+ static inline uint32_t
89
+ archive_le32dec(const void *pp)
90
+ {
91
+ unsigned char const *p = (unsigned char const *)pp;
92
+
93
+ return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
94
+ }
95
+
96
+ static inline uint64_t
97
+ archive_le64dec(const void *pp)
98
+ {
99
+ unsigned char const *p = (unsigned char const *)pp;
100
+
101
+ return (((uint64_t)archive_le32dec(p + 4) << 32) | archive_le32dec(p));
102
+ }
103
+
104
+ static inline void
105
+ archive_be16enc(void *pp, uint16_t u)
106
+ {
107
+ unsigned char *p = (unsigned char *)pp;
108
+
109
+ p[0] = (u >> 8) & 0xff;
110
+ p[1] = u & 0xff;
111
+ }
112
+
113
+ static inline void
114
+ archive_be32enc(void *pp, uint32_t u)
115
+ {
116
+ unsigned char *p = (unsigned char *)pp;
117
+
118
+ p[0] = (u >> 24) & 0xff;
119
+ p[1] = (u >> 16) & 0xff;
120
+ p[2] = (u >> 8) & 0xff;
121
+ p[3] = u & 0xff;
122
+ }
123
+
124
+ static inline void
125
+ archive_be64enc(void *pp, uint64_t u)
126
+ {
127
+ unsigned char *p = (unsigned char *)pp;
128
+
129
+ archive_be32enc(p, u >> 32);
130
+ archive_be32enc(p + 4, u & 0xffffffff);
131
+ }
132
+
133
+ static inline void
134
+ archive_le16enc(void *pp, uint16_t u)
135
+ {
136
+ unsigned char *p = (unsigned char *)pp;
137
+
138
+ p[0] = u & 0xff;
139
+ p[1] = (u >> 8) & 0xff;
140
+ }
141
+
142
+ static inline void
143
+ archive_le32enc(void *pp, uint32_t u)
144
+ {
145
+ unsigned char *p = (unsigned char *)pp;
146
+
147
+ p[0] = u & 0xff;
148
+ p[1] = (u >> 8) & 0xff;
149
+ p[2] = (u >> 16) & 0xff;
150
+ p[3] = (u >> 24) & 0xff;
151
+ }
152
+
153
+ static inline void
154
+ archive_le64enc(void *pp, uint64_t u)
155
+ {
156
+ unsigned char *p = (unsigned char *)pp;
157
+
158
+ archive_le32enc(p, u & 0xffffffff);
159
+ archive_le32enc(p + 4, u >> 32);
160
+ }
161
+
162
+ #endif