| Index: bootstat.c
|
| diff --git a/bootstat.c b/bootstat.c
|
| index 573f9efe7880bb50bdfd6023022391f6890c3dc8..e13e0df3d3b061979f78da1f6b3c340bd4c7fd0b 100644
|
| --- a/bootstat.c
|
| +++ b/bootstat.c
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
| +// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -6,26 +6,56 @@
|
| // 'bootstat' facility. The command provides a command line wrapper
|
| // around the key functionality declared in "bootstat.h"
|
|
|
| +#include <errno.h>
|
| #include <stdio.h>
|
| #include <stdlib.h>
|
| #include <string.h>
|
|
|
| +#include <getopt.h>
|
| #include <libgen.h>
|
|
|
| #include "bootstat.h"
|
|
|
| -static void usage(char* cmd)
|
| +static void usage(const char* cmd)
|
| {
|
| - fprintf(stderr, "usage: %s <event-name>\n", basename(strdup(cmd)));
|
| + fprintf(stderr,
|
| + "usage: %s [options] <event-name>\n"
|
| + "Options:\n"
|
| + " -o/--output-dir <directory>\n"
|
| + " specify alternate directory for timestamp output\n",
|
| + basename(strdup(cmd)));
|
| exit(EXIT_FAILURE);
|
| }
|
|
|
|
|
| int main(int argc, char* argv[])
|
| {
|
| - if (argc != 2)
|
| - usage(argv[0]);
|
| -
|
| - bootstat_log(argv[1]);
|
| + static const struct option command_options[] = {
|
| + { "o", required_argument, NULL, 'o' },
|
| + { "output-dir", required_argument, NULL, 'o' },
|
| + { 0, 0, 0, 0 }
|
| + };
|
| + char *output_dir = NULL;
|
| +
|
| + for (;;) {
|
| + int c = getopt_long_only(argc, argv, "", command_options, NULL);
|
| +
|
| + if (c == -1) {
|
| + break;
|
| + }
|
| +
|
| + if (c == 'o') {
|
| + output_dir = optarg;
|
| + }
|
| + }
|
| +
|
| + if (output_dir != NULL) {
|
| + if (bootstat_set_output_directory(output_dir) < 0) {
|
| + perror(output_dir);
|
| + usage(argv[0]);
|
| + }
|
| + }
|
| +
|
| + bootstat_log(argv[optind]);
|
| return EXIT_SUCCESS;
|
| }
|
|
|