aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-09-04 16:51:55 +0000
committerMatt Kraai <kraai@debian.org>2000-09-04 16:51:55 +0000
commit43c8c38bbfe3d25e21f37d899184de52c6dc9c17 (patch)
treed452df754e6eea4886060de8b04e458342b3d7bb
parent61a9d8d1450474507a3e5cebb0620f72205d60ca (diff)
downloadbusybox-w32-43c8c38bbfe3d25e21f37d899184de52c6dc9c17.tar.gz
busybox-w32-43c8c38bbfe3d25e21f37d899184de52c6dc9c17.tar.bz2
busybox-w32-43c8c38bbfe3d25e21f37d899184de52c6dc9c17.zip
Allow compilation when not using BB_FEATURE_TAR_EXCLUDE, and fix
handling of --exclude option.
-rw-r--r--archival/tar.c41
-rw-r--r--tar.c41
2 files changed, 38 insertions, 44 deletions
diff --git a/archival/tar.c b/archival/tar.c
index d3b0e5c0a..d31661184 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -49,6 +49,7 @@
49#include <utime.h> 49#include <utime.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/sysmacros.h> 51#include <sys/sysmacros.h>
52#include <getopt.h>
52 53
53/* Tar file constants */ 54/* Tar file constants */
54#ifndef MAJOR 55#ifndef MAJOR
@@ -136,6 +137,13 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
136 int verboseFlag, int argc, char **argv, char** excludeList); 137 int verboseFlag, int argc, char **argv, char** excludeList);
137#endif 138#endif
138 139
140static struct option longopts[] =
141{
142#ifdef BB_FEATURE_TAR_EXCLUDE
143 {"exclude",required_argument,NULL,'e'},
144#endif
145 {NULL,0,NULL,0}
146};
139 147
140extern int tar_main(int argc, char **argv) 148extern int tar_main(int argc, char **argv)
141{ 149{
@@ -155,7 +163,7 @@ extern int tar_main(int argc, char **argv)
155 usage(tar_usage); 163 usage(tar_usage);
156 164
157 /* do normal option parsing */ 165 /* do normal option parsing */
158 while ((opt = getopt(argc, argv, "cxtvOf:-:")) > 0) { 166 while ((opt = getopt_long(argc, argv, "cxtvOf:", longopts, NULL)) != EOF) {
159 switch (opt) { 167 switch (opt) {
160 case 'c': 168 case 'c':
161 if (extractFlag == TRUE || listFlag == TRUE) 169 if (extractFlag == TRUE || listFlag == TRUE)
@@ -186,28 +194,19 @@ extern int tar_main(int argc, char **argv)
186 if (!strcmp(tarName, "-") && createFlag == TRUE) 194 if (!strcmp(tarName, "-") && createFlag == TRUE)
187 tostdoutFlag = TRUE; 195 tostdoutFlag = TRUE;
188 break; 196 break;
189 case '-':
190#if defined BB_FEATURE_TAR_EXCLUDE 197#if defined BB_FEATURE_TAR_EXCLUDE
191 if (strcmp(optarg, "exclude")==0) { 198 case 'e':
192 if (argv[optind]==NULL) 199 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
193 fatalError( "option `--exclude' requires an argument\n"); 200 excludeList[excludeListSize] = optarg;
194 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 201 /* Remove leading "/"s */
195 excludeList[excludeListSize] = argv[optind]; 202 if (*excludeList[excludeListSize] =='/')
196 /* Remove leading "/"s */ 203 excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
197 if (*excludeList[excludeListSize] =='/') { 204 /* Tack a NULL onto the end of the list */
198 excludeList[excludeListSize] = (excludeList[excludeListSize])+1; 205 excludeList[++excludeListSize] = NULL;
199 } 206 break;
200 /* Tack a NULL onto the end of the list */
201 excludeList[excludeListSize] = NULL;
202 optind++;
203 break;
204 }
205#endif 207#endif
206 fatalError( "Unknown tar flag '%s'\n"
207 "Try `tar --help' for more information\n", optarg);
208 default: 208 default:
209 fatalError( "Unknown tar flag '%c'\n" 209 usage(tar_usage);
210 "Try `tar --help' for more information\n", **argv);
211 } 210 }
212 } 211 }
213 212
@@ -485,9 +484,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
485 int errorFlag=FALSE; 484 int errorFlag=FALSE;
486 TarHeader rawHeader; 485 TarHeader rawHeader;
487 TarInfo header; 486 TarInfo header;
488#if defined BB_FEATURE_TAR_EXCLUDE
489 char** tmpList; 487 char** tmpList;
490#endif
491 488
492 /* Open the tar file for reading. */ 489 /* Open the tar file for reading. */
493 if (!strcmp(tarName, "-")) 490 if (!strcmp(tarName, "-"))
diff --git a/tar.c b/tar.c
index d3b0e5c0a..d31661184 100644
--- a/tar.c
+++ b/tar.c
@@ -49,6 +49,7 @@
49#include <utime.h> 49#include <utime.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <sys/sysmacros.h> 51#include <sys/sysmacros.h>
52#include <getopt.h>
52 53
53/* Tar file constants */ 54/* Tar file constants */
54#ifndef MAJOR 55#ifndef MAJOR
@@ -136,6 +137,13 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
136 int verboseFlag, int argc, char **argv, char** excludeList); 137 int verboseFlag, int argc, char **argv, char** excludeList);
137#endif 138#endif
138 139
140static struct option longopts[] =
141{
142#ifdef BB_FEATURE_TAR_EXCLUDE
143 {"exclude",required_argument,NULL,'e'},
144#endif
145 {NULL,0,NULL,0}
146};
139 147
140extern int tar_main(int argc, char **argv) 148extern int tar_main(int argc, char **argv)
141{ 149{
@@ -155,7 +163,7 @@ extern int tar_main(int argc, char **argv)
155 usage(tar_usage); 163 usage(tar_usage);
156 164
157 /* do normal option parsing */ 165 /* do normal option parsing */
158 while ((opt = getopt(argc, argv, "cxtvOf:-:")) > 0) { 166 while ((opt = getopt_long(argc, argv, "cxtvOf:", longopts, NULL)) != EOF) {
159 switch (opt) { 167 switch (opt) {
160 case 'c': 168 case 'c':
161 if (extractFlag == TRUE || listFlag == TRUE) 169 if (extractFlag == TRUE || listFlag == TRUE)
@@ -186,28 +194,19 @@ extern int tar_main(int argc, char **argv)
186 if (!strcmp(tarName, "-") && createFlag == TRUE) 194 if (!strcmp(tarName, "-") && createFlag == TRUE)
187 tostdoutFlag = TRUE; 195 tostdoutFlag = TRUE;
188 break; 196 break;
189 case '-':
190#if defined BB_FEATURE_TAR_EXCLUDE 197#if defined BB_FEATURE_TAR_EXCLUDE
191 if (strcmp(optarg, "exclude")==0) { 198 case 'e':
192 if (argv[optind]==NULL) 199 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
193 fatalError( "option `--exclude' requires an argument\n"); 200 excludeList[excludeListSize] = optarg;
194 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 201 /* Remove leading "/"s */
195 excludeList[excludeListSize] = argv[optind]; 202 if (*excludeList[excludeListSize] =='/')
196 /* Remove leading "/"s */ 203 excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
197 if (*excludeList[excludeListSize] =='/') { 204 /* Tack a NULL onto the end of the list */
198 excludeList[excludeListSize] = (excludeList[excludeListSize])+1; 205 excludeList[++excludeListSize] = NULL;
199 } 206 break;
200 /* Tack a NULL onto the end of the list */
201 excludeList[excludeListSize] = NULL;
202 optind++;
203 break;
204 }
205#endif 207#endif
206 fatalError( "Unknown tar flag '%s'\n"
207 "Try `tar --help' for more information\n", optarg);
208 default: 208 default:
209 fatalError( "Unknown tar flag '%c'\n" 209 usage(tar_usage);
210 "Try `tar --help' for more information\n", **argv);
211 } 210 }
212 } 211 }
213 212
@@ -485,9 +484,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
485 int errorFlag=FALSE; 484 int errorFlag=FALSE;
486 TarHeader rawHeader; 485 TarHeader rawHeader;
487 TarInfo header; 486 TarInfo header;
488#if defined BB_FEATURE_TAR_EXCLUDE
489 char** tmpList; 487 char** tmpList;
490#endif
491 488
492 /* Open the tar file for reading. */ 489 /* Open the tar file for reading. */
493 if (!strcmp(tarName, "-")) 490 if (!strcmp(tarName, "-"))