aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive/filter_accept_reject_list.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-09-25 02:47:48 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-09-25 02:47:48 +0000
commit7ca04f328e22fcbee4659d73f9a72dfdf1dd6a23 (patch)
treef38c7ef4317eea28c6abdb0adbbb286fe041711e /archival/libunarchive/filter_accept_reject_list.c
parentecfa290cfd4953598e6d91989bd66ac16e135f84 (diff)
downloadbusybox-7ca04f328e22fcbee4659d73f9a72dfdf1dd6a23.tar.gz
New common unarchive code.
Diffstat (limited to 'archival/libunarchive/filter_accept_reject_list.c')
-rw-r--r--archival/libunarchive/filter_accept_reject_list.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/archival/libunarchive/filter_accept_reject_list.c b/archival/libunarchive/filter_accept_reject_list.c
new file mode 100644
index 000000000..c893dfcfc
--- /dev/null
+++ b/archival/libunarchive/filter_accept_reject_list.c
@@ -0,0 +1,34 @@
+#include <fnmatch.h>
+#include <stdlib.h>
+#include "unarchive.h"
+
+static char check_list(const llist_t *list, const char *filename)
+{
+ if (list) {
+ while (list) {
+ if (fnmatch(list->data, filename, 0) == 0) {
+ return(EXIT_SUCCESS);
+ }
+ list = list->link;
+ }
+ }
+ return(EXIT_FAILURE);
+}
+
+/*
+ * Accept names that are in the accept list
+ */
+extern char filter_accept_reject_list(const llist_t *accept_list, const llist_t *reject_list, const char *key)
+{
+ /* Fail if an accept list was specified and the key wasnt in there */
+ if ((accept_list) && (check_list(accept_list, key) == EXIT_FAILURE)) {
+ return(EXIT_FAILURE);
+ }
+
+ /* If the key is in a reject list fail */
+ if (check_list(reject_list, key) == EXIT_FAILURE) {
+ return(EXIT_FAILURE);
+ }
+
+ return(EXIT_SUCCESS);
+}