// // Created on 2018/10/17 by Ondrej Hruska // #ifndef FBNODE_EMBEDDED_FILES_H #define FBNODE_EMBEDDED_FILES_H #include #include #include struct embedded_file_info { const uint8_t * start; const uint8_t * end; const char * name; const char * mime; }; enum file_access_level { /** Public = file accessed by a wildcard route */ FILE_ACCESS_PUBLIC = 0, /** Protected = file included in a template or explicitly specified in a route */ FILE_ACCESS_PROTECTED = 1, /** Files protected against read-out */ FILE_ACCESS_PRIVATE = 2, }; extern const struct embedded_file_info EMBEDDED_FILE_LOOKUP[]; extern const size_t EMBEDDED_FILE_LOOKUP_LEN; /** * Find an embedded file by its name. * * This function is weak. It crawls the EMBEDDED_FILE_LOOKUP table and checks for exact match, also * testing with www_get_static_file_access_check if the access is allowed. * * @param name - file name * @param access - access level (public - wildcard fallthrough, protected - files for the server, loaded explicitly) * @param[out] file - the file struct is stored here if found, unchanged if not found. * @return status code */ esp_err_t www_get_static_file(const char *name, enum file_access_level access, const struct embedded_file_info **file); /** * Check file access permission (if using the default www_get_static_file implementation). * * This function is weak. The default implementation returns always true. */ bool www_get_static_file_access_check(const struct embedded_file_info *file, enum file_access_level access); #endif //FBNODE_EMBEDDED_FILES_H