Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: bootstat.c

Issue 6870023: Add "bootstat --output-dir" option. Base URL: ssh://gitrw.chromium.org:9222/bootstat.git@master
Patch Set: Get bootstat.c to where it actually compiles. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bootstat.h ('k') | bootstat_log.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Implementation of the 'bootstat' command, part of the Chromium OS 5 // Implementation of the 'bootstat' command, part of the Chromium OS
6 // 'bootstat' facility. The command provides a command line wrapper 6 // 'bootstat' facility. The command provides a command line wrapper
7 // around the key functionality declared in "bootstat.h" 7 // around the key functionality declared in "bootstat.h"
8 8
9 #include <errno.h>
9 #include <stdio.h> 10 #include <stdio.h>
10 #include <stdlib.h> 11 #include <stdlib.h>
11 #include <string.h> 12 #include <string.h>
12 13
14 #include <getopt.h>
13 #include <libgen.h> 15 #include <libgen.h>
14 16
15 #include "bootstat.h" 17 #include "bootstat.h"
16 18
17 static void usage(char* cmd) 19 static void usage(const char* cmd)
18 { 20 {
19 fprintf(stderr, "usage: %s <event-name>\n", basename(strdup(cmd))); 21 fprintf(stderr,
22 "usage: %s [options] <event-name>\n"
23 "Options:\n"
24 " -o/--output-dir <directory>\n"
25 " specify alternate directory for timestamp output\n",
26 basename(strdup(cmd)));
20 exit(EXIT_FAILURE); 27 exit(EXIT_FAILURE);
21 } 28 }
22 29
23 30
24 int main(int argc, char* argv[]) 31 int main(int argc, char* argv[])
25 { 32 {
26 if (argc != 2) 33 static const struct option command_options[] = {
27 usage(argv[0]); 34 { "o", required_argument, NULL, 'o' },
35 { "output-dir", required_argument, NULL, 'o' },
36 { 0, 0, 0, 0 }
37 };
38 char *output_dir = NULL;
28 39
29 bootstat_log(argv[1]); 40 for (;;) {
41 int c = getopt_long_only(argc, argv, "", command_options, NULL);
42
43 if (c == -1) {
44 break;
45 }
46
47 if (c == 'o') {
48 output_dir = optarg;
49 }
50 }
51
52 if (output_dir != NULL) {
53 if (bootstat_set_output_directory(output_dir) < 0) {
54 perror(output_dir);
55 usage(argv[0]);
56 }
57 }
58
59 bootstat_log(argv[optind]);
30 return EXIT_SUCCESS; 60 return EXIT_SUCCESS;
31 } 61 }
OLDNEW
« no previous file with comments | « bootstat.h ('k') | bootstat_log.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698