forked from electro/esp-irblaster
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
//
|
|
// Created on 2018/10/17 by Ondrej Hruska <ondra@ondrovo.com>
|
|
//
|
|
|
|
#ifndef FBNODE_EMBEDDED_FILES_H
|
|
#define FBNODE_EMBEDDED_FILES_H
|
|
|
|
#include <stdint.h>
|
|
#include <esp_err.h>
|
|
#include <stdbool.h>
|
|
|
|
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
|
|
|