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; } }
static void cherokee_client_headers (cherokee_handler_dbslayer_t *hdl) { ret_t ret; char *hdr = NULL; cuint_t len = 0; cherokee_connection_t *conn = HANDLER_CONN(hdl); ret = cherokee_header_get_unknown (&conn->header, "X-Beautify", 10, &hdr, &len); if ((ret == ret_ok) && hdr) { ret = cherokee_atob (hdr, &hdl->writer.pretty); if (ret != ret_ok) return ret; } hdr = NULL; ret = cherokee_header_get_unknown (&conn->header, "X-Rollback", 10, &hdr, &len); if ((ret == ret_ok) && hdr) { ret = cherokee_atob (hdr, &hdl->rollback); if (ret != ret_ok) return ret; } }
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_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); } }
/* 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; } }
ret_t cherokee_handler_tmi_configure (cherokee_config_node_t *conf, cherokee_server_t *srv, cherokee_module_props_t **_props) { ret_t ret; cherokee_list_t *i; cherokee_handler_tmi_props_t *props; cherokee_plugin_info_t *info = NULL; /* Instance a new property object */ if (*_props == NULL) { CHEROKEE_NEW_STRUCT (n, handler_tmi_props); cherokee_handler_props_init_base (HANDLER_PROPS(n), MODULE_PROPS_FREE(props_free)); cherokee_buffer_init (&n->reply); cherokee_buffer_init (&n->subscriberid); cherokee_buffer_init (&n->version); cherokee_buffer_init (&n->dossiername); cherokee_buffer_init (&n->endpoint); n->io_threads = 1; n->validate_xml = false; CHEROKEE_MUTEX_INIT (&n->mutex, CHEROKEE_MUTEX_FAST); *_props = MODULE_PROPS(n); } props = PROP_TMI(*_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, "subscriberid")) { cherokee_buffer_clean (&props->subscriberid); cherokee_buffer_add_buffer (&props->subscriberid, &subconf->val); } else if (equal_buf_str (&subconf->key, "version")) { cherokee_buffer_clean (&props->version); cherokee_buffer_add_buffer (&props->version, &subconf->val); } else if (equal_buf_str (&subconf->key, "dossiername")) { cherokee_buffer_clean (&props->dossiername); cherokee_buffer_add_buffer (&props->dossiername, &subconf->val); } else 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, "validate_xml")) { cherokee_atob (subconf->val.buf, &props->validate_xml); } 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; } }