static ret_t configure_rewrite_entry (cherokee_list_t *list, cherokee_config_node_t *conf, cherokee_regex_table_t *regexs) { ret_t ret; cherokee_regex_entry_t *n; cherokee_buffer_t *substring; cint_t hidden = 1; pcre *re = NULL; cherokee_buffer_t *regex = NULL; TRACE(ENTRIES, "Converting rewrite rule '%s'\n", conf->key.buf); /* Query conf */ cherokee_config_node_read_int (conf, "show", &hidden); hidden = !hidden; ret = cherokee_config_node_read (conf, "regex", ®ex); if (ret == ret_ok) { ret = cherokee_regex_table_get (regexs, regex->buf, (void **)&re); if (ret != ret_ok) return ret; } ret = cherokee_config_node_read (conf, "substring", &substring); if (ret != ret_ok) return ret; /* New RegEx */ n = (cherokee_regex_entry_t *) malloc(sizeof(cherokee_regex_entry_t)); if (unlikely (n == NULL)) return ret_nomem; INIT_LIST_HEAD (&n->listed); n->re = re; n->hidden = hidden; cherokee_buffer_init (&n->subs); cherokee_buffer_add_buffer (&n->subs, substring); /* Add the list */ cherokee_list_add_tail (&n->listed, list); return ret_ok; }
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; }