diff options
author | Nathan Straz <nstraz@redhat.com> | 2009-10-01 10:58:42 -0400 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2009-10-01 10:58:42 -0400 |
commit | f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe (patch) | |
tree | 433aabc7da536cb376fee4c3b94ceb8ad1b76d1f /btimec.c | |
parent | 8d6f3aff31e7c60b1baff013a55e34e5116abcc5 (diff) | |
download | qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.gz qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.xz qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.zip |
Add quiet option, document exit status
Diffstat (limited to 'btimec.c')
-rw-r--r-- | btimec.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -29,21 +29,24 @@ #include "btime.h" -char usage[] = "USAGE: %s [-r] <host>\n"; +char usage[] = "USAGE: %s [-qr] <host>\n"; int main(int argc, char **argv) { unsigned int bt; char *btimedhost; - int readable = 0; + int readable = 1; int c; int ret = 0; - while ((c = getopt(argc, argv, "r")) != -1) { + while ((c = getopt(argc, argv, "qr")) != -1) { switch (c) { + case 'q': + readable = 0; + break; case 'r': - readable = 1; + readable = 2; break; default: fprintf(stderr, usage, argv[0]); @@ -59,11 +62,11 @@ main(int argc, char **argv) for ( ; optind < argc; optind++) { btimedhost = argv[optind]; bt = btime(btimedhost); - if (readable) { + if (readable == 2) { time_t tt = bt; time_t *ttp = &tt; printf("%s: %s", btimedhost, bt ? ctime(ttp) : "down\n"); - } else { + } else if (readable == 1) { printf("%s: %u\n", btimedhost, bt); } if (bt == 0) ret = 1; |