diff --git a/espfstest/Makefile b/espfstest/Makefile new file mode 100644 index 0000000..11de153 --- /dev/null +++ b/espfstest/Makefile @@ -0,0 +1,10 @@ +CFLAGS=-I../lib/heatshrink -I../user -I../include -std=gnu99 + +espfs.o: espfs.c ../user/espfs.c + +espfstest: main.o espfs.o heatshrink_decoder.o + $(CC) -o $@ $^ + + +clean: + rm -f *.o espfstest diff --git a/espfstest/espfs.c b/espfstest/espfs.c new file mode 100644 index 0000000..2a10112 --- /dev/null +++ b/espfstest/espfs.c @@ -0,0 +1,3 @@ + +#include +#include "../user/espfs.c" diff --git a/espfstest/heatshrink_decoder.c b/espfstest/heatshrink_decoder.c new file mode 100644 index 0000000..e1c6dbb --- /dev/null +++ b/espfstest/heatshrink_decoder.c @@ -0,0 +1,8 @@ +#include "httpdconfig.h" +#ifdef EFS_HEATSHRINK +//Stupid wrapper so we don't have to move c-files around +//Also loads httpd-specific config. + +#include "../lib/heatshrink/heatshrink_decoder.c" + +#endif diff --git a/espfstest/main.c b/espfstest/main.c new file mode 100644 index 0000000..26143ee --- /dev/null +++ b/espfstest/main.c @@ -0,0 +1,60 @@ +/* +Simple and stupid file decompressor for an espfs image. Mostly used as a testbed for espfs.c and +the decompressors: code compiled natively is way easier to debug using gdb et all :) +*/ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "espfs.h" + +char *espFsData; + +int main(int argc, char **argv) { + int f, out; + int len; + char buff[128]; + EspFsFile *ef; + off_t size; + + if (argc!=3) { + printf("Usage: %s espfs-image file\nExpands file from the espfs-image archive.\n", argv[0]); + exit(0); + } + + f=open(argv[1], O_RDONLY); + if (f<=0) { + perror(argv[1]); + exit(1); + } + size=lseek(f, 0, SEEK_END); + espFsData=mmap(NULL, size, PROT_READ, MAP_SHARED, f, 0); + if (espFsData==MAP_FAILED) { + perror("mmap"); + exit(1); + } + + ef=espFsOpen(argv[2]); + if (ef==NULL) { + printf("Couldn't find %s in image.\n", argv[2]); + exit(1); + } + + out=open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (out<=0) { + perror(argv[2]); + exit(1); + } + + while ((len=espFsRead(ef, buff, 128))!=0) { + write(out, buff, len); + } + espFsClose(ef); + //munmap, close, ... I can't be bothered. +}