Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "string.h"
- #include "stdlib.h"
- typedef struct music_t {
- char* name;
- unsigned int length;
- } music_t;
- int main(int argc, char** argv){
- if(argc < 2) return 1;
- music_t files[20];
- int x, c, length;
- FILE* f = fopen(argv[1], "rb");
- char namebuff[256], *nameptr = namebuff;
- memset(namebuff, 0, 256);
- for(x = 0; x < 15; x++){
- while((c = fgetc(f)) != '\0'){
- *nameptr++ = (char)c;
- }
- fseek(f, 51 - (nameptr - namebuff), SEEK_CUR);
- fread(&length, 4, 1, f);
- fseek(f, 4, SEEK_CUR);
- files[x].name = strdup(namebuff);
- files[x].length = length;
- nameptr = namebuff;
- memset(namebuff, 0, 256);
- }
- fseek(f, 0x1E00, SEEK_SET);
- for(x = 0; x < 15; x++){
- char* musicdata = malloc(files[x].length);
- fread(musicdata, files[x].length, 1, f);
- FILE* out = fopen(files[x].name+11, "wb");
- fwrite(musicdata, files[x].length, 1, out);
- fflush(out);
- fclose(out);
- free(musicdata);
- }
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement