off_t's are quad, use %qd not %ld
[unix-history] / usr / src / usr.bin / ar / contents.c
index c5fbb7a..3e8f81a 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)contents.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)contents.c 5.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -19,9 +19,11 @@ static char sccsid[] = "@(#)contents.c       5.4 (Berkeley) %G%";
 #include <unistd.h>
 #include <tzfile.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <tzfile.h>
 #include <dirent.h>
-#include <stdio.h>
 #include <ar.h>
 #include <ar.h>
+#include <stdio.h>
+#include <string.h>
 #include "archive.h"
 #include "archive.h"
+#include "extern.h"
 
 extern CHDR chdr;                      /* converted header */
 extern char *archive;                  /* archive name */
 
 extern CHDR chdr;                      /* converted header */
 extern char *archive;                  /* archive name */
@@ -35,23 +37,19 @@ contents(argv)
        register char **argv;
 {
        register int afd, all;
        register char **argv;
 {
        register int afd, all;
-       int eval;
        struct tm *tp;
        char *file, buf[25];
        
        afd = open_archive(O_RDONLY);
 
        struct tm *tp;
        char *file, buf[25];
        
        afd = open_archive(O_RDONLY);
 
-       for (all = !*argv; get_header(afd);) {
+       for (all = !*argv; get_arobj(afd);) {
                if (all)
                        file = chdr.name;
                if (all)
                        file = chdr.name;
-               else {
-                       file = *argv;
-                       if (!files(argv))
-                               goto next;
-               }
+               else if (!(file = files(argv)))
+                       goto next;
                if (options & AR_V) {
                        (void)strmode(chdr.mode, buf);
                if (options & AR_V) {
                        (void)strmode(chdr.mode, buf);
-                       (void)printf("%s %6d/%-6d %8ld ",
+                       (void)printf("%s %6d/%-6d %8qd ",
                            buf + 1, chdr.uid, chdr.gid, chdr.size);
                        tp = localtime(&chdr.date);
                        (void)strftime(buf, sizeof(buf), "%b %e %H:%M %Y", tp);
                            buf + 1, chdr.uid, chdr.gid, chdr.size);
                        tp = localtime(&chdr.date);
                        (void)strftime(buf, sizeof(buf), "%b %e %H:%M %Y", tp);
@@ -60,10 +58,13 @@ contents(argv)
                        (void)printf("%s\n", file);
                if (!all && !*argv)
                        break;
                        (void)printf("%s\n", file);
                if (!all && !*argv)
                        break;
-next:          skipobj(afd);
+next:          skip_arobj(afd);
        } 
        } 
-       eval = 0;
-       ORPHANS;
        close_archive(afd);
        close_archive(afd);
-       return(eval);
+
+       if (*argv) {
+               orphans(argv);
+               return(1);
+       }
+       return(0);
 }
 }