summaryrefslogtreecommitdiffstats
path: root/btimec.c
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2009-10-01 10:58:42 -0400
committerNathan Straz <nstraz@redhat.com>2009-10-01 10:58:42 -0400
commitf5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe (patch)
tree433aabc7da536cb376fee4c3b94ceb8ad1b76d1f /btimec.c
parent8d6f3aff31e7c60b1baff013a55e34e5116abcc5 (diff)
downloadqarsh-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.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/btimec.c b/btimec.c
index f1d4518..2f791ff 100644
--- a/btimec.c
+++ b/btimec.c
@@ -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;