Beispiel #1
0
static ret_t
file_match_add_cb (char *entry, void *data)
{
    ret_t            ret;
    file_match_t    *new_match = NULL;
    cherokee_list_t *list      = LIST(data);

    ret = file_match_new (&new_match);
    if (unlikely ((ret != ret_ok) || (new_match == NULL)))
        return ret_error;

    if ((strchr (entry, '*')) || (strchr (entry, '?')))
    {
        new_match->is_wildcard = true;
    }

    cherokee_buffer_add (&new_match->filename, entry, strlen(entry));

    TRACE(ENTRIES, "Match file entry: '%s' (wildcard: %s)\n",
          new_match->filename.buf,
          new_match->is_wildcard ? "yes" : "no");

    cherokee_list_add_tail (&new_match->list_node, list);
    return ret_ok;
}
Beispiel #2
0
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;
	cherokee_boolean_t      hidden     = true;
	pcre                   *re         = NULL;
	cherokee_buffer_t      *regex      = NULL;

	TRACE(ENTRIES, "Converting rewrite rule '%s'\n", conf->key.buf);

	/* Query conf
	 */
	cherokee_config_node_read_bool (conf, "show", &hidden);
	hidden = !hidden;

	ret = cherokee_config_node_read (conf, "regex", &regex);
	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;
}