static.h
author Tero Marttila <terom@fixme.fi>
Fri, 29 Aug 2008 23:31:17 +0300
changeset 48 1c67f512779b
parent 27 1e79b4cc8f1b
permissions -rw-r--r--
fix doc tpyos, rename some enums, fix printf format len for non-zero terminated strings (hg status), pass args to memcache_cmd_format_header via memcache_req_*, handle zero-length STORE requests, memcache_req is_buf_ours + free, other function name typos (keymemcache_req_key), fix req state behaviour re *_DATA_* for STORE requests and FETCH/END, better memcache_server connpool events/management, modular memcache_test with a working benchmark. This is a long commit message.
#ifndef STATIC_H
#define STATIC_H

#include <event2/http.h>

/*
 * I serve up simple static files over HTTP by just loading them directly into memory.
 *
 * This is inefficient, but for small files it's OK.
 */

struct static_file {
    // the file descriptor
    int fh;

    // the size of the file in bytes
    off_t size;

    // the mmap address
    void *mmap_addr;
};

int static_init (struct static_file *ctx, struct evhttp *http_server, const char *url, const char *path);
void static_deinit (struct static_file *ctx);

#define STATIC_DIR_MAX 16
#define STATIC_PATH_MAX 1024

struct static_dir {
    struct static_file files[STATIC_DIR_MAX];

    int file_count;
};

int static_dir_init (struct static_dir *ctx, struct evhttp *http_server, const char *url_prefix, const char *dir_path);
void static_dir_deinit (struct static_dir *ctx);

#endif /* STATIC_H */