⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_jk.c

📁 以便Apache与其他服务进行整合 Mod_JK安装
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************** * * Parsing the log format string */static char *format_integer(apr_pool_t * p, int i){    return apr_psprintf(p, "%d", i);}static char *pfmt(apr_pool_t * p, int i){    if (i <= 0) {        return "-";    }    else {        return format_integer(p, i);    }}static const char *constant_item(request_rec * dummy, char *stuff){    return stuff;}static const char *log_worker_name(request_rec * r, char *a){    return apr_table_get(r->notes, JK_NOTE_WORKER_NAME);}static const char *log_worker_route(request_rec * r, char *a){    return apr_table_get(r->notes, JK_NOTE_WORKER_ROUTE);}static const char *log_request_duration(request_rec * r, char *a){    return apr_table_get(r->notes, JK_NOTE_REQUEST_DURATION);}static const char *log_request_line(request_rec * r, char *a){    /* NOTE: If the original request contained a password, we     * re-write the request line here to contain XXXXXX instead:     * (note the truncation before the protocol string for HTTP/0.9 requests)     * (note also that r->the_request contains the unmodified request)     */    return (r->parsed_uri.password) ? apr_pstrcat(r->pool, r->method, " ",                                                  apr_uri_unparse(r->pool,                                                                  &r->                                                                  parsed_uri,                                                                  0),                                                  r->                                                  assbackwards ? NULL : " ",                                                  r->protocol, NULL)        : r->the_request;}/* These next two routines use the canonical name:port so that log * parsers don't need to duplicate all the vhost parsing crud. */static const char *log_virtual_host(request_rec * r, char *a){    return r->server->server_hostname;}static const char *log_server_port(request_rec * r, char *a){    return apr_psprintf(r->pool, "%u",                        r->server->port ? r->server->                        port : ap_default_port(r));}/* This respects the setting of UseCanonicalName so that * the dynamic mass virtual hosting trick works better. */static const char *log_server_name(request_rec * r, char *a){    return ap_get_server_name(r);}static const char *log_request_uri(request_rec * r, char *a){    return r->uri;}static const char *log_request_method(request_rec * r, char *a){    return r->method;}static const char *log_request_protocol(request_rec * r, char *a){    return r->protocol;}static const char *log_request_query(request_rec * r, char *a){    return (r->args != NULL) ? apr_pstrcat(r->pool, "?", r->args, NULL)        : "";}static const char *log_status(request_rec * r, char *a){    return pfmt(r->pool, r->status);}static const char *clf_log_bytes_sent(request_rec * r, char *a){    if (!r->sent_bodyct) {        return "-";    }    else {        return apr_off_t_toa(r->pool, r->bytes_sent);    }}static const char *log_bytes_sent(request_rec * r, char *a){    if (!r->sent_bodyct) {        return "0";    }    else {        return apr_psprintf(r->pool, "%" APR_OFF_T_FMT, r->bytes_sent);    }}static struct log_item_list{    char ch;    item_key_func func;} log_item_keys[] = {    {    'T', log_request_duration}, {    'r', log_request_line}, {    'U', log_request_uri}, {    's', log_status}, {    'b', clf_log_bytes_sent}, {    'B', log_bytes_sent}, {    'V', log_server_name}, {    'v', log_virtual_host}, {    'p', log_server_port}, {    'H', log_request_protocol}, {    'm', log_request_method}, {    'q', log_request_query}, {    'w', log_worker_name}, {    'R', log_worker_route}, {    '\0'}};static struct log_item_list *find_log_func(char k){    int i;    for (i = 0; log_item_keys[i].ch; ++i)        if (k == log_item_keys[i].ch) {            return &log_item_keys[i];        }    return NULL;}static char *parse_request_log_misc_string(apr_pool_t * p,                                           request_log_format_item * it,                                           const char **sa){    const char *s;    char *d;    it->func = constant_item;    s = *sa;    while (*s && *s != '%') {        s++;    }    /*     * This might allocate a few chars extra if there's a backslash     * escape in the format string.     */    it->arg = apr_palloc(p, s - *sa + 1);    d = it->arg;    s = *sa;    while (*s && *s != '%') {        if (*s != '\\') {            *d++ = *s++;        }        else {            s++;            switch (*s) {            case '\\':                *d++ = '\\';                s++;                break;            case 'n':                *d++ = '\n';                s++;                break;            case 't':                *d++ = '\t';                s++;                break;            default:                /* copy verbatim */                *d++ = '\\';                /*                 * Allow the loop to deal with this *s in the normal                 * fashion so that it handles end of string etc.                 * properly.                 */                break;            }        }    }    *d = '\0';    *sa = s;    return NULL;}static char *parse_request_log_item(apr_pool_t * p,                                    request_log_format_item * it,                                    const char **sa){    const char *s = *sa;    struct log_item_list *l;    if (*s != '%') {        return parse_request_log_misc_string(p, it, sa);    }    ++s;    it->arg = "";               /* For safety's sake... */    l = find_log_func(*s++);    if (!l) {        char dummy[2];        dummy[0] = s[-1];        dummy[1] = '\0';        return apr_pstrcat(p, "Unrecognized JkRequestLogFormat directive %",                           dummy, NULL);    }    it->func = l->func;    *sa = s;    return NULL;}static apr_array_header_t *parse_request_log_string(apr_pool_t * p,                                                    const char *s,                                                    const char **err){    apr_array_header_t *a =        apr_array_make(p, 15, sizeof(request_log_format_item));    char *res;    while (*s) {        if ((res =             parse_request_log_item(p,                                    (request_log_format_item *)                                    apr_array_push(a), &s))) {            *err = res;            return NULL;        }    }    return a;}/* * JkRequestLogFormat Directive Handling * * JkRequestLogFormat format string * * %b - Bytes sent, excluding HTTP headers. In CLF format * %B - Bytes sent, excluding HTTP headers. * %H - The request protocol * %m - The request method * %p - The canonical Port of the server serving the request * %q - The query string (prepended with a ? if a query string exists, *      otherwise an empty string) * %r - First line of request * %s - request HTTP status code * %T - Requset duration, elapsed time to handle request in seconds '.' micro seconds * %U - The URL path requested, not including any query string. * %v - The canonical ServerName of the server serving the request. * %V - The server name according to the UseCanonicalName setting. * %w - Tomcat worker name */static const char *jk_set_request_log_format(cmd_parms * cmd,                                             void *dummy, const char *format){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->format_string = apr_pstrdup(cmd->pool, format);    return NULL;}/* * JkWorkerIndicator Directive Handling * * JkWorkerIndicator JkWorker */static const char *jk_set_worker_indicator(cmd_parms * cmd,                                           void *dummy, const char *indicator){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->worker_indicator = apr_pstrdup(cmd->pool, indicator);    return NULL;}/* * JkExtractSSL Directive Handling * * JkExtractSSL On/Off */static const char *jk_set_enable_ssl(cmd_parms * cmd, void *dummy, int flag){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    /* Set up our value */    conf->ssl_enable = flag ? JK_TRUE : JK_FALSE;    return NULL;}/* * JkHTTPSIndicator Directive Handling * * JkHTTPSIndicator HTTPS */static const char *jk_set_https_indicator(cmd_parms * cmd,                                          void *dummy, const char *indicator){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->https_indicator = apr_pstrdup(cmd->pool, indicator);    return NULL;}/* * JkCERTSIndicator Directive Handling * * JkCERTSIndicator SSL_CLIENT_CERT */static const char *jk_set_certs_indicator(cmd_parms * cmd,                                          void *dummy, const char *indicator){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->certs_indicator = apr_pstrdup(cmd->pool, indicator);    return NULL;}/* * JkCIPHERIndicator Directive Handling * * JkCIPHERIndicator SSL_CIPHER */static const char *jk_set_cipher_indicator(cmd_parms * cmd,                                           void *dummy, const char *indicator){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->cipher_indicator = apr_pstrdup(cmd->pool, indicator);    return NULL;}/* * JkCERTCHAINPrefix Directive Handling * * JkCERTCHAINPrefix SSL_CLIENT_CERT_CHAIN_ */static const char *jk_set_certchain_prefix(cmd_parms * cmd,                                           void *dummy, const char *prefix){    server_rec *s = cmd->server;    jk_server_conf_t *conf =        (jk_server_conf_t *) ap_get_module_config(s->module_config,                                                  &jk_module);    conf->certchain_prefix = apr_pstrdup(cmd->pool, prefix);    return NULL;}/* * JkSESSIONIndicator Directive Handling

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -