/*-----------------------------------------------------------------------------------*/ struct fs_file * fs_open(const char *name) { struct fs_file *file; const struct fsdata_file *f; file = fs_malloc(); if(file == NULL) { return NULL; } #if LWIP_HTTPD_CUSTOM_FILES if(fs_open_custom(file, name)) { file->is_custom_file = 1; return file; } file->is_custom_file = 0; #endif /* LWIP_HTTPD_CUSTOM_FILES */ for(f = FS_ROOT; f != NULL; f = f->next) { if (!strcmp(name, (char *)f->name)) { file->data = (const char *)f->data; file->len = f->len; file->index = f->len; file->pextension = NULL; file->http_header_included = f->http_header_included; #if HTTPD_PRECALCULATED_CHECKSUM file->chksum_count = f->chksum_count; file->chksum = f->chksum; #endif /* HTTPD_PRECALCULATED_CHECKSUM */ #if LWIP_HTTPD_FILE_STATE file->state = fs_state_init(file, name); #endif /* #if LWIP_HTTPD_FILE_STATE */ return file; } } fs_free(file); return NULL; }
/*-----------------------------------------------------------------------------------*/ err_t fs_open(struct fs_file *file, const char *name) { const struct fsdata_file *f; if ((file == NULL) || (name == NULL)) { return ERR_ARG; } #if LWIP_HTTPD_CUSTOM_FILES if (fs_open_custom(file, name)) { file->is_custom_file = 1; return ERR_OK; } file->is_custom_file = 0; #endif /* LWIP_HTTPD_CUSTOM_FILES */ for (f = FS_ROOT; f != NULL; f = f->next) { if (!strcmp(name, (const char *)f->name)) { file->data = (const char *)f->data; file->len = f->len; file->index = f->len; file->pextension = NULL; file->http_header_included = f->http_header_included; #if HTTPD_PRECALCULATED_CHECKSUM file->chksum_count = f->chksum_count; file->chksum = f->chksum; #endif /* HTTPD_PRECALCULATED_CHECKSUM */ #if LWIP_HTTPD_FILE_STATE file->state = fs_state_init(file, name); #endif /* #if LWIP_HTTPD_FILE_STATE */ return ERR_OK; } } /* file not found */ return ERR_VAL; }