예제 #1
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;
}
예제 #2
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;
}
예제 #3
0
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;
}
예제 #4
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;
}
예제 #5
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;
}
예제 #6
0
ret_t
cherokee_vrule_free (cherokee_vrule_t *vrule)
{
	if (MODULE(vrule)->free) {
		MODULE(vrule)->free (vrule);
	}

	free (vrule);
	return ret_ok;
}
예제 #7
0
ret_t
cherokee_encoder_free (cherokee_encoder_t *enc)
{
	ret_t ret;

	if (MODULE(enc)->free == NULL)
		return ret_error;

	ret = MODULE(enc)->free (enc);
	return ret;
}
예제 #8
0
파일: math.c 프로젝트: hpersh/ool2
void
math_module_init(void)
{
  vm_push(0);
  
  MODULE(module_cur)->consts  = (obj_t *) &math_consts;
  MODULE(module_cur)->nconsts = sizeof(math_consts) / sizeof(obj_t);
  
  init_strs(math_init_str_tbl, ARRAY_SIZE(math_init_str_tbl));
  
  init_inst_methods(math_init_inst_method_tbl, ARRAY_SIZE(math_init_inst_method_tbl));
  
  vm_pop(0);
}
예제 #9
0
/* Encoder
 */
ret_t
cherokee_encoder_init_base (cherokee_encoder_t       *enc,
			    cherokee_plugin_info_t   *info,
			    cherokee_encoder_props_t *props)
{
	cherokee_module_init_base (MODULE(enc), NULL, info);

	MODULE(enc)->props = props;
	enc->encode        = NULL;
	enc->add_headers   = NULL;
	enc->flush         = NULL;

	return ret_ok;
}
예제 #10
0
파일: rule_geoip.c 프로젝트: BeQ/webserver
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;
}
예제 #11
0
파일: collector.c 프로젝트: BeQ/webserver
static ret_t
base_init (cherokee_collector_base_t *collector,
	   cherokee_plugin_info_t    *info,
	   cherokee_config_node_t    *config)
{
	ret_t ret;

	/* Init the base class
	 */
	cherokee_module_init_base (MODULE(collector), NULL, info);

	/* Pure virtual methods
	 */
	collector->free       = NULL;

	/* Properties
	 */
	collector->rx         = 0;
	collector->rx_partial = 0;
	collector->tx         = 0;
	collector->tx_partial = 0;

	/* Private
	 */
	ret = priv_new ((priv_t **) &collector->priv);
	if (ret != ret_ok) {
		return ret;
	}

	/* Read configuration
	 */
	UNUSED (config);

	return ret_ok;
}
예제 #12
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;
}
예제 #13
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;
}
예제 #14
0
파일: logger.c 프로젝트: BeQ/webserver
/* Virtual method hiding layer
 */
ret_t
cherokee_logger_free (cherokee_logger_t *logger)
{
	CHEROKEE_MUTEX_DESTROY (&PRIV(logger)->mutex);

	if (MODULE(logger)->free) {
		MODULE(logger)->free (logger);
	}

	if (logger->priv) {
		cherokee_x_real_ip_mrproper (&logger->priv->x_real_ip);
		free (logger->priv);
	}

	free (logger);
	return ret_ok;
}
예제 #15
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;
}
예제 #16
0
ret_t
cherokee_handler_free (cherokee_handler_t *hdl)
{
	/* Sanity check
	 */
	return_if_fail (hdl != NULL, ret_error);

	if (MODULE(hdl)->free == NULL) {
		return ret_error;
	}

	MODULE(hdl)->free (hdl);

	/* Free the handler memory
	 */
	free (hdl);
	return ret_ok;
}
예제 #17
0
CMainFrmModules::CMainFrmModules(void)
{
    IModuleList* pModules = CModuleLoader::Get().GetModules();
    if (pModules->first())
    {
        do
        {
            push_back(MODULE(&(pModules->current()), size() + 1, size()));
        } while (pModules->next());
    }
}
예제 #18
0
파일: logger.c 프로젝트: BeQ/webserver
ret_t
cherokee_logger_init (cherokee_logger_t *logger)
{
	logger_func_init_t init_func;

	init_func = (logger_func_init_t) MODULE(logger)->init;

	if (init_func) {
		return init_func (logger);
	}

	return ret_error;
}
예제 #19
0
ret_t
cherokee_vrule_init_base (cherokee_vrule_t       *vrule,
			  cherokee_plugin_info_t *info)
{
	cherokee_module_init_base (MODULE(vrule), NULL, info);
	INIT_LIST_HEAD (&vrule->list_node);

	vrule->virtual_server = NULL;
	vrule->match          = NULL;
	vrule->priority       = CHEROKEE_VRULE_PRIO_NONE;

	return ret_ok;
}
예제 #20
0
ret_t
cherokee_handler_dbslayer_new (cherokee_handler_t     **hdl,
			       void                    *cnt,
			       cherokee_module_props_t *props)
{
	CHEROKEE_NEW_STRUCT (n, handler_dbslayer);

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

	MODULE(n)->init         = (handler_func_init_t) cherokee_handler_dbslayer_init;
	MODULE(n)->free         = (module_func_free_t) dbslayer_free;
	HANDLER(n)->step        = (handler_func_step_t) dbslayer_step;
	HANDLER(n)->add_headers = (handler_func_add_headers_t) dbslayer_add_headers;

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

	/* Properties
	 */
	n->src_ref  = NULL;
	n->rollback = false;

	/* Data writer */
	cherokee_dwriter_init (&n->writer, &CONN_THREAD(cnt)->tmp_buf1);
	n->writer.lang = PROP_DBSLAYER(props)->lang;

	/* MySQL */
	n->conn = mysql_init (NULL);
	if (unlikely (n->conn == NULL)) {
		cherokee_handler_free (HANDLER(n));
		return ret_nomem;
	}

	*hdl = HANDLER(n);
	return ret_ok;
}
예제 #21
0
파일: validator.c 프로젝트: chetan/cherokee
ret_t
cherokee_validator_free (cherokee_validator_t *validator)
{
	module_func_free_t func;

	return_if_fail (validator!=NULL, ret_error);

	func = (module_func_free_t) MODULE(validator)->free;

	if (func == NULL) {
		return ret_error;
	}

	return func (validator);
}
예제 #22
0
/* Utilities
 */
ret_t
cherokee_handler_add_header_options (cherokee_handler_t *hdl,
                                     cherokee_buffer_t  *buffer)
{
	ret_t                   ret;
	int                     http_n;
	const char             *method_name;
	cuint_t                 method_name_len;
	cherokee_http_method_t  method;
	cherokee_http_method_t  supported_methods;
	cherokee_boolean_t      first              = true;

	/* Introspect the handler
	 */
	supported_methods = PLUGIN_INFO_HANDLER (MODULE (hdl)->info)->valid_methods;

	/* Build the response string
	 */
	cherokee_buffer_add_str (buffer, "Allow: ");

	for (http_n=0; http_n < cherokee_http_method_LENGTH; http_n++)
	{
		method = HTTP_METHOD (1LL << http_n);

		if (supported_methods & method) {
			method_name     = NULL;
			method_name_len = 0;

			if (! first) {
				cherokee_buffer_add_str (buffer, ", ");
			} else {
				first = false;
			}

			ret = cherokee_http_method_to_string (method, &method_name, &method_name_len);
			if (unlikely ((ret != ret_ok) || (! method_name))) {
				continue;
			}

			cherokee_buffer_add (buffer, method_name, method_name_len);
		}
	}

	cherokee_buffer_add_str (buffer, CRLF);
	return ret_ok;

}
예제 #23
0
ret_t
cherokee_handler_init (cherokee_handler_t *hdl)
{
	handler_func_init_t init_func;

	/* Sanity check
	 */
	return_if_fail (hdl != NULL, ret_error);

	init_func = (handler_func_init_t) MODULE(hdl)->init;

	if (init_func) {
		return init_func(hdl);
	}

	return ret_error;
}
예제 #24
0
ret_t
cherokee_encoder_init (cherokee_encoder_t *enc, void *conn)
{
	encoder_func_init_t init_func;

	/* Properties
	 */
	enc->conn = conn;

	/* Call the virtual method
	 */
	init_func = (encoder_func_init_t) MODULE(enc)->init;
	if (init_func == NULL)
		return ret_error;

	return init_func (enc);
}
ret_t
cherokee_validator_htdigest_new (cherokee_validator_htdigest_t **htdigest, cherokee_module_props_t *props)
{
	CHEROKEE_NEW_STRUCT(n,validator_htdigest);

	/* Init
	 */
	cherokee_validator_file_init_base (VFILE(n),
					   PROP_VFILE(props),
					   PLUGIN_INFO_VALIDATOR_PTR(htdigest));

	VALIDATOR(n)->support = http_auth_basic | http_auth_digest;

	MODULE(n)->free           = (module_func_free_t)           cherokee_validator_htdigest_free;
	VALIDATOR(n)->check       = (validator_func_check_t)       cherokee_validator_htdigest_check;
	VALIDATOR(n)->add_headers = (validator_func_add_headers_t) cherokee_validator_htdigest_add_headers;

	/* Return obj
	 */
	*htdigest = n;
	return ret_ok;
}
예제 #26
0
ret_t
cherokee_rule_not_new (cherokee_rule_t **rule)
{
	CHEROKEE_NEW_STRUCT (n, rule_not);

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

	/* 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->right = NULL;

	*rule = RULE(n);
	return ret_ok;
}
예제 #27
0
파일: validator.c 프로젝트: chetan/cherokee
ret_t
cherokee_validator_init_base (cherokee_validator_t             *validator,
			      cherokee_validator_props_t       *props,
			      cherokee_plugin_info_validator_t *info)
{
	cherokee_module_init_base (MODULE(validator), MODULE_PROPS(props), PLUGIN_INFO(info));

	validator->check = NULL;

	cherokee_buffer_init (&validator->user);
	cherokee_buffer_init (&validator->passwd);
	cherokee_buffer_init (&validator->realm);
	cherokee_buffer_init (&validator->response);
	cherokee_buffer_init (&validator->uri);
	cherokee_buffer_init (&validator->qop);
	cherokee_buffer_init (&validator->nonce);
	cherokee_buffer_init (&validator->cnonce);
	cherokee_buffer_init (&validator->algorithm);
	cherokee_buffer_init (&validator->nc);

	return ret_ok;
}
예제 #28
0
ret_t
cherokee_handler_init_base (cherokee_handler_t             *hdl,
                            void                           *conn,
                            cherokee_handler_props_t       *props,
                            cherokee_plugin_info_handler_t *info)
{
	/* Init the base class
	 */
	cherokee_module_init_base (MODULE(hdl), MODULE_PROPS(props), PLUGIN_INFO(info));

	/* Pure virtual methods
	 */
	hdl->read_post     = NULL;
	hdl->add_headers   = NULL;
	hdl->step          = NULL;

	/* Parent reference
	 */
	hdl->connection    = conn;

	return ret_ok;
}
예제 #29
0
ret_t
cherokee_rule_directory_new (cherokee_rule_directory_t **rule)
{
	CHEROKEE_NEW_STRUCT (n, rule_directory);

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

	/* 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
	 */
	cherokee_buffer_init (&n->directory);

	*rule = n;
 	return ret_ok;
}
예제 #30
0
파일: vrule_or.c 프로젝트: BeQ/webserver
ret_t
cherokee_vrule_v_or_new (cherokee_vrule_t **vrule)
{
	CHEROKEE_NEW_STRUCT (n, vrule_or);

	/* Parent class constructor
	 */
	cherokee_vrule_init_base (VRULE(n), PLUGIN_INFO_PTR(v_or));

	/* Virtual methods
	 */
	VRULE(n)->match     = (vrule_func_match_t) match;
	VRULE(n)->configure = (vrule_func_configure_t) configure;
	MODULE(n)->free     = (module_func_free_t) _free;

	/* Properties
	 */
	n->left  = NULL;
	n->right = NULL;

	*vrule = VRULE(n);
	return ret_ok;
}