Commits

Adam Knight committed 3648a82

Moved some code to memdmp.

Comments (0)

Files changed (3)

 all: finspect
 
 clean:
-	$(RM) *.o $(BINARIES)
+	$(RM) memdmp/*.o *.o $(BINARIES)
 
-finspect: output.o memdmp/memdmp.o main.o
+finspect: memdmp/output.o memdmp/memdmp.o main.o
 	$(CC) -o $@ $^
 
 .PHONY: all clean

output.c

-#include <unistd.h>
-#include "output.h"
-
-bool _useColor(FILE* f)
-{
-    return isatty(fileno(f));
-}
-
-void _print_reset(FILE* f)
-{
-    if (_useColor(f) == false) return;
-    fprintf(f, "\x1b[0m");
-}
-
-void _print_gray(FILE* f, uint8_t gray, bool background)
-{
-    if (_useColor(f) == false) return;
-    // values must be from 0-23.
-    int color = 232 + gray;
-    fprintf(f, "\x1b[%u;5;%um", (background?48:38), color);
-}
-
-void _print_color(FILE* f, uint8_t red, uint8_t green, uint8_t blue, bool background)
-{
-    if (_useColor(f) == false) return;
-    // values must be from 0-5.
-    if (red == green && green == blue) {
-        _print_gray(f, red, background);
-        return;
-    }
-    
-    int color = 16 + (36 * red) + (6 * green) + blue;
-    fprintf(f, "\x1b[%u;5;%um", (background?48:38), color);
-}

output.h

-#include <stdio.h>
-#include <stdint.h>
-#include <stdbool.h>
-
-bool _useColor(FILE* f);
-void _print_reset(FILE* f);
-void _print_gray(FILE* f, uint8_t gray, bool background);
-void _print_color(FILE* f, uint8_t red, uint8_t green, uint8_t blue, bool background);
-