Mercurial > veg
annotate veg.c @ 0:b4d1a6e4bbde default tip
*: initial commit and research on the .veg file format
| author | Paper <paper@tflc.us> |
|---|---|
| date | Fri, 17 Oct 2025 19:01:34 -0400 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
1 /* Sony Vegas RIFF parser |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
2 * |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
3 * Ok, here's a bit of what's going on here. |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
4 * Sony Vegas uses Wave64 chunks; these are sort-of-RIFF-but-not-really. |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
5 * Most notably, they use GUIDs (aka UUIDs) instead of chunk identifiers, |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
6 * and have 64-bit chunk sizes instead of 32-bit. */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
7 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
8 #include <stdio.h> |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
9 #include <string.h> |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
10 #include <stdint.h> |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
11 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
12 /* The first chunk is the "riff_chunk" in this file. |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
13 * This is basically equivalent to a LIST chunk. */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
14 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
15 /* 5A 2D 8F B2 0F 23 D2 11 86 AF 00 C0 4F 8E DB 8A -- header chunk; always at the start |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
16 * I'm going to completely ignore this chunk, as it's not PARTICULARLY useful for me. |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
17 * also for some reason this includes the full path to the veg?? (no wonder people |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
18 * kept getting doxxed from this, hurr durr) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
19 * 6C 69 73 74 2F 91 CF 11 A5 D6 28 DB 04 C1 00 00 -- seems to be equivalent to RIFF LIST |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
20 * in fact, the beginning is "list" in ASCII |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
21 * D8 B9 CC 2C DD DE AC 46 85 3D 19 16 A9 9A 9A 02 -- LIST chunk ID (like LIST-INFO) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
22 * but I don't know what it's used for |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
23 * 39 8C 8A 5E 6B DA 99 44 B0 B2 36 63 70 9E 1C E4 -- chunk ID; part of the previous chunk |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
24 * 5B 2D 8F B2 0F 23 D2 11 86 AF 00 C0 4F 8E DB 8A -- another LIST chunk ID; this is also used as the containing identifier |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
25 * so like LIST-INFO-ISFT if it was LIST-INFO-INFO, which is odd */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
26 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
27 static const unsigned char riff_chunk[16] = "\x72\x69\x66\x66\x2E\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00"; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
28 static const unsigned char list_chunk[16] = "\x6C\x69\x73\x74\x2F\x91\xCF\x11\xA5\xD6\x28\xDB\x04\xC1\x00\x00"; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
29 /* this is the GUID used to identify the list of sources */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
30 static const unsigned char list_sources_chunk[16] = "\x5B\x2D\x8F\xB2\x0F\x23\xD2\x11\x86\xAF\x00\xC0\x4F\x8E\xDB\x8A"; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
31 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
32 /* fread() but it doesn't suck */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
33 #define freadb(fp, data, size) (fread(data, 1, size, fp)) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
34 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
35 struct w64_chunk { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
36 unsigned char id[16]; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
37 uint64_t size; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
38 int64_t offset; /* into the file */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
39 }; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
40 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
41 /* endianness-independent little endian byteswap |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
42 * (works regardless of endianness) */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
43 static uint64_t bswapLE64(uint64_t n) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
44 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
45 unsigned char *np = (unsigned char *)&n; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
46 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
47 return ((uint64_t)np[7] << 56) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
48 ((uint64_t)np[6] << 48) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
49 ((uint64_t)np[5] << 40) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
50 ((uint64_t)np[4] << 32) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
51 ((uint64_t)np[3] << 24) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
52 ((uint64_t)np[2] << 16) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
53 ((uint64_t)np[1] << 8) | |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
54 ((uint64_t)np[0]); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
55 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
56 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
57 static int w64_chunk_peek(struct w64_chunk *chunk, FILE *fp, int64_t off) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
58 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
59 if (freadb(fp, chunk->id, sizeof(chunk->id)) != sizeof(chunk->id)) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
60 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
61 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
62 if (freadb(fp, &chunk->size, sizeof(chunk->size)) != sizeof(chunk->size)) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
63 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
64 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
65 chunk->size = bswapLE64(chunk->size); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
66 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
67 /* Size includes the size of the header, for whatever reason. */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
68 if (chunk->size < 24) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
69 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
70 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
71 chunk->size -= 24; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
72 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
73 chunk->offset = ftell(fp); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
74 if (chunk->offset < 0) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
75 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
76 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
77 /* w64 sizes are aligned to 64-bit boundaries */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
78 fseek(fp, (chunk->size + 7) & ~7, SEEK_CUR); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
79 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
80 /* ehhh, okay */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
81 return ftell(fp) <= off; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
82 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
83 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
84 //#define C_STRING_UUIDS 1 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
85 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
86 static void print_uuid(unsigned char id[16]) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
87 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
88 #ifdef C_STRING_UUIDS |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
89 uint32_t i; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
90 printf("\""); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
91 for (i = 0; i < 16; i++) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
92 printf("\\x%02X", (unsigned int)id[i]); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
93 printf("\"\n"); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
94 #else |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
95 printf("{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n", |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
96 id[3], id[2], id[1], id[0], id[5], id[4], id[7], id[6], |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
97 id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
98 #endif |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
99 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
100 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
101 static void print_tabs(uint32_t tabs) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
102 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
103 uint32_t i; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
104 for (i = 0; i < tabs; i++) putc('\t', stdout); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
105 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
106 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
107 static void parse_list(FILE *fp, int64_t size, uint32_t tabs) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
108 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
109 struct w64_chunk w64; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
110 int64_t off = ftell(fp) + size; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
111 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
112 /* we're now inside the chunk, so start printing out which |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
113 * ones we have */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
114 while (w64_chunk_peek(&w64, fp, off)) { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
115 int64_t pos; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
116 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
117 pos = ftell(fp); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
118 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
119 print_tabs(tabs); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
120 print_uuid(w64.id); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
121 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
122 fseek(fp, w64.offset, SEEK_SET); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
123 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
124 if (!memcmp(list_chunk, w64.id, 16) || !memcmp(riff_chunk, w64.id, 16)) { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
125 unsigned char id[16]; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
126 freadb(fp, id, 16); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
127 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
128 print_tabs(tabs); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
129 printf("LIST UUID: "); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
130 print_uuid(id); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
131 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
132 if (!memcmp(list_sources_chunk, id, 16)) { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
133 print_tabs(tabs); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
134 printf("### This is the sources chunk!\n"); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
135 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
136 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
137 /* jump into the list */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
138 parse_list(fp, w64.size, tabs + 1); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
139 } else { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
140 print_tabs(tabs); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
141 printf("chunk data: { "); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
142 for (uint64_t i = 0; i < w64.size; i++) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
143 printf("%02x ", fgetc(fp)); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
144 printf("}\n"); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
145 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
146 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
147 fseek(fp, pos, SEEK_SET); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
148 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
149 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
150 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
151 static int parse_veg(FILE *fp) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
152 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
153 /* eh, alright */ |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
154 parse_list(fp, INT64_MAX, 0); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
155 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
156 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
157 } |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
158 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
159 int main(int argc, char *argv[]) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
160 { |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
161 FILE *fp = NULL; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
162 char riff[4]; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
163 uint32_t x; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
164 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
165 if (argc < 2) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
166 return 255; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
167 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
168 fp = fopen(argv[1], "rb"); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
169 if (!fp) |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
170 return 1; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
171 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
172 parse_veg(fp); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
173 |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
174 fclose(fp); |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
175 return 0; |
|
b4d1a6e4bbde
*: initial commit and research on the .veg file format
Paper <paper@tflc.us>
parents:
diff
changeset
|
176 } |
