SpriteHTTPD - embedded HTTP server with read-only filesystem and templating, originally developed for ESP8266, now stand-alone and POSIX compatible.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
spritehttpd/spritehttpd/lib/espfs/espfsformat.h

45 lines
1.7 KiB

#pragma once
/*
Stupid cpio-like tool to make read-only 'filesystems' that live on the flash SPI chip of the module.
Can (will) use lzf compression (when I come around to it) to make shit quicker. Aligns names, files,
headers on 4-byte boundaries so the SPI abstraction hardware in the ESP8266 doesn't crap on itself
when trying to do a <4byte or unaligned read.
*/
/*
The idea 'borrows' from cpio: it's basically a concatenation of {header, filename, file} data.
Header, filename and file data is 32-bit aligned. The last file is indicated by data-less header
with the FLAG_LASTFILE flag set.
*/
#include <stdint.h>
/// Last file in the filesystem image
#define EFS_FLAG_LASTFILE (1<<0)
/// Gzipped file. This does not affect espfs, it's a user-level flag; un-gzip is not implemented as part
/// of the FS or CGI - gzipped files are sent directly to the browser with the appropriate header -
/// saving bandwidth and getting us better compression ratios than heatshrink can achieve for larger files.
#define EFS_FLAG_GZIP (1<<1)
/// No filesystem level compression
#define EFS_COMPRESS_NONE 0
/// The file is stored as compressed
#define EFS_COMPRESS_HEATSHRINK 1
/// Magic number leading each file record
#define EFS_MAGIC 0x73665345 /* ASCII sequence of bytes 'E' 'S' 'f' 's' interpreted as a little endian uint32_t */
/* 16 bytes long for alignment */
typedef struct {
/// Magic number
uint32_t magic;
/// File flags
uint8_t flags;
/// Filesystem-level compression used
uint8_t compression;
/// Length of the file name
uint16_t nameLen;
/// Compressed file length (differs from the decompressed size if either gzip or heatshrink is used)
uint32_t fileLenComp;
/// Decompressed file length
uint32_t fileLenDecomp;
} __attribute__((packed)) EspFsHeader;