From c3a74a6dd54d35cf53d3b150d374bb2d55fb7486 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Fri, 6 Apr 2018 16:07:35 -0700 Subject: [PATCH] Removed old versions of code --- test/main.c | 85 ++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 70 deletions(-) diff --git a/test/main.c b/test/main.c index a8dc956..6bf10b0 100644 --- a/test/main.c +++ b/test/main.c @@ -6,47 +6,6 @@ #include "devil1pld.h" #include "devil1tex.h" -bool writedata(const char *basename, - unsigned int id, - const char *data, - unsigned int dsize) { - bool status = false; - char *fn = (char*)malloc(sizeof(char) * strlen(basename) + 4); - sprintf(fn, "%s_%d", basename, id); - FILE *out = fopen(fn, "w"); - if (out != NULL) { - fwrite(data, sizeof(char), dsize, out); - fclose(out); - status = true; - } - free(fn); - return status; -} - -void splitpld(const char *filedata, - unsigned int filesize, - const struct PldHeader *ph, - const char *name) { - char *wbuffer = NULL; // write buffer that will change. - unsigned int wsize = 0; // size of wbuffer. - unsigned int i; - unsigned int start = 0; // ending offset for data - unsigned int end = 0; // ending offset for data - for (i = 0; (i + 1) < (ph -> numOffset) + 1; i++) { - start = ph -> offsets[i]; - // the last offset still has some data until the end of file - end = (i == (ph -> numOffset) - 1) ? - filesize : ph -> offsets[i + 1]; - // copy sector to write buffer - wsize = end - start; - wbuffer = (char*)malloc(sizeof(char) * wsize); - memcpy(wbuffer, filedata + start, wsize); - // create a file. - writedata(name, i, wbuffer, wsize); - free(wbuffer); - } -} - char *loadfile(const char *fname, unsigned int *s) { FILE *f = fopen(fname, "rb"); unsigned int size = 0; // number of elements to buffer; @@ -76,19 +35,22 @@ char *loadfile(const char *fname, unsigned int *s) { return buf; } -/* bool unpackpld (const char *filedata, - unsigned int filesize, - const char *filename) { - bool status = false; - printf("fsize is %i\n", filesize); - if (filedata != NULL && filesize != 0) { - struct PldHeader *pldh = getpldh(filedata); - splitpld(filedata, filesize, pldh, filename); - destroypldh(pldh); - status = true; +void write(const char *filename, + const char* t, + unsigned int size) { + if (filename == NULL) { + return; } - return status; -} */ + unsigned int written = 0; + FILE *out = fopen(filename, "wb"); + if (out != NULL) { + written = fwrite(t, sizeof(unsigned char), size, out); + fclose(out); + if (written == 0) { + perror("texture write error"); + } + } +} bool unpackpld(const char *filedata, unsigned int filesize, @@ -111,23 +73,6 @@ bool unpackpld(const char *filedata, return true; } -void write(const char *filename, - const char* t, - unsigned int size) { - if (filename == NULL) { - return; - } - unsigned int written = 0; - FILE *out = fopen(filename, "wb"); - if (out != NULL) { - written = fwrite(t, sizeof(unsigned char), size, out); - fclose(out); - if (written == 0) { - perror("texture write error"); - } - } -} - void exporttextures(const char *filedata, unsigned int filesize, const char *filename) {