From 4291a19ff2a34af04adfdb28e3902e4ac1aad38d Mon Sep 17 00:00:00 2001
From: andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Date: Mon, 4 Dec 2000 18:51:09 +0000
Subject: Patch to add in the -X option and fix the --exclude bug, originally
 by Sebastien Huet, and now ported to the latest and greatest by both Arne
 Bernin <ab@netropol.de> and kent robotti <robotti@metconnect.com>.

git-svn-id: svn://busybox.net/trunk/busybox@1373 69ca8d6d-28ef-0310-b511-8ec308f3f277
---
 tar.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

(limited to 'tar.c')

diff --git a/tar.c b/tar.c
index 6d8e633b0..7e56fb99a 100644
--- a/tar.c
+++ b/tar.c
@@ -147,6 +147,9 @@ extern int tar_main(int argc, char **argv)
 	char** extractList=NULL;
 #if defined BB_FEATURE_TAR_EXCLUDE
 	int excludeListSize=0;
+        char *excludeFileName ="-";
+        FILE *fileList;
+        char file[256];
 #endif
 	const char *tarName="-";
 	int listFlag     = FALSE;
@@ -198,7 +201,7 @@ extern int tar_main(int argc, char **argv)
 					break;
 #if defined BB_FEATURE_TAR_EXCLUDE
 				case 'e':
-					if (strcmp(*argv, "exclude")==0) {
+					if (strcmp(*argv, "xclude")==0) {
 						excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
 						excludeList[excludeListSize] = *(++argv);
 						if (excludeList[excludeListSize] == NULL)
@@ -211,6 +214,30 @@ extern int tar_main(int argc, char **argv)
 						stopIt=TRUE;
 						break;
 					}
+                                case 'X':
+                                       if (*excludeFileName != '-')
+                                               fatalError("Only one 'X' option allowed\n");
+                                       excludeFileName = *(++argv);
+                                       if  (excludeFileName == NULL)
+                                               fatalError("Option requires an argument: No file specified\n");
+                                       fileList = fopen (excludeFileName, "rt");
+                                       if (! fileList)
+                                               fatalError("Exclude file: file not found\n");
+                                       while (!feof(fileList)) {
+                                               fscanf(fileList, "%s", file);
+                                               excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
+                                               excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
+                                               strcpy(excludeList[excludeListSize],file);
+                                               /* Remove leading "/"s */
+                                               if (*excludeList[excludeListSize] == '/')
+                                                       excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
+                                               /* Tack a NULL onto the end of the list */
+                                                       excludeList[++excludeListSize] = NULL;
+                                       }
+ 
+                                       fclose(fileList);
+                                       stopIt=TRUE;
+                                       break;
 #endif
 				case '-':
 						break;
-- 
cgit v1.2.3-55-g6feb