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);*/