From 1678b21a94a5660758147a721867c76fc25fd5ab Mon Sep 17 00:00:00 2001 From: Mike Kleshov Date: Mon, 25 Jan 2021 21:49:17 +0300 Subject: [PATCH] httpd: remove fs_file::is_custom_file, use fs_file::flags instead --- src/apps/http/fs.c | 7 +++---- src/apps/http/httpd.c | 2 +- src/include/lwip/apps/fs.h | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/apps/http/fs.c b/src/apps/http/fs.c index f15a4801..27094399 100644 --- a/src/apps/http/fs.c +++ b/src/apps/http/fs.c @@ -64,10 +64,9 @@ fs_open(struct fs_file *file, const char *name) #if LWIP_HTTPD_CUSTOM_FILES if (fs_open_custom(file, name)) { - file->is_custom_file = 1; + file->flags |= FS_FILE_FLAGS_CUSTOM; return ERR_OK; } - file->is_custom_file = 0; #endif /* LWIP_HTTPD_CUSTOM_FILES */ for (f = FS_ROOT; f != NULL; f = f->next) { @@ -96,7 +95,7 @@ void fs_close(struct fs_file *file) { #if LWIP_HTTPD_CUSTOM_FILES - if (file->is_custom_file) { + if ((file->flags & FS_FILE_FLAGS_CUSTOM) != 0) { fs_close_custom(file); } #endif /* LWIP_HTTPD_CUSTOM_FILES */ @@ -124,7 +123,7 @@ fs_read(struct fs_file *file, char *buffer, int count) LWIP_UNUSED_ARG(callback_arg); #endif /* LWIP_HTTPD_FS_ASYNC_READ */ #if LWIP_HTTPD_CUSTOM_FILES - if (file->is_custom_file) { + if ((file->flags & FS_FILE_FLAGS_CUSTOM) != 0) { #if LWIP_HTTPD_FS_ASYNC_READ return fs_read_async_custom(file, buffer, count, callback_fn, callback_arg); #else /* LWIP_HTTPD_FS_ASYNC_READ */ diff --git a/src/apps/http/httpd.c b/src/apps/http/httpd.c index d844d9f5..125ee851 100644 --- a/src/apps/http/httpd.c +++ b/src/apps/http/httpd.c @@ -2379,7 +2379,7 @@ http_init_file(struct http_state *hs, struct fs_file *file, int is_09, const cha hs->file = file->data; LWIP_ASSERT("File length must be positive!", (file->len >= 0)); #if LWIP_HTTPD_CUSTOM_FILES - if (file->is_custom_file && (file->data == NULL)) { + if (((file->flags & FS_FILE_FLAGS_CUSTOM) != 0) && (file->data == NULL)) { /* custom file, need to read data first (via fs_read_custom) */ hs->left = 0; } else diff --git a/src/include/lwip/apps/fs.h b/src/include/lwip/apps/fs.h index 5be77c1b..2241e886 100644 --- a/src/include/lwip/apps/fs.h +++ b/src/include/lwip/apps/fs.h @@ -54,6 +54,7 @@ struct fsdata_chksum { #define FS_FILE_FLAGS_HEADER_PERSISTENT 0x02 #define FS_FILE_FLAGS_HEADER_HTTPVER_1_1 0x04 #define FS_FILE_FLAGS_SSI 0x08 +#define FS_FILE_FLAGS_CUSTOM 0x10 /** Define FS_FILE_EXTENSION_T_DEFINED if you have typedef'ed to your private * pointer type (defaults to 'void' so the default usage is 'void*') @@ -74,9 +75,6 @@ struct fs_file { u16_t chksum_count; #endif /* HTTPD_PRECALCULATED_CHECKSUM */ u8_t flags; -#if LWIP_HTTPD_CUSTOM_FILES - u8_t is_custom_file; -#endif /* LWIP_HTTPD_CUSTOM_FILES */ #if LWIP_HTTPD_FILE_STATE void *state; #endif /* LWIP_HTTPD_FILE_STATE */