diff --git a/platform/avr-raven/apps/raven-webserver/http-strings.c b/platform/avr-raven/apps/raven-webserver/http-strings.c index f6b86dae6..c78c70aa5 100644 --- a/platform/avr-raven/apps/raven-webserver/http-strings.c +++ b/platform/avr-raven/apps/raven-webserver/http-strings.c @@ -1,3 +1,4 @@ +#if 0 /*This file not used when strings reside in flash memory only*/ const char http_http[8] = /* "http://" */ {0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, }; @@ -100,3 +101,4 @@ const char http_text[6] = const char http_txt[5] = /* ".txt" */ {0x2e, 0x74, 0x78, 0x74, }; +#endif diff --git a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c index 57ce361ff..e6d21d81a 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c +++ b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: httpd-cgi.c,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $ + * $Id: httpd-cgi.c,v 1.2 2009/06/19 17:11:28 dak664 Exp $ * */ @@ -49,61 +49,35 @@ #include "httpd.h" #include "httpd-cgi.h" #include "httpd-fs.h" +#include "httpd-fsdata.h" -#include "lib/petsciiconv.h" +//#include "lib/petsciiconv.h" #include "sensors.h" static struct httpd_cgi_call *calls = NULL; -static const char closed[] = /* "CLOSED",*/ -{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0}; -static const char syn_rcvd[] = /* "SYN-RCVD",*/ -{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, - 0x44, 0}; -static const char syn_sent[] = /* "SYN-SENT",*/ -{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, - 0x54, 0}; -static const char established[] = /* "ESTABLISHED",*/ -{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, - 0x53, 0x48, 0x45, 0x44, 0}; -static const char fin_wait_1[] = /* "FIN-WAIT-1",*/ -{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, - 0x54, 0x2d, 0x31, 0}; -static const char fin_wait_2[] = /* "FIN-WAIT-2",*/ -{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, - 0x54, 0x2d, 0x32, 0}; -static const char closing[] = /* "CLOSING",*/ -{0x43, 0x4c, 0x4f, 0x53, 0x49, - 0x4e, 0x47, 0}; -static const char time_wait[] = /* "TIME-WAIT,"*/ -{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, - 0x49, 0x54, 0}; -static const char last_ack[] = /* "LAST-ACK"*/ -{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, - 0x4b, 0}; -static const char none[] = /* "NONE"*/ -{0x4e, 0x4f, 0x4e, 0x45, 0}; -static const char running[] = /* "RUNNING"*/ -{0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, - 0}; -static const char called[] = /* "CALLED"*/ -{0x43, 0x41, 0x4c, 0x4c, 0x45, 0x44, 0}; -static const char file_name[] = /* "file-stats"*/ -{0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, - 0x61, 0x74, 0x73, 0}; -static const char tcp_name[] = /* "tcp-connections"*/ -{0x74, 0x63, 0x70, 0x2d, 0x63, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0}; -static const char proc_name[] = /* "processes"*/ -{0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, - 0x65, 0x73, 0}; - -static const char sensor_name[] = "sensors"; - -char sensor_temperature[12]; +/*cgi function names*/ +#if HTTPD_FS_STATISTICS +static const char file_name[] PROGMEM = "file-stats"; +#endif +static const char tcp_name[] PROGMEM = "tcp-connections"; +static const char proc_name[] PROGMEM = "processes"; +static const char sensor_name[] PROGMEM = "sensors"; +/*Process states for processes cgi*/ +static const char closed[] PROGMEM = "CLOSED"; +static const char syn_rcvd[] PROGMEM = "SYN-RCVD"; +static const char syn_sent[] PROGMEM = "SYN-SENT"; +static const char established[] PROGMEM = "ESTABLISHED"; +static const char fin_wait_1[] PROGMEM = "FIN-WAIT-1"; +static const char fin_wait_2[] PROGMEM = "FIN-WAIT-2"; +static const char closing[] PROGMEM = "CLOSING"; +static const char time_wait[] PROGMEM = "TIME-WAIT"; +static const char last_ack[] PROGMEM = "LAST-ACK"; +static const char none[] PROGMEM = "NONE"; +static const char running[] PROGMEM = "RUNNING"; +static const char called[] PROGMEM = "CALLED"; static const char *states[] = { closed, syn_rcvd, @@ -118,6 +92,8 @@ static const char *states[] = { running, called}; + char sensor_temperature[12]; + uint8_t sprint_ip6(uip_ip6addr_t addr, char * result); @@ -142,30 +118,53 @@ httpd_cgi(char *name) /* Find the matching name in the table, return the function. */ for(f = calls; f != NULL; f = f->next) { - if(strncmp(f->name, name, strlen(f->name)) == 0) { + if(strncmp_P(name, f->name, strlen_P(f->name)) == 0) { return f->function; } } return nullfunction; } + +#if HTTPD_FS_STATISTICS +static char *thisfilename; /*---------------------------------------------------------------------------*/ static unsigned short generate_file_stats(void *arg) { - char *f = (char *)arg; - int i; char tmp[20]; -// for (i=0;i<20;i++) if (pgm_read_byte(f++)==' ') break; //skip file-stats string - for (i=0;i<19;i++) { - tmp[i]=pgm_read_byte(f++); //transfer "/filename" to RAM - if (tmp[i]==' ') { - tmp[i]=0; - break; - } + struct httpd_fsdata_file_noconst *f,fram; + u16_t i,numprinted; + + /* Transfer arg from flash file to RAM */ + memcpy_P_trim(tmp, (char *)arg); + + /* Count for this page, with common page footer */ + if (tmp[0]=='.') { + return snprintf_P((char *)uip_appdata, uip_mss(), + PSTR("
This page has been sent %u times