#include #include static unsigned char buf[655360]; static int compressed_size; static int original_size; static int fname_size; static unsigned char fname[256]; static int id; static int header_size; static unsigned char header[256]; static unsigned char compressed_data[65536]; static void dump(unsigned char *p, int len) { int i; for (i = 0; i < len; i++) { printf("%02x ", *p++); if (!((i + 1) % 16)) printf("\n"); } printf("\n"); } static void analyze(int size) { int pos = 0; while (pos < size) { printf("pos:%#x ", pos); compressed_size = buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24); pos += 4; if (!compressed_size) { printf("no more data\n"); break; } original_size = buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24); pos += 4; fname_size = buf[pos] | (buf[pos + 1] << 8); pos += 2; memset(fname, 0, sizeof(fname)); memcpy(fname, &buf[pos], fname_size); pos += fname_size; id = buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24); pos += 4; header_size = buf[pos] | (buf[pos + 1] << 8); pos += 2; memset(header, 0, sizeof(header)); memcpy(header, &buf[pos], header_size); pos += header_size; memset(compressed_data, 0, sizeof(compressed_data)); memcpy(compressed_data, &buf[pos], compressed_size); pos += compressed_size; printf("compressed_size:%d ", compressed_size); printf("orignal_size:%d\n", original_size); printf("fname_size:%d [%s] ", fname_size, fname); printf("id:%#x ", id); printf("header_size:%d\n", header_size); dump(header, header_size); printf("compressed_data:\n"); dump(compressed_data, compressed_size); } } int main(int argc, char *argv[]) { FILE *fp; int result, size; fp = fopen("MUSIC.ncl", "rb"); if (fp == NULL) { printf("file open error\n"); result = EXIT_FAILURE; goto fin0; } size = fread(buf, 1, sizeof(buf), fp); printf("size %d bytes\n", size); analyze(size); fin1: fclose(fp); fin0: return result; }