Created
October 1, 2014 10:31
-
-
Save msg7086/7e88b3f8362ae2c84c0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define bread(buffer) fread(&buffer, sizeof(buffer), 1, fp) | |
int to_i(unsigned char* data) { | |
return (data[3]<<0) | (data[2]<<8) | (data[1]<<16) | (data[0]<<24); | |
} | |
int main() { | |
char* source = "00012.clpi"; | |
FILE * fp = fopen(source, "r"); | |
unsigned char buffer[4]; | |
bread(buffer); | |
int id = to_i(buffer); | |
if (id != 0x48444d56) | |
return -1; | |
fseek(fp, 4, SEEK_CUR); | |
const int n = 8; | |
int offsets[n]; | |
for (int i = 0; i < n; i++) | |
{ | |
bread(buffer); | |
offsets[i] = to_i(buffer); | |
} | |
int intime = 0, length = 0; | |
for (int i = 0; i < n-1; i++) | |
{ | |
if (offsets[i+1] - offsets[i] == 0x1A) | |
{ | |
fseek(fp, offsets[i] + 0x12, SEEK_SET); | |
bread(buffer); | |
intime = to_i(buffer); | |
bread(buffer); | |
length = to_i(buffer); | |
break; | |
} | |
} | |
printf("intime: %d, length: %d\n", intime, length); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment