Fix various issues, bad ages, etc. with ez80+uIP webserver

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1638 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-03-22 16:10:28 +00:00
parent 5cc7066b41
commit 85d77c281b
11 changed files with 751 additions and 757 deletions

View File

@ -603,6 +603,14 @@ CONFIG_NX_BLOCKING=y
CONFIG_NX_MXSERVERMSGS=32 CONFIG_NX_MXSERVERMSGS=32
CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NX_MXCLIENTMSGS=16
#
# Settings for netutils/httpd
CONFIG_NETUTILS_HTTPDSTACKSIZE=2048
CONFIG_NETUTILS_HTTPDFILESTATS=y
CONFIG_NETUTILS_HTTPDNETSTATS=y
CONFIG_NETUTILS_HTTPD_DUMPBUFFER=n
CONFIG_NETUTILS_HTTPD_DUMPPSTATE=n
# #
# Settings for examples/poll # Settings for examples/poll
CONFIG_EXAMPLE_POLL_NOMAC=y CONFIG_EXAMPLE_POLL_NOMAC=y
@ -789,6 +797,6 @@ CONFIG_STACK_POINTER=
CONFIG_IDLETHREAD_STACKSIZE=1024 CONFIG_IDLETHREAD_STACKSIZE=1024
CONFIG_USERMAIN_STACKSIZE=1024 CONFIG_USERMAIN_STACKSIZE=1024
CONFIG_PTHREAD_STACK_MIN=256 CONFIG_PTHREAD_STACK_MIN=256
CONFIG_PTHREAD_STACK_DEFAULT=1024 CONFIG_PTHREAD_STACK_DEFAULT=2048
CONFIG_HEAP_BASE= CONFIG_HEAP_BASE=
CONFIG_HEAP_SIZE= CONFIG_HEAP_SIZE=

View File

@ -441,6 +441,14 @@ CONFIG_USBSTRG_PRODUCTSTR="USBdev Storage"
CONFIG_USBSTRG_VERSIONNO=0x0399 CONFIG_USBSTRG_VERSIONNO=0x0399
CONFIG_USBSTRG_REMOVABLE=y CONFIG_USBSTRG_REMOVABLE=y
#
# Settings for netutils/httpd
CONFIG_NETUTILS_HTTPDSTACKSIZE=4096
CONFIG_NETUTILS_HTTPDFILESTATS=y
CONFIG_NETUTILS_HTTPDNETSTATS=y
CONFIG_NETUTILS_HTTPD_DUMPBUFFER=n
CONFIG_NETUTILS_HTTPD_DUMPPSTATE=n
# #
# Settings for examples/uip # Settings for examples/uip
CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2) CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2)

View File

@ -249,9 +249,17 @@ examples/udp
examples/uip examples/uip
^^^^^^^^^^^^ ^^^^^^^^^^^^
This is a port of uIP example application. It includes This is a port of uIP example application. It includes conditionally
conditionally compiled logic to exercise the uIP webserver, compiled logic to exercise the uIP webserver, webclient, telnet, smtp,
webclient, telnet, smtp, dncpc, and resolver. dncpc, and resolver.
Other configuratin items apply also to the selected network utility.
For example, the additional relevant settings for the uIP webserver
are:
CONFIG_NETUTILS_HTTPDSTACKSIZE
CONFIG_NETUTILS_HTTPDFILESTATS
CONFIG_NETUTILS_HTTPDNETSTATS
examples/usbserial examples/usbserial
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,7 @@
############################################################################ ############################################################################
# Make.defs # Make.defs
# #
# Copyright (C) 2007 Gregory Nutt. All rights reserved. # Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr> # Author: Gregory Nutt <spudmonkey@racsa.co.cr>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View File

@ -76,9 +76,6 @@
#define ISO_slash 0x2f #define ISO_slash 0x2f
#define ISO_colon 0x3a #define ISO_colon 0x3a
#undef CONFIG_NETUTILS_HTTPD_DUMPBUFFER
#undef CONFIG_NETUTILS_HTTPD_DUMPPSTATE
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
@ -186,7 +183,7 @@ static int handle_script(struct httpd_state *pstate)
int len; int len;
char *ptr; char *ptr;
while(pstate->ht_file.len > 0) while (pstate->ht_file.len > 0)
{ {
/* Check if we should start executing a script */ /* Check if we should start executing a script */
@ -353,8 +350,10 @@ static int httpd_sendfile(struct httpd_state *pstate)
pstate->ht_sndlen = 0; pstate->ht_sndlen = 0;
nvdbg("[%d] sending file '%s'\n", pstate->ht_sockfd, pstate->ht_filename);
if (!httpd_fs_open(pstate->ht_filename, &pstate->ht_file)) if (!httpd_fs_open(pstate->ht_filename, &pstate->ht_file))
{ {
ndbg("[%d] '%s' not found\n", pstate->ht_sockfd, pstate->ht_filename);
memcpy(pstate->ht_filename, g_http404path, strlen(g_http404path)); memcpy(pstate->ht_filename, g_http404path, strlen(g_http404path));
httpd_fs_open(g_http404path, &pstate->ht_file); httpd_fs_open(g_http404path, &pstate->ht_file);
if (send_headers(pstate, g_httpheader404, strlen(g_httpheader404)) == OK) if (send_headers(pstate, g_httpheader404, strlen(g_httpheader404)) == OK)
@ -466,19 +465,14 @@ static void *httpd_handler(void *arg)
if (pstate) if (pstate)
{ {
/* Loop processing each HTTP command */ /* Re-initialize the thread state structure */
// do
{
/* Re-initialize the thread state structure */
memset(pstate, 0, sizeof(struct httpd_state)); memset(pstate, 0, sizeof(struct httpd_state));
pstate->ht_sockfd = sockfd; pstate->ht_sockfd = sockfd;
/* Then handle the next httpd command */ /* Then handle the next httpd command */
ret = httpd_cmd(pstate); ret = httpd_cmd(pstate);
}
// while (ret == OK);
/* End of command processing -- Clean up and exit */ /* End of command processing -- Clean up and exit */

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/webserver/httpd.h * netutils/webserver/httpd.h
* *
* Copyright (C) 2007 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Based on uIP which also has a BSD style license: * Based on uIP which also has a BSD style license:
@ -53,7 +53,20 @@
* Definitions * Definitions
****************************************************************************/ ****************************************************************************/
#define HTTPD_FS_STATISTICS 1 /* As threads are created to handle each request, a stack must be allocated
* for the thread. Use a default if the user provided no stacksize.
*/
#ifndef CONFIG_NETUTILS_HTTPDSTACKSIZE
# define CONFIG_NETUTILS_HTTPDSTACKSIZE 4096
#endif
#undef CONFIG_NETUTILS_HTTPDFSSTATS
#define CONFIG_NETUTILS_HTTPDFSSTATS 1
#ifndef CONFIG_NET_STATISTICS
# undef CONFIG_NETUTILS_HTTPDNETSTATS
#endif
/* For efficiency reasons, the size of the IO buffer should be a multiple /* For efficiency reasons, the size of the IO buffer should be a multiple
* of the TCP MSS value. Also, the current design requires that the IO * of the TCP MSS value. Also, the current design requires that the IO
@ -66,14 +79,6 @@
#define HTTPD_MAX_FILENAME 20 #define HTTPD_MAX_FILENAME 20
/* As threads are created to handle each request, a stack must be allocated
* for the thread. Use a default if the user provided no stacksize.
*/
#ifndef CONFIG_NETUTILS_HTTPDSTACKSIZE
# define CONFIG_NETUTILS_HTTPDSTACKSIZE 4096
#endif
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
@ -99,11 +104,11 @@ struct httpd_state
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
#ifdef HTTPD_FS_STATISTICS #ifdef CONFIG_NETUTILS_HTTPDFSSTATS
#if HTTPD_FS_STATISTICS == 1 #if CONFIG_NETUTILS_HTTPDFSSTATS == 1
extern uint16 httpd_fs_count(char *name); extern uint16 httpd_fs_count(char *name);
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
/* file must be allocated by caller and will be filled in by the function. */ /* file must be allocated by caller and will be filled in by the function. */

View File

@ -1,4 +1,5 @@
/* httpd_cgi.c /****************************************************************************
* httpd_cgi.c
* Web server script interface * Web server script interface
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
@ -28,7 +29,12 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ *
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -41,134 +47,60 @@
#include "httpd_cgi.h" #include "httpd_cgi.h"
#define CONFIG_HTTPDCGI_FILESTATS 1 /****************************************************************************
#undef CONFIG_HTTPDCGI_DCPSTATS * Pre-processor Definitions
#define CONFIG_HTTPDCGI_NETSTATS 1 ****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
HTTPD_CGI_CALL(file, "file-stats", file_stats); HTTPD_CGI_CALL(file, "file-stats", file_stats);
#if CONFIG_HTTPDCGI_TCPSTATS #ifdef CONFIG_NETUTILS_HTTPDNETSTATS
HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
#endif
HTTPD_CGI_CALL(net, "net-stats", net_stats); HTTPD_CGI_CALL(net, "net-stats", net_stats);
#endif
#if 0 /* Revisit */ static const struct httpd_cgi_call *calls[] =
static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL }; {
#else #ifdef CONFIG_NETUTILS_HTTPDFILESTATS
static const struct httpd_cgi_call *calls[] = {
#ifdef CONFIG_HTTPDCGI_FILESTATS
&file, &file,
#endif #endif
#ifdef CONFIG_HTTPDCGI_DCPSTATS #ifdef CONFIG_NETUTILS_HTTPDNETSTATS
&tcp,
#endif
#ifdef CONFIG_HTTPDCGI_NETSTATS
&net, &net,
#endif #endif
NULL NULL
}; };
#endif
static const char closed[] = /* "CLOSED",*/ static const char closed[] = /* "CLOSED",*/
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0}; {0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
static const char syn_rcvd[] = /* "SYN-RCVD",*/ static const char syn_rcvd[] = /* "SYN-RCVD",*/
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 0x44, 0}; {0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 0x44, 0};
static const char syn_sent[] = /* "SYN-SENT",*/ static const char syn_sent[] = /* "SYN-SENT",*/
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 0x54, 0}; {0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 0x54, 0};
static const char established[] = /* "ESTABLISHED",*/ static const char established[] = /* "ESTABLISHED",*/
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 0x45, 0x44, 0}; {0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 0x45, 0x44, 0};
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x31, 0}; {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x31, 0};
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x32, 0}; {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 0x54, 0x2d, 0x32, 0};
static const char closing[] = /* "CLOSING",*/ static const char closing[] = /* "CLOSING",*/
{0x43, 0x4c, 0x4f, 0x53, 0x49, 0x4e, 0x47, 0}; {0x43, 0x4c, 0x4f, 0x53, 0x49, 0x4e, 0x47, 0};
static const char time_wait[] = /* "TIME-WAIT,"*/ static const char time_wait[] = /* "TIME-WAIT,"*/
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 0x49, 0x54, 0}; {0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 0x49, 0x54, 0};
static const char last_ack[] = /* "LAST-ACK"*/ static const char last_ack[] = /* "LAST-ACK"*/
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 0x4b, 0}; {0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 0x4b, 0};
#if CONFIG_HTTPDCGI_TCPSTATS /****************************************************************************
static const char *states[] = * Private Functions
{ ****************************************************************************/
closed,
syn_rcvd,
syn_sent,
established,
fin_wait_1,
fin_wait_2,
closing,
time_wait,
last_ack
};
#endif
static void nullfunction(struct httpd_state *pstate, char *ptr) static void nullfunction(struct httpd_state *pstate, char *ptr)
{ {
} }
httpd_cgifunction httpd_cgi(char *name) #ifdef CONFIG_NETUTILS_HTTPDNETSTATS
{
const struct httpd_cgi_call **f;
/* Find the matching name in the table, return the function. */
for(f = calls; *f != NULL; ++f) {
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
return (*f)->function;
}
}
#ifdef CONFIG_CPP_HAVE_WARNING
# warning REVISIT -- must wait to return
#endif
return nullfunction;
}
#ifdef CONFIG_HTTPDCGI_FILESTATS
static void file_stats(struct httpd_state *pstate, char *ptr)
{
char buffer[16];
char *pcount = strchr(ptr, ' ') + 1;
snprintf(buffer, 16, "%5u", httpd_fs_count(pcount));
(void)send(pstate->ht_sockfd, buffer, strlen(buffer), 0);
}
#endif
#if CONFIG_HTTPDCGI_TCPSTATS
static void tcp_stats(struct httpd_state *pstate, char *ptr)
{
struct uip_conn *conn;
struct httpd_state *pstate = (struct httpd_state *)arg;
char buffer[256];
for(pstate->count = 0; pstate->count < CONFIG_NET_TCP_CONNS; ++pstate->count)
{
conn = &uip_conns[pstate->count];
if((conn->tcpstateflags & UIP_TS_MASK) != UIP_CLOSED)
{
snprintf(buffer, 25t,
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->lport),
htons(conn->ripaddr[0]) >> 8,
htons(conn->ripaddr[0]) & 0xff,
htons(conn->ripaddr[1]) >> 8,
htons(conn->ripaddr[1]) & 0xff,
htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' ');
(void)send(pstate->sockout, buffer, strlen(buffer), 0);
}
}
}
#endif
#ifdef CONFIG_HTTPDCGI_NETSTATS
static void net_stats(struct httpd_state *pstate, char *ptr) static void net_stats(struct httpd_state *pstate, char *ptr)
{ {
#ifdef CONFIG_NET_STATISTICS
char buffer[16]; char buffer[16];
int i; int i;
@ -177,6 +109,35 @@ static void net_stats(struct httpd_state *pstate, char *ptr)
snprintf(buffer, 16, "%5u\n", ((uip_stats_t *)&uip_stat)[i]); snprintf(buffer, 16, "%5u\n", ((uip_stats_t *)&uip_stat)[i]);
send(pstate->ht_sockfd, buffer, strlen(buffer), 0); send(pstate->ht_sockfd, buffer, strlen(buffer), 0);
} }
#endif }
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
httpd_cgifunction httpd_cgi(char *name)
{
const struct httpd_cgi_call **f;
/* Find the matching name in the table, return the function. */
for(f = calls; *f != NULL; ++f)
{
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0)
{
return (*f)->function;
}
}
return nullfunction;
}
#ifdef CONFIG_NETUTILS_HTTPDFILESTATS
static void file_stats(struct httpd_state *pstate, char *ptr)
{
char buffer[16];
char *pcount = strchr(ptr, ' ') + 1;
snprintf(buffer, 16, "%5u", httpd_fs_count(pcount));
(void)send(pstate->ht_sockfd, buffer, strlen(buffer), 0);
} }
#endif #endif

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/webserver/httpd_fs.c * netutils/webserver/httpd_fs.c
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Based on uIP which also has a BSD style license: * Based on uIP which also has a BSD style license:
@ -38,7 +38,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Files * Included Header Files
****************************************************************************/ ****************************************************************************/
#include <sys/types.h> #include <sys/types.h>
@ -48,15 +48,27 @@
#include "httpd.h" #include "httpd.h"
#include "httpd_fsdata.h" #include "httpd_fsdata.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef NULL #ifndef NULL
#define NULL 0 #define NULL 0
#endif /* NULL */ #endif /* NULL */
/****************************************************************************
* Private Data
****************************************************************************/
#include "httpd_fsdata.c" #include "httpd_fsdata.c"
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
static uint16 count[HTTPD_FS_NUMFILES]; static uint16 count[HTTPD_FS_NUMFILES];
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
/****************************************************************************
* Private Functions
****************************************************************************/
static uint8 httpd_fs_strcmp(const char *str1, const char *str2) static uint8 httpd_fs_strcmp(const char *str1, const char *str2)
{ {
@ -79,11 +91,15 @@ static uint8 httpd_fs_strcmp(const char *str1, const char *str2)
} }
} }
/****************************************************************************
* Public Functions
****************************************************************************/
int httpd_fs_open(const char *name, struct httpd_fs_file *file) int httpd_fs_open(const char *name, struct httpd_fs_file *file)
{ {
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
uint16 i = 0; uint16 i = 0;
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
struct httpd_fsdata_file_noconst *f; struct httpd_fsdata_file_noconst *f;
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
@ -94,30 +110,30 @@ int httpd_fs_open(const char *name, struct httpd_fs_file *file)
{ {
file->data = f->data; file->data = f->data;
file->len = f->len; file->len = f->len;
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
++count[i]; ++count[i];
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
return 1; return 1;
} }
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
++i; ++i;
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
} }
return 0; return 0;
} }
void httpd_fs_init(void) void httpd_fs_init(void)
{ {
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
uint16 i; uint16 i;
for(i = 0; i < HTTPD_FS_NUMFILES; i++) for(i = 0; i < HTTPD_FS_NUMFILES; i++)
{ {
count[i] = 0; count[i] = 0;
} }
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
} }
#if HTTPD_FS_STATISTICS #if CONFIG_NETUTILS_HTTPDFSSTATS
uint16 httpd_fs_count(char *name) uint16 httpd_fs_count(char *name)
{ {
struct httpd_fsdata_file_noconst *f; struct httpd_fsdata_file_noconst *f;
@ -136,4 +152,4 @@ uint16 httpd_fs_count(char *name)
} }
return 0; return 0;
} }
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* netutils/webserver/httpd_fsdata.h * netutils/webserver/httpd_fsdata.h
* *
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Based on uIP which also has a BSD style license: * Based on uIP which also has a BSD style license:
@ -56,11 +56,11 @@ struct httpd_fsdata_file
FAR const ubyte *name; FAR const ubyte *name;
FAR const ubyte *data; FAR const ubyte *data;
int len; int len;
#ifdef HTTPD_FS_STATISTICS #ifdef CONFIG_NETUTILS_HTTPDFSSTATS
#if HTTPD_FS_STATISTICS == 1 #if CONFIG_NETUTILS_HTTPDFSSTATS == 1
uint16 count; uint16 count;
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
}; };
struct httpd_fsdata_file_noconst struct httpd_fsdata_file_noconst
@ -69,11 +69,11 @@ struct httpd_fsdata_file_noconst
FAR char *name; FAR char *name;
FAR char *data; FAR char *data;
int len; int len;
#ifdef HTTPD_FS_STATISTICS #ifdef CONFIG_NETUTILS_HTTPDFSSTATS
#if HTTPD_FS_STATISTICS == 1 #if CONFIG_NETUTILS_HTTPDFSSTATS == 1
uint16 count; uint16 count;
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
#endif /* HTTPD_FS_STATISTICS */ #endif /* CONFIG_NETUTILS_HTTPDFSSTATS */
}; };
#endif /* __HTTPD_FSDATA_H__ */ #endif /* __HTTPD_FSDATA_H__ */

View File

@ -33,27 +33,24 @@ foreach $file (@files) {
$fvar =~ s-/-_-g; $fvar =~ s-/-_-g;
$fvar =~ s-\.-_-g; $fvar =~ s-\.-_-g;
# for AVR, add PROGMEM here # for AVR, add PROGMEM here
print(OUTPUT "static const unsigned char data".$fvar."[] = {\n"); print(OUTPUT "static const unsigned char data".$fvar."[] =\n");
print(OUTPUT "\t/* $file */\n\t"); print(OUTPUT "{\n /* $file */\n\n ");
for($j = 0; $j < length($file); $j++) { for($j = 0; $j < length($file); $j++) {
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1))); printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
} }
printf(OUTPUT "0,\n"); printf(OUTPUT "0x00,\n ");
$i = 0; $i = 0;
while(read(FILE, $data, 1)) { while(read(FILE, $data, 1)) {
if($i == 0) {
print(OUTPUT "\t");
}
printf(OUTPUT "%#02x, ", unpack("C", $data)); printf(OUTPUT "%#02x, ", unpack("C", $data));
$i++; $i++;
if($i == 10) { if($i == 10) {
print(OUTPUT "\n"); print(OUTPUT "\n");
$i = 0; $i = 0;
print(OUTPUT " ");
} }
} }
print(OUTPUT "0};\n\n"); print(OUTPUT "0x00\n};\n\n");
close(FILE); close(FILE);
push(@fvars, $fvar); push(@fvars, $fvar);
push(@pfiles, $file); push(@pfiles, $file);
@ -74,5 +71,5 @@ for($i = 0; $i < @fvars; $i++) {
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n"); print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
} }
print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n"); print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n"); print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");