summaryrefslogtreecommitdiff
path: root/tools/snapshot_viewer.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/snapshot_viewer.c')
-rw-r--r--tools/snapshot_viewer.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/snapshot_viewer.c b/tools/snapshot_viewer.c
new file mode 100644
index 0000000..30ece56
--- /dev/null
+++ b/tools/snapshot_viewer.c
@@ -0,0 +1,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;
+}