Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ espfs/espfstest/*.o
espfs/espfstest/espfstest
*.DS_Store
html_compressed/
libwebpages-espfs.a
libwebpages-espfs.a
*.swp
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
$(Q) mkdir -p $@

#ignore vim swap files
FIND_OPTIONS = -not -iname '*.swp'

webpages.espfs: $(HTMLDIR) espfs/mkespfsimage/mkespfsimage
ifeq ("$(COMPRESS_W_YUI)","yes")
Expand All @@ -191,9 +193,9 @@ ifeq ("$(COMPRESS_W_YUI)","yes")
$(Q) awk "BEGIN {printf \"YUI compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s ../html/ | sed 's/\([0-9]*\).*/\1/'`)*100}"
# mkespfsimage will compress html, css, svg and js files with gzip by default if enabled
# override with -g cmdline parameter
$(Q) cd html_compressed; find . | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..;
$(Q) cd html_compressed; find . $(FIND_OPTIONS) | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..;
else
$(Q) cd ../html; find . | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..
$(Q) cd ../html; find . $(FIND_OPTIONS) | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..
endif

libwebpages-espfs.a: webpages.espfs
Expand Down
14 changes: 8 additions & 6 deletions core/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ static void ICACHE_FLASH_ATTR httpdProcessRequest(HttpdConnData *conn) {
if (match) {
httpd_printf("Is url index %d\n", i);
conn->cgiData=NULL;
conn->userData=NULL;
conn->cgi=builtInUrls[i].cgiCb;
conn->cgiArg=builtInUrls[i].cgiArg;
break;
Expand Down Expand Up @@ -683,15 +684,16 @@ void ICACHE_FLASH_ATTR httpdRecvCb(ConnTypePtr rconn, char *remIp, int remPort,
int x, r;
char *p, *e;
httpdPlatLock();
char *sendBuff=malloc(HTTPD_MAX_SENDBUFF_LEN);
if (sendBuff==NULL) {
printf("Malloc sendBuff failed!\n");

HttpdConnData *conn=httpdFindConnData(rconn, remIp, remPort);
if (conn==NULL) {
httpdPlatUnlock();
return;
}

HttpdConnData *conn=httpdFindConnData(rconn, remIp, remPort);
if (conn==NULL) {
char *sendBuff=malloc(HTTPD_MAX_SENDBUFF_LEN);
if (sendBuff==NULL) {
printf("Malloc sendBuff failed!\n");
httpdPlatUnlock();
return;
}
Expand All @@ -714,7 +716,7 @@ void ICACHE_FLASH_ATTR httpdRecvCb(ConnTypePtr rconn, char *remIp, int remPort,
}
}
//ToDo: return http error code 431 (request header too long) if this happens
if (conn->priv->headPos!=HTTPD_MAX_HEAD_LEN) conn->priv->head[conn->priv->headPos++]=data[x];
if (conn->priv->headPos<HTTPD_MAX_HEAD_LEN-1) conn->priv->head[conn->priv->headPos++]=data[x];
conn->priv->head[conn->priv->headPos]=0;
//Scan for /r/n/r/n. Receiving this indicate the headers end.
if (data[x]=='\n' && (char *)strstr(conn->priv->head, "\r\n\r\n")!=NULL) {
Expand Down
6 changes: 4 additions & 2 deletions espfs/espfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ EspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) {
char namebuf[256];
EspFsHeader h;
EspFsFile *r;
//Strip initial slashes
while(fileName[0]=='/') fileName++;
//Strip first initial slash
//We should not strip any next slashes otherwise there is potential security risk when mapped authentication handler will not invoke (ex. ///security.html)
if(fileName[0]=='/') fileName++;
//Go find that file!
while(1) {
hpos=p;
Expand Down Expand Up @@ -183,6 +184,7 @@ EspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) {
#endif
} else {
httpd_printf("Invalid compression: %d\n", h.compression);
free(r);
return NULL;
}
return r;
Expand Down
2 changes: 1 addition & 1 deletion include/esp8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <user_interface.h>

#ifdef FREERTOS
#include <stdint.h>
Expand All @@ -25,7 +26,6 @@
#include <gpio.h>
#include <mem.h>
#include <osapi.h>
#include <user_interface.h>
#include <upgrade.h>
#endif

Expand Down
25 changes: 13 additions & 12 deletions include/espmissingincludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ int strcasecmp(const char *a, const char *b);
#ifndef FREERTOS
#include <eagle_soc.h>
#include <ets_sys.h>

//Missing function prototypes in include folders. Gcc will warn on these if we don't define 'em anywhere.
//MOST OF THESE ARE GUESSED! but they seem to swork and shut up the compiler.
typedef struct espconn espconn;

int atoi(const char *nptr);
void ets_install_putc1(void *routine);
void ets_isr_attach(int intr, void *handler, void *arg);
void ets_install_putc1(void (*routine)(char c));
void ets_isr_attach(int intr, void (*handler)(void *), void *arg);
void ets_isr_mask(unsigned intr);
void ets_isr_unmask(unsigned intr);
int ets_memcmp(const void *s1, const void *s2, size_t n);
Expand All @@ -25,24 +26,24 @@ int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (pri
int ets_str2macaddr(void *, void *);
int ets_strcmp(const char *s1, const char *s2);
char *ets_strcpy(char *dest, const char *src);
size_t ets_strlen(const char *s);
int ets_strncmp(const char *s1, const char *s2, int len);
int ets_strlen(const char *s);
int ets_strncmp(const char *s1, const char *s2, unsigned int len);
char *ets_strncpy(char *dest, const char *src, size_t n);
char *ets_strstr(const char *haystack, const char *needle);
void ets_timer_arm_new(os_timer_t *a, int b, int c, int isMstimer);
void ets_timer_arm_new(os_timer_t *a, uint32_t b, bool repeat, bool isMstimer);
void ets_timer_disarm(os_timer_t *a);
void ets_timer_setfn(os_timer_t *t, ETSTimerFunc *fn, void *parg);
void ets_update_cpu_frequency(int freqmhz);
void *os_memmove(void *dest, const void *src, size_t n);
int os_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
void uart_div_modify(int no, unsigned int freq);
void uart_div_modify(uint8 no, uint32 freq);
uint8 wifi_get_opmode(void);
uint32 system_get_time();
int rand(void);
void ets_bzero(void *s, size_t n);
void ets_delay_us(int ms);
void ets_delay_us(uint16_t ms);

//Hack: this is defined in SDK 1.4.0 and undefined in 1.3.0. It's only used for this, the symbol itself
//has no meaning here.
Expand All @@ -54,11 +55,11 @@ void vPortFree(void *ptr);
void *vPortMalloc(size_t xWantedSize);
void pvPortFree(void *ptr);
#else
void *pvPortMalloc(size_t xWantedSize, const char *file, int line);
void *pvPortZalloc(size_t, const char *file, int line);
void vPortFree(void *ptr, const char *file, int line);
void *vPortMalloc(size_t xWantedSize, const char *file, int line);
void pvPortFree(void *ptr, const char *file, int line);
void *pvPortMalloc(size_t xWantedSize, const char *file, unsigned line);
void *pvPortZalloc(size_t, const char *file, unsigned line);
void vPortFree(void *ptr, const char *file, unsigned line);
void *vPortMalloc(size_t xWantedSize, const char *file, unsigned line);
void pvPortFree(void *ptr, const char *file, unsigned line);
#endif

//Standard PIN_FUNC_SELECT gives a warning. Replace by a non-warning one.
Expand Down
1 change: 1 addition & 0 deletions include/httpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct HttpdConnData {
int remote_port; // Remote TCP port
uint8 remote_ip[4]; // IP address of client
uint8 slot; // Slot ID
void *userData; // Variable for storing any user data
};

//A struct describing the POST data sent inside the http connection. This is used by the CGI functions
Expand Down