version 1.5, 2005/04/03 18:31:00 |
version 1.6, 2005/04/03 18:38:28 |
|
|
|
|
void usage(const char *); |
void usage(const char *); |
void output(const struct stat *, const char *, |
void output(const struct stat *, const char *, |
const char *, int, int, int); |
const char *, int, int); |
int format1(const struct stat *, /* stat info */ |
int format1(const struct stat *, /* stat info */ |
const char *, /* the file name */ |
const char *, /* the file name */ |
const char *, int, /* the format string itself */ |
const char *, int, /* the format string itself */ |
|
|
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
struct stat st; |
struct stat st; |
int ch, rc, errs, am_readlink; |
int ch, rc, errs; |
int lsF, fmtchar, usestat, fn, nonl, quiet; |
int lsF, fmtchar, usestat, fn, nonl, quiet; |
char *statfmt, *options, *synopsis; |
char *statfmt, *options, *synopsis; |
|
|
am_readlink = 0; |
|
lsF = 0; |
lsF = 0; |
fmtchar = '\0'; |
fmtchar = '\0'; |
usestat = 0; |
usestat = 0; |
|
|
statfmt = NULL; |
statfmt = NULL; |
timefmt = NULL; |
timefmt = NULL; |
|
|
if (strcmp(__progname, "readlink") == 0) { |
options = "f:FlLnqrst:x"; |
am_readlink = 1; |
synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]"; |
options = "n"; |
|
synopsis = "[-n] [file ...]"; |
|
statfmt = "%Y"; |
|
fmtchar = 'f'; |
|
quiet = 1; |
|
} else { |
|
options = "f:FlLnqrst:x"; |
|
synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]"; |
|
} |
|
|
|
while ((ch = getopt(argc, argv, options)) != -1) |
while ((ch = getopt(argc, argv, options)) != -1) |
switch (ch) { |
switch (ch) { |
|
|
warn("%s: stat", |
warn("%s: stat", |
argc == 0 ? "(stdin)" : argv[0]); |
argc == 0 ? "(stdin)" : argv[0]); |
} else |
} else |
output(&st, argv[0], statfmt, fn, nonl, quiet); |
output(&st, argv[0], statfmt, fn, nonl); |
|
|
argv++; |
argv++; |
argc--; |
argc--; |
fn++; |
fn++; |
} while (argc > 0); |
} while (argc > 0); |
|
|
return (am_readlink ? linkfail : errs); |
return (errs); |
} |
} |
|
|
void |
void |
|
|
*/ |
*/ |
void |
void |
output(const struct stat *st, const char *file, |
output(const struct stat *st, const char *file, |
const char *statfmt, int fn, int nonl, int quiet) |
const char *statfmt, int fn, int nonl) |
{ |
{ |
int flags, size, prec, ofmt, hilo, what; |
int flags, size, prec, ofmt, hilo, what; |
char buf[PATH_MAX]; |
char buf[PATH_MAX]; |