Fix mg_prefix test

This commit is contained in:
Sergey Lyubka 2021-07-26 09:15:17 +01:00
parent 299075c930
commit bdb747f9de
7 changed files with 14 additions and 14 deletions

View File

@ -117,7 +117,7 @@ uninstall:
arm: Makefile mongoose.c mongoose.h test/unit_test.c
$(ARM) arm-none-eabi-gcc mongoose.c -c -Itest -DMG_ARCH=MG_ARCH_CUSTOM $(OPTS) $(WARN) $(INCS) -DMG_MAX_HTTP_HEADERS=5 -DMG_ENABLE_LINES -DMG_ENABLE_DIRECTORY_LISTING=0 -DMG_ENABLE_SSI=1
mongoose.c: Makefile
mongoose.c: Makefile $(wildcard src/*)
(cat src/license.h; echo; echo '#include "mongoose.h"' ; (for F in src/private.h src/*.c ; do echo; echo '#ifdef MG_ENABLE_LINES'; echo "#line 1 \"$$F\""; echo '#endif'; cat $$F | sed -e 's,#include ".*,,'; done))> $@
mongoose.h: $(HDRS) Makefile

View File

@ -13,7 +13,7 @@
// ./pack file1.data file2.data > fs.c
//
// 3. In your application code, you can access files using this function:
// const char *unpack(const char *file_name, size_t *size);
// const char *mg_unpack(const char *file_name, size_t *size);
//
// 4. Build your app with fs.c:
// cc -o my_app my_app.c fs.c
@ -22,9 +22,9 @@
#include <stdlib.h>
static const char *code =
"const char *unpack(const char *name, size_t *size) {\n"
"const char *mg_unpack(const char *name, size_t *size) {\n"
" const struct packed_file *p;\n"
" for (p = g_packed_files; p->name != NULL; p++) {\n"
" for (p = packed_files; p->name != NULL; p++) {\n"
" if (strcmp(p->name, name) != 0) continue;\n"
" if (size != NULL) *size = p->size - 1;\n"
" return (const char *) p->data;\n"
@ -60,11 +60,11 @@ int main(int argc, char *argv[]) {
fclose(fp);
}
printf("%s", "\nconst struct packed_file {\n");
printf("%s", "\nstatic const struct packed_file {\n");
printf("%s", " const char *name;\n");
printf("%s", " const unsigned char *data;\n");
printf("%s", " size_t size;\n");
printf("%s", "} g_packed_files[] = {\n");
printf("%s", "} packed_files[] = {\n");
for (i = 1; i < argc; i++) {
printf(" {\"%s\", v%d, sizeof(v%d) },\n", argv[i], i, i);

View File

@ -423,7 +423,7 @@ const char *unpack(const char *path, size_t *size) {
return NULL;
}
#if defined(__linux__)
#if defined(__linux__) && defined(GCC)
ssize_t packed_read(void *cookie, char *buf, size_t size) {
struct packed_file *fp = (struct packed_file *) cookie;
if (size > fp->size - fp->pos) size = fp->size - fp->pos;
@ -452,7 +452,7 @@ int packed_close(void *cookie) {
return 0;
}
FILE *fopen_packed(const char *path, const char *mode) {
FILE *mg_fopen_packed(const char *path, const char *mode) {
cookie_io_functions_t funcs = {
.read = packed_read,
.write = packed_write,
@ -469,7 +469,7 @@ FILE *fopen_packed(const char *path, const char *mode) {
return fopencookie(cookie, mode, funcs);
}
#else
FILE *fopen_packed(const char *path, const char *mode) {
FILE *mg_fopen_packed(const char *path, const char *mode) {
(void) path, (void) mode;
return NULL;
}

View File

@ -606,7 +606,7 @@ void mg_usleep(unsigned long usecs);
FILE *fopen_packed(const char *path, const char *mode);
FILE *mg_fopen_packed(const char *path, const char *mode);

View File

@ -41,7 +41,7 @@ int packed_close(void *cookie) {
return 0;
}
FILE *fopen_packed(const char *path, const char *mode) {
FILE *mg_fopen_packed(const char *path, const char *mode) {
cookie_io_functions_t funcs = {
.read = packed_read,
.write = packed_write,
@ -58,7 +58,7 @@ FILE *fopen_packed(const char *path, const char *mode) {
return fopencookie(cookie, mode, funcs);
}
#else
FILE *fopen_packed(const char *path, const char *mode) {
FILE *mg_fopen_packed(const char *path, const char *mode) {
(void) path, (void) mode;
return NULL;
}

View File

@ -2,4 +2,4 @@
#include "arch.h"
FILE *fopen_packed(const char *path, const char *mode);
FILE *mg_fopen_packed(const char *path, const char *mode);

View File

@ -1336,7 +1336,7 @@ static void test_multipart(void) {
}
static void test_packed(void) {
FILE *fp = fopen_packed("Makefile", "r");
FILE *fp = mg_fopen_packed("Makefile", "r");
#if defined(__linux__) && defined(GCC)
ASSERT(fp != NULL);
fseek(fp, 0, SEEK_END);