/* * btimec.c -- * * Example program for libbtime */ #include #include #include #include #include "btime.h" char usage[] = "USAGE: %s [-r] \n"; int main(int argc, char **argv) { unsigned int bt; char *btimedhost; int readable = 0; int c; while ((c = getopt(argc, argv, "r")) != -1) { switch (c) { case 'r': readable = 1; break; default: fprintf(stderr, usage, argv[0]); exit(2); } } if (optind >= argc) { fprintf(stderr, usage, argv[0]); exit(2); } for ( ; optind < argc; optind++) { btimedhost = argv[optind]; bt = btime(btimedhost); if (readable) { time_t tt = bt; time_t *ttp = &tt; printf("%s: %s", btimedhost, bt ? ctime(ttp) : "down\n"); } else { printf("%s: %u\n", btimedhost, bt); } } exit(0); }