mirror of https://github.com/rusefi/ChibiOS.git
Cleanup.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14991 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
1f49aa5cef
commit
066b450ad7
|
@ -5,7 +5,7 @@
|
|||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
USE_OPT = -Og -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
endif
|
||||
|
||||
# C specific options here (added to USE_OPT).
|
||||
|
|
|
@ -21,13 +21,88 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "lwip/apps/fs.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/apps/httpd.h"
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
static GUARDEDMEMORYPOOL_DECL (http_file_pool, sizeof(FIL), sizeof(int));
|
||||
static FIL http_file_array[16];
|
||||
|
||||
void httpd_fatfs_init(void) {
|
||||
|
||||
chGuardedPoolLoadArray(&http_file_pool,
|
||||
http_file_array,
|
||||
sizeof http_file_array / sizeof (FIL));
|
||||
}
|
||||
|
||||
int fs_open_custom(struct fs_file *file, const char *name) {
|
||||
FIL *filp;
|
||||
|
||||
filp = (FIL *) chGuardedPoolAllocTimeout(&http_file_pool, TIME_INFINITE);
|
||||
memset(file, '\0', sizeof (struct fs_file));
|
||||
|
||||
if (f_open(filp, _T(name), FA_READ) != FR_OK) {
|
||||
chGuardedPoolFree(&http_file_pool, (void *)filp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
file->data = NULL;
|
||||
file->len = (FSIZE_t)f_size(filp);
|
||||
file->index = 0;
|
||||
file->pextension = (fs_file_extension *)filp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void fs_close_custom(struct fs_file *file) {
|
||||
|
||||
if (file != NULL) {
|
||||
if (file->pextension != NULL) {
|
||||
f_close((FIL *)file->pextension);
|
||||
chGuardedPoolFree(&http_file_pool, (void *)file->pextension);
|
||||
file->pextension = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fs_read_custom(struct fs_file *file, char *buffer, int count) {
|
||||
|
||||
do {
|
||||
FRESULT res;
|
||||
UINT br;
|
||||
FIL *fil;
|
||||
|
||||
if (file == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (file->pextension == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
fil = (FIL *)file->pextension;
|
||||
if (f_eof(fil)) {
|
||||
break;
|
||||
}
|
||||
|
||||
res = f_read(fil, buffer, count, &br);
|
||||
if (res != FR_OK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
file->index += (int)br;
|
||||
return (int)br;
|
||||
|
||||
} while (false);
|
||||
|
||||
return FS_READ_EOF;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -41,17 +41,17 @@
|
|||
#endif
|
||||
|
||||
#if !LWIP_HTTPD_DYNAMIC_FILE_READ
|
||||
#error "LWIP_HTTPD_CUSTOM_FILES not enabled"
|
||||
#error "LWIP_HTTPD_DYNAMIC_FILE_READ not enabled"
|
||||
#endif
|
||||
|
||||
#if !LWIP_HTTPD_DYNAMIC_HEADERS
|
||||
#error "LWIP_HTTPD_CUSTOM_FILES not enabled"
|
||||
#error "LWIP_HTTPD_DYNAMIC_HEADERS not enabled"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void httpd_fatfs_init(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue