terom@27: #ifndef STATIC_H terom@27: #define STATIC_H terom@27: terom@27: #include terom@27: terom@27: /* terom@27: * I serve up simple static files over HTTP by just loading them directly into memory. terom@27: * terom@27: * This is inefficient, but for small files it's OK. terom@27: */ terom@27: terom@27: struct static_file { terom@27: // the file descriptor terom@27: int fh; terom@27: terom@27: // the size of the file in bytes terom@27: off_t size; terom@27: terom@27: // the mmap address terom@27: void *mmap_addr; terom@27: }; terom@27: terom@27: int static_init (struct static_file *ctx, struct evhttp *http_server, const char *url, const char *path); terom@27: void static_deinit (struct static_file *ctx); terom@27: terom@27: #define STATIC_DIR_MAX 16 terom@27: #define STATIC_PATH_MAX 1024 terom@27: terom@27: struct static_dir { terom@27: struct static_file files[STATIC_DIR_MAX]; terom@27: terom@27: int file_count; terom@27: }; terom@27: terom@27: int static_dir_init (struct static_dir *ctx, struct evhttp *http_server, const char *url_prefix, const char *dir_path); terom@27: void static_dir_deinit (struct static_dir *ctx); terom@27: terom@27: #endif /* STATIC_H */