コード例 #1
0
ファイル: dwriter.c プロジェクト: 304471720/webserver
ret_t
cherokee_dwriter_lang_to_type (cherokee_buffer_t       *buf,
                               cherokee_dwriter_lang_t *lang)
{
	if (equal_buf_str (buf, "json")) {
		*lang = dwriter_json;
		return ret_ok;
	}

	if (equal_buf_str (buf, "python")) {
		*lang = dwriter_python;
		return ret_ok;
	}

	if (equal_buf_str (buf, "php")) {
		*lang = dwriter_php;
		return ret_ok;
	}

	if (equal_buf_str (buf, "ruby")) {
		*lang = dwriter_ruby;
		return ret_ok;
	}

	return ret_not_found;
}
コード例 #2
0
ファイル: validator.c プロジェクト: chetan/cherokee
ret_t
cherokee_validator_configure (cherokee_config_node_t *conf, void *config_entry)
{
	ret_t                    ret;
	cherokee_list_t         *i;
	cherokee_config_node_t  *subconf;
	cherokee_config_entry_t *entry = CONF_ENTRY(config_entry);

	cherokee_config_node_foreach (i, conf) {
		subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "realm")) {
			TRACE(ENTRIES, "Realm: %s\n", subconf->val.buf);

			ret = cherokee_buffer_dup (&subconf->val, &entry->auth_realm);
			if (ret != ret_ok)
				return ret;

		} else if (equal_buf_str (&subconf->key, "methods")) {
			TRACE(ENTRIES, "Methods: %s\n", subconf->val.buf);

			ret = cherokee_config_node_read_list (subconf, NULL, add_method, entry);
			if (ret != ret_ok)
				return ret;

		} else if (equal_buf_str (&subconf->key, "users")) {
			if (entry->users == NULL) {
				cherokee_avl_new (&entry->users);
			}

			ret = cherokee_config_node_read_list (subconf, NULL, add_user, entry->users);
			if (ret != ret_ok)
				return ret;
		}
	}
コード例 #3
0
ファイル: logger_writer.c プロジェクト: 304471720/webserver
static ret_t
config_read_type (cherokee_config_node_t         *config,
                  cherokee_logger_writer_types_t *type)
{
	ret_t              ret;
	cherokee_buffer_t *tmp = NULL;

	ret = cherokee_config_node_read (config, "type", &tmp);
	if (ret != ret_ok) {
		LOG_ERROR_S (CHEROKEE_ERROR_LOGGER_NO_WRITER);
		return ret_error;
	}

	if (equal_buf_str (tmp, "syslog")) {
		*type = cherokee_logger_writer_syslog;
	} else if (equal_buf_str (tmp, "stderr")) {
		*type = cherokee_logger_writer_stderr;
	} else if (equal_buf_str (tmp, "file")) {
		*type = cherokee_logger_writer_file;
	} else if (equal_buf_str (tmp, "exec")) {
		*type = cherokee_logger_writer_pipe;
	} else {
		LOG_CRITICAL (CHEROKEE_ERROR_LOGGER_WRITER_UNKNOWN, tmp->buf);
		return ret_error;
	}

	return ret_ok;
}
コード例 #4
0
ファイル: handler_file.c プロジェクト: 304471720/webserver
ret_t
cherokee_handler_file_configure (cherokee_config_node_t   *conf,
				 cherokee_server_t        *srv,
				 cherokee_module_props_t **_props)
{
	ret_t                          ret;
	cherokee_list_t               *i;
	cherokee_handler_file_props_t *props;

	UNUSED(srv);

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_file_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n),
						  MODULE_PROPS_FREE(cherokee_handler_file_props_free));

		n->use_cache = true;
		n->send_symlinks = true;
		*_props = MODULE_PROPS(n);
	}

	props = PROP_FILE(*_props);

	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "iocache")) {
			ret = cherokee_atob (subconf->val.buf, &props->use_cache);
			if (ret != ret_ok) return ret;
		} else if (equal_buf_str (&subconf->key, "symlinks")) {
			ret = cherokee_atob (subconf->val.buf, &props->send_symlinks);
			if (ret != ret_ok) return ret;
		}
	}
コード例 #5
0
ファイル: iocache.c プロジェクト: nuxleus/cherokee-webserver
ret_t
cherokee_iocache_configure (cherokee_iocache_t     *iocache,
			    cherokee_config_node_t *conf)
{
	ret_t            ret;
	cherokee_list_t *i;

	/* Configure parent class
	 */
	ret = cherokee_cache_configure (CACHE(iocache), conf);
	if (ret != ret_ok)
		return ret;

	/* Configure it own properties
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "max_file_size")) {
			iocache->max_file_size = atoi(subconf->val.buf);
		} else if (equal_buf_str (&subconf->key, "min_file_size")) {
			iocache->min_file_size = atoi(subconf->val.buf);

		} else if (equal_buf_str (&subconf->key, "lasting_stat")) {
			iocache->lasting_stat = atoi(subconf->val.buf);
		} else if (equal_buf_str (&subconf->key, "lasting_mmap")) {
			iocache->lasting_mmap = atoi(subconf->val.buf);
		}
	}
コード例 #6
0
ret_t
cherokee_handler_dbslayer_configure (cherokee_config_node_t  *conf,
				     cherokee_server_t       *srv,
				     cherokee_module_props_t **_props)
{
	ret_t                              ret;
	cherokee_list_t                   *i;
	cherokee_handler_dbslayer_props_t *props;

	/* Instance a new property object
	 */
	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_dbslayer_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n),
						  MODULE_PROPS_FREE(props_free));
		n->balancer = NULL;
		cherokee_buffer_init (&n->user);
		cherokee_buffer_init (&n->password);
		cherokee_buffer_init (&n->db);

		*_props = MODULE_PROPS(n);
	}

	props = PROP_DBSLAYER(*_props);

	/* Parse the configuration tree
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "balancer")) {
			ret = cherokee_balancer_instance (&subconf->val, subconf, srv, &props->balancer);
			if (ret != ret_ok)
				return ret;

		} else  if (equal_buf_str (&subconf->key, "user")) {
			cherokee_buffer_clean (&props->user);
			cherokee_buffer_add_buffer (&props->user, &subconf->val);

		} else  if (equal_buf_str (&subconf->key, "password")) {
			cherokee_buffer_clean (&props->password);
			cherokee_buffer_add_buffer (&props->password, &subconf->val);

		} else  if (equal_buf_str (&subconf->key, "db")) {
			cherokee_buffer_clean (&props->db);
			cherokee_buffer_add_buffer (&props->db, &subconf->val);

		} else  if (equal_buf_str (&subconf->key, "lang")) {

			ret = cherokee_dwriter_lang_to_type (&subconf->val, &props->lang);
			if (ret != ret_ok) {
				LOG_CRITICAL (CHEROKEE_ERROR_HANDLER_DBSLAYER_LANG, subconf->val.buf);
				return ret_error;
			}
		}
	}
コード例 #7
0
ret_t 
cherokee_handler_zeromq_configure (cherokee_config_node_t *conf,
								   cherokee_server_t *srv,
								   cherokee_module_props_t **_props)
{
	ret_t							ret;
	cherokee_list_t				 *i;
	cherokee_handler_zeromq_props_t *props;
	cherokee_plugin_info_t		  *info = NULL;
	
	/* Instance a new property object
	 */
	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_zeromq_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n), 
						  MODULE_PROPS_FREE(props_free));
		cherokee_buffer_init (&n->endpoint);
		n->io_threads = 1;
		CHEROKEE_MUTEX_INIT (&n->mutex, CHEROKEE_MUTEX_FAST);

		*_props = MODULE_PROPS(n);
	}

	props = PROP_ZEROMQ(*_props);
	
	/* Voodoo to get our own backend gzipper
	 */
	ret = cherokee_plugin_loader_get (&srv->loader, "gzip", &info);
	if (ret != ret_ok) {
		return ret;
	}

	/* Parse the configuration tree
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "endpoint")) {
			cherokee_buffer_clean (&props->endpoint);
			cherokee_buffer_add_buffer (&props->endpoint, &subconf->val);
		} else if (equal_buf_str (&subconf->key, "io_threads")) {
			props->io_threads = atoi(subconf->val.buf);
		} else if (equal_buf_str (&subconf->key, "encoder") && info->configure) {
			encoder_func_configure_t configure = info->configure;
			props->encoder_props = NULL;

			ret = configure (subconf, srv, (cherokee_module_props_t **)&props->encoder_props);
			if (ret != ret_ok) {
				return ret;
			}

			props->encoder_props->instance_func = PLUGIN_INFO(info)->instance;
		}

	}
コード例 #8
0
ファイル: rule_header.c プロジェクト: felipebuarque/PL-Stats
static ret_t
type_str_to_type (cherokee_buffer_t           *type_str,
		  cherokee_rule_header_type_t *type)
{
	if (equal_buf_str (type_str, "regex")) {
		*type = rule_header_type_regex;
	} else if (equal_buf_str (type_str, "provided")) {
		*type = rule_header_type_provided;
	} else {
		LOG_CRITICAL (CHEROKEE_ERROR_RULE_HEADER_UNKNOWN_TYPE, type_str->buf);
		return ret_error;
	}

	return ret_ok;
}
コード例 #9
0
ret_t
cherokee_handler_fcgi_configure (cherokee_config_node_t   *conf,
				 cherokee_server_t        *srv,
				 cherokee_module_props_t **_props)
{
	ret_t                          ret;
	cherokee_list_t               *i;
	cherokee_handler_fcgi_props_t *props;

	/* Instance a new property object
	 */
	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_fcgi_props);

		cherokee_handler_cgi_base_props_init_base (PROP_CGI_BASE(n),
							   MODULE_PROPS_FREE(props_free));

		INIT_LIST_HEAD (&n->server_list);
		n->balancer = NULL;

		*_props = MODULE_PROPS(n);
	}

	props = PROP_FCGI(*_props);

	/* Parse the configuration tree
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "balancer")) {
			ret = cherokee_balancer_instance (&subconf->val, subconf, srv, &props->balancer);
			if (ret != ret_ok) return ret;
		}
	}
コード例 #10
0
ret_t
cherokee_handler_custom_error_configure (cherokee_config_node_t   *conf,
                                         cherokee_server_t        *srv,
                                         cherokee_module_props_t **_props)
{
	ret_t                                  ret;
	int                                    val;
	cherokee_list_t                       *i;
	cherokee_config_node_t                *subconf;
	cherokee_handler_custom_error_props_t *props;

	UNUSED(srv);

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_custom_error_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n),
		                                  MODULE_PROPS_FREE(props_free));

		n->error_code = http_unset;
		*_props = MODULE_PROPS(n);
	}

	props = PROP_CUSTOM_ERROR(*_props);

	cherokee_config_node_foreach (i, conf) {
		subconf = CONFIG_NODE(i);
		if (equal_buf_str (&subconf->key, "error")) {
			ret = cherokee_atoi (subconf->val.buf, &val);
			if (ret != ret_ok) return ret;
			props->error_code = val;
		}
	}
コード例 #11
0
ファイル: rule_header.c プロジェクト: felipebuarque/PL-Stats
static ret_t
configure (cherokee_rule_header_t    *rule,
	   cherokee_config_node_t    *conf,
	   cherokee_virtual_server_t *vsrv)
{
	ret_t                   ret;
	cherokee_buffer_t      *type     = NULL;
	cherokee_buffer_t      *header   = NULL;
	cherokee_regex_table_t *regexs   = VSERVER_SRV(vsrv)->regexs;

	/* Read the header
	 */
	ret = cherokee_config_node_read (conf, "header", &header);
	if (ret != ret_ok) {
		LOG_ERROR (CHEROKEE_ERROR_RULE_NO_PROPERTY,
			   RULE(rule)->priority, "header");
		return ret_error;
	}

	ret = header_str_to_type (header, &rule->header);
	if (ret != ret_ok) {
		return ret;
	}

	/* Type
	 */
	ret = cherokee_config_node_read (conf, "type", &type);
	if (ret == ret_ok) {
		ret = type_str_to_type (type, &rule->type);
		if (ret != ret_ok) {
			return ret;
		}
	}

	/* Read the match
	 */
	ret = cherokee_config_node_copy (conf, "match", &rule->match);
	if (ret != ret_ok) {
		if (equal_buf_str (type, "regex")) {
			LOG_ERROR (CHEROKEE_ERROR_RULE_NO_PROPERTY,
				   RULE(rule)->priority, "match");
			return ret_error;
		}
	}

	/* Compile the regular expression
	 */
	if (! cherokee_buffer_is_empty (&rule->match)) {
		ret = cherokee_regex_table_add (regexs, rule->match.buf);
		if (ret != ret_ok)
			return ret;

		ret = cherokee_regex_table_get (regexs, rule->match.buf, &rule->pcre);
		if (ret != ret_ok)
			return ret;
	}

	return ret_ok;
}
コード例 #12
0
ファイル: rule_header.c プロジェクト: felipebuarque/PL-Stats
static ret_t
header_str_to_type (cherokee_buffer_t        *header,
		    cherokee_common_header_t *common_header)
{
	if (equal_buf_str (header, "Accept-Encoding")) {
		*common_header = header_accept_encoding;
	} else if (equal_buf_str (header, "Accept-Charset")) {
		*common_header = header_accept_charset;
	} else if (equal_buf_str (header, "Accept-Language")) {
		*common_header = header_accept_language;
	} else if (equal_buf_str (header, "Referer")) {
		*common_header = header_referer;
	} else if (equal_buf_str (header, "User-Agent")) {
		*common_header = header_user_agent;
	} else if (equal_buf_str (header, "Cookie")) {
		*common_header = header_cookie;
	} else if (equal_buf_str (header, "Host")) {
		*common_header = header_host;
	} else {
		LOG_CRITICAL (CHEROKEE_ERROR_RULE_HEADER_UNKNOWN_HEADER, header->buf);
		return ret_error;
	}

	return ret_ok;
}
コード例 #13
0
ファイル: handler_streaming.c プロジェクト: BeQ/webserver
ret_t
cherokee_handler_streaming_configure (cherokee_config_node_t   *conf,
				      cherokee_server_t        *srv,
				      cherokee_module_props_t **_props)
{
	ret_t                               ret;
	cherokee_list_t                    *i;
	cherokee_handler_streaming_props_t *props;

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_streaming_props);

		cherokee_handler_props_init_base (HANDLER_PROPS(n),
			MODULE_PROPS_FREE(cherokee_handler_streaming_props_free));

		n->props_file       = NULL;
		n->auto_rate        = true;
		n->auto_rate_factor = 0.1;
		n->auto_rate_boost  = 5;

		*_props = MODULE_PROPS(n);
	}

	props = PROP_STREAMING(*_props);

	/* Parse 'streaming' parameters
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "rate")) {
			ret = cherokee_atob (subconf->val.buf, &props->auto_rate);
			if (ret != ret_ok) return ret_error;

		} else if (equal_buf_str (&subconf->key, "rate_factor")) {
			props->auto_rate_factor = strtof (subconf->val.buf, NULL);

		} else if (equal_buf_str (&subconf->key, "rate_boost")) {
			ret = cherokee_atoi (subconf->val.buf, &props->auto_rate_boost);
			if (ret != ret_ok) return ret_error;
		}
	}
コード例 #14
0
ファイル: validator_file.c プロジェクト: BeQ/webserver
ret_t
cherokee_validator_file_configure (cherokee_config_node_t     *conf,
				   cherokee_server_t          *srv,
				   cherokee_module_props_t  **_props)
{
	ret_t                            ret;
	cherokee_config_node_t          *subconf;
	cherokee_validator_file_props_t *props    = PROP_VFILE(*_props);

	UNUSED (srv);

	/* Password file
	 */
	ret = cherokee_config_node_get (conf, "passwdfile", &subconf);
	if (ret == ret_ok) {
		cherokee_buffer_add_buffer (&props->password_file, &subconf->val);
	}

	/* Path type
	 */
	ret = cherokee_config_node_get (conf, "passwdfile_path", &subconf);
	if (ret == ret_ok) {
		if (equal_buf_str (&subconf->val, "full")) {
			props->password_path_type = val_path_full;
		} else if (equal_buf_str (&subconf->val, "local_dir")) {
			props->password_path_type = val_path_local_dir;
		} else {
			LOG_ERROR (CHEROKEE_ERROR_VALIDATOR_FILE, subconf->val.buf);
			return ret_error;
		}
	}

	/* Final checks
	 */
	if (cherokee_buffer_is_empty (&props->password_file)) {
		LOG_CRITICAL_S (CHEROKEE_ERROR_VALIDATOR_FILE_NO_FILE);
		return ret_error;
	}

	return ret_ok;
}
コード例 #15
0
ret_t
cherokee_handler_server_info_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	cherokee_list_t                      *i;
	cherokee_handler_server_info_props_t *props;

	UNUSED(srv);

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_server_info_props);

		cherokee_module_props_init_base (MODULE_PROPS(n),
						 MODULE_PROPS_FREE(props_free));
		n->just_about         = false;
		n->connection_details = false;

		*_props = MODULE_PROPS(n);
	}

	props = PROP_SRV_INFO(*_props);

	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "type")) {
			if (equal_buf_str (&subconf->val, "normal")) {

			} else if (equal_buf_str (&subconf->val, "just_about")) {
				props->just_about = true;

			} else if (equal_buf_str (&subconf->val, "connection_details")) {
				props->connection_details = true;

			} else {
				LOG_ERROR (CHEROKEE_ERROR_HANDLER_SRV_INFO_TYPE, subconf->val.buf);
				return ret_error;
			}
		}
	}
コード例 #16
0
ファイル: encoder.c プロジェクト: nuxleus/cherokee-webserver
ret_t
cherokee_encoder_configure (cherokee_config_node_t   *config,
			    cherokee_server_t        *srv,
			    cherokee_module_props_t **_props)
{
	cherokee_encoder_props_t *props = ENCODER_PROPS(*_props);

	UNUSED (srv);

	/* Unset
	 */
	if (equal_buf_str (&config->val, "0")) {
		TRACE (ENTRIES, "Encoder %s: unset\n", config->key.buf);

	/* Deny
	 */
	} else if (equal_buf_str (&config->val, "forbid") ||
		   equal_buf_str (&config->val, "deny")) {
		TRACE (ENTRIES, "Encoder %s: deny\n", config->key.buf);
		props->perms = cherokee_encoder_forbid;

	/* Allow
	 */
	} else if (equal_buf_str (&config->val, "1") ||
		   equal_buf_str (&config->val, "allow")) {
		TRACE (ENTRIES, "Encoder %s: allow\n", config->key.buf);
		props->perms = cherokee_encoder_allow;

	/* Error
	 */
	} else {
		LOG_ERROR (CHEROKEE_ERROR_ENCODER_NOT_SET_VALUE, config->val.buf);
		return ret_error;
	}

	return ret_ok;
}
コード例 #17
0
ファイル: source.c プロジェクト: BeQ/webserver
ret_t
cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf)
{
	cherokee_list_t        *i;
	cherokee_config_node_t *child;

	cherokee_config_node_foreach (i, conf) {
		child = CONFIG_NODE(i);

		if (equal_buf_str (&child->key, "host")) {
			set_host (src, &child->val);
		}

		/* Base class: do not display error here
		 */
	}
コード例 #18
0
ファイル: validator_ldap.c プロジェクト: abbrev/webserver
ret_t
cherokee_validator_ldap_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	ret_t                            ret;
	cherokee_list_t                 *i;
	cherokee_validator_ldap_props_t *props;

	UNUSED(srv);

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, validator_ldap_props);

		cherokee_validator_props_init_base (VALIDATOR_PROPS(n), MODULE_PROPS_FREE(props_free));

		n->port = LDAP_DEFAULT_PORT;
		n->tls  = false;

		cherokee_buffer_init (&n->server);
		cherokee_buffer_init (&n->binddn);
		cherokee_buffer_init (&n->bindpw);
		cherokee_buffer_init (&n->basedn);
		cherokee_buffer_init (&n->filter);
		cherokee_buffer_init (&n->ca_file);

		*_props = MODULE_PROPS(n);
	}

	props = PROP_LDAP(*_props);

	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "server")) {
			cherokee_buffer_add_buffer (&props->server, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "port")) {
			ret = cherokee_atoi (subconf->val.buf, &props->port);
			if (ret != ret_ok) return ret_error;

		} else if (equal_buf_str (&subconf->key, "bind_dn")) {
			cherokee_buffer_add_buffer (&props->binddn, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "bind_pw")) {
			cherokee_buffer_add_buffer (&props->bindpw, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "base_dn")) {
			cherokee_buffer_add_buffer (&props->basedn, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "filter")) {
			cherokee_buffer_add_buffer (&props->filter, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "tls")) {
			ret = cherokee_atob (subconf->val.buf, &props->tls);
			if (ret != ret_ok) return ret_error;

		} else if (equal_buf_str (&subconf->key, "ca_file")) {
			cherokee_buffer_add_buffer (&props->ca_file, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "methods") ||
		           equal_buf_str (&subconf->key, "realm")   ||
		           equal_buf_str (&subconf->key, "users")) {
			/* Handled in validator.c
			 */
		} else {
			LOG_WARNING (CHEROKEE_ERROR_VALIDATOR_LDAP_KEY, subconf->key.buf);
		}
	}
コード例 #19
0
ファイル: handler_xslt.c プロジェクト: skinkie/webserver
/* A _configure function will be executed by the webserver
 * at the moment of 'first' initialisation. Here you do the
 * start of memory management. The processing of the configuration
 * parameters.
 */
ret_t 
cherokee_handler_xslt_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	cherokee_list_t               *i;
	cherokee_handler_xslt_props_t *props;
	ret_t                          ret;

	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_xslt_props);

		cherokee_module_props_init_base (MODULE_PROPS(n), 
						 MODULE_PROPS_FREE(props_free));		
        
		/* Look at handler_xslt.h
		 * This is an xslt of configuration.
		 */
		xmlInitMemory();
		
		LIBXML_TEST_VERSION

		/*
		 * Register the EXSLT extensions and the test module
		 */
		exsltRegisterAll();
		xsltRegisterTestModule();

		cherokee_buffer_init (&n->content_type);
		cherokee_buffer_init (&n->stylesheet);
		n->global = NULL;
		n->globalDoc = NULL;
		n->xinclude = false;
		n->xincludestyle = false;
//		n->sec = xsltNewSecurityPrefs();
//		xsltSetDefaultSecurityPrefs(n->sec);
		n->defaultEntityLoader = xmlGetExternalEntityLoader();
//		xmlSetExternalEntityLoader(xsltprocExternalEntityLoader);

		*_props = MODULE_PROPS(n);
	}

	props = PROP_XSLT(*_props);

	/* processing of the parameters, we only know about xslt_config
	 * it might be a good thing to abort if we found a wrong key, understand
	 * the consequences: your handler will prevent the server startup upon
	 * a wrong configuration.
         *
         * You see the for each method is rather creative. Read more code
         * to see with what nice things Cherokee extended the C syntax.
	 */
	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		/* Cherokee has a nifty string equal function that allows
                 * lazy programmers to do strcmp without the == 0.
                 */
		/*if (equal_buf_str (&subconf->key, "maxdepth")) {
			cherokee_atoi(subconf->val.buf, &props->xsltMaxDepth);
		} else if (equal_buf_str (&subconf->key, "maxparserdepth")) {
			cherokee_atoi(subconf->val.buf, &props->xsltParserMaxDepth);
		} else */
		if (equal_buf_str (&subconf->key, "options")) {
			if (equal_buf_str (&subconf->val, "novalid")) {
				props->options |= XML_PARSE_NOENT | XML_PARSE_NOCDATA;
			} else if (equal_buf_str (&subconf->val, "nodtdattr")) {
				props->options |= XML_PARSE_NOENT | XML_PARSE_DTDLOAD | XML_PARSE_NOCDATA;
			} else {
				PRINT_MSG ("ERROR: Handler xslt: Unknown value: '%s'\n", subconf->val.buf);
				return ret_error;
			}
		} else if (equal_buf_str (&subconf->key, "nodict")) {
			cherokee_boolean_t nodict;
		        ret = cherokee_atob (subconf->val.buf, &nodict);
			if (ret != ret_ok) return ret;
			if (nodict) {
				props->options |= XML_PARSE_NODICT;
			}
#ifdef LIBXML_CATALOG_ENABLED
		} else if (equal_buf_str (&subconf->key, "catalogs")) {
			cherokee_boolean_t catalogs;
		        ret = cherokee_atob (subconf->val.buf, &catalogs);
			if (ret != ret_ok) return ret;
			if (catalogs) {
				const char *catalogs = getenv("SGML_CATALOG_FILES");
				if (catalogs != NULL) {
					xmlLoadCatalogs(catalogs);
				}
			}
#endif
#ifdef LIBXML_XINCLUDE_ENABLED
		} else if (equal_buf_str (&subconf->key, "xinclude")) {
		        ret = cherokee_atob (subconf->val.buf, &props->xinclude);
		} else if (equal_buf_str (&subconf->key, "xincludestyle")) {
		        ret = cherokee_atob (subconf->val.buf, &props->xincludestyle);
			if (props->xincludestyle) {
				xsltSetXIncludeDefault(1);
			}
#endif
		} else if (equal_buf_str (&subconf->key, "contenttype")) {
			cherokee_buffer_add(&props->content_type, subconf->val.buf, subconf->val.len);
		} else if (equal_buf_str (&subconf->key, "stylesheet")) {
			cherokee_buffer_add(&props->stylesheet, subconf->val.buf, subconf->val.len);
		} else {
			PRINT_MSG ("ERROR: Handler xslt: Unknown key: '%s'\n", subconf->key.buf);
			return ret_error;
		}
	}
コード例 #20
0
ret_t
cherokee_validator_mysql_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	cherokee_list_t			 *i;
	cherokee_validator_mysql_props_t *props;

	UNUSED(srv);

	if(*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, validator_mysql_props);

		cherokee_validator_props_init_base (VALIDATOR_PROPS (n), MODULE_PROPS_FREE(props_free));

		cherokee_buffer_init (&n->host);
		cherokee_buffer_init (&n->unix_socket);
		cherokee_buffer_init (&n->user);
		cherokee_buffer_init (&n->passwd);
		cherokee_buffer_init (&n->database);
		cherokee_buffer_init (&n->query);

		n->port      = MYSQL_DEFAULT_PORT;
		n->hash_type = cherokee_mysql_hash_none;

		*_props = MODULE_PROPS (n);
	}

	props = PROP_MYSQL(*_props);

	cherokee_config_node_foreach (i, conf) {
		cherokee_config_node_t *subconf = CONFIG_NODE(i);

		if (equal_buf_str (&subconf->key, "host")) {
			cherokee_buffer_add_buffer (&props->host, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "port")) {
			props->port = atoi (subconf->val.buf);

		} else if (equal_buf_str (&subconf->key, "unix_socket")) {
			cherokee_buffer_add_buffer (&props->unix_socket, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "user")) {
			cherokee_buffer_add_buffer (&props->user, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "passwd")) {
			cherokee_buffer_add_buffer (&props->passwd, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "database")) {
			cherokee_buffer_add_buffer (&props->database, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "query")) {
			cherokee_buffer_add_buffer (&props->query, &subconf->val);

		} else if (equal_buf_str (&subconf->key, "hash")) {
			if (equal_buf_str (&subconf->val, "md5")) {
				props->hash_type = cherokee_mysql_hash_md5;

			} else if (equal_buf_str (&subconf->val, "sha1")) {
				props->hash_type = cherokee_mysql_hash_sha1;

			} else {
				LOG_CRITICAL (CHEROKEE_ERROR_VALIDATOR_MYSQL_HASH, subconf->val.buf);
				return ret_error;
			}

		} else if ((equal_buf_str (&subconf->key, "methods") ||
			    equal_buf_str (&subconf->key, "realm")))
		{
			/* not handled here
			 */
		} else {
			LOG_CRITICAL (CHEROKEE_ERROR_VALIDATOR_MYSQL_KEY, subconf->key.buf);
			return ret_error;
		}
	}
コード例 #21
0
ファイル: handler_dirlist.c プロジェクト: chetan/cherokee
ret_t
cherokee_handler_dirlist_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
    ret_t                             ret;
    cherokee_list_t                  *i;
    cherokee_handler_dirlist_props_t *props;
    const char                       *theme      = NULL;
    cherokee_buffer_t                 theme_path = CHEROKEE_BUF_INIT;

    UNUSED(srv);

    if (*_props == NULL) {
        CHEROKEE_NEW_STRUCT (n, handler_dirlist_props);

        cherokee_handler_props_init_base (HANDLER_PROPS(n),
                                          MODULE_PROPS_FREE(cherokee_handler_dirlist_props_free));

        n->show_size      = true;
        n->show_date      = true;
        n->show_user      = false;
        n->show_group     = false;
        n->show_icons     = true;
        n->show_symlinks  = true;
        n->redir_symlinks = false;

        n->show_hidden    = false;
        n->show_backup    = false;

        cherokee_buffer_init (&n->header);
        cherokee_buffer_init (&n->footer);
        cherokee_buffer_init (&n->entry);
        cherokee_buffer_init (&n->css);

        cherokee_buffer_init (&n->icon_web_dir);
        cherokee_buffer_add_str (&n->icon_web_dir, ICON_WEB_DIR_DEFAULT);

        INIT_LIST_HEAD (&n->notice_files);
        INIT_LIST_HEAD (&n->hidden_files);

        *_props = MODULE_PROPS(n);
    }

    props = PROP_DIRLIST(*_props);

    cherokee_config_node_foreach (i, conf) {
        cherokee_config_node_t *subconf = CONFIG_NODE(i);

        /* Convert the properties
         */
        if (equal_buf_str (&subconf->key, "size")) {
            props->show_size  = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "date")) {
            props->show_date  = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "user")) {
            props->show_user  = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "group")) {
            props->show_group = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "symlinks")) {
            props->show_symlinks = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "redir_symlinks")) {
            props->redir_symlinks = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "hidden")) {
            props->show_hidden = !! atoi (subconf->val.buf);
        } else if (equal_buf_str (&subconf->key, "backup")) {
            props->show_backup = !! atoi (subconf->val.buf);

        } else if (equal_buf_str (&subconf->key, "theme")) {
            theme = subconf->val.buf;

        } else if (equal_buf_str (&subconf->key, "icon_dir")) {
            cherokee_buffer_clean (&props->icon_web_dir);
            cherokee_buffer_add_buffer (&props->icon_web_dir, &subconf->val);

        } else if (equal_buf_str (&subconf->key, "notice_files")) {
            ret = cherokee_config_node_read_list (subconf, NULL, file_match_add_cb, &props->notice_files);
            if (unlikely (ret != ret_ok))
                return ret;

        } else if (equal_buf_str (&subconf->key, "hidden_files")) {
            ret = cherokee_config_node_read_list (subconf, NULL, file_match_add_cb, &props->hidden_files);
            if (unlikely (ret != ret_ok))
                return ret;
        }
    }