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;
		}
	}
示例#2
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_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;
			}
		}
	}
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;
		}

	}
示例#5
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;
		}
	}
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;
}
示例#7
0
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;
        }
    }