示例#1
0
文件: dirlisting.c 项目: clbr/monkey
#include <time.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

#include "MKPlugin.h"

#include "dirlisting.h"

MONKEY_PLUGIN("dirlisting",          /* shortname */
              "Directory Listing",   /* name */
              VERSION,              /* version */
              MK_PLUGIN_STAGE_30);   /* hooks */

const mk_pointer mk_dirhtml_default_mime = mk_pointer_init(MK_DIRHTML_DEFAULT_MIME);
const mk_pointer mk_iov_dash = mk_pointer_init("-");
const mk_pointer mk_iov_none = mk_pointer_init("");
const mk_pointer mk_iov_slash = mk_pointer_init("/");

/* DIR_HTML logic:
 * ---------------
 * [Monkey Start]
 * |
 * *--> mk_dirhtml_conf()
 *      |
 *      *--> mk_dirhtml_read_config()
 *      *--> mk_dirhtml_theme_load()
 *           |
 *           *--> mk_dirhtml_load_file() (FILE_HEADER, FILE_ENTRY, FILE_FOOTER)
 *           *--> mk_dirhtml_template_create()
示例#2
0
文件: monkey.c 项目: swpd/monkey
#include "mk_signals.h"
#include "mk_clock.h"
#include "mk_cache.h"
#include "mk_server.h"
#include "mk_plugin.h"
#include "mk_macros.h"
#include "mk_env.h"
#include "mk_http.h"

#if defined(__DATE__) && defined(__TIME__)
static const char MONKEY_BUILT[] = __DATE__ " " __TIME__;
#else
static const char MONKEY_BUILT[] = "Unknown";
#endif

const mk_pointer mk_monkey_protocol = mk_pointer_init(HTTP_PROTOCOL_11_STR);
gid_t EGID;
gid_t EUID;

void mk_thread_keys_init(void)
{
    /* Create thread keys */
    pthread_key_create(&worker_sched_node, NULL);
    pthread_key_create(&request_list, NULL);
    pthread_key_create(&mk_epoll_state_k, NULL);
    pthread_key_create(&mk_cache_iov_header, NULL);
    pthread_key_create(&mk_cache_header_lm, NULL);
    pthread_key_create(&mk_cache_header_cl, NULL);
    pthread_key_create(&mk_cache_header_ka, NULL);
    pthread_key_create(&mk_cache_header_ka_max, NULL);
    pthread_key_create(&mk_cache_utils_gmtime, NULL);
示例#3
0
#include "mk_header.h"
#include "mk_memory.h"
#include "mk_request.h"
#include "mk_iov.h"
#include "mk_http_status.h"
#include "mk_config.h"
#include "mk_socket.h"
#include "mk_utils.h"
#include "mk_clock.h"
#include "mk_cache.h"
#include "mk_http.h"
#include "mk_string.h"
#include "mk_macros.h"


const mk_pointer mk_header_short_date = mk_pointer_init(MK_HEADER_SHORT_DATE);
const mk_pointer mk_header_short_location = mk_pointer_init(MK_HEADER_SHORT_LOCATION);
const mk_pointer mk_header_short_ct = mk_pointer_init(MK_HEADER_SHORT_CT);
const mk_pointer mk_header_allow = mk_pointer_init(MK_HEADER_ALLOWED_METHODS);

const mk_pointer mk_header_conn_ka = mk_pointer_init(MK_HEADER_CONN_KA);
const mk_pointer mk_header_conn_close = mk_pointer_init(MK_HEADER_CONN_CLOSE);
const mk_pointer mk_header_content_length = mk_pointer_init(MK_HEADER_CONTENT_LENGTH);
const mk_pointer mk_header_content_encoding = mk_pointer_init(MK_HEADER_CONTENT_ENCODING);
const mk_pointer mk_header_accept_ranges = mk_pointer_init(MK_HEADER_ACCEPT_RANGES);
const mk_pointer mk_header_te_chunked = mk_pointer_init(MK_HEADER_TE_CHUNKED);
const mk_pointer mk_header_last_modified = mk_pointer_init(MK_HEADER_LAST_MODIFIED);

#define status_entry(num, str) {num, sizeof(str) - 1, str}

static const struct header_status_response status_response[] = {
示例#4
0
#include <fcntl.h>

#include <sys/uio.h>
#include <sys/mman.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

#include "monkey.h"

#include "mk_macros.h"
#include "mk_header.h"
#include "mk_memory.h"
#include "mk_iov.h"

const mk_pointer mk_iov_crlf = mk_pointer_init(MK_IOV_CRLF);
const mk_pointer mk_iov_lf = mk_pointer_init(MK_IOV_LF);
const mk_pointer mk_iov_space = mk_pointer_init(MK_IOV_SPACE);
const mk_pointer mk_iov_slash = mk_pointer_init(MK_IOV_SLASH);
const mk_pointer mk_iov_none = mk_pointer_init(MK_IOV_NONE);
const mk_pointer mk_iov_equal = mk_pointer_init(MK_IOV_EQUAL);

struct mk_iov *mk_iov_create(int n, int offset)
{
    int i;
    struct mk_iov *iov;

    iov = mk_mem_malloc_z(sizeof(struct mk_iov));
    iov->iov_idx = offset;
    iov->io = mk_mem_malloc(n * sizeof(struct iovec));
    iov->buf_to_free = mk_mem_malloc(n * sizeof(char *));
示例#5
0
文件: mk_request.c 项目: clbr/monkey
#include "mk_string.h"
#include "mk_config.h"
#include "mk_scheduler.h"
#include "mk_epoll.h"
#include "mk_utils.h"
#include "mk_header.h"
#include "mk_user.h"
#include "mk_method.h"
#include "mk_memory.h"
#include "mk_socket.h"
#include "mk_cache.h"
#include "mk_clock.h"
#include "mk_plugin.h"
#include "mk_macros.h"

const mk_pointer mk_crlf = mk_pointer_init(MK_CRLF);
const mk_pointer mk_endblock = mk_pointer_init(MK_ENDBLOCK);

const mk_pointer mk_rh_accept = mk_pointer_init(RH_ACCEPT);
const mk_pointer mk_rh_accept_charset = mk_pointer_init(RH_ACCEPT_CHARSET);
const mk_pointer mk_rh_accept_encoding = mk_pointer_init(RH_ACCEPT_ENCODING);
const mk_pointer mk_rh_accept_language = mk_pointer_init(RH_ACCEPT_LANGUAGE);
const mk_pointer mk_rh_connection = mk_pointer_init(RH_CONNECTION);
const mk_pointer mk_rh_cookie = mk_pointer_init(RH_COOKIE);
const mk_pointer mk_rh_content_length = mk_pointer_init(RH_CONTENT_LENGTH);
const mk_pointer mk_rh_content_range = mk_pointer_init(RH_CONTENT_RANGE);
const mk_pointer mk_rh_content_type = mk_pointer_init(RH_CONTENT_TYPE);
const mk_pointer mk_rh_if_modified_since = mk_pointer_init(RH_IF_MODIFIED_SINCE);
const mk_pointer mk_rh_host = mk_pointer_init(RH_HOST);
const mk_pointer mk_rh_last_modified = mk_pointer_init(RH_LAST_MODIFIED);
const mk_pointer mk_rh_last_modified_since = mk_pointer_init(RH_LAST_MODIFIED_SINCE);