diff options
author | Darren Hart <dvhltc@us.ibm.com> | 2009-12-29 14:17:37 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-29 14:40:37 -0500 |
commit | 7141d5ba5a7bad1fd822ccb9055b9cb3c96b3c45 (patch) | |
tree | c2dd681794a1418d18c47240e483e25b85c37315 /trace-graph-main.c | |
parent | 98d89eabeb07983c6db970bc795bbf32b1d16b99 (diff) |
trace-view: Add getopt support to gui tools for input file
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
LKML-Reference: <4B3A5AD1.8020001@us.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'trace-graph-main.c')
-rw-r--r-- | trace-graph-main.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/trace-graph-main.c b/trace-graph-main.c index 4eb257f..54194e1 100644 --- a/trace-graph-main.c +++ b/trace-graph-main.c | |||
@@ -1,4 +1,7 @@ | |||
1 | #define _GNU_SOURCE | ||
1 | #include <gtk/gtk.h> | 2 | #include <gtk/gtk.h> |
3 | #include <getopt.h> | ||
4 | #include <string.h> | ||
2 | 5 | ||
3 | #include "trace-cmd.h" | 6 | #include "trace-cmd.h" |
4 | #include "trace-graph.h" | 7 | #include "trace-graph.h" |
@@ -7,10 +10,18 @@ | |||
7 | 10 | ||
8 | #define TRACE_WIDTH 800 | 11 | #define TRACE_WIDTH 800 |
9 | #define TRACE_HEIGHT 600 | 12 | #define TRACE_HEIGHT 600 |
10 | #define input_file "trace.dat" | ||
11 | 13 | ||
14 | #define default_input_file "trace.dat" | ||
15 | static char *input_file = default_input_file; | ||
12 | static struct graph_info *ginfo; | 16 | static struct graph_info *ginfo; |
13 | 17 | ||
18 | void usage(char *prog) | ||
19 | { | ||
20 | printf("Usage: %s\n", prog); | ||
21 | printf(" -h Display this help message\n"); | ||
22 | printf(" -i input_file, default is %s\n", default_input_file); | ||
23 | } | ||
24 | |||
14 | /* Callback for the clicked signal of the Exit button */ | 25 | /* Callback for the clicked signal of the Exit button */ |
15 | static void | 26 | static void |
16 | exit_clicked (GtkWidget *widget, gpointer data) | 27 | exit_clicked (GtkWidget *widget, gpointer data) |
@@ -42,6 +53,21 @@ void trace_graph(int argc, char **argv) | |||
42 | GtkWidget *sub_item; | 53 | GtkWidget *sub_item; |
43 | GtkWidget *scrollwin; | 54 | GtkWidget *scrollwin; |
44 | GtkWidget *draw; | 55 | GtkWidget *draw; |
56 | int c; | ||
57 | |||
58 | while ((c = getopt(argc, argv, "hi:")) != -1) { | ||
59 | switch(c) { | ||
60 | case 'h': | ||
61 | usage(basename(argv[0])); | ||
62 | return; | ||
63 | case 'i': | ||
64 | input_file = optarg; | ||
65 | break; | ||
66 | default: | ||
67 | /* assume the other options are for gtk */ | ||
68 | break; | ||
69 | } | ||
70 | } | ||
45 | 71 | ||
46 | handle = tracecmd_open(input_file); | 72 | handle = tracecmd_open(input_file); |
47 | 73 | ||