trace-view: add getopt support to gui tools for input file (resend)
PATCH 1/1 trace-view: add getopt support to gui tools for input file (resend)
Quoted 1 line
From
b3acaddbe845dd3296374a32951b29616519da86Mon Sep 17 00:00:00 2001
From: Darren Hart <[email protected]>
Date: Tue, 29 Dec 2009 11:17:37 -0800
Subject: [PATCH] trace-cmd: add getopt support to gui tools for input file
Signed-off-by Darren Hart <[email protected]>
--- kernel-shark.c | 28 +++++++++++++++++++++++++++- trace-graph-main.c | 28 +++++++++++++++++++++++++++- trace-view-main.c | 29 ++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 3 deletions(-)
kernel-shark.c +27 -1
@@ -18,12 +18,15 @@* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#define _GNU_SOURCE#include <stdio.h> #include <string.h> #include <stdarg.h> #include <fcntl.h> #include <unistd.h> #include <gtk/gtk.h> +#include <getopt.h> +#include <string.h> #include "trace-compat.h" #include "trace-cmd.h"
@@ -34,7 +37,15 @@#define TRACE_WIDTH 800#define TRACE_HEIGHT 600 -#define input_file "trace.dat" +#define default_input_file "trace.dat" +static char *input_file = default_input_file; + +void usage (char *prog) +{ +printf ("Usage: %s\n" , prog); +printf (" -h Display this help message\n" ); +printf (" -i input_file, default is %s\n" , default_input_file); +}/* graph callbacks */
@@ -161,6 +172,21 @@ void kernel_shark(int argc, char **argv)GtkWidget *draw;GtkWidget *label;GtkWidget *spin; +int c; + +while ((c =getopt (argc, argv,"hi:" )) !=-1 ) { +switch (c) { +case 'h' : +usage (basename (argv[0 ])); +return ; +case 'i' : + input_file = optarg; +break ; +default : +/* assume the other options are for gtk */ +break ; + } + } info =g_new0 (typeof (*info),1 );if (!info)
trace-graph-main.c +27 -1
@@ -1,4 +1,7 @@ +#define _GNU_SOURCE#include <gtk/gtk.h> +#include <getopt.h> +#include <string.h> #include "trace-cmd.h" #include "trace-graph.h"
@@ -7,10 +10,18 @@#define TRACE_WIDTH 800#define TRACE_HEIGHT 600 -#define input_file "trace.dat" +#define default_input_file "trace.dat" +static char *input_file = default_input_file;static struct graph_info *ginfo; +void usage (char *prog) +{ +printf ("Usage: %s\n" , prog); +printf (" -h Display this help message\n" ); +printf (" -i input_file, default is %s\n" , default_input_file); +} +/* Callback for the clicked signal of the Exit button */ static void exit_clicked (GtkWidget *widget,gpointer data)
@@ -42,6 +53,21 @@ void trace_graph(int argc, char **argv)GtkWidget *sub_item;GtkWidget *scrollwin;GtkWidget *draw; +int c; + +while ((c =getopt (argc, argv,"hi:" )) !=-1 ) { +switch (c) { +case 'h' : +usage (basename (argv[0 ])); +return ; +case 'i' : + input_file = optarg; +break ; +default : +/* assume the other options are for gtk */ +break ; + } + } handle =tracecmd_open (input_file);
trace-view-main.c +28 -1
@@ -1,4 +1,7 @@ +#define _GNU_SOURCE#include <gtk/gtk.h> +#include <getopt.h> +#include <string.h> #include "trace-cmd.h" #include "trace-view.h"
@@ -7,11 +10,20 @@#define TRACE_WIDTH 800#define TRACE_HEIGHT 600 -#define input_file "trace.dat" + +#define default_input_file "trace.dat" +static char *input_file = default_input_file;GtkWidget *trace_tree;static struct tracecmd_input *handle; +void usage (char *prog) +{ +printf ("Usage: %s\n" , prog); +printf (" -h Display this help message\n" ); +printf (" -i input_file, default is %s\n" , default_input_file); +} +/* Callback for the clicked signal of the Exit button */ static void exit_clicked (GtkWidget *widget,gpointer data)
@@ -76,6 +88,21 @@ void trace_view(int argc, char **argv)GtkWidget *scrollwin;GtkWidget *label;GtkWidget *spin; +int c; + +while ((c =getopt (argc, argv,"hi:" )) !=-1 ) { +switch (c) { +case 'h' : +usage (basename (argv[0 ])); +return ; +case 'i' : + input_file = optarg; +break ; +default : +/* assume the other options are for gtk */ +break ; + } + } handle =tracecmd_open (input_file);
Signature · 5 lines
1.6.3.3 -- Darren Hart IBM Linux Technology Center Real-Time Linux Team