mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
Revert "Make packed fs always available, and manually settable"
This commit is contained in:
1 parent
b852e0f8c3
commit
bb37f72a63
83 files changed
+8051
-288
No files matched your search
@@ -5,7 +5,7 @@ SOURCES = main.c mongoose.c net.c packed_fs.c # Source code files
|
||||
CFLAGS = -W -Wall -Wextra -g -I. # Build options
|
||||
|
||||
# Mongoose build options. See https://mongoose.ws/documentation/#build-options
|
||||
CFLAGS_MONGOOSE +=
|
||||
CFLAGS_MONGOOSE += -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_LINES=1
|
||||
|
||||
ifeq ($(OS),Windows_NT) # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe
|
||||
PROG ?= example.exe # Use .exe suffix for the binary
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
#define MG_ARCH MG_ARCH_ESP32
|
||||
|
||||
#define MG_ENABLE_PACKED_FS 1
|
||||
@@ -225,7 +225,6 @@ void uart_bridge_fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
#if 1
|
||||
opts.root_dir = "/web_root";
|
||||
opts.fs = &mg_fs_packed;
|
||||
mg_mem_files = mg_packed_files;
|
||||
#else
|
||||
opts.root_dir = "web_root";
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,43 @@
|
||||
#include "mongoose.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
const char *mg_unlist(size_t no);
|
||||
const char *mg_unpack(const char *, size_t *, time_t *);
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
static const unsigned char v1[] = {
|
||||
31, 139, 8, 8, 61, 100, 194, 105, 0, 3, 109, 97, // ....=d.i..ma
|
||||
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 105, 110, // ....C..g..in
|
||||
100, 101, 120, 46, 104, 116, 109, 108, 0, 93, 144, 177, // dex.html.]..
|
||||
78, 196, 48, 12, 134, 247, 123, 138, 144, 153, 180, 176, // N.0...{.....
|
||||
49, 36, 149, 208, 245, 6, 38, 24, 64, 130, 49, 77, // 1$....&.@.1M
|
||||
124, 23, 67, 154, 148, 196, 237, 169, 111, 79, 218, 30, // |.C.....oO..
|
||||
226, 196, 100, 255, 246, 103, 203, 254, 229, 77, 251, 188, // ..d..g...M..
|
||||
127, 253, 120, 57, 48, 71, 189, 111, 118, 114, 9, 204, // ..x90G.ovr..
|
||||
235, 112, 82, 28, 2, 111, 118, 140, 73, 7, 218, 46, // .pR..ov.I...
|
||||
73, 73, 9, 201, 67, 211, 194, 132, 6, 88, 171, 179, // II..C....X..
|
||||
235, 162, 78, 86, 214, 91, 125, 99, 122, 32, 205, 140, // ..NV.[}cz ..
|
||||
211, 41, 3, 41, 62, 210, 81, 60, 112, 86, 95, 55, // .).)>.Q<pV_7
|
||||
29, 209, 32, 224, 123, 196, 73, 241, 119, 241, 246, 40, // .. .{.I.w..(
|
||||
246, 177, 31, 52, 97, 231, 129, 51, 19, 3, 65, 40, // ...4a..3..A(
|
||||
147, 79, 7, 5, 246, 4, 255, 102, 131, 238, 65, 241, // .O.....f..A.
|
||||
9, 225, 60, 196, 68, 87, 248, 25, 45, 57, 101, 215, // ..<.DW..-9e.
|
||||
211, 196, 42, 110, 25, 6, 36, 212, 94, 100, 163, 61, // ..*n..$.^d.=
|
||||
168, 251, 234, 238, 111, 153, 199, 240, 197, 18, 120, 197, // ....o.....x.
|
||||
51, 205, 30, 178, 3, 40, 219, 92, 130, 227, 165, 82, // 3....(.....R
|
||||
153, 156, 47, 184, 172, 127, 45, 144, 93, 180, 115, 35, // ../...-.].s#
|
||||
235, 53, 44, 58, 155, 132, 3, 49, 154, 135, 114, 85, // .5,:...1..rU
|
||||
31, 237, 184, 188, 144, 147, 41, 66, 99, 168, 62, 51, // ......)Bc.>3
|
||||
47, 244, 6, 21, 115, 235, 205, 228, 31, 137, 226, 92, // /...s.......
|
||||
130, 117, 1, 0, 0, 0 // .u...
|
||||
};
|
||||
static const unsigned char v2[] = {
|
||||
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 109, 97, // ....C..g..ma
|
||||
105, 110, 46, 106, 115, 0, 181, 88, 109, 111, 219, 70, // in.js..Xmo.F
|
||||
18, 254, 174, 95, 49, 80, 125, 37, 121, 165, 72, 43, // ..._1P}%y.H+
|
||||
113, 225, 131, 44, 235, 144, 6, 45, 112, 135, 38, 233, // q..,...-p.&.
|
||||
@@ -165,10 +201,10 @@ static const unsigned char v1[] = {
|
||||
106, 14, 189, 187, 24, 169, 117, 130, 89, 191, 113, 150, // j.....u.Y.q.
|
||||
114, 18, 117, 139, 172, 102, 133, 109, 199, 246, 171, 60, // r.u..f.m...<
|
||||
199, 81, 34, 226, 97, 169, 86, 130, 158, 26, 220, 113, // .Q".a.V....q
|
||||
154, 248, 11, 218, 252, 214, 171, 12, 23, 0, 0,// ...........
|
||||
154, 248, 11, 218, 252, 214, 171, 12, 23, 0, 0, 0 // ...........
|
||||
};
|
||||
static const unsigned char v2[] = {
|
||||
31, 139, 8, 8, 61, 100, 194, 105, 0, 3, 112, 114, // ....=d.i..pr
|
||||
static const unsigned char v3[] = {
|
||||
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 112, 114, // ....C..g..pr
|
||||
101, 97, 99, 116, 46, 109, 105, 110, 46, 106, 115, 0, // eact.min.js.
|
||||
157, 91, 123, 119, 219, 182, 146, 255, 127, 63, 69, 164, // .[{w.....?E.
|
||||
211, 163, 18, 43, 68, 177, 147, 182, 187, 75, 5, 213, // ...+D....K..
|
||||
@@ -611,35 +647,10 @@ static const unsigned char v2[] = {
|
||||
77, 151, 97, 116, 45, 181, 118, 45, 118, 85, 153, 107, // M.at-.v-vU.k
|
||||
232, 188, 93, 25, 184, 54, 206, 156, 124, 141, 179, 51, // ..]..6..|..3
|
||||
14, 139, 221, 126, 250, 31, 255, 11, 22, 19, 178, 116, // ...~.......t
|
||||
138, 51, 0, 0,// .3..
|
||||
};
|
||||
static const unsigned char v3[] = {
|
||||
31, 139, 8, 8, 61, 100, 194, 105, 0, 3, 105, 110, // ....=d.i..in
|
||||
100, 101, 120, 46, 104, 116, 109, 108, 0, 93, 144, 177, // dex.html.]..
|
||||
78, 196, 48, 12, 134, 247, 123, 138, 144, 153, 180, 176, // N.0...{.....
|
||||
49, 36, 149, 208, 245, 6, 38, 24, 64, 130, 49, 77, // 1$....&.@.1M
|
||||
124, 23, 67, 154, 148, 196, 237, 169, 111, 79, 218, 30, // |.C.....oO..
|
||||
226, 196, 100, 255, 246, 103, 203, 254, 229, 77, 251, 188, // ..d..g...M..
|
||||
127, 253, 120, 57, 48, 71, 189, 111, 118, 114, 9, 204, // ..x90G.ovr..
|
||||
235, 112, 82, 28, 2, 111, 118, 140, 73, 7, 218, 46, // .pR..ov.I...
|
||||
73, 73, 9, 201, 67, 211, 194, 132, 6, 88, 171, 179, // II..C....X..
|
||||
235, 162, 78, 86, 214, 91, 125, 99, 122, 32, 205, 140, // ..NV.[}cz ..
|
||||
211, 41, 3, 41, 62, 210, 81, 60, 112, 86, 95, 55, // .).)>.Q<pV_7
|
||||
29, 209, 32, 224, 123, 196, 73, 241, 119, 241, 246, 40, // .. .{.I.w..(
|
||||
246, 177, 31, 52, 97, 231, 129, 51, 19, 3, 65, 40, // ...4a..3..A(
|
||||
147, 79, 7, 5, 246, 4, 255, 102, 131, 238, 65, 241, // .O.....f..A.
|
||||
9, 225, 60, 196, 68, 87, 248, 25, 45, 57, 101, 215, // ..<.DW..-9e.
|
||||
211, 196, 42, 110, 25, 6, 36, 212, 94, 100, 163, 61, // ..*n..$.^d.=
|
||||
168, 251, 234, 238, 111, 153, 199, 240, 197, 18, 120, 197, // ....o.....x.
|
||||
51, 205, 30, 178, 3, 40, 219, 92, 130, 227, 165, 82, // 3....(.....R
|
||||
153, 156, 47, 184, 172, 127, 45, 144, 93, 180, 115, 35, // ../...-.].s#
|
||||
235, 53, 44, 58, 155, 132, 3, 49, 154, 135, 114, 85, // .5,:...1..rU
|
||||
31, 237, 184, 188, 144, 147, 41, 66, 99, 168, 62, 51, // ......)Bc.>3
|
||||
47, 244, 6, 21, 115, 235, 205, 228, 31, 137, 226, 92, // /...s.......
|
||||
130, 117, 1, 0, 0,// .u...
|
||||
138, 51, 0, 0, 0 // .3..
|
||||
};
|
||||
static const unsigned char v4[] = {
|
||||
31, 139, 8, 8, 61, 100, 194, 105, 0, 3, 115, 116, // ....=d.i..st
|
||||
31, 139, 8, 8, 67, 234, 193, 103, 0, 3, 115, 116, // ....C..g..st
|
||||
121, 108, 101, 46, 99, 115, 115, 0, 149, 85, 193, 142, // yle.css..U..
|
||||
155, 48, 16, 189, 231, 43, 92, 173, 42, 181, 171, 192, // .0...+..*...
|
||||
134, 16, 96, 33, 151, 222, 250, 17, 85, 15, 6, 155, // ..`!....U...
|
||||
@@ -707,14 +718,36 @@ static const unsigned char v4[] = {
|
||||
164, 9, 220, 6, 95, 161, 120, 245, 2, 113, 66, 79, // ...._.x..qBO
|
||||
181, 251, 194, 222, 28, 143, 16, 202, 223, 43, 229, 126, // .........+.~
|
||||
66, 50, 118, 143, 86, 46, 125, 129, 23, 255, 0, 132, // B2v.V.}.....
|
||||
122, 103, 55, 254, 7, 0, 0,// zg7....
|
||||
122, 103, 55, 254, 7, 0, 0, 0 // zg7....
|
||||
};
|
||||
|
||||
const struct mg_mem_file mg_packed_files[] = {
|
||||
{"/web_root/main.js.gz", v1, sizeof(v1), 1774347325},
|
||||
{"/web_root/preact.min.js.gz", v2, sizeof(v2), 1774347325},
|
||||
{"/web_root/index.html.gz", v3, sizeof(v3), 1774347325},
|
||||
{"/web_root/style.css.gz", v4, sizeof(v4), 1774347325},
|
||||
static const struct packed_file {
|
||||
const char *name;
|
||||
const unsigned char *data;
|
||||
size_t size;
|
||||
time_t mtime;
|
||||
} packed_files[] = {
|
||||
{"/web_root/index.html.gz", v1, sizeof(v1), 1740761667},
|
||||
{"/web_root/main.js.gz", v2, sizeof(v2), 1740761667},
|
||||
{"/web_root/preact.min.js.gz", v3, sizeof(v3), 1740761667},
|
||||
{"/web_root/style.css.gz", v4, sizeof(v4), 1740761667},
|
||||
{NULL, NULL, 0, 0}
|
||||
};
|
||||
|
||||
static int scmp(const char *a, const char *b) {
|
||||
while (*a && (*a == *b)) a++, b++;
|
||||
return *(const unsigned char *) a - *(const unsigned char *) b;
|
||||
}
|
||||
const char *mg_unlist(size_t no) {
|
||||
return packed_files[no].name;
|
||||
}
|
||||
const char *mg_unpack(const char *name, size_t *size, time_t *mtime) {
|
||||
const struct packed_file *p;
|
||||
for (p = packed_files; p->name != NULL; p++) {
|
||||
if (scmp(p->name, name) != 0) continue;
|
||||
if (size != NULL) *size = p->size - 1;
|
||||
if (mtime != NULL) *mtime = p->mtime;
|
||||
return (const char *) p->data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Reference in new issue
Block a user