Commit | Line | Data |
---|---|---|
42a58cd1 JA |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <fcntl.h> | |
4 | #include <unistd.h> | |
5 | ||
6 | int main(int argc, char *argv[]) | |
7 | { | |
8 | double this_time, last_time; | |
9 | char line[256], *p; | |
10 | int major, minor, cpu, seq; | |
11 | FILE *f; | |
12 | ||
13 | if (argc < 2) { | |
14 | fprintf(stderr, "%s: file\n", argv[0]); | |
15 | return 1; | |
16 | } | |
17 | ||
18 | f = fopen(argv[1], "r"); | |
19 | if (!f) { | |
20 | perror("fopen"); | |
21 | return 1; | |
22 | } | |
23 | ||
24 | last_time = 0; | |
25 | while ((p = fgets(line, sizeof(line), f)) != NULL) { | |
26 | if (!sscanf(p, "%3d,%3d %2d %8d %lf", &major, &minor, &cpu, &seq, &this_time)) | |
27 | break; | |
28 | ||
29 | if (this_time < last_time) | |
30 | printf("%s", p); | |
31 | else | |
32 | last_time = this_time; | |
33 | } | |
34 | ||
35 | fclose(f); | |
36 | return 0; | |
37 | } |