commit 6f8346c3fc9fa2be042a669303195aa13039c450 from: Evan Burkey date: Wed Mar 13 17:32:27 2024 UTC update docs, new_WAD commit - 4d13ac6a73c607439e69ad96da38dab806adf15d commit + 6f8346c3fc9fa2be042a669303195aa13039c450 blob - 9ab0ced9ac03fcce95af58cb1eae389cacb70547 blob + 0d2db45523b91c80ac392c4ce59008226b77fcbf --- README.md +++ README.md @@ -1,5 +1,14 @@ -# spitWAD +# spitwad -`spitWAD` is a simple DOOM WAD management library +Originally conceived as a joke between some friends after we laughed about how it would be better to use WADs to send data +between applications then JSON, because JSON is stupid and wasteful. `spitwad` is a library for interacting with WAD +files, popularized by ID games like DOOM and Quake. You can use it in your DOOM clone, or to package your data and +send it over a network as a WAD. Why? Why not! -`DOOM1.WAD` contained in this repo is the shareware version of DOOM and is used for tests +## Requirements + +Should work on any POSIX platform out of the box + +## Usage + +Docs are a work in progress! blob - a9e26a92b4ea533f785837ef6cc73f7feb765fdd blob + 8e8812898f17bcdf50c44202a7b180e4dfd225d0 --- spitwad.c +++ spitwad.c @@ -22,9 +22,9 @@ static char* getstring(const unsigned char* data, size return s; } -int new_WAD(struct WAD* wad, const unsigned char* data, size_t data_sz) { +int new_WAD_from_data(struct WAD* wad, const unsigned char* data, size_t data_sz) { if (wad == NULL) { - return fail("Supplied wad to new_WAD was NULL"); + return fail("Supplied wad to new_WAD_from_data was NULL"); } wad->data = malloc(sizeof(unsigned char) * data_sz); @@ -98,18 +98,25 @@ int new_WAD_from_file(struct WAD* wad, const char* pat fread(buf, 1, fsz, fp); fclose(fp); - new_WAD(wad, buf, fsz); + new_WAD_from_data(wad, buf, fsz); free(buf); return 0; } +int new_WAD(struct WAD* wad) { + wad->data = NULL; + wad->data_sz = 0; + wad->directory = NULL; + wad->dir_sz = 0; + wad->dir_offset = 0; +} + void destroy_WAD(struct WAD* wad) { free(wad->data); free(wad->directory); free(wad); } - int write_to_file(struct WAD* wad, const char* path) { FILE *fp = NULL; fp = fopen(path, "wb"); blob - 3bd7f733e85e9ee7d265a5f09d0fd7e3654e5a5b blob + 3783f1be9e6f56351d578b08410921ddabb5abb9 --- spitwad.h +++ spitwad.h @@ -24,9 +24,11 @@ struct WAD { struct DirEntry *directory; }; -int new_WAD(struct WAD* wad, const unsigned char* data, size_t data_sz); +int new_WAD_from_data(struct WAD* wad, const unsigned char* data, size_t data_sz); int new_WAD_from_file(struct WAD* wad, const char* path); +int new_WAD(struct WAD* wad); void destroy_WAD(struct WAD* wad); int write_to_file(struct WAD* wad, const char* path); + #endif //SPITWAD_H