mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
Fix mg_prefix test
This commit is contained in:
1 parent
299075c930
commit
bdb747f9de
7 files changed
+14
-14
No files matched your search
@@ -117,7 +117,7 @@ uninstall:
|
|||||||
arm: Makefile mongoose.c mongoose.h test/unit_test.c
|
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
|
$(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))> $@
|
(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
|
mongoose.h: $(HDRS) Makefile
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
// ./pack file1.data file2.data > fs.c
|
// ./pack file1.data file2.data > fs.c
|
||||||
//
|
//
|
||||||
// 3. In your application code, you can access files using this function:
|
// 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:
|
// 4. Build your app with fs.c:
|
||||||
// cc -o my_app my_app.c fs.c
|
// cc -o my_app my_app.c fs.c
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const char *code =
|
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"
|
" 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 (strcmp(p->name, name) != 0) continue;\n"
|
||||||
" if (size != NULL) *size = p->size - 1;\n"
|
" if (size != NULL) *size = p->size - 1;\n"
|
||||||
" return (const char *) p->data;\n"
|
" return (const char *) p->data;\n"
|
||||||
@@ -60,11 +60,11 @@ int main(int argc, char *argv[]) {
|
|||||||
fclose(fp);
|
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 char *name;\n");
|
||||||
printf("%s", " const unsigned char *data;\n");
|
printf("%s", " const unsigned char *data;\n");
|
||||||
printf("%s", " size_t size;\n");
|
printf("%s", " size_t size;\n");
|
||||||
printf("%s", "} g_packed_files[] = {\n");
|
printf("%s", "} packed_files[] = {\n");
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
printf(" {\"%s\", v%d, sizeof(v%d) },\n", argv[i], i, i);
|
printf(" {\"%s\", v%d, sizeof(v%d) },\n", argv[i], i, i);
|
||||||
|
|||||||
+3
-3
@@ -423,7 +423,7 @@ const char *unpack(const char *path, size_t *size) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) && defined(GCC)
|
||||||
ssize_t packed_read(void *cookie, char *buf, size_t size) {
|
ssize_t packed_read(void *cookie, char *buf, size_t size) {
|
||||||
struct packed_file *fp = (struct packed_file *) cookie;
|
struct packed_file *fp = (struct packed_file *) cookie;
|
||||||
if (size > fp->size - fp->pos) size = fp->size - fp->pos;
|
if (size > fp->size - fp->pos) size = fp->size - fp->pos;
|
||||||
@@ -452,7 +452,7 @@ int packed_close(void *cookie) {
|
|||||||
return 0;
|
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 = {
|
cookie_io_functions_t funcs = {
|
||||||
.read = packed_read,
|
.read = packed_read,
|
||||||
.write = packed_write,
|
.write = packed_write,
|
||||||
@@ -469,7 +469,7 @@ FILE *fopen_packed(const char *path, const char *mode) {
|
|||||||
return fopencookie(cookie, mode, funcs);
|
return fopencookie(cookie, mode, funcs);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
FILE *fopen_packed(const char *path, const char *mode) {
|
FILE *mg_fopen_packed(const char *path, const char *mode) {
|
||||||
(void) path, (void) mode;
|
(void) path, (void) mode;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ int packed_close(void *cookie) {
|
|||||||
return 0;
|
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 = {
|
cookie_io_functions_t funcs = {
|
||||||
.read = packed_read,
|
.read = packed_read,
|
||||||
.write = packed_write,
|
.write = packed_write,
|
||||||
@@ -58,7 +58,7 @@ FILE *fopen_packed(const char *path, const char *mode) {
|
|||||||
return fopencookie(cookie, mode, funcs);
|
return fopencookie(cookie, mode, funcs);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
FILE *fopen_packed(const char *path, const char *mode) {
|
FILE *mg_fopen_packed(const char *path, const char *mode) {
|
||||||
(void) path, (void) mode;
|
(void) path, (void) mode;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
|
|
||||||
FILE *fopen_packed(const char *path, const char *mode);
|
FILE *mg_fopen_packed(const char *path, const char *mode);
|
||||||
+1
-1
@@ -1336,7 +1336,7 @@ static void test_multipart(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_packed(void) {
|
static void test_packed(void) {
|
||||||
FILE *fp = fopen_packed("Makefile", "r");
|
FILE *fp = mg_fopen_packed("Makefile", "r");
|
||||||
#if defined(__linux__) && defined(GCC)
|
#if defined(__linux__) && defined(GCC)
|
||||||
ASSERT(fp != NULL);
|
ASSERT(fp != NULL);
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
|
|||||||
Reference in new issue
Block a user