int result;
FILE *fp;
int print = 0;
+ int i;
+ char *filename = NULL;
+
+ if(argc > 1) {
+ for(i=1; i<argc; i++) {
+ if(!strcmp(argv[i], "-p")) {
+ print = 1;
+ }
+ else {
+ filename = argv[i];
+ }
+ }
+ }
- if(argc >= 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;
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);