aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-11-04 23:47:31 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-11-04 23:47:31 +0000
commit8e940984231a5baf98b6e2a637477dd701d314a9 (patch)
tree5864c9961fdbfbcb8ecf09e78077544f9c8d12c3
parentf92caa7619d3f2dd7159a8bfb846e0f6dd4bab25 (diff)
downloadbusybox-w32-8e940984231a5baf98b6e2a637477dd701d314a9.tar.gz
busybox-w32-8e940984231a5baf98b6e2a637477dd701d314a9.tar.bz2
busybox-w32-8e940984231a5baf98b6e2a637477dd701d314a9.zip
Change filter paramaters, filters can be more powefull now
-rw-r--r--archival/cpio.c6
-rw-r--r--archival/libunarchive/filter_accept_all.c28
-rw-r--r--archival/libunarchive/filter_accept_list.c25
-rw-r--r--archival/libunarchive/filter_accept_reject_list.c36
-rw-r--r--archival/libunarchive/get_header_ar.c2
-rw-r--r--archival/libunarchive/get_header_tar.c2
-rw-r--r--include/unarchive.h8
7 files changed, 82 insertions, 25 deletions
diff --git a/archival/cpio.c b/archival/cpio.c
index 0d0614932..2aa11943e 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -116,7 +116,7 @@ extern int cpio_main(int argc, char **argv)
116 tmp = tmp->next; 116 tmp = tmp->next;
117 } 117 }
118 pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */ 118 pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
119 } 119 }
120 120
121 /* There can be padding before archive header */ 121 /* There can be padding before archive header */
122 data_align(archive_handle, 4); 122 data_align(archive_handle, 4);
@@ -138,7 +138,7 @@ extern int cpio_main(int argc, char **argv)
138 138
139 if ((cpio_header[5] != '1') && (cpio_header[5] != '2')) { 139 if ((cpio_header[5] != '1') && (cpio_header[5] != '2')) {
140 error_msg_and_die("Unsupported cpio format, use newc or crc"); 140 error_msg_and_die("Unsupported cpio format, use newc or crc");
141 } 141 }
142 142
143 sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c", 143 sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
144 dummy, &inode, (unsigned int*)&file_header->mode, 144 dummy, &inode, (unsigned int*)&file_header->mode,
@@ -206,7 +206,7 @@ extern int cpio_main(int argc, char **argv)
206 file_header->device = (major << 8) | minor; 206 file_header->device = (major << 8) | minor;
207 207
208 extract_flag = FALSE; 208 extract_flag = FALSE;
209 if (archive_handle->filter(archive_handle->accept, archive_handle->reject, file_header->name) == EXIT_SUCCESS) { 209 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
210 struct stat statbuf; 210 struct stat statbuf;
211 211
212 extract_flag = TRUE; 212 extract_flag = TRUE;
diff --git a/archival/libunarchive/filter_accept_all.c b/archival/libunarchive/filter_accept_all.c
index 2838ea1f2..d7bccb5cd 100644
--- a/archival/libunarchive/filter_accept_all.c
+++ b/archival/libunarchive/filter_accept_all.c
@@ -1,12 +1,30 @@
1/*
2 * Copyright (C) 2002 by Glenn McGrath
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
1#include <fnmatch.h> 19#include <fnmatch.h>
2#include <stdlib.h> 20#include <stdlib.h>
21
3#include "unarchive.h" 22#include "unarchive.h"
4/* 23
5 * Accept names that are in the accept list 24/* Accept any non-null name, its not really a filter at all */
6 */ 25extern char filter_accept_all(const archive_handle_t *archive_handle)
7extern char filter_accept_all(const llist_t *accept_list, const llist_t *reject_list, const char *key)
8{ 26{
9 if (key) { 27 if (archive_handle->file_header->name) {
10 return(EXIT_SUCCESS); 28 return(EXIT_SUCCESS);
11 } else { 29 } else {
12 return(EXIT_FAILURE); 30 return(EXIT_FAILURE);
diff --git a/archival/libunarchive/filter_accept_list.c b/archival/libunarchive/filter_accept_list.c
index 2b023ec70..5ff3ad2dd 100644
--- a/archival/libunarchive/filter_accept_list.c
+++ b/archival/libunarchive/filter_accept_list.c
@@ -1,13 +1,32 @@
1/*
2 * Copyright (C) 2002 by Glenn McGrath
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
1#include <fnmatch.h> 19#include <fnmatch.h>
2#include <stdlib.h> 20#include <stdlib.h>
21
3#include "unarchive.h" 22#include "unarchive.h"
4 23
5/* 24/*
6 * Accept names that are in the accept list 25 * Accept names that are in the accept list, ignoring reject list.
7 */ 26 */
8extern char filter_accept_list(const llist_t *accept_list, const llist_t *reject_list, const char *key) 27extern char filter_accept_list(const archive_handle_t *archive_handle)
9{ 28{
10 if (find_list_entry(accept_list, key)) { 29 if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
11 return(EXIT_SUCCESS); 30 return(EXIT_SUCCESS);
12 } else { 31 } else {
13 return(EXIT_FAILURE); 32 return(EXIT_FAILURE);
diff --git a/archival/libunarchive/filter_accept_reject_list.c b/archival/libunarchive/filter_accept_reject_list.c
index 21fecf120..48e9ed8ea 100644
--- a/archival/libunarchive/filter_accept_reject_list.c
+++ b/archival/libunarchive/filter_accept_reject_list.c
@@ -1,22 +1,42 @@
1/*
2 * Copyright (C) 2002 by Glenn McGrath
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
1#include <fnmatch.h> 19#include <fnmatch.h>
2#include <stdlib.h> 20#include <stdlib.h>
21
3#include "unarchive.h" 22#include "unarchive.h"
4 23
5/* 24/*
6 * Accept names that are in the accept list 25 * Accept names that are in the accept list and not in the reject list
7 */ 26 */
8extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key) 27extern char filter_accept_reject_list(const archive_handle_t *archive_handle)
9{ 28{
10 const llist_t *accept_entry = find_list_entry(accept_list, key); 29 const char *key = archive_handle->file_header->name;
11 const llist_t *reject_entry = find_list_entry(reject_list, key); 30 const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
31 const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
12 32
13 /* Fail if an accept list was specified and the key wasnt in there */ 33 /* If the key is in a reject list fail */
14 if (accept_list && (accept_entry == NULL)) { 34 if (reject_entry) {
15 return(EXIT_FAILURE); 35 return(EXIT_FAILURE);
16 } 36 }
17 37
18 /* If the key is in a reject list fail */ 38 /* Fail if an accept list was specified and the key wasnt in there */
19 if (reject_entry) { 39 if (archive_handle->accept && (accept_entry == NULL)) {
20 return(EXIT_FAILURE); 40 return(EXIT_FAILURE);
21 } 41 }
22 42
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index b7f2cfbcd..1e0e6c12d 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -104,7 +104,7 @@ extern char get_header_ar(archive_handle_t *archive_handle)
104 104
105 typed->name[strcspn(typed->name, " /")] = '\0'; 105 typed->name[strcspn(typed->name, " /")] = '\0';
106 106
107 if (archive_handle->filter(archive_handle->accept, archive_handle->reject, typed->name) == EXIT_SUCCESS) { 107 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
108 archive_handle->action_header(typed); 108 archive_handle->action_header(typed);
109 if (archive_handle->sub_archive) { 109 if (archive_handle->sub_archive) {
110 while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS); 110 while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index b2b9e0b03..20451d996 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -160,7 +160,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
160# endif 160# endif
161 } 161 }
162#endif 162#endif
163 if (archive_handle->filter(archive_handle->accept, archive_handle->reject, archive_handle->file_header->name) == EXIT_SUCCESS) { 163 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
164 archive_handle->action_header(archive_handle->file_header); 164 archive_handle->action_header(archive_handle->file_header);
165 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET; 165 archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
166 archive_handle->action_data(archive_handle); 166 archive_handle->action_data(archive_handle);
diff --git a/include/unarchive.h b/include/unarchive.h
index b13388b54..a1010aae8 100644
--- a/include/unarchive.h
+++ b/include/unarchive.h
@@ -28,7 +28,7 @@ typedef struct llist_s {
28 28
29typedef struct archive_handle_s { 29typedef struct archive_handle_s {
30 /* define if the header and data compenent should processed */ 30 /* define if the header and data compenent should processed */
31 char (*filter)(const llist_t *, const llist_t *, const char *); 31 char (*filter)(const struct archive_handle_s *);
32 const llist_t *accept; 32 const llist_t *accept;
33 const llist_t *reject; 33 const llist_t *reject;
34 const llist_t *passed; /* List of files that have successfully been worked on */ 34 const llist_t *passed; /* List of files that have successfully been worked on */
@@ -68,9 +68,9 @@ typedef struct archive_handle_s {
68 68
69extern archive_handle_t *init_handle(void); 69extern archive_handle_t *init_handle(void);
70 70
71extern char filter_accept_all(const llist_t *accept_list, const llist_t *reject_list, const char *key); 71extern char filter_accept_all(const archive_handle_t *archive_handle);
72extern char filter_accept_list(const llist_t *accept_list, const llist_t *reject_list, const char *key); 72extern char filter_accept_list(const archive_handle_t *archive_handle);
73extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key); 73extern char filter_accept_reject_list(const archive_handle_t *archive_handle);
74 74
75extern void unpack_ar_archive(archive_handle_t *ar_archive); 75extern void unpack_ar_archive(archive_handle_t *ar_archive);
76 76