-
Notifications
You must be signed in to change notification settings - Fork 3
/
testdec.c
44 lines (35 loc) · 677 Bytes
/
testdec.c
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
#include <stdio.h>
#include <malloc.h>
#include <bsreader.h>
int main( int argc, const char* argv[] )
{
FILE* file;
void* buffer;
size_t size;
void* bs;
const char* piece;
if ( argc != 2 )
{
printf( "Usage: testdec <input.bs>\n" );
return 1;
}
file = fopen( argv[ 1 ], "rb" );
fseek( file, 0, SEEK_END );
size = ftell( file );
fseek( file, 0, SEEK_SET );
buffer = malloc( size );
fread( buffer, 1, size, file );
fclose( file );
bs = bsnew( buffer );
for ( ;; )
{
piece = bsread( NULL, bs, &size );
if ( !piece )
{
break;
}
printf( "%s", piece );
}
free( bs );
return 0;
}