-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimestamp_validate.c
67 lines (58 loc) · 1.46 KB
/
timestamp_validate.c
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
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Usage: gcc -o validate timestamp_validate.c
// ./validate -f [transcript you want to validate]
//
// EXAMPLE OUTPUT:
// ./validate -f transcript1.txt
// ? != 0:00:00.000 //Ignore output, comparing garbage before first two timestamps are read in.
// 0:15:23:00 != 0:15:22:00 //Error - check timestamp at 0:15:23
// 0:00:00:00 != 0:22:16:00 //Error - possibly due to reloading console and previous time marker being erased
FILE *fp = NULL;
#define DEBUG 1
void parseFile (char *file) {
char line[2048];
// doesn't handle extremely large datasets buffer is at 2048 currently
// for larger datasets use manual testing
char *token = NULL;
int a;
char tmp;
char *line2;
char prevend[12];
char start[12];
char end[12];
char seps[] = ",";
int i = 0, var = 0, ret=0;
fp = fopen(file, "rt");
if( fp != NULL ) {
while( fgets(line, sizeof(line), fp) != NULL ) {
i = 0;
tmp = line[0];
line2 = line;
a = (int) tmp;
if (a == '0') {
memcpy(&start, &line[0], 11);
start[11] = '\0';
memcpy(&end, &line[12], 11);
end[11] = '\0';
if(strcmp(prevend, start) != 0)
printf("%s != %s\n",prevend, start );
memcpy(&prevend, &end, 11);
}
}
fclose(fp);
} else {
perror(file);
}
}
int main (int argc, char *argv[]) {
if( argc < 2 ) {
printf("ERROR:Invalid Usage\n");
} else {
if(strncmp(argv[1], "-f", 2) == 0 ) {
parseFile(argv[2]);
}
}
return 0;
}