예제 #1
0
/* 
 * File:   wbt_http_consts.c
 * Author: Fcten
 *
 * Created on 2014年10月24日, 下午3:40
 */

#include "../webit.h"
#include "../common/wbt_string.h"

wbt_str_t http_ver_1_0 = wbt_string("HTTP/1.0");
wbt_str_t http_ver_1_1 = wbt_string("HTTP/1.1");

wbt_str_t header_server = wbt_string("Webit");
wbt_str_t header_connection_keep_alive = wbt_string("keep-alive");
wbt_str_t header_connection_close = wbt_string("close");
wbt_str_t header_cache_control = wbt_string("max-age=3600");
wbt_str_t header_content_type_text_html = wbt_string("text/html");

wbt_str_t REQUEST_METHOD[] = {
    wbt_null_string,
    wbt_string("GET"),
    wbt_string("POST"),
    wbt_string("HEAD"),
    wbt_string("PUT"), 
    wbt_string("DELETE"), 
    wbt_string("TRACE"),
    wbt_string("CONNECT"),
    wbt_string("OPTIONS"),
    wbt_null_string
};
예제 #2
0
파일: wbt_file.c 프로젝트: fcten/BitMQ
 * Author: Fcten
 *
 * Created on 2014年11月12日, 上午10:44
 */

#include "../event/wbt_event.h"
#include "wbt_module.h"
#include "wbt_memory.h"
#include "wbt_log.h"
#include "wbt_file.h"
#include "wbt_rbtree.h"
#include "wbt_time.h"
#include "wbt_gzip.h"

wbt_module_t wbt_module_file = {
    wbt_string("file"),
    wbt_file_init,
    wbt_file_exit
};

wbt_file_t tmp;

#define WBT_MAX_OPEN_FILES 1024

wbt_rb_t wbt_file_rbtree;

extern wbt_atomic_t wbt_wating_to_exit;

wbt_str_t MIME_TYPE[][2] = {
    { wbt_string("bmq"),  wbt_string("text/plain") },
    { wbt_string("html"), wbt_string("text/html")  },
예제 #3
0
파일: wbt_log.c 프로젝트: fcten/BitMQ
/* 
 * File:   wbt_log.c
 * Author: Fcten
 *
 * Created on 2014年8月25日, 下午4:05
 */

#include "wbt_log.h"
#include "wbt_module.h"
#include "wbt_config.h"

wbt_module_t wbt_module_log = {
    wbt_string("log"),
    wbt_log_init
};

wbt_fd_t wbt_log_file_fd;
ssize_t wbt_log_file_size;
wbt_str_t wbt_log_buf;

wbt_status wbt_log_init() {
    char log_file[256];
    snprintf( log_file, sizeof(log_file), "%.*s/bmq.log", wbt_conf.logs.len, wbt_conf.logs.str );
    
    /* O_CLOEXEC 需要 Linux 内核版本大于等于 2.6.23 */
    /* TODO 每个 worker 进程需要单独的日志文件,否则并发写会丢失一部分数据 */
    wbt_log_file_fd = wbt_open_logfile(log_file);
    if( (int)wbt_log_file_fd <=0 ) {
        wbt_log_debug("can't open log file, errno: %d\n", wbt_errno);
        return WBT_ERROR;
    }
예제 #4
0
파일: wbt_config.c 프로젝트: fcten/BitMQ
 * Author: Fcten
 *
 * Created on 2014年12月16日, 下午3:03
 */

#include "wbt_config.h"
#include "wbt_module.h"
#include "wbt_file.h"
#include "wbt_log.h"
#include "wbt_rbtree.h"
#include "../os/linux/wbt_os_util.h"
#include "../os/linux/wbt_setproctitle.h"
#include "../mq/wbt_mq_snowflake.h"

wbt_module_t wbt_module_conf = {
    wbt_string("config"),
    wbt_conf_init,
    wbt_conf_exit
};

/* 默认的配置文件位置 */
wbt_str_t wbt_config_file_name = wbt_string("./bmq.conf");

wbt_str_t wbt_conf_option_on = wbt_string("on");
wbt_str_t wbt_conf_option_off = wbt_string("off");

wbt_str_t wbt_conf_option_always = wbt_string("always");
wbt_str_t wbt_conf_option_everysec = wbt_string("everysec");

wbt_str_t wbt_conf_option_none = wbt_string("none");
wbt_str_t wbt_conf_option_basic = wbt_string("basic");