summaryrefslogtreecommitdiff
path: root/tools/snapshot_viewer.c
blob: 30ece569eb5ef3004a45189deebc9aac3be1b3e1 (plain)
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
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]) {
    const char *file = (argc > 1) ? argv[1] : "gentoo_snapshot.txt";
    FILE *fp = fopen(file, "r");
    if (!fp) {
        perror("fopen");
        return 1;
    }

    char line[1024];
    while (fgets(line, sizeof line, fp)) {
        if (strncmp(line, "=====", 5) == 0) {
            printf("\033[1;32m%s\033[0m", line);
        } else if (strncmp(line, "##", 2) == 0) {
            printf("\033[1;34m%s\033[0m", line);
        } else if (strncmp(line, "###", 3) == 0) {
            printf("\033[1;36m%s\033[0m", line);
        } else {
            fputs(line, stdout);
        }
    }

    fclose(fp);
    return 0;
}