+/* vi: set sw=4 ts=4: */
+/*
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
+ */
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#ifndef IN_BUSYBOX
-static void __attribute__ ((noreturn)) show_usage(void)
+static void ATTRIBUTE_NORETURN show_usage(void)
{
printf(
"Usage: dumpleases -f <file> -[r|a]\n\n"
" -f, --file=FILENAME Leases file to load\n"
-" -r, --remaining Interepret lease times as time remaing\n"
+" -r, --remaining Interepret lease times as time remaining\n"
" -a, --absolute Interepret lease times as expire time\n");
exit(0);
}
const char *file = LEASES_FILE;
struct dhcpOfferedAddr lease;
struct in_addr addr;
-
+
static const struct option options[] = {
{"absolute", 0, 0, 'a'},
{"remaining", 0, 0, 'r'},
int option_index = 0;
c = getopt_long(argc, argv, "arf:", options, &option_index);
if (c == -1) break;
-
+
switch (c) {
case 'a': mode = ABSOLUTE; break;
case 'r': mode = REMAINING; break;
show_usage();
}
}
-
+
fp = xfopen(file, "r");
- printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at");
+ printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at");
/* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */
while (fread(&lease, sizeof(lease), 1, fp)) {
} else printf("%s", ctime(&expires));
}
fclose(fp);
-
+
return 0;
}