static int XSFStart(void *lpPtr, DWORD dwSize) { return !xsf_start(lpPtr, dwSize); }
// load and set up a 2sf file int read_in_file(char *name) { FILE *file; uint32 filesig; uint8 *filedata; uint64 file_len; unsigned int size; struct stat st; c = NULL; file = fopen(name, "rb"); if (!file) { RED(); printf("ERROR: could not open file %s\n", name); NORMAL(); return -1; } // get the length of the file by using fstat fstat(fileno(file), &st); if (st.st_size > UINT_MAX) { fclose(file); RED(); printf("ERROR: file size of %zu bytes is larger than maximum supported value of %u\n", st.st_size, UINT_MAX); NORMAL(); return -1; } size = (unsigned int) st.st_size; buffer = malloc((size_t) size); if (!buffer) { fclose(file); RED(); printf("ERROR: could not allocate %d bytes of memory\n", size); NORMAL(); return -1; } // read the file fread(buffer, size, 1, file); fclose(file); // init our *SF engine so we can get tags if (corlett_decode(buffer, size, &filedata, &file_len, &c) != AO_SUCCESS) { RED(); printf("ERROR: Tag format unreadable in file "); MAGENTA(); printf("%s\n", name); NORMAL(); return -1; } free(filedata); // we don't use this if (xsf_start(buffer, size) != XSF_TRUE) { RED(); printf("ERROR: vio2sf failed to load file \n"); MAGENTA(); printf("%s\n", name); NORMAL(); return -1; } return 0; }