From: pmf Date: Wed, 13 Aug 2008 15:40:54 +0000 (+0000) Subject: allow specification of the input file name on the command line X-Git-Tag: v0.12.20~480 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7d1dd76aa20f2d5f1915b66276950ad05c847b47;p=lttv.git allow specification of the input file name on the command line git-svn-id: http://ltt.polymtl.ca/svn@3009 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/masters-pmf/java_speed_test/c/main.c b/trunk/masters-pmf/java_speed_test/c/main.c index 08baaf62..de666de8 100644 --- a/trunk/masters-pmf/java_speed_test/c/main.c +++ b/trunk/masters-pmf/java_speed_test/c/main.c @@ -15,11 +15,26 @@ int main(int argc, char **argv) int result; FILE *fp; int print = 0; + int i; + char *filename = NULL; + + if(argc > 1) { + for(i=1; i= 2 && !strcmp(argv[1], "-p")) - print = 1; + if(filename == NULL) { + fprintf(stderr, "No trace file specified\n"); + return 1; + } - fp = fopen("../trace.dat", "r"); + fp = fopen(filename, "r"); if(fp == NULL) { perror("fopen"); return 1; diff --git a/trunk/masters-pmf/java_speed_test/java/read_trace.java b/trunk/masters-pmf/java_speed_test/java/read_trace.java index 91f48fd5..aacb08eb 100644 --- a/trunk/masters-pmf/java_speed_test/java/read_trace.java +++ b/trunk/masters-pmf/java_speed_test/java/read_trace.java @@ -3,9 +3,25 @@ import java.io.*; public class read_trace { public static void main(String[] args) { int tmp = 0; + boolean print = false; + String filename = ""; + + for(String s : args) { + if(s.equals("-p")) { + print = true; + } + else { + filename = s; + } + } + + if(filename.equals("")) { + System.out.println("error: no filename specified"); + return; + } try { - FileInputStream file_input = new FileInputStream ("../trace.dat"); + FileInputStream file_input = new FileInputStream (filename); BufferedInputStream buffered_input = new BufferedInputStream(file_input); DataInputStream data_input = new DataInputStream (buffered_input);