* @param dict to user for partial resolution.
* @param attribute name to parse.
* @param value to parse (must be a hex string).
- * @param op to assign to new valuepair.
* @return new #fr_pair_t or NULL on error.
*/
static fr_pair_t *fr_pair_make_unknown(TALLOC_CTX *ctx, fr_dict_t const *dict,
- char const *attribute, char const *value,
- fr_token_t op)
+ char const *attribute, char const *value)
{
fr_pair_t *vp;
fr_dict_attr_t *n;
if (fr_pair_value_from_str(vp, value, strlen(value), &fr_value_unescape_double, false) < 0) goto error;
- vp->op = (op == 0) ? T_OP_EQ : op;
+ vp->op = T_OP_EQ;
return vp;
}
* @param[in] vps list where the attribute will be added (optional)
* @param[in] attribute name.
* @param[in] value attribute value (may be NULL if value will be set later).
- * @param[in] op to assign to new #fr_pair_t.
* @return a new #fr_pair_t.
*/
fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict, fr_pair_list_t *vps,
- char const *attribute, char const *value, fr_token_t op)
+ char const *attribute, char const *value)
{
fr_dict_attr_t const *da;
fr_pair_t *vp;
*/
da = fr_dict_attr_search_by_qualified_oid(NULL, dict, attrname, true, true);
if (!da) {
- vp = fr_pair_make_unknown(ctx, dict, attrname, value, op);
+ vp = fr_pair_make_unknown(ctx, dict, attrname, value);
if (!vp) return NULL;
if (vps) fr_pair_append(vps, vp);
vp = fr_pair_afrom_da(ctx, da);
if (!vp) return NULL;
- vp->op = (op == 0) ? T_OP_EQ : op;
-
- switch (vp->op) {
- case T_OP_CMP_TRUE:
- case T_OP_CMP_FALSE:
- fr_pair_value_clear(vp);
- value = NULL; /* ignore it! */
- break;
-
- /*
- * Regular expression comparison of integer attributes
- * does a STRING comparison of the names of their
- * integer attributes.
- */
- case T_OP_REG_EQ: /* =~ */
- case T_OP_REG_NE: /* !~ */
- {
-#ifndef HAVE_REGEX
- fr_strerror_const("Regular expressions are not supported");
- return NULL;
-#else
- ssize_t slen;
- regex_t *preg;
-
- /*
- * Someone else will fill in the value.
- */
- if (!value) break;
-
- talloc_free(vp);
-
- slen = regex_compile(ctx, &preg, value, strlen(value), NULL, false, true);
- if (slen <= 0) {
- fr_strerror_printf_push("Error at offset %zu compiling regex for %s", -slen, attribute);
- return NULL;
- }
- talloc_free(preg);
-
- vp = fr_pair_afrom_da(ctx, da);
- if (!vp) return NULL;
- vp->op = op;
-
- if (fr_pair_mark_xlat(vp, value) < 0) {
- talloc_free(vp);
- return NULL;
- }
-
- value = NULL; /* ignore it */
- break;
-#endif
- }
- default:
- break;
- }
+ vp->op = T_OP_EQ;
/*
* We probably want to fix fr_pair_value_from_str to accept
#endif
fr_pair_t *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict,
- fr_pair_list_t *vps, char const *attribute, char const *value, fr_token_t op);
+ fr_pair_list_t *vps, char const *attribute, char const *value);
int fr_pair_mark_xlat(fr_pair_t *vp, char const *value);
fr_pair_list_init(&list);
TEST_CASE("Creating 'vp' using fr_pair_make()");
- TEST_CHECK((vp = fr_pair_make(ctx, test_dict, &list, "Test-String-0", test_string, T_DOUBLE_QUOTED_STRING)) != NULL);
+ TEST_CHECK((vp = fr_pair_make(ctx, test_dict, &list, "Test-String-0", test_string)) != NULL);
TEST_CASE("Validating PAIR_VERIFY()");
PAIR_VERIFY(vp);
(i != inst->key_field) && inst->pwd_fmt->listflag[i] == when) {
if (!inst->ignore_empty || pw->field[i][0] != 0 ) { /* if value in key/value pair is not empty */
vp = fr_pair_make(ctx, request->dict,
- vps, inst->pwd_fmt->field[i], pw->field[i], T_OP_EQ);
+ vps, inst->pwd_fmt->field[i], pw->field[i]);
if (vp) {
RDEBUG2("Added %s: '%s' to %s ", inst->pwd_fmt->field[i], pw->field[i], listname);
}
* Value Pair Format
*
*/
-static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps, char *key, SV *sv, fr_token_t op,
+static int pairadd_sv(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vps, char *key, SV *sv,
const char *hash_name, const char *list_name)
{
char *val;
if (!SvOK(sv)) return -1;
val = SvPV(sv, len);
- vp = fr_pair_make(ctx, request->dict, vps, key, NULL, op);
+ vp = fr_pair_make(ctx, request->dict, vps, key, NULL);
if (!vp) {
fail:
- REDEBUG("Failed to create pair %s.%s %s %s", list_name, key,
- fr_table_str_by_value(fr_tokens_table, op, "<INVALID>"), val);
+ REDEBUG("Failed to create pair %s.%s = %s", list_name, key, val);
return -1;
}
PAIR_VERIFY(vp);
- RDEBUG2("&%s.%s %s $%s{'%s'} -> '%s'", list_name, key, fr_table_str_by_value(fr_tokens_table, op, "<INVALID>"),
- hash_name, key, val);
+ RDEBUG2("&%s.%s = $%s{'%s'} -> '%s'", list_name, key, hash_name, key, val);
return 0;
}
len = av_len(av);
for (j = 0; j <= len; j++) {
av_sv = av_fetch(av, j, 0);
- ret = pairadd_sv(ctx, request, vps, key, *av_sv, T_OP_ADD_EQ, hash_name, list_name) + ret;
+ ret = pairadd_sv(ctx, request, vps, key, *av_sv, hash_name, list_name) + ret;
}
- } else ret = pairadd_sv(ctx, request, vps, key, res_sv, T_OP_EQ, hash_name, list_name) + ret;
+ } else ret = pairadd_sv(ctx, request, vps, key, res_sv, hash_name, list_name) + ret;
}
if (!fr_pair_list_empty(vps)) PAIR_LIST_VERIFY(vps);