From d0b500244b0f73ecb6688a83d2c87678fd4b7431 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Thu, 27 Mar 2008 18:33:18 +0000 Subject: [PATCH] ~patch #6459: Changed file name variables to const; changed file size in httpd from u16_t to u32_t to allow file sizes > 64KB (fsdata.c file size is int) --- apps/httpserver_raw/fs.c | 12 ++++++------ apps/httpserver_raw/fs.h | 4 ++-- apps/httpserver_raw/fsdata.h | 7 ------- apps/httpserver_raw/httpd.c | 6 ++++-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/apps/httpserver_raw/fs.c b/apps/httpserver_raw/fs.c index 402c22f..5405d08 100644 --- a/apps/httpserver_raw/fs.c +++ b/apps/httpserver_raw/fs.c @@ -39,15 +39,15 @@ /*-----------------------------------------------------------------------------------*/ int -fs_open(char *name, struct fs_file *file) +fs_open(const char *name, struct fs_file *file) { - struct fsdata_file_noconst *f; + const struct fsdata_file *f; - for(f = (struct fsdata_file_noconst *)FS_ROOT; + for(f = FS_ROOT; f != NULL; - f = (struct fsdata_file_noconst *)f->next) { - if (!strcmp(name, (char *)f->name)) { - file->data = (char *)f->data; + f = f->next) { + if (!strcmp(name, (const char*)f->name)) { + file->data = f->data; file->len = f->len; return 1; } diff --git a/apps/httpserver_raw/fs.h b/apps/httpserver_raw/fs.h index 6c4eb10..1f7d434 100644 --- a/apps/httpserver_raw/fs.h +++ b/apps/httpserver_raw/fs.h @@ -33,12 +33,12 @@ #define __FS_H__ struct fs_file { - char *data; + const unsigned char *data; int len; }; /* file must be allocated by caller and will be filled in by the function. */ -int fs_open(char *name, struct fs_file *file); +int fs_open(const char *name, struct fs_file *file); #endif /* __FS_H__ */ diff --git a/apps/httpserver_raw/fsdata.h b/apps/httpserver_raw/fsdata.h index ee4947b..a6c5262 100644 --- a/apps/httpserver_raw/fsdata.h +++ b/apps/httpserver_raw/fsdata.h @@ -39,11 +39,4 @@ struct fsdata_file { const int len; }; -struct fsdata_file_noconst { - struct fsdata_file *next; - unsigned char *name; - unsigned char *data; - int len; -}; - #endif /* __FSDATA_H__ */ diff --git a/apps/httpserver_raw/httpd.c b/apps/httpserver_raw/httpd.c index eb0ef26..e13d8d0 100644 --- a/apps/httpserver_raw/httpd.c +++ b/apps/httpserver_raw/httpd.c @@ -41,8 +41,8 @@ #include "fs.h" struct http_state { - char *file; - u16_t left; + u32_t left; + const unsigned char *file; u8_t retries; }; @@ -80,6 +80,7 @@ send_data(struct tcp_pcb *pcb, struct http_state *hs) len = tcp_sndbuf(pcb); } else { len = hs->left; + LWIP_ASSERT((len == hs->left), "hs->left did not fit into u16_t!"); } do { @@ -176,6 +177,7 @@ http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) } hs->file = file.data; + LWIP_ASSERT((file.len >= 0), "File length must be positive!"); hs->left = file.len; /* printf("data %p len %ld\n", hs->file, hs->left);*/