-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.c
More file actions
61 lines (47 loc) · 1.14 KB
/
parse.c
File metadata and controls
61 lines (47 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <string.h>
#include "cpu.h"
#include "clock.h"
#include "memory.h"
#include "imemory.h"
#include "cache.h"
#include "iodev.h"
int main(int argc, char *argv[]) {
char device[11]; // The device being called (cpu, clock, or memory)
static FILE *infile;
// Open the file
infile = fopen(argv[1], "r");
// Read the whole file
while (1 == fscanf(infile, "%10s", device)) {
// Handles the clock
if (0 == strcmp(device, "clock")) {
parseClock(infile);
}
// Handles the memory
else if (0 == strcmp(device, "memory")) {
parseMemory(infile);
}
// Handles the cpu
else if (0 == strcmp(device, "cpu")) {
parseCpu(infile);
}
// Handles the imemory
else if (0 == strcmp( device, "imemory")) {
parseIMemory(infile);
}
// Handles the cache
else if (0 == strcmp( device, "cache")) {
parseCache(infile);
}
// Handles the iodevice
else if (0 == strcmp( device, "iodev")) {
parseIODevice(infile);
}
}
// Close the file
fclose(infile);
// Free the memory and imemory
memClean();
iMemClean();
return 0;
}