return (opt_policy_name_eq(conf, token, req->policy->s, matches));
OPT_SERV_X_EQ(req->policy->s->policy_name); else if (OPT_SERV_SYM_EQ("connection-tag-eq") || OPT_SERV_SYM_EQ("connection-tag==")) OPT_SERV_X_EQ(con->tag); else if (OPT_SERV_SYM_EQ("tag-eq") || OPT_SERV_SYM_EQ("tag==")) OPT_SERV_X_EQ(req->tag);
static int httpd__policy_request_tst_d1(struct Con *con,                                        Httpd_req_data *req,                                        Conf_parse *conf, Conf_token *token,                                        int *matches){  Vstr_base *http_data = con->evnt->io_r;  int clist = FALSE;    ASSERT(con && req);    ASSERT(matches);    CONF_SC_TOGGLE_CLIST_VAR(clist);  if (token->type >= CONF_TOKEN_TYPE_USER_BEG)  {    unsigned int type = token->type - CONF_TOKEN_TYPE_USER_BEG;    unsigned int nxt = 0;    Vstr_ref *ref = conf_token_get_user_value(conf, token, &nxt);        switch (type)    {      case HTTPD_POLICY_REQ_PATH_BEG:      case HTTPD_POLICY_REQ_PATH_END:      case HTTPD_POLICY_REQ_PATH_EQ:              case HTTPD_POLICY_REQ_NAME_BEG:      case HTTPD_POLICY_REQ_NAME_END:      case HTTPD_POLICY_REQ_NAME_EQ:              case HTTPD_POLICY_REQ_BWEN_BEG:      case HTTPD_POLICY_REQ_BWEN_END:      case HTTPD_POLICY_REQ_BWEN_EQ:              case HTTPD_POLICY_REQ_BWES_BEG:      case HTTPD_POLICY_REQ_BWES_END:      case HTTPD_POLICY_REQ_BWES_EQ:              case HTTPD_POLICY_REQ_EXTN_BEG:      case HTTPD_POLICY_REQ_EXTN_END:      case HTTPD_POLICY_REQ_EXTN_EQ:              case HTTPD_POLICY_REQ_EXTS_BEG:      case HTTPD_POLICY_REQ_EXTS_END:      case HTTPD_POLICY_REQ_EXTS_EQ:      {        size_t pos = 1;        size_t len = req->fname->len;        unsigned int lim = httpd_policy_path_req2lim(type);        vstr_ref_add(ref);        *matches = httpd_policy_path_lim_eq(req->fname, &pos, &len, lim,                                            req->vhost_prefix_len, ref);      }      break;            case HTTPD_POLICY_CLIENT_IPV4_CIDR_EQ:      {        struct sockaddr *sa = CON_CEVNT_SA(con);        *matches = httpd_policy_ipv4_cidr_eq(con, req, ref->ptr, sa);      }      break;              case HTTPD_POLICY_SERVER_IPV4_CIDR_EQ:      {        struct sockaddr *sa = CON_SEVNT_SA(con);        *matches = httpd_policy_ipv4_cidr_eq(con, req, ref->ptr, sa);      }              default:        vstr_ref_del(ref);        return (FALSE);    }    vstr_ref_del(ref);    if (nxt)      return (conf_parse_num_token(conf, token, nxt));  }  else if (OPT_SERV_SYM_EQ("policy-eq") || OPT_SERV_SYM_EQ("policy=="))    return (opt_policy_name_eq(conf, token, req->policy->s, matches));  else if (OPT_SERV_SYM_EQ("client-ipv4-cidr-eq") ||           OPT_SERV_SYM_EQ("client-ipv4-cidr=="))    return (httpd_policy_ipv4_make(con, req, conf, token,                                   HTTPD_POLICY_CLIENT_IPV4_CIDR_EQ,                                   CON_CEVNT_SA(con), matches));  else if (OPT_SERV_SYM_EQ("server-ipv4-cidr-eq") ||           OPT_SERV_SYM_EQ("server-ipv4-cidr=="))    return (httpd_policy_ipv4_make(con, req, conf, token,                                   HTTPD_POLICY_SERVER_IPV4_CIDR_EQ,                                   CON_SEVNT_SA(con), matches));  else if (OPT_SERV_SYM_EQ("hostname-eq") || OPT_SERV_SYM_EQ("hostname=="))  { /* doesn't do escaping because DNS is ASCII */    Vstr_sect_node *h_h = req->http_hdrs->hdr_host;    Vstr_base *d_h = req->policy->default_hostname;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    if (h_h->len)      *matches = conf_token_cmp_case_val_eq(conf, token,                                            http_data, h_h->pos, h_h->len);    else      *matches = conf_token_cmp_case_val_eq(conf, token,                                            d_h, 1, d_h->len);  }  else if (OPT_SERV_SYM_EQ("user-agent-eq") || OPT_SERV_SYM_EQ("UA-eq") ||           OPT_SERV_SYM_EQ("user-agent==") || OPT_SERV_SYM_EQ("UA=="))  { /* doesn't do escaping because URLs are ASCII */    Vstr_sect_node *h_ua = req->http_hdrs->hdr_ua;    req->vary_ua = TRUE;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = conf_token_cmp_case_val_eq(conf, token, http_data, 1, h_ua->len);  }  else if (OPT_SERV_SYM_EQ("user-agent-search-eq") ||           OPT_SERV_SYM_EQ("user-agent-search==") ||           OPT_SERV_SYM_EQ("user-agent-srch-eq") ||           OPT_SERV_SYM_EQ("user-agent-srch==") ||           OPT_SERV_SYM_EQ("UA-srch-eq") ||           OPT_SERV_SYM_EQ("UA-srch=="))  { /* doesn't do escaping because URLs are ASCII */    Vstr_sect_node *h_ua = req->http_hdrs->hdr_ua;    req->vary_ua = TRUE;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = !!conf_token_srch_case_val(conf, token, http_data, 1, h_ua->len);  }  else if (OPT_SERV_SYM_EQ("referrer-eq") || OPT_SERV_SYM_EQ("referer-eq") ||           OPT_SERV_SYM_EQ("referrer==")  || OPT_SERV_SYM_EQ("referer=="))  { /* doesn't do escaping because URLs are ASCII */    Vstr_sect_node *h_ref = req->http_hdrs->hdr_referer;    req->vary_rf = TRUE;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = conf_token_cmp_case_val_eq(conf, token,                                          http_data, 1, h_ref->len);  }  else if (OPT_SERV_SYM_EQ("referrer-beg") || OPT_SERV_SYM_EQ("referer-beg"))  { /* doesn't do escaping because URLs are ASCII */    Vstr_sect_node *h_ref = req->http_hdrs->hdr_referer;    req->vary_rf = TRUE;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = conf_token_cmp_case_val_beg_eq(conf, token,                                              http_data, 1, h_ref->len);  }  else if (OPT_SERV_SYM_EQ("referrer-search-eq") ||           OPT_SERV_SYM_EQ("referrer-search==") ||           OPT_SERV_SYM_EQ("referrer-srch-eq") ||           OPT_SERV_SYM_EQ("referrer-srch==") ||           OPT_SERV_SYM_EQ("referer-search-eq") ||           OPT_SERV_SYM_EQ("referer-search==") ||           OPT_SERV_SYM_EQ("referer-srch-eq") ||           OPT_SERV_SYM_EQ("referer-srch=="))  { /* doesn't do escaping because URLs are ASCII */    Vstr_sect_node *h_ref = req->http_hdrs->hdr_referer;    req->vary_rf = TRUE;    CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = !!conf_token_srch_case_val(conf, token,                                          http_data, 1, h_ref->len);  }  else if (OPT_SERV_SYM_EQ("http-0.9-eq") || OPT_SERV_SYM_EQ("http-0.9=="))    *matches =  req->ver_0_9;  else if (OPT_SERV_SYM_EQ("http-1.0-eq") || OPT_SERV_SYM_EQ("http-1.0=="))    *matches = !req->ver_0_9 && !req->ver_1_1;  else if (OPT_SERV_SYM_EQ("http-1.1-eq") || OPT_SERV_SYM_EQ("http-1.1=="))    *matches = !req->ver_0_9 &&  req->ver_1_1;  else if (OPT_SERV_SYM_EQ("method-eq") || OPT_SERV_SYM_EQ("method=="))  { /* doesn't do escaping because methods are ASCII */    Vstr_sect_node *meth = VSTR_SECTS_NUM(req->sects, 1);        CONF_SC_PARSE_TOP_TOKEN_RET(conf, token, FALSE);    *matches = conf_token_cmp_case_val_eq(conf, token,                                          http_data, meth->pos, meth->len);  }  else if (OPT_SERV_SYM_EQ("tm-dow-eq") || OPT_SERV_SYM_EQ("tm-dow=="))  { /* so we can do msff :) */    Opt_serv_opts *opts = req->policy->s->beg;    Httpd_opts *hopts = (Httpd_opts *)opts;    const struct tm *tm = date_gmtime(hopts->date, req->now);    int tmp = 0;    if (!tm) return (FALSE);    /* vary_star ... or nothing ? */    OPT_SERV_X_UINT(tmp);    *matches = tmp == tm->tm_wday;  }  else  { /* spend time doing path/name/extn/bnwe */    Vstr_ref *ref = NULL;    unsigned int type = HTTPD_POLICY_REQ_PATH_BEG;    unsigned int lim  = 0;    size_t pos = 1;    size_t len = req->fname->len;        if (0) { }    else if (OPT_SERV_SYM_EQ("path-beg"))      type = HTTPD_POLICY_REQ_PATH_BEG;    else if (OPT_SERV_SYM_EQ("path-end"))      type = HTTPD_POLICY_REQ_PATH_END;    else if (OPT_SERV_SYM_EQ("path-eq") || OPT_SERV_SYM_EQ("path=="))      type = HTTPD_POLICY_REQ_PATH_EQ;    else if (OPT_SERV_SYM_EQ("basename-beg"))      type = HTTPD_POLICY_REQ_NAME_BEG;    else if (OPT_SERV_SYM_EQ("basename-end"))      type = HTTPD_POLICY_REQ_NAME_END;    else if (OPT_SERV_SYM_EQ("basename-eq") || OPT_SERV_SYM_EQ("basename=="))      type = HTTPD_POLICY_REQ_NAME_EQ;    else if (OPT_SERV_SYM_EQ("extension-beg"))      type = HTTPD_POLICY_REQ_EXTN_BEG;    else if (OPT_SERV_SYM_EQ("extension-end"))      type = HTTPD_POLICY_REQ_EXTN_END;    else if (OPT_SERV_SYM_EQ("extension-eq") || OPT_SERV_SYM_EQ("extension=="))      type = HTTPD_POLICY_REQ_EXTN_EQ;    else if (OPT_SERV_SYM_EQ("extensions-beg"))      type = HTTPD_POLICY_REQ_EXTS_BEG;    else if (OPT_SERV_SYM_EQ("extensions-end"))      type = HTTPD_POLICY_REQ_EXTS_END;    else if (OPT_SERV_SYM_EQ("extensions-eq") ||             OPT_SERV_SYM_EQ("extensions=="))      type = HTTPD_POLICY_REQ_EXTS_EQ;    else if (OPT_SERV_SYM_EQ("basename-without-extension-beg"))      type = HTTPD_POLICY_REQ_BWEN_BEG;    else if (OPT_SERV_SYM_EQ("basename-without-extension-end"))      type = HTTPD_POLICY_REQ_BWEN_END;    else if (OPT_SERV_SYM_EQ("basename-without-extension-eq") ||             OPT_SERV_SYM_EQ("basename-without-extension=="))      type = HTTPD_POLICY_REQ_BWEN_EQ;    else if (OPT_SERV_SYM_EQ("basename-without-extensions-beg"))      type = HTTPD_POLICY_REQ_BWES_BEG;    else if (OPT_SERV_SYM_EQ("basename-without-extensions-end"))      type = HTTPD_POLICY_REQ_BWES_END;    else if (OPT_SERV_SYM_EQ("basename-without-extensions-eq") ||             OPT_SERV_SYM_EQ("basename-without-extensions=="))      type = HTTPD_POLICY_REQ_BWES_EQ;    else    {      struct Httpd__policy_req_tst_data data[1];      data->con = con;      data->req = req;      return (opt_serv_sc_tst(conf, token, matches,                              httpd__policy_request_tst_op_d1, data));    }        if (!httpd_policy_path_make(con, req, conf, token, type, &ref))    {      vstr_ref_del(ref);      return (FALSE);    }        lim = httpd_policy_path_req2lim(type);    *matches = httpd_policy_path_lim_eq(req->fname, &pos, &len, lim,                                        req->vhost_prefix_len, ref);  }  return (TRUE);}