aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-09-15 22:23:41 +0000
committerMatt Kraai <kraai@debian.org>2000-09-15 22:23:41 +0000
commit6fc2a7d04da066f40ad91e3a11b6418e76181f86 (patch)
treea0e3f85a9a4400a45bdaf6cc4f2c8f2a1f1968d0
parent82cfbad2164d4f8893c87129ffa241c57edbc6bf (diff)
downloadbusybox-w32-6fc2a7d04da066f40ad91e3a11b6418e76181f86.tar.gz
busybox-w32-6fc2a7d04da066f40ad91e3a11b6418e76181f86.tar.bz2
busybox-w32-6fc2a7d04da066f40ad91e3a11b6418e76181f86.zip
Reorganize listing code.
-rw-r--r--archival/tar.c93
-rw-r--r--tar.c93
2 files changed, 94 insertions, 92 deletions
diff --git a/archival/tar.c b/archival/tar.c
index de99656c6..3e1a65062 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -564,54 +564,46 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
564 continue; 564 continue;
565 } 565 }
566 } 566 }
567 /* Special treatment if the list (-t) flag is on */
568 if (verboseFlag == TRUE && extractFlag == FALSE) {
569 int len, len1;
570 char buf[35];
571 struct tm *tm = localtime (&(header.mtime));
572
573 len=printf("%s ", modeString(header.mode));
574 memset(buf, 0, 8*sizeof(char));
575 my_getpwuid(buf, header.uid);
576 if (! *buf)
577 len+=printf("%d", header.uid);
578 else
579 len+=printf("%s", buf);
580 memset(buf, 0, 8*sizeof(char));
581 my_getgrgid(buf, header.gid);
582 if (! *buf)
583 len+=printf("/%-d ", header.gid);
584 else
585 len+=printf("/%-s ", buf);
586 567
587 if (header.type==CHRTYPE || header.type==BLKTYPE) {
588 len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
589 header.devmajor, header.devminor);
590 } else {
591 len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
592 }
593 /* Jump through some hoops to make the columns match up */
594 for(;(len+len1)<31;len++)
595 printf(" ");
596 printf(buf);
597
598 /* Use ISO 8610 time format */
599 if (tm) {
600 printf ("%04d-%02d-%02d %02d:%02d:%02d ",
601 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
602 tm->tm_hour, tm->tm_min, tm->tm_sec);
603 }
604 }
605 /* List contents if we are supposed to do that */
606 if (verboseFlag == TRUE && listFlag != TRUE) {
607 /* Now the normal listing */
608 FILE *vbFd = stdout;
609 if (tostdoutFlag == TRUE) // If the archive goes to stdout, verbose to stderr
610 vbFd = stderr;
611 fprintf(vbFd, "%s\n", header.name);
612 }
613
614 if (listFlag == TRUE) { 568 if (listFlag == TRUE) {
569 /* Special treatment if the list (-t) flag is on */
570 if (verboseFlag == TRUE) {
571 int len, len1;
572 char buf[35];
573 struct tm *tm = localtime (&(header.mtime));
574
575 len=printf("%s ", modeString(header.mode));
576 memset(buf, 0, 8*sizeof(char));
577 my_getpwuid(buf, header.uid);
578 if (! *buf)
579 len+=printf("%d", header.uid);
580 else
581 len+=printf("%s", buf);
582 memset(buf, 0, 8*sizeof(char));
583 my_getgrgid(buf, header.gid);
584 if (! *buf)
585 len+=printf("/%-d ", header.gid);
586 else
587 len+=printf("/%-s ", buf);
588
589 if (header.type==CHRTYPE || header.type==BLKTYPE) {
590 len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
591 header.devmajor, header.devminor);
592 } else {
593 len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
594 }
595 /* Jump through some hoops to make the columns match up */
596 for(;(len+len1)<31;len++)
597 printf(" ");
598 printf(buf);
599
600 /* Use ISO 8610 time format */
601 if (tm) {
602 printf ("%04d-%02d-%02d %02d:%02d:%02d ",
603 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
604 tm->tm_hour, tm->tm_min, tm->tm_sec);
605 }
606 }
615 printf("%s", header.name); 607 printf("%s", header.name);
616 if (verboseFlag == TRUE) { 608 if (verboseFlag == TRUE) {
617 if (header.type==LNKTYPE) /* If this is a link, say so */ 609 if (header.type==LNKTYPE) /* If this is a link, say so */
@@ -622,6 +614,15 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
622 printf("\n"); 614 printf("\n");
623 } 615 }
624 616
617 /* List contents if we are supposed to do that */
618 if (verboseFlag == TRUE && extractFlag == TRUE) {
619 /* Now the normal listing */
620 FILE *vbFd = stdout;
621 if (tostdoutFlag == TRUE) // If the archive goes to stdout, verbose to stderr
622 vbFd = stderr;
623 fprintf(vbFd, "%s\n", header.name);
624 }
625
625 /* Remove files if we would overwrite them */ 626 /* Remove files if we would overwrite them */
626 if (extractFlag == TRUE && tostdoutFlag == FALSE) 627 if (extractFlag == TRUE && tostdoutFlag == FALSE)
627 unlink(header.name); 628 unlink(header.name);
diff --git a/tar.c b/tar.c
index de99656c6..3e1a65062 100644
--- a/tar.c
+++ b/tar.c
@@ -564,54 +564,46 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
564 continue; 564 continue;
565 } 565 }
566 } 566 }
567 /* Special treatment if the list (-t) flag is on */
568 if (verboseFlag == TRUE && extractFlag == FALSE) {
569 int len, len1;
570 char buf[35];
571 struct tm *tm = localtime (&(header.mtime));
572
573 len=printf("%s ", modeString(header.mode));
574 memset(buf, 0, 8*sizeof(char));
575 my_getpwuid(buf, header.uid);
576 if (! *buf)
577 len+=printf("%d", header.uid);
578 else
579 len+=printf("%s", buf);
580 memset(buf, 0, 8*sizeof(char));
581 my_getgrgid(buf, header.gid);
582 if (! *buf)
583 len+=printf("/%-d ", header.gid);
584 else
585 len+=printf("/%-s ", buf);
586 567
587 if (header.type==CHRTYPE || header.type==BLKTYPE) {
588 len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
589 header.devmajor, header.devminor);
590 } else {
591 len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
592 }
593 /* Jump through some hoops to make the columns match up */
594 for(;(len+len1)<31;len++)
595 printf(" ");
596 printf(buf);
597
598 /* Use ISO 8610 time format */
599 if (tm) {
600 printf ("%04d-%02d-%02d %02d:%02d:%02d ",
601 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
602 tm->tm_hour, tm->tm_min, tm->tm_sec);
603 }
604 }
605 /* List contents if we are supposed to do that */
606 if (verboseFlag == TRUE && listFlag != TRUE) {
607 /* Now the normal listing */
608 FILE *vbFd = stdout;
609 if (tostdoutFlag == TRUE) // If the archive goes to stdout, verbose to stderr
610 vbFd = stderr;
611 fprintf(vbFd, "%s\n", header.name);
612 }
613
614 if (listFlag == TRUE) { 568 if (listFlag == TRUE) {
569 /* Special treatment if the list (-t) flag is on */
570 if (verboseFlag == TRUE) {
571 int len, len1;
572 char buf[35];
573 struct tm *tm = localtime (&(header.mtime));
574
575 len=printf("%s ", modeString(header.mode));
576 memset(buf, 0, 8*sizeof(char));
577 my_getpwuid(buf, header.uid);
578 if (! *buf)
579 len+=printf("%d", header.uid);
580 else
581 len+=printf("%s", buf);
582 memset(buf, 0, 8*sizeof(char));
583 my_getgrgid(buf, header.gid);
584 if (! *buf)
585 len+=printf("/%-d ", header.gid);
586 else
587 len+=printf("/%-s ", buf);
588
589 if (header.type==CHRTYPE || header.type==BLKTYPE) {
590 len1=snprintf(buf, sizeof(buf), "%ld,%-ld ",
591 header.devmajor, header.devminor);
592 } else {
593 len1=snprintf(buf, sizeof(buf), "%lu ", (long)header.size);
594 }
595 /* Jump through some hoops to make the columns match up */
596 for(;(len+len1)<31;len++)
597 printf(" ");
598 printf(buf);
599
600 /* Use ISO 8610 time format */
601 if (tm) {
602 printf ("%04d-%02d-%02d %02d:%02d:%02d ",
603 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
604 tm->tm_hour, tm->tm_min, tm->tm_sec);
605 }
606 }
615 printf("%s", header.name); 607 printf("%s", header.name);
616 if (verboseFlag == TRUE) { 608 if (verboseFlag == TRUE) {
617 if (header.type==LNKTYPE) /* If this is a link, say so */ 609 if (header.type==LNKTYPE) /* If this is a link, say so */
@@ -622,6 +614,15 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
622 printf("\n"); 614 printf("\n");
623 } 615 }
624 616
617 /* List contents if we are supposed to do that */
618 if (verboseFlag == TRUE && extractFlag == TRUE) {
619 /* Now the normal listing */
620 FILE *vbFd = stdout;
621 if (tostdoutFlag == TRUE) // If the archive goes to stdout, verbose to stderr
622 vbFd = stderr;
623 fprintf(vbFd, "%s\n", header.name);
624 }
625
625 /* Remove files if we would overwrite them */ 626 /* Remove files if we would overwrite them */
626 if (extractFlag == TRUE && tostdoutFlag == FALSE) 627 if (extractFlag == TRUE && tostdoutFlag == FALSE)
627 unlink(header.name); 628 unlink(header.name);