aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /archival/libunarchive
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/data_extract_all.c14
-rw-r--r--archival/libunarchive/decompress_bunzip2.c10
-rw-r--r--archival/libunarchive/decompress_unzip.c4
-rw-r--r--archival/libunarchive/get_header_ar.c12
-rw-r--r--archival/libunarchive/get_header_cpio.c9
-rw-r--r--archival/libunarchive/get_header_tar.c10
6 files changed, 13 insertions, 46 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 6337e0c85..5d1ec302a 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -3,16 +3,6 @@
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
4 */ 4 */
5 5
6#include <sys/types.h>
7
8#include <errno.h>
9#include <fcntl.h>
10#include <stdlib.h>
11#include <string.h>
12#include <utime.h>
13#include <unistd.h>
14#include <stdlib.h>
15
16#include "libbb.h" 6#include "libbb.h"
17#include "unarchive.h" 7#include "unarchive.h"
18 8
@@ -23,7 +13,7 @@ void data_extract_all(archive_handle_t *archive_handle)
23 int res; 13 int res;
24 14
25 if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { 15 if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
26 char *name = bb_xstrdup(file_header->name); 16 char *name = xstrdup(file_header->name);
27 bb_make_directory (dirname(name), -1, FILEUTILS_RECUR); 17 bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
28 free(name); 18 free(name);
29 } 19 }
@@ -68,7 +58,7 @@ void data_extract_all(archive_handle_t *archive_handle)
68 switch(file_header->mode & S_IFMT) { 58 switch(file_header->mode & S_IFMT) {
69 case S_IFREG: { 59 case S_IFREG: {
70 /* Regular file */ 60 /* Regular file */
71 dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL); 61 dst_fd = xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
72 bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size); 62 bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
73 close(dst_fd); 63 close(dst_fd);
74 break; 64 break;
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c
index ae96ea375..657d4ab01 100644
--- a/archival/libunarchive/decompress_bunzip2.c
+++ b/archival/libunarchive/decompress_bunzip2.c
@@ -28,15 +28,7 @@
28 Manuel 28 Manuel
29 */ 29 */
30 30
31#include <setjmp.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <limits.h>
37
38#include "libbb.h" 31#include "libbb.h"
39
40#include "unarchive.h" 32#include "unarchive.h"
41 33
42/* Constants for Huffman coding */ 34/* Constants for Huffman coding */
@@ -655,7 +647,7 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
655 647
656 /* Init the CRC32 table (big endian) */ 648 /* Init the CRC32 table (big endian) */
657 649
658 bd->crc32Table = bb_crc32_filltable(1); 650 bd->crc32Table = crc32_filltable(1);
659 651
660 /* Setup for I/O error handling via longjmp */ 652 /* Setup for I/O error handling via longjmp */
661 653
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 8f33e6e6c..7362da8c2 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -34,8 +34,6 @@
34 */ 34 */
35 35
36#include "libbb.h" 36#include "libbb.h"
37#include <sys/wait.h>
38#include <signal.h>
39#include "unarchive.h" 37#include "unarchive.h"
40 38
41typedef struct huft_s { 39typedef struct huft_s {
@@ -853,7 +851,7 @@ int inflate_unzip(int in, int out)
853 gunzip_bb = 0; 851 gunzip_bb = 0;
854 852
855 /* Create the crc table */ 853 /* Create the crc table */
856 gunzip_crc_table = bb_crc32_filltable(0); 854 gunzip_crc_table = crc32_filltable(0);
857 gunzip_crc = ~0; 855 gunzip_crc = ~0;
858 856
859 /* Allocate space for buffer */ 857 /* Allocate space for buffer */
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index 4627695e4..cabb4101b 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -4,12 +4,8 @@
4 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 4 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
5 */ 5 */
6 6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include <unistd.h>
11#include "unarchive.h"
12#include "libbb.h" 7#include "libbb.h"
8#include "unarchive.h"
13 9
14char get_header_ar(archive_handle_t *archive_handle) 10char get_header_ar(archive_handle_t *archive_handle)
15{ 11{
@@ -31,7 +27,7 @@ char get_header_ar(archive_handle_t *archive_handle)
31 static unsigned int ar_long_name_size; 27 static unsigned int ar_long_name_size;
32#endif 28#endif
33 29
34 /* dont use bb_xread as we want to handle the error ourself */ 30 /* dont use xread as we want to handle the error ourself */
35 if (read(archive_handle->src_fd, ar.raw, 60) != 60) { 31 if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
36 /* End Of File */ 32 /* End Of File */
37 return(EXIT_FAILURE); 33 return(EXIT_FAILURE);
@@ -85,14 +81,14 @@ char get_header_ar(archive_handle_t *archive_handle)
85 if (long_offset >= ar_long_name_size) { 81 if (long_offset >= ar_long_name_size) {
86 bb_error_msg_and_die("Cant resolve long filename"); 82 bb_error_msg_and_die("Cant resolve long filename");
87 } 83 }
88 typed->name = bb_xstrdup(ar_long_names + long_offset); 84 typed->name = xstrdup(ar_long_names + long_offset);
89 } 85 }
90#else 86#else
91 bb_error_msg_and_die("long filenames not supported"); 87 bb_error_msg_and_die("long filenames not supported");
92#endif 88#endif
93 } else { 89 } else {
94 /* short filenames */ 90 /* short filenames */
95 typed->name = bb_xstrndup(ar.formatted.name, 16); 91 typed->name = xstrndup(ar.formatted.name, 16);
96 } 92 }
97 93
98 typed->name[strcspn(typed->name, " /")] = '\0'; 94 typed->name[strcspn(typed->name, " /")] = '\0';
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c
index 28c743589..d405d0e1b 100644
--- a/archival/libunarchive/get_header_cpio.c
+++ b/archival/libunarchive/get_header_cpio.c
@@ -4,13 +4,8 @@
4 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 4 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
5 */ 5 */
6 6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10#include <unistd.h>
11#include <sys/sysmacros.h> /* major() and minor() */
12#include "unarchive.h"
13#include "libbb.h" 7#include "libbb.h"
8#include "unarchive.h"
14 9
15typedef struct hardlinks_s { 10typedef struct hardlinks_s {
16 file_header_t *entry; 11 file_header_t *entry;
@@ -123,7 +118,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
123 pending_hardlinks = 1; 118 pending_hardlinks = 1;
124 while (tmp) { 119 while (tmp) {
125 if (tmp->inode == inode) { 120 if (tmp->inode == inode) {
126 tmp->entry->link_name = bb_xstrdup(file_header->name); 121 tmp->entry->link_name = xstrdup(file_header->name);
127 nlink--; 122 nlink--;
128 } 123 }
129 tmp = tmp->next; 124 tmp = tmp->next;
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index fb7e9ae8f..0c622f44a 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -11,12 +11,8 @@
11 * http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html 11 * http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
12 */ 12 */
13 13
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <sys/sysmacros.h> /* For makedev */
18#include "unarchive.h"
19#include "libbb.h" 14#include "libbb.h"
15#include "unarchive.h"
20 16
21#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS 17#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
22static char *longname = NULL; 18static char *longname = NULL;
@@ -106,7 +102,7 @@ char get_header_tar(archive_handle_t *archive_handle)
106 } else 102 } else
107#endif 103#endif
108 { 104 {
109 file_header->name = bb_xstrndup(tar.formatted.name,100); 105 file_header->name = xstrndup(tar.formatted.name,100);
110 106
111 if (tar.formatted.prefix[0]) { 107 if (tar.formatted.prefix[0]) {
112 char *temp = file_header->name; 108 char *temp = file_header->name;
@@ -120,7 +116,7 @@ char get_header_tar(archive_handle_t *archive_handle)
120 file_header->size = strtol(tar.formatted.size, NULL, 8); 116 file_header->size = strtol(tar.formatted.size, NULL, 8);
121 file_header->mtime = strtol(tar.formatted.mtime, NULL, 8); 117 file_header->mtime = strtol(tar.formatted.mtime, NULL, 8);
122 file_header->link_name = (tar.formatted.linkname[0] != '\0') ? 118 file_header->link_name = (tar.formatted.linkname[0] != '\0') ?
123 bb_xstrdup(tar.formatted.linkname) : NULL; 119 xstrdup(tar.formatted.linkname) : NULL;
124 file_header->device = makedev(strtol(tar.formatted.devmajor, NULL, 8), 120 file_header->device = makedev(strtol(tar.formatted.devmajor, NULL, 8),
125 strtol(tar.formatted.devminor, NULL, 8)); 121 strtol(tar.formatted.devminor, NULL, 8));
126 122