head 1.4; access; symbols; locks; strict; comment @ * @; 1.4 date 2001.05.09.12.06.11; author ahuxley; state Exp; branches; next 1.3; 1.3 date 2001.03.15.08.13.31; author ahuxley; state Exp; branches; next 1.2; 1.2 date 96.10.20.10.10.21; author alexis; state Exp; branches; next 1.1; 1.1 date 96.10.19.10.57.21; author alexis; state Exp; branches; next ; desc @File Statter @ 1.4 log @widened fields 4 digit year used @ text @#include #include #include #include #define TRUE (0==0) #define FALSE (!TRUE) #define USAGE "Usage: %s [ -h ] [ -f ] file ..." char *progname; main(argc, argv) int argc; char *argv[]; { struct stat sb; char mbuf[18], abuf[18], cbuf[18]; char errbuf[256]; int had_flag_h = FALSE; int had_flag_f = FALSE; int header, fname; progname = argv[0]; header = TRUE; fname = TRUE; for (;argc > 1 && argv[1][0] == '-'; argc--,argv++) switch (argv[1][1]) { case 'h': if (had_flag_h) usage(); had_flag_h = FALSE; header = FALSE; break; case 'f': if (had_flag_f) usage(); had_flag_f = FALSE; fname = FALSE; break; default: usage(); } if (argc == 1) usage(); if (header) fprintf(stdout, "%10s %10s %10s %c %-4s %-2s %4s %4s %9s %-14s %-14s %-s\n", "dev", "rdv", "inode", 't', "mode", "ln", "uid", "gid", "size", "modified", "changed", fname ? "name" : ""); for (;argc > 1; argv++,argc--) { if (lstat(argv[1], &sb) == 0 || stat(argv[1], &sb)) { strftime(mbuf, sizeof(mbuf), "%Y%m%d%H%M%S", localtime(&sb.st_mtime)); /* last access time not used */ strftime(abuf, sizeof(abuf), "%Y%m%d%H%M%S", localtime(&sb.st_atime)); strftime(cbuf, sizeof(cbuf), "%Y%m%d%H%M%S", localtime(&sb.st_ctime)); fprintf(stdout, "%10d %10d %10d %c %04o %2d %4d %4d %9ld %14s %14s %s\n", sb.st_dev, sb.st_rdev, sb.st_ino, ( S_ISLNK(sb.st_mode) * 'l' ) | ( S_ISREG(sb.st_mode) * 'f' ) | ( S_ISDIR(sb.st_mode) * 'd' ) | ( S_ISCHR(sb.st_mode) * 'c' ) | ( S_ISBLK(sb.st_mode) * 'b' ) | ( S_ISFIFO(sb.st_mode) * 'f' ) | ( S_ISSOCK(sb.st_mode) * 's' ), sb.st_mode & 07777, sb.st_nlink, sb.st_uid, sb.st_gid, sb.st_size, mbuf, cbuf, fname ? argv[1] : ""); } else { sprintf(errbuf, "%s: %s", progname, argv[1]); perror(errbuf); } } } usage() { fprintf(stderr, USAGE, progname); fprintf(stderr, "\n"); exit(1); } @ 1.3 log @unknown - changes made a long time ago @ text @d50 1 a50 1 fprintf(stdout, "%-8s %3s %9s %c %4s %2s %4s %4s %5s %12s %12s %s\n", "dv", "rdv", "inode", 't', "mod", "ln", "uid", "gid", "size", "modified", "changed", fname ? "name" : ""); d53 5 a57 4 strftime(mbuf, sizeof(mbuf), "%y%m%d%H%M%S", localtime(&sb.st_mtime)); strftime(abuf, sizeof(abuf), "%y%m%d%H%M%S", localtime(&sb.st_atime)); strftime(cbuf, sizeof(cbuf), "%y%m%d%H%M%S", localtime(&sb.st_ctime)); fprintf(stdout, "%-8d %-3d %-9d %c %04o %2d %4d %4d %5ld %12s %12s %s\n", @ 1.2 log @fixed argument counting bug whereby program core dumped with no args. @ text @d50 1 a50 1 fprintf(stdout, "Dev RDev Inode Mode Links Uid Gid Size Last modified Last changed %s\n", fname ? "Name" : ""); d52 14 a65 6 if (stat(argv[1], &sb) == 0) { strftime(mbuf, sizeof(mbuf), "%d/%m/%y %H:%M:%S", localtime(&sb.st_mtime)); strftime(abuf, sizeof(abuf), "%d/%m/%y %H:%M:%S", localtime(&sb.st_atime)); strftime(cbuf, sizeof(cbuf), "%d/%m/%y %H:%M:%S", localtime(&sb.st_ctime)); fprintf(stdout, "%3d %5d %03d %06o %2d %3d %3d %5ld %17s %17s %s\n", sb.st_dev, sb.st_rdev, sb.st_ino, sb.st_mode, @ 1.1 log @Initial revision @ text @d27 1 a27 1 for (;argc >= 1 && argv[1][0] == '-'; argc--,argv++) @