/*-----------------------------------------------------------------------------------*/ uint16_t httpd_fs_open(const char *name, struct httpd_fs_file *file) { #if WEBSERVER_CONF_FILESTATS u16_t i = 0; #endif struct httpd_fsdata_file_noconst *f,fram; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; f != NULL; f = (struct httpd_fsdata_file_noconst *)fram.next) { /*Get the linked list entry into ram from wherever it is */ httpd_memcpy(&fram,f,sizeof(fram)); /*Compare name passed in RAM with name in whatever flash the file is in */ /*makefsdata adds an extra zero byte at the end of the file */ if(httpd_fs_strcmp((char *)name, fram.name) == 0) { if (file) { file->data = fram.data; file->len = fram.len-1; #if WEBSERVER_CONF_FILESTATS==2 //increment count in linked list field if it is in RAM f->count++; } return f->count; } ++i #elif WEBSERVER_CONF_FILESTATS==1 //increment count in RAM array when linked list is in flash ++httpd_filecount[i]; } return httpd_filecount[i]; }
/*-----------------------------------------------------------------------------------*/ int httpd_fs_open(const char *name, struct httpd_fs_file *file) { #if HTTPD_FS_STATISTICS u16_t i = 0; #endif /* HTTPD_FS_STATISTICS */ struct httpd_fsdata_file_noconst *f; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; f != NULL; f = (struct httpd_fsdata_file_noconst *)f->next) { if(httpd_fs_strcmp(name, f->name) == 0) { file->data = f->data; file->len = f->len; #if HTTPD_FS_STATISTICS ++count[i]; #endif /* HTTPD_FS_STATISTICS */ return 1; } #if HTTPD_FS_STATISTICS ++i; #endif /* HTTPD_FS_STATISTICS */ } return 0; }
/*-----------------------------------------------------------------------------------*/ int httpd_fs_open(const char *name, struct httpd_fs_file *file) { #if HTTPD_FS_STATISTICS u16_t i = 0; #endif /* HTTPD_FS_STATISTICS */ struct httpd_fsdata_file_noconst *f; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; f != NULL; f = (struct httpd_fsdata_file_noconst *)f->next) { //加载下一个页面数据 ,遍历顺序由httpd_fsdata_file结构体中 next决定(见 httpd-fsdata.c) if(httpd_fs_strcmp(name, f->name) == 0) { //校验请求的页面是否为此页面 file->data = f->data; file->len = f->len; #if HTTPD_FS_STATISTICS ++count[i]; #endif /* HTTPD_FS_STATISTICS */ return 1; } #if HTTPD_FS_STATISTICS ++i; #endif /* HTTPD_FS_STATISTICS */ } return 0; }
int httpd_fs_open(const char *name, struct httpd_fs_file *file) { #if HTTPD_FS_STATISTICS u16_t i = 0; #endif /* HTTPD_FS_STATISTICS */ if (httpd_fs_strcmp(name, "/data.xml") == 0){ file->data = XML_getContent(XML_DATA); file->len = XML_getLength(XML_DATA); return 1; } else if (httpd_fs_strcmp(name, "/devices.xml") == 0){ file->data = XML_getContent(XML_DEVICES); file->len = XML_getLength(XML_DEVICES); return 1; } struct httpd_fsdata_file_noconst *f; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; f != NULL; f = (struct httpd_fsdata_file_noconst *)f->next) { if(httpd_fs_strcmp(name, f->name) == 0) { file->data = f->data; file->len = f->len; #if HTTPD_FS_STATISTICS ++count[i]; #endif /* HTTPD_FS_STATISTICS */ return 1; } #if HTTPD_FS_STATISTICS ++i; #endif /* HTTPD_FS_STATISTICS */ } return 0; }
u16_t httpd_fs_count (char *name) { struct httpd_fsdata_file_noconst *f; u16_t i; i = 0; for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT; f != NULL; f = (struct httpd_fsdata_file_noconst *)f->next) { if(httpd_fs_strcmp(name, f->name) == 0) { return count[i]; } ++i; } return 0; }