Provide links to C file and diff for download.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user