1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#include <ungrateful.h>
#include <cynic.h>
#include <stdio.h>
int main(void) {
/*
u64 file_size, bytes_read;
Buffer buf, output_buffer;
Allocator talloc;
FILE *file;
un_init(UN_KB(10));
talloc = un_alloc_temp_get();
file = fopen(__FILE__, "rb");
if (file) {
fseek(file, 0L, SEEK_END);
file_size = ftell(file);
rewind(file);
if (file_size == 0) {
fclose(file);
return 100;
}
buf.size = file_size;
buf.data = un_memory_alloc(buf.size, talloc);
assert(buf.data != NULL);
bytes_read = fread(buf.data, sizeof(u8), buf.size, file);
if (bytes_read != buf.size) {
fclose(file);
return 120;
}
fclose(file);
} else {
return 300;
}
output_buffer = un_compress(buf, talloc);
fprintf(stdout, "Compressed: %lluB, Uncompressed: %lluB\n", output_buffer.size, buf.size);
*/
return 0;
}
|