httpd: remove fs_file::is_custom_file, use fs_file::flags instead

This commit is contained in:
Mike Kleshov 2021-01-25 21:49:17 +03:00
parent f7ff2d416c
commit 1678b21a94
3 changed files with 5 additions and 8 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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 */