/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0.If a copy of the MPL was not distributed with this * file, You can obtain one at http ://mozilla.org/MPL/2.0/. */ #include "ESPReader.h" #include #include #undef NDEBUG #include int main(void) { FILE *fp; errno_t ret = fopen_s(&fp, "Skyrim.esm", "rb"); if (ret || !fp) return ret; fseek(fp, 0L, SEEK_END); size_t size = ftell(fp); rewind(fp); char *buffer = malloc(size); if (!buffer) return errno; size_t read = fread(buffer, sizeof(char), size, fp); assert(read == size); size_t dc_size = espr_decompressed_size(buffer, size); char *decompressed = malloc(dc_size); if (!decompressed) return errno; espr_decompress(buffer, size, decompressed, dc_size); free(buffer); size_t formid_count = espr_formid_count(decompressed, dc_size); printf("FormID Count: %zu\n", formid_count); free(decompressed); return 0; }