📄 mod_jk.c
字号:
/* * JkMountCopy directive handling * * JkMountCopy On/Off */static const char *jk_set_mountcopy(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->mountcopy = flag ? JK_TRUE : JK_FALSE; return NULL;}/* * JkMount directive handling * * JkMount URI(context) worker */static const char *jk_mount_context(cmd_parms * cmd, void *dummy, const char *context, const char *worker){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); const char *c, *w; if (worker != NULL && cmd->path == NULL ) { c = context; w = worker; } else if (worker == NULL && cmd->path != NULL) { c = cmd->path; w = context; } else { if (worker == NULL) return "JkMount needs a path when not defined in a location"; else return "JkMount can not have a path when defined in a location"; } if (c[0] != '/') return "JkMount context should start with /"; /* * Add the new worker to the alias map. */ jk_map_put(conf->uri_to_context, c, w, NULL); return NULL;}/* * JkUnMount directive handling * * JkUnMount URI(context) worker */static const char *jk_unmount_context(cmd_parms * cmd, void *dummy, const char *context, const char *worker){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); char *uri; const char *c, *w; if (worker != NULL && cmd->path == NULL ) { c = context; w = worker; } else if (worker == NULL && cmd->path != NULL) { c = cmd->path; w = context; } else { if (worker == NULL) return "JkUnMount needs a path when not defined in a location"; else return "JkUnMount can not have a path when defined in a location"; } if (c[0] != '/') return "JkUnMount context should start with /"; uri = apr_pstrcat(cmd->temp_pool, "!", c, NULL); /* * Add the new worker to the alias map. */ jk_map_put(conf->uri_to_context, uri, w, NULL); return NULL;}/* * JkAutoMount directive handling * * JkAutoMount worker [virtualhost] * This is an experimental and undocumented extension made in j-t-c/jk. */static const char *jk_automount_context(cmd_parms * cmd, void *dummy, const char *worker, const char *virtualhost){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); /* * Add the new automount to the auto map. */ jk_map_put(conf->automount, worker, virtualhost, NULL); return NULL;}/* * JkWorkersFile Directive Handling * * JkWorkersFile file */static const char *jk_set_worker_file(cmd_parms * cmd, void *dummy, const char *worker_file){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); const char *err_string = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err_string != NULL) { return err_string; } /* we need an absolute path (ap_server_root_relative does the ap_pstrdup) */ conf->worker_file = ap_server_root_relative(cmd->pool, worker_file); if (conf->worker_file == NULL) return "JkWorkersFile file name invalid"; if (jk_file_exists(conf->worker_file) != JK_TRUE) return "Can't find the workers file specified"; return NULL;}/* * JkMountFile Directive Handling * * JkMountFile file */static const char *jk_set_mount_file(cmd_parms * cmd, void *dummy, const char *mount_file){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); /* we need an absolute path (ap_server_root_relative does the ap_pstrdup) */ conf->mount_file = ap_server_root_relative(cmd->pool, mount_file); if (conf->mount_file == NULL) return "JkMountFile file name invalid"; if (jk_file_exists(conf->mount_file) != JK_TRUE) return "Can't find the mount file specified"; return NULL;}/* * JkMountFileReload Directive Handling * * JkMountFileReload seconds */static const char *jk_set_mount_file_reload(cmd_parms * cmd, void *dummy, const char *mount_file_reload){ server_rec *s = cmd->server; int interval; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); interval = atoi(mount_file_reload); if (interval < 0) { interval = 0; } conf->mount_file_reload = interval; return NULL;}/* * JkLogFile Directive Handling * * JkLogFile file */static const char *jk_set_log_file(cmd_parms * cmd, void *dummy, const char *log_file){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); /* we need an absolute path */ if (*log_file != '|') conf->log_file = ap_server_root_relative(cmd->pool, log_file); else conf->log_file = apr_pstrdup(cmd->pool, log_file); if (conf->log_file == NULL) return "JkLogFile file name invalid"; return NULL;}/* * JkShmFile Directive Handling * * JkShmFile file */static const char *jk_set_shm_file(cmd_parms * cmd, void *dummy, const char *shm_file){ const char *err_string = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err_string != NULL) { return err_string; } /* we need an absolute path */ jk_shm_file = ap_server_root_relative(cmd->pool, shm_file); if (jk_shm_file == NULL) return "JkShmFile file name invalid"; return NULL;}/* * JkShmSize Directive Handling * * JkShmSize size in kilobytes */static const char *jk_set_shm_size(cmd_parms * cmd, void *dummy, const char *shm_size){ int sz = 0; const char *err_string = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err_string != NULL) { return err_string; } sz = atoi(shm_size) * 1024; if (sz < JK_SHM_DEF_SIZE) sz = JK_SHM_DEF_SIZE; else sz = JK_SHM_ALIGN(sz); jk_shm_size = (size_t)sz; return NULL;}/* * JkLogLevel Directive Handling * * JkLogLevel debug/info/error/emerg */static const char *jk_set_log_level(cmd_parms * cmd, void *dummy, const char *log_level){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); conf->log_level = jk_parse_log_level(log_level); return NULL;}/* * JkLogStampFormat Directive Handling * * JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " */static const char *jk_set_log_fmt(cmd_parms * cmd, void *dummy, const char *log_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->stamp_format_string = apr_pstrdup(cmd->pool, log_format); return NULL;}/* * JkAutoAlias Directive Handling * * JkAutoAlias application directory */static const char *jk_set_auto_alias(cmd_parms * cmd, void *dummy, const char *directory){ server_rec *s = cmd->server; jk_server_conf_t *conf = (jk_server_conf_t *) ap_get_module_config(s->module_config, &jk_module); conf->alias_dir = apr_pstrdup(cmd->pool, directory); if (conf->alias_dir == NULL) return "JkAutoAlias directory invalid"; return NULL;}/* * JkStripSession directive handling * * JkStripSession On/Off */static const char *jk_set_strip_session(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->strip_session = flag ? JK_TRUE : JK_FALSE; return NULL;}/***************************************************************** * * Actually logging. */typedef const char *(*item_key_func) (request_rec *, char *);typedef struct{ item_key_func func; char *arg;} request_log_format_item;static const char *process_item(request_rec * r, request_log_format_item * item){ const char *cp; cp = (*item->func) (r, item->arg); return cp ? cp : "-";}static void request_log_transaction(request_rec * r, jk_server_conf_t * conf){ request_log_format_item *items; char *str, *s; int i; int len = 0; const char **strs; int *strl; apr_array_header_t *format = conf->format; strs = apr_palloc(r->pool, sizeof(char *) * (format->nelts)); strl = apr_palloc(r->pool, sizeof(int) * (format->nelts)); items = (request_log_format_item *) format->elts; for (i = 0; i < format->nelts; ++i) { strs[i] = process_item(r, &items[i]); } for (i = 0; i < format->nelts; ++i) { len += strl[i] = strlen(strs[i]); } str = apr_palloc(r->pool, len + 1); for (i = 0, s = str; i < format->nelts; ++i) { memcpy(s, strs[i], strl[i]); s += strl[i]; } *s = 0; jk_log(conf->log, JK_LOG_REQUEST, "%s", str);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -