35 lines
507 B
C
35 lines
507 B
C
#include <err.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
FILE *f;
|
|
size_t fsize;
|
|
uint8_t *buf, len, *dbuf;
|
|
|
|
f = fopen(argv[1], "rb");
|
|
fseek(f, 0, SEEK_END);
|
|
fsize = ftell(f);
|
|
rewind(f);
|
|
|
|
buf = malloc(fsize + 1);
|
|
if (buf == NULL)
|
|
err(1, NULL);
|
|
fread(buf, fsize, 1, f);
|
|
fclose(f);
|
|
|
|
buf[fsize] = 0;
|
|
|
|
len = buf[0];
|
|
|
|
dbuf = malloc(len);
|
|
if (dbuf == NULL)
|
|
err(1, NULL);
|
|
memcpy(buf +1, dbuf, fsize -1);
|
|
warnx("len: %d", len);
|
|
return 0;
|
|
}
|