diff --git a/Misc/gray_big.bmp b/Misc/gray_big.bmp new file mode 100644 index 00000000..fafed45f Binary files /dev/null and b/Misc/gray_big.bmp differ diff --git a/Misc/gray_big.lmp b/Misc/gray_big.lmp new file mode 100644 index 00000000..09d68e6f Binary files /dev/null and b/Misc/gray_big.lmp differ diff --git a/Misc/mk_header.c b/Misc/mk_header.c new file mode 100644 index 00000000..0c01df75 --- /dev/null +++ b/Misc/mk_header.c @@ -0,0 +1,102 @@ +/* gcc -Wall mk_header.c -o mk_header */ + +/* + +dump the bytes of given input to a C header. + +use the header in the relevant source like: + +const char array[] = +{ +# include "conback.h" +}; + +*/ + +#include +#include +#include + +int main (int argc, char **argv) +{ + FILE *f; + struct stat s; + unsigned char *buf, *ptr; + const char *output; + int i, j; + + if (argc != 2 && argc != 3) + { + printf ("Usage: mk_header [output]\n" + " output defaults to conback.h\n"); + return 1; + } + + if (stat(argv[1], &s) == -1 || + ! S_ISREG(s.st_mode) ) + { + printf ("Couldn't stat %s\n", argv[1]); + return 1; + } + + if (s.st_size == 0) + { + printf ("%s is an empty file\n", argv[1]); + return 1; + } + + buf = (unsigned char *) malloc (s.st_size); + if (!buf) + { + printf ("Couldn't malloc %ld bytes\n", + (long)s.st_size); + return 1; + } + + f = fopen (argv[1], "rb"); + if (!f) + { + printf ("Couldn't open %s\n", argv[1]); + return 1; + } + + if (fread (buf, 1, s.st_size, f) != s.st_size) + { + fclose (f); + free (buf); + printf ("Error reading %s\n", argv[1]); + return 1; + } + fclose (f); + + output = (argc == 3) ? argv[2] : "conback.h"; + f = fopen (output, "wb"); + if (!f) + { + free (buf); + printf ("Couldn't open %s\n", output); + return 1; + } + + for (i = 0, j = 0, ptr = buf; i < s.st_size; ++i) + { + fprintf (f, "0x%02x", *ptr++); + if (i == s.st_size - 1) + break; + fprintf (f, ","); + if (++j < 16) + fprintf (f, " "); + else + { + j = 0; + fprintf (f, "\n"); + } + } + fprintf (f, "\n"); + + fclose (f); + free (buf); + + return 0; +} +