options.c (93ef08af3ef1a9fb7a3af6b7212d3ca094e9aba6) options.c (a885d9dcf9631f6bc175a29bf5427c8218d1fbea)
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 20 unchanged lines hidden (view full) ---

29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 20 unchanged lines hidden (view full) ---

29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * $Id: options.c,v 1.7 1997/02/22 14:04:33 peter Exp $
37 * $Id: options.c,v 1.8 1997/03/28 15:24:27 imp Exp $
38 */
39
40#ifndef lint
41static char const sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
42#endif /* not lint */
43
44#include <sys/types.h>
45#include <sys/time.h>

--- 158 unchanged lines hidden (view full) ---

204 flg |= AF;
205 break;
206 case 'b':
207 /*
208 * specify blocksize
209 */
210 flg |= BF;
211 if ((wrblksz = (int)str_offt(optarg)) <= 0) {
38 */
39
40#ifndef lint
41static char const sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
42#endif /* not lint */
43
44#include <sys/types.h>
45#include <sys/time.h>

--- 158 unchanged lines hidden (view full) ---

204 flg |= AF;
205 break;
206 case 'b':
207 /*
208 * specify blocksize
209 */
210 flg |= BF;
211 if ((wrblksz = (int)str_offt(optarg)) <= 0) {
212 warn(1, "Invalid block size %s", optarg);
212 pax_warn(1, "Invalid block size %s", optarg);
213 pax_usage();
214 }
215 break;
216 case 'c':
217 /*
218 * inverse match on patterns
219 */
220 cflag = 1;

--- 85 unchanged lines hidden (view full) ---

306 break;
307 case 'p':
308 /*
309 * preserver file mode bits
310 */
311 pmode = 1;
312 break;
313 default:
213 pax_usage();
214 }
215 break;
216 case 'c':
217 /*
218 * inverse match on patterns
219 */
220 cflag = 1;

--- 85 unchanged lines hidden (view full) ---

306 break;
307 case 'p':
308 /*
309 * preserver file mode bits
310 */
311 pmode = 1;
312 break;
313 default:
314 warn(1, "Invalid -p string: %c", *pt);
314 pax_warn(1, "Invalid -p string: %c", *pt);
315 pax_usage();
316 break;
317 }
318 }
319 flg |= PF;
320 break;
321 case 'r':
322 /*

--- 43 unchanged lines hidden (view full) ---

366 * specify an archive format on write
367 */
368 tmp.name = optarg;
369 if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
370 sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt))) {
371 flg |= XF;
372 break;
373 }
315 pax_usage();
316 break;
317 }
318 }
319 flg |= PF;
320 break;
321 case 'r':
322 /*

--- 43 unchanged lines hidden (view full) ---

366 * specify an archive format on write
367 */
368 tmp.name = optarg;
369 if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
370 sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt))) {
371 flg |= XF;
372 break;
373 }
374 warn(1, "Unknown -x format: %s", optarg);
374 pax_warn(1, "Unknown -x format: %s", optarg);
375 (void)fputs("pax: Known -x formats are:", stderr);
376 for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
377 (void)fprintf(stderr, " %s", fsub[i].name);
378 (void)fputs("\n\n", stderr);
379 pax_usage();
380 break;
381 case 'B':
382 /*
383 * non-standard option on number of bytes written on a
384 * single archive volume.
385 */
386 if ((wrlimit = str_offt(optarg)) <= 0) {
375 (void)fputs("pax: Known -x formats are:", stderr);
376 for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
377 (void)fprintf(stderr, " %s", fsub[i].name);
378 (void)fputs("\n\n", stderr);
379 pax_usage();
380 break;
381 case 'B':
382 /*
383 * non-standard option on number of bytes written on a
384 * single archive volume.
385 */
386 if ((wrlimit = str_offt(optarg)) <= 0) {
387 warn(1, "Invalid write limit %s", optarg);
387 pax_warn(1, "Invalid write limit %s", optarg);
388 pax_usage();
389 }
390 if (wrlimit % BLKMULT) {
388 pax_usage();
389 }
390 if (wrlimit % BLKMULT) {
391 warn(1, "Write limit is not a %d byte multiple",
391 pax_warn(1, "Write limit is not a %d byte multiple",
392 BLKMULT);
393 pax_usage();
394 }
395 flg |= CBF;
396 break;
397 case 'D':
398 /*
399 * On extraction check file inode change time before the

--- 7 unchanged lines hidden (view full) ---

407 * non-standard limit on read faults
408 * 0 indicates stop after first error, values
409 * indicate a limit, "NONE" try forever
410 */
411 flg |= CEF;
412 if (strcmp(NONE, optarg) == 0)
413 maxflt = -1;
414 else if ((maxflt = atoi(optarg)) < 0) {
392 BLKMULT);
393 pax_usage();
394 }
395 flg |= CBF;
396 break;
397 case 'D':
398 /*
399 * On extraction check file inode change time before the

--- 7 unchanged lines hidden (view full) ---

407 * non-standard limit on read faults
408 * 0 indicates stop after first error, values
409 * indicate a limit, "NONE" try forever
410 */
411 flg |= CEF;
412 if (strcmp(NONE, optarg) == 0)
413 maxflt = -1;
414 else if ((maxflt = atoi(optarg)) < 0) {
415 warn(1, "Error count value must be positive");
415 pax_warn(1, "Error count value must be positive");
416 pax_usage();
417 }
418 break;
419 case 'G':
420 /*
421 * non-standard option for selecting files within an
422 * archive by group (gid or name)
423 */

--- 118 unchanged lines hidden (view full) ---

542 case LIST:
543 case EXTRACT:
544 for (; optind < argc; optind++)
545 if (pat_add(argv[optind]) < 0)
546 pax_usage();
547 break;
548 case COPY:
549 if (optind >= argc) {
416 pax_usage();
417 }
418 break;
419 case 'G':
420 /*
421 * non-standard option for selecting files within an
422 * archive by group (gid or name)
423 */

--- 118 unchanged lines hidden (view full) ---

542 case LIST:
543 case EXTRACT:
544 for (; optind < argc; optind++)
545 if (pat_add(argv[optind]) < 0)
546 pax_usage();
547 break;
548 case COPY:
549 if (optind >= argc) {
550 warn(0, "Destination directory was not supplied");
550 pax_warn(0, "Destination directory was not supplied");
551 pax_usage();
552 }
553 --argc;
554 dirptr = argv[argc];
555 /* FALL THROUGH */
556 case ARCHIVE:
557 case APPND:
558 for (; optind < argc; optind++)

--- 40 unchanged lines hidden (view full) ---

599 * skip over -
600 */
601 break;
602 case 'b':
603 /*
604 * specify blocksize
605 */
606 if (*argv == (char *)NULL) {
551 pax_usage();
552 }
553 --argc;
554 dirptr = argv[argc];
555 /* FALL THROUGH */
556 case ARCHIVE:
557 case APPND:
558 for (; optind < argc; optind++)

--- 40 unchanged lines hidden (view full) ---

599 * skip over -
600 */
601 break;
602 case 'b':
603 /*
604 * specify blocksize
605 */
606 if (*argv == (char *)NULL) {
607 warn(1,"blocksize must be specified with 'b'");
607 pax_warn(1,"blocksize must be specified with 'b'");
608 tar_usage();
609 }
610 if ((wrblksz = (int)str_offt(*argv)) <= 0) {
608 tar_usage();
609 }
610 if ((wrblksz = (int)str_offt(*argv)) <= 0) {
611 warn(1, "Invalid block size %s", *argv);
611 pax_warn(1, "Invalid block size %s", *argv);
612 tar_usage();
613 }
614 ++argv;
615 break;
616 case 'c':
617 /*
618 * create an archive
619 */

--- 5 unchanged lines hidden (view full) ---

625 */
626 maxflt = 0;
627 break;
628 case 'f':
629 /*
630 * filename where the archive is stored
631 */
632 if (*argv == (char *)NULL) {
612 tar_usage();
613 }
614 ++argv;
615 break;
616 case 'c':
617 /*
618 * create an archive
619 */

--- 5 unchanged lines hidden (view full) ---

625 */
626 maxflt = 0;
627 break;
628 case 'f':
629 /*
630 * filename where the archive is stored
631 */
632 if (*argv == (char *)NULL) {
633 warn(1, "filename must be specified with 'f'");
633 pax_warn(1, "filename must be specified with 'f'");
634 tar_usage();
635 }
636 if ((argv[0][0] == '-') && (argv[0][1]== '\0')) {
637 /*
638 * treat a - as stdin
639 */
640 ++argv;
641 ++fstdin;

--- 246 unchanged lines hidden (view full) ---

888{
889 register OPLIST *opt;
890
891 if (ophead == NULL)
892 return(0);
893 /*
894 * print all we were given
895 */
634 tar_usage();
635 }
636 if ((argv[0][0] == '-') && (argv[0][1]== '\0')) {
637 /*
638 * treat a - as stdin
639 */
640 ++argv;
641 ++fstdin;

--- 246 unchanged lines hidden (view full) ---

888{
889 register OPLIST *opt;
890
891 if (ophead == NULL)
892 return(0);
893 /*
894 * print all we were given
895 */
896 warn(1,"These format options are not supported");
896 pax_warn(1,"These format options are not supported");
897 while ((opt = opt_next()) != NULL)
898 (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value);
899 pax_usage();
900 return(0);
901}
902
903/*
904 * opt_add()

--- 14 unchanged lines hidden (view full) ---

919#endif
920{
921 register OPLIST *opt;
922 register char *frpt;
923 register char *pt;
924 register char *endpt;
925
926 if ((str == NULL) || (*str == '\0')) {
897 while ((opt = opt_next()) != NULL)
898 (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value);
899 pax_usage();
900 return(0);
901}
902
903/*
904 * opt_add()

--- 14 unchanged lines hidden (view full) ---

919#endif
920{
921 register OPLIST *opt;
922 register char *frpt;
923 register char *pt;
924 register char *endpt;
925
926 if ((str == NULL) || (*str == '\0')) {
927 warn(0, "Invalid option name");
927 pax_warn(0, "Invalid option name");
928 return(-1);
929 }
930 frpt = endpt = str;
931
932 /*
933 * break into name and values pieces and stuff each one into a
934 * OPLIST structure. When we know the format, the format specific
935 * option function will go through this list
936 */
937 while ((frpt != NULL) && (*frpt != '\0')) {
938 if ((endpt = strchr(frpt, ',')) != NULL)
939 *endpt = '\0';
940 if ((pt = strchr(frpt, '=')) == NULL) {
928 return(-1);
929 }
930 frpt = endpt = str;
931
932 /*
933 * break into name and values pieces and stuff each one into a
934 * OPLIST structure. When we know the format, the format specific
935 * option function will go through this list
936 */
937 while ((frpt != NULL) && (*frpt != '\0')) {
938 if ((endpt = strchr(frpt, ',')) != NULL)
939 *endpt = '\0';
940 if ((pt = strchr(frpt, '=')) == NULL) {
941 warn(0, "Invalid options format");
941 pax_warn(0, "Invalid options format");
942 return(-1);
943 }
944 if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) {
942 return(-1);
943 }
944 if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) {
945 warn(0, "Unable to allocate space for option list");
945 pax_warn(0, "Unable to allocate space for option list");
946 return(-1);
947 }
948 *pt++ = '\0';
949 opt->name = frpt;
950 opt->value = pt;
951 opt->fow = NULL;
952 if (endpt != NULL)
953 frpt = endpt + 1;

--- 188 unchanged lines hidden ---
946 return(-1);
947 }
948 *pt++ = '\0';
949 opt->name = frpt;
950 opt->value = pt;
951 opt->fow = NULL;
952 if (endpt != NULL)
953 frpt = endpt + 1;

--- 188 unchanged lines hidden ---