ret_t
cherokee_handler_zeromq_new (cherokee_handler_t	 **hdl, void *cnt, cherokee_module_props_t *props)
{
	CHEROKEE_NEW_STRUCT (n, handler_zeromq);
	
	/* Init the base class object
	 */
	cherokee_handler_init_base (HANDLER(n), cnt, HANDLER_PROPS(props), PLUGIN_INFO_HANDLER_PTR(zeromq));

	MODULE(n)->init			= (handler_func_init_t) cherokee_handler_zeromq_init;
	MODULE(n)->free			= (module_func_free_t) zeromq_free;
	HANDLER(n)->read_post   = (handler_func_read_post_t) cherokee_handler_zeromq_read_post;
	HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_zeromq_add_headers;
	HANDLER(n)->step		= (handler_func_step_t) cherokee_handler_zeromq_step;

	/* Supported features
	 */
	HANDLER(n)->support	 = hsupport_nothing;
	 
	cherokee_buffer_init (&n->output);
	cherokee_buffer_ensure_size (&n->output, 2097152);
	n->encoder = NULL;

	*hdl = HANDLER(n);
	return ret_ok;
}
Esempio n. 2
0
ret_t
cherokee_handler_ssi_new (cherokee_handler_t     **hdl,
                          cherokee_connection_t   *cnt,
                          cherokee_module_props_t *props)
{
	CHEROKEE_NEW_STRUCT (n, handler_ssi);

	/* Init the base class object
	 */
	cherokee_handler_init_base (HANDLER(n), cnt, HANDLER_PROPS(props), PLUGIN_INFO_HANDLER_PTR(ssi));

	MODULE(n)->free         = (module_func_free_t) cherokee_handler_ssi_free;
	MODULE(n)->init         = (handler_func_init_t) cherokee_handler_ssi_init;
	HANDLER(n)->step        = (handler_func_step_t) cherokee_handler_ssi_step;
	HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_ssi_add_headers;

	/* Supported features
	*/
	HANDLER(n)->support     = hsupport_nothing;

	/* Init
	 */
	n->mime = NULL;
	cherokee_buffer_init (&n->dir);
	cherokee_buffer_init (&n->source);
	cherokee_buffer_init (&n->render);

	/* Return the object
	 */
	*hdl = HANDLER(n);
	return ret_ok;
}
Esempio n. 3
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;
		}
	}
Esempio n. 4
0
ret_t
cherokee_rule_extensions_new (cherokee_rule_extensions_t **rule)
{
	CHEROKEE_NEW_STRUCT (n, rule_extensions);

	/* Parent class constructor
	 */
	cherokee_rule_init_base (RULE(n), PLUGIN_INFO_PTR(extensions));

	/* Virtual methods
	 */
	RULE(n)->match     = (rule_func_match_t) match;
	RULE(n)->configure = (rule_func_configure_t) configure;
	MODULE(n)->free    = (module_func_free_t) _free;

	/* Properties
	 */
	n->check_local_file = false;
	n->use_iocache      = true;

	cherokee_avl_init (&n->extensions);

	*rule = n;
 	return ret_ok;
}
Esempio n. 5
0
ret_t
cherokee_logger_writer_new (cherokee_logger_writer_t **writer)
{
	CHEROKEE_NEW_STRUCT(n,logger_writer);

	INIT_LIST_HEAD (&n->listed);

	n->type        = cherokee_logger_writer_syslog;
	n->fd          = -1;
	n->max_bufsize = DEFAULT_LOGGER_MAX_BUFSIZE;

	cherokee_buffer_init (&n->command);
	cherokee_buffer_init (&n->filename);
	cherokee_buffer_init (&n->buffer);

	cherokee_buffer_ensure_size (&n->buffer, n->max_bufsize);

	n->priv = malloc (sizeof(priv_t));
	if (n->priv == NULL) {
		cherokee_buffer_mrproper (&n->buffer);
		free(n);
		return ret_nomem;
	}

	CHEROKEE_MUTEX_INIT (&PRIV(n)->mutex, NULL);
	n->initialized = false;

	*writer = n;
	return ret_ok;
}
Esempio n. 6
0
ret_t
cherokee_rule_geoip_new (cherokee_rule_t **rule)
{
	CHEROKEE_NEW_STRUCT (n, rule_geoip);

	/* Parent class constructor
	 */
	cherokee_rule_init_base (RULE(n), PLUGIN_INFO_PTR(geoip));

	/* Virtual methods
	 */
	RULE(n)->match     = (rule_func_match_t) match;
	RULE(n)->configure = (rule_func_configure_t) configure;
	MODULE(n)->free    = (module_func_free_t) _free;

	/* Properties
	 */
	n->geoip = geoip_get();
	if (n->geoip == NULL)
		return ret_error;

	cherokee_avl_init (&n->countries);

	*rule = RULE(n);
	return ret_ok;
}
Esempio n. 7
0
ret_t
cherokee_handler_error_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt, cherokee_module_props_t *props)
{
	ret_t ret;
	CHEROKEE_NEW_STRUCT (n, handler_error);

	/* Init the base class object
	 */
	cherokee_handler_init_base (HANDLER(n), cnt, HANDLER_PROPS(props), PLUGIN_INFO_HANDLER_PTR(error));

	/* Supported features
	*/
	HANDLER(n)->support = hsupport_error;

	MODULE(n)->init         = (handler_func_init_t) cherokee_handler_error_init;
	MODULE(n)->free         = (module_func_free_t) cherokee_handler_error_free;
	HANDLER(n)->step        = (handler_func_step_t) cherokee_handler_error_step;
	HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_error_add_headers;

	/* Init
	 */
	ret = cherokee_buffer_init (&n->content);
	if (unlikely(ret < ret_ok))
		return ret;

	/* Return the object
	 */
	*hdl = HANDLER(n);
	return ret_ok;
}
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;
		}
	}
Esempio n. 9
0
ret_t
cherokee_handler_admin_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_props_t *props)
{
    CHEROKEE_NEW_STRUCT (n, handler_admin);

    /* Init the base class object
     */
    cherokee_handler_init_base (HANDLER(n), cnt, HANDLER_PROPS(props), PLUGIN_INFO_HANDLER_PTR(admin));

    MODULE(n)->init         = (module_func_init_t) cherokee_handler_admin_init;
    MODULE(n)->free         = (module_func_free_t) cherokee_handler_admin_free;
    HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_admin_add_headers;
    HANDLER(n)->read_post   = (handler_func_read_post_t) cherokee_handler_admin_read_post;
    HANDLER(n)->step        = (handler_func_step_t) cherokee_handler_admin_step;

    /* Supported features
     */
    HANDLER(n)->support     = hsupport_nothing;

    cherokee_buffer_init (&n->reply);

    /* Configure the data writer object
     */
    cherokee_dwriter_init       (&n->dwriter, THREAD_TMP_BUF1(CONN_THREAD(cnt)));
    cherokee_dwriter_set_buffer (&n->dwriter, &n->reply);

    /* Return the object
     */
    *hdl = HANDLER(n);
    return ret_ok;
}
Esempio n. 10
0
ret_t
cherokee_rule_header_new (cherokee_rule_header_t **rule)
{
	CHEROKEE_NEW_STRUCT (n, rule_header);

	/* Parent class constructor
	 */
	cherokee_rule_init_base (RULE(n), PLUGIN_INFO_PTR(header));

	/* Virtual methods
	 */
	RULE(n)->match     = (rule_func_match_t) match;
	RULE(n)->configure = (rule_func_configure_t) configure;
	MODULE(n)->free    = (module_func_free_t) _free;

	/* Properties
	 */
	n->pcre = NULL;
	n->type = rule_header_type_regex;

	cherokee_buffer_init (&n->match);

	*rule = n;
 	return ret_ok;
}
Esempio n. 11
0
ret_t
cherokee_logger_ncsa_new (cherokee_logger_t         **logger,
			  cherokee_virtual_server_t  *vsrv,
			  cherokee_config_node_t     *config)
{
	ret_t ret;
	CHEROKEE_NEW_STRUCT (n, logger_ncsa);

	/* Init the base class object
	 */
	cherokee_logger_init_base (LOGGER(n), PLUGIN_INFO_PTR(ncsa), config);

	MODULE(n)->init         = (logger_func_init_t) cherokee_logger_ncsa_init;
	MODULE(n)->free         = (logger_func_free_t) cherokee_logger_ncsa_free;

	LOGGER(n)->flush        = (logger_func_flush_t) cherokee_logger_ncsa_flush;
	LOGGER(n)->reopen       = (logger_func_reopen_t) cherokee_logger_ncsa_reopen;
	LOGGER(n)->write_access = (logger_func_write_access_t) cherokee_logger_ncsa_write_access;

	n->writer_access = NULL;

	ret = cherokee_logger_ncsa_init_base (n, VSERVER(vsrv), config);
	if (unlikely(ret < ret_ok)) {
		cherokee_logger_free (LOGGER(n));
		return ret;
	}

	/* Return the object
	 */
	*logger = LOGGER(n);
	return ret_ok;
}
Esempio n. 12
0
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;
		}
	}
ret_t
cherokee_handler_proxy_conn_new (cherokee_handler_proxy_conn_t **pconn)
{
	CHEROKEE_NEW_STRUCT (n, handler_proxy_conn);

	/* Socket stuff
	 */
	cherokee_socket_init (&n->socket);

	n->post.sent        = 0;
	n->post.do_buf_sent = true;
	cherokee_buffer_init (&n->post.buf_temp);

	cherokee_buffer_init (&n->header_in_raw);
	cherokee_buffer_ensure_size (&n->header_in_raw, 512);

	n->poll_ref      = NULL;
	n->keepalive_in  = false;
	n->size_in       = 0;
	n->sent_out      = 0;
	n->enc           = pconn_enc_none;

	*pconn = n;
	return ret_ok;
}
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;
			}
		}
	}
Esempio n. 15
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;
		}

	}
Esempio n. 16
0
ret_t
cherokee_header_op_new (cherokee_header_op_t **op)
{
	CHEROKEE_NEW_STRUCT (n, header_op);

	INIT_LIST_HEAD (&n->entry);
	cherokee_buffer_init (&n->header);
	cherokee_buffer_init (&n->value);

	*op = n;
	return ret_ok;
}
Esempio n. 17
0
/* Entries
 */
static ret_t
entry_new (cherokee_resolv_cache_entry_t **entry)
{
	CHEROKEE_NEW_STRUCT(n, resolv_cache_entry);

	n->addr = NULL;
	cherokee_buffer_init (&n->ip_str);
	cherokee_buffer_init (&n->ip_str_all);

	*entry = n;
	return ret_ok;
}
Esempio n. 18
0
ret_t
cherokee_avl_r_init (cherokee_avl_r_t *avl_r)
{
	ret_t ret;
	CHEROKEE_NEW_STRUCT(n, avl_r_priv);

	ret = cherokee_avl_init (&avl_r->avl);
	if (ret != ret_ok)
		return ret;

	avl_r->priv = n;
	CHEROKEE_RWLOCK_INIT (AVL_R_LOCK(avl_r), NULL);

	return ret_ok;
}
Esempio n. 19
0
ret_t
cherokee_regex_table_new  (cherokee_regex_table_t **table)
{
	CHEROKEE_NEW_STRUCT (n, regex_table);

	/* Init
	 */
	CHEROKEE_RWLOCK_INIT (&n->rwlock, NULL);
	cherokee_avl_init (&n->cache);

	/* Return the new object
	 */
	*table = n;
	return ret_ok;
}
Esempio n. 20
0
ret_t
cherokee_mime_entry_new (cherokee_mime_entry_t **mentry)
{
    CHEROKEE_NEW_STRUCT(n, mime_entry);

    INIT_LIST_HEAD(&n->base);

    n->maxage     = -1;
    n->maxage_set = false;

    cherokee_buffer_init (&n->mime_name);

    *mentry = n;
    return ret_ok;
}
ret_t
cherokee_handler_proxy_poll_new (cherokee_handler_proxy_poll_t **poll,
				 cuint_t                         reuse_max)
{
	CHEROKEE_NEW_STRUCT (n, handler_proxy_poll);

	n->reuse_len = 0;
	n->reuse_max = reuse_max;

	INIT_LIST_HEAD (&n->active);
	INIT_LIST_HEAD (&n->reuse);
	CHEROKEE_MUTEX_INIT (&n->mutex, CHEROKEE_MUTEX_FAST);

	*poll = n;
	return ret_ok;
}
Esempio n. 22
0
ret_t
cherokee_resolv_cache_get_default (cherokee_resolv_cache_t **resolv)
{
	ret_t ret;

	if (unlikely (__global_resolv == NULL)) {
		CHEROKEE_NEW_STRUCT (n, resolv_cache);

		ret = cherokee_resolv_cache_init (n);
		if (ret != ret_ok) return ret;

		__global_resolv = n;
	}

	*resolv = __global_resolv;
	return ret_ok;
}
Esempio n. 23
0
ret_t
cherokee_handler_cgi_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	/* Instance a new property object
	 */
	if (*_props == NULL) {
		CHEROKEE_NEW_STRUCT (n, handler_cgi_props);

		cherokee_handler_cgi_base_props_init_base (PROP_CGI_BASE(n),
			MODULE_PROPS_FREE(cherokee_handler_cgi_props_free));
		*_props = MODULE_PROPS(n);
	}

	/* Parse local options
	 */
	return cherokee_handler_cgi_base_configure (conf, srv, _props);
}
Esempio n. 24
0
ret_t
cherokee_handler_cgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_props_t *props)
{
	int i;
	CHEROKEE_NEW_STRUCT (n, handler_cgi);

	/* Init the base class
	 */
	cherokee_handler_cgi_base_init (HDL_CGI_BASE(n), cnt, PLUGIN_INFO_HANDLER_PTR(cgi),
					HANDLER_PROPS(props), cherokee_handler_cgi_add_env_pair, read_from_cgi);

	/* Virtual methods
	 */
	MODULE(n)->init         = (module_func_init_t) cherokee_handler_cgi_init;
	MODULE(n)->free         = (module_func_free_t) cherokee_handler_cgi_free;
	HANDLER(n)->read_post   = (handler_func_read_post_t) cherokee_handler_cgi_read_post;

	/* Virtual methods: implemented by handler_cgi_base
	 */
	HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_cgi_base_add_headers;
	HANDLER(n)->step        = (handler_func_step_t) cherokee_handler_cgi_base_step;

	/* Init
	 */
	n->pipeInput  = -1;
	n->pipeOutput = -1;

#ifdef _WIN32
	n->process   = NULL;
	n->thread    = NULL;

	cherokee_buffer_init (&n->envp);
#else
	n->pid       = -1;
	n->envp_last =  0;

	for (i=0; i<ENV_VAR_NUM; i++)
		n->envp[i] = NULL;
#endif

	/* Return the object
	 */
	*hdl = HANDLER(n);
	return ret_ok;
}
Esempio n. 25
0
ret_t
cherokee_buffer_dup (cherokee_buffer_t *buf, cherokee_buffer_t **dup)
{
	CHEROKEE_NEW_STRUCT(n, buffer);

	n->buf = (char *) malloc(buf->len + 1);
	if (unlikely (n->buf == NULL)) {
		free(n);
		return ret_nomem;
	}

	memcpy (n->buf, buf->buf, buf->len + 1);

	n->len  = buf->len;
	n->size = buf->len + 1;

	*dup = n;
	return ret_ok;
}
Esempio n. 26
0
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;
		}
	}
Esempio n. 27
0
ret_t
cherokee_handler_secdownload_configure (cherokee_config_node_t   *conf,
					cherokee_server_t        *srv,
					cherokee_module_props_t **_props)
{
	ret_t                                 ret;
	cherokee_handler_secdownload_props_t *props;

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

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

		cherokee_buffer_init (&n->secret);
		n->timeout = 60;

		*_props = MODULE_PROPS(n);
	}

	props = PROP_SECDOWN(*_props);

	/* Parse 'file' parameters
	 */
	props->props_file = NULL;
	ret = cherokee_handler_file_configure (conf, srv, (cherokee_module_props_t **)&props->props_file);
	if ((ret != ret_ok) && (ret != ret_deny))
		return ret;

	/* Properties
	 */
	ret = cherokee_config_node_copy (conf, "secret", &props->secret);
	if (ret != ret_ok) {
		LOG_CRITICAL_S (CHEROKEE_ERROR_HANDLER_SECDOWN_SECRET);
		return ret_error;
	}

	cherokee_config_node_read_int (conf, "timeout", (int*)&props->timeout);

	return ret_ok;
}
ret_t
cherokee_validator_htdigest_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props)
{
	cherokee_validator_htdigest_props_t *props;

	UNUSED(srv);

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

		cherokee_validator_file_props_init_base (PROP_VFILE(n),
							 MODULE_PROPS_FREE(props_free));
		*_props = MODULE_PROPS(n);
	}

	props = PROP_HTDIGEST(*_props);

	/* Call the file based validator configure
	 */
	return cherokee_validator_file_configure (conf, srv, _props);
}
Esempio n. 29
0
static ret_t
iocache_entry_new_cb (cherokee_cache_t        *cache,
		      cherokee_buffer_t       *key,
		      void                    *param,
		      cherokee_cache_entry_t **ret_entry)
{
	CHEROKEE_NEW_STRUCT(n, iocache_entry_extension);

	UNUSED(param);

	CHEROKEE_MUTEX_INIT (&PRIV(n)->parent_lock, CHEROKEE_MUTEX_FAST);

	/* Init its parent class
	 */
#ifdef HAVE_PTHREAD
	cherokee_cache_entry_init (CACHE_ENTRY(n), key, cache, &PRIV(n)->parent_lock);
#else
	cherokee_cache_entry_init (CACHE_ENTRY(n), key, cache, NULL);
#endif

	/* Set the virtual methods
	 */
	CACHE_ENTRY(n)->clean_cb = clean_info_cb;
	CACHE_ENTRY(n)->fetch_cb = fetch_info_cb;
	CACHE_ENTRY(n)->free_cb  = free_cb;

	/* Init its properties
	 */
	PRIV(n)->stat_expiration = 0;
	PRIV(n)->mmap_expiration = 0;
	PUBL(n)->mmaped          = NULL;
	PUBL(n)->mmaped_len      = 0;
	PUBL(n)->info            = 0;
	PUBL(n)->state_ret       = ret_ok;

	/* Return the new object
	 */
	*ret_entry = CACHE_ENTRY(n);
	return ret_ok;
}
Esempio n. 30
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;
			}
		}
	}