2011-06-04 21:33:11 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <stdlib.h>
|
2002-02-01 23:40:38 +00:00
|
|
|
#include <stdio.h>
|
2011-10-09 12:25:30 +02:00
|
|
|
|
|
|
|
#include "c.h"
|
|
|
|
#include "nls.h"
|
2002-02-01 22:47:29 +00:00
|
|
|
#include "proc/whattime.h"
|
|
|
|
#include "proc/version.h"
|
|
|
|
|
2011-10-09 12:25:30 +02:00
|
|
|
static void __attribute__ ((__noreturn__)) usage(FILE * out)
|
2011-06-04 21:33:11 +02:00
|
|
|
{
|
2011-10-09 12:25:30 +02:00
|
|
|
fputs(USAGE_HEADER, out);
|
|
|
|
fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
|
|
|
|
fputs(USAGE_OPTIONS, out);
|
|
|
|
fputs(USAGE_HELP, out);
|
|
|
|
fputs(USAGE_VERSION, out);
|
|
|
|
fprintf(out, USAGE_MAN_TAIL("uptime(1)"));
|
2011-06-04 21:33:11 +02:00
|
|
|
|
|
|
|
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
|
|
|
|
static const struct option longopts[] = {
|
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"version", no_argument, NULL, 'V'},
|
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
};
|
|
|
|
|
2012-01-03 18:48:43 +11:00
|
|
|
program_invocation_name = program_invocation_short_name;
|
2011-12-07 13:27:21 +01:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
|
2011-06-04 21:33:11 +02:00
|
|
|
while ((c = getopt_long(argc, argv, "hV", longopts, NULL)) != -1)
|
|
|
|
switch (c) {
|
|
|
|
case 'h':
|
|
|
|
usage(stdout);
|
|
|
|
case 'V':
|
2011-10-09 12:25:30 +02:00
|
|
|
printf(PROCPS_NG_VERSION);
|
2011-06-04 21:33:11 +02:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
default:
|
|
|
|
usage(stderr);
|
|
|
|
}
|
|
|
|
|
|
|
|
print_uptime();
|
|
|
|
return EXIT_SUCCESS;
|
2002-02-01 22:47:29 +00:00
|
|
|
}
|