ssize_t tmpl_afrom_str(TALLOC_CTX *ctx, value_pair_tmpl_t **out, char const *name, size_t inlen,
FR_TOKEN type, request_refs_t request_def, pair_lists_t list_def, bool do_escape);
-bool tmpl_cast_in_place(value_pair_tmpl_t *vpt, PW_TYPE type, DICT_ATTR const *enumv);
+int tmpl_cast_in_place(value_pair_tmpl_t *vpt, PW_TYPE type, DICT_ATTR const *enumv);
void tmpl_cast_in_place_str(value_pair_tmpl_t *vpt);
int tmpl_find_vp(VALUE_PAIR **out, REQUEST *request, value_pair_tmpl_t const *vpt);
-bool tmpl_define_unknown_attr(value_pair_tmpl_t *vpt);
+int tmpl_define_unknown_attr(value_pair_tmpl_t *vpt);
#ifdef __cplusplus
}
goto marker;
}
- if (!tmpl_define_unknown_attr(map->lhs)) {
+ if (tmpl_define_unknown_attr(map->lhs) < 0) {
cf_log_err_cp(cp, "Failed creating attribute %s: %s",
map->lhs->name, fr_strerror());
goto error;
} else {
slen = tmpl_afrom_str(map, &map->rhs, value, strlen(value), type, src_request_def, src_list_def, true);
if (slen < 0) goto marker;
- if (!tmpl_define_unknown_attr(map->rhs)) {
+ if (tmpl_define_unknown_attr(map->rhs) < 0) {
cf_log_err_cp(cp, "Failed creating attribute %s: %s", map->rhs->name, fr_strerror());
goto error;
}
(cf_pair_value_type(cp) == T_SINGLE_QUOTED_STRING)) {
tmpl_cast_in_place_str(map->rhs);
} else {
- if (!tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da)) {
+ if (tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da) < 0) {
cf_log_err(map->ci, "%s", fr_strerror());
return -1;
}
if (f->vpt->type == TMPL_TYPE_ATTR) {
rad_assert(f->vpt->tmpl_da != NULL);
- if (!tmpl_cast_in_place(g->vpt, f->vpt->tmpl_da->type, f->vpt->tmpl_da)) {
+ if (tmpl_cast_in_place(g->vpt, f->vpt->tmpl_da->type, f->vpt->tmpl_da) < 0) {
cf_log_err_cs(g->cs, "Invalid argument for case statement: %s",
fr_strerror());
return false;
return_P(fr_strerror());
}
- if (!tmpl_define_unknown_attr(map->lhs)) {
+ if (tmpl_define_unknown_attr(map->lhs) < 0) {
return_lhs("Failed defining attribute");
return_lhs:
if (lhs) talloc_free(lhs);
return_P(fr_strerror());
}
- if (!tmpl_define_unknown_attr(map->rhs)) {
+ if (tmpl_define_unknown_attr(map->rhs) < 0) {
return_rhs("Failed defining attribute");
}
}
* Cast it to the appropriate data type.
*/
if ((c->data.map->lhs->type == TMPL_TYPE_LITERAL) &&
- !tmpl_cast_in_place(c->data.map->lhs, c->cast->type, c->cast)) {
+ (tmpl_cast_in_place(c->data.map->lhs, c->cast->type, c->cast) < 0)) {
*error = "Failed to parse field";
if (lhs) talloc_free(lhs);
if (rhs) talloc_free(rhs);
*/
if ((c->data.map->lhs->type == TMPL_TYPE_DATA) &&
(c->data.map->rhs->type == TMPL_TYPE_LITERAL) &&
- !tmpl_cast_in_place(c->data.map->rhs, c->cast->type, c->cast)) {
+ (tmpl_cast_in_place(c->data.map->rhs, c->cast->type, c->cast) < 0)) {
return_rhs("Failed to parse field");
}
* literal. Cast the RHS to the type of the cast.
*/
if (c->cast && (c->data.map->rhs->type == TMPL_TYPE_LITERAL) &&
- !tmpl_cast_in_place(c->data.map->rhs, c->cast->type, c->cast)) {
+ (tmpl_cast_in_place(c->data.map->rhs, c->cast->type, c->cast) < 0)) {
return_rhs("Failed to parse field");
}
break;
}
- if (!tmpl_cast_in_place(c->data.map->rhs, type, c->data.map->lhs->tmpl_da)) {
+ if (tmpl_cast_in_place(c->data.map->rhs, type, c->data.map->lhs->tmpl_da) < 0) {
DICT_ATTR const *da = c->data.map->lhs->tmpl_da;
if ((da->vendor == 0) &&
* @param[in,out] vpt The template to modify. Must be of type #TMPL_TYPE_LITERAL.
* @param[in] type to cast to.
* @param[in] enumv Enumerated dictionary values associated with a #DICT_ATTR.
- * @return true for success, false for failure.
+ * @return 0 on success, -1 on failure.
*/
-bool tmpl_cast_in_place(value_pair_tmpl_t *vpt, PW_TYPE type, DICT_ATTR const *enumv)
+int tmpl_cast_in_place(value_pair_tmpl_t *vpt, PW_TYPE type, DICT_ATTR const *enumv)
{
ssize_t ret;
* Why do we pass a pointer to the tmpl type? Goddamn WiMAX.
*/
ret = value_data_from_str(vpt, &vpt->tmpl_data_value, &vpt->tmpl_data_type, enumv, vpt->name, vpt->len, '\0');
- if (ret < 0) return false;
+ if (ret < 0) return -1;
vpt->type = TMPL_TYPE_DATA;
vpt->tmpl_data_length = (size_t) ret;
VERIFY_TMPL(vpt);
- return true;
+ return 0;
}
/** Convert #value_pair_tmpl_t of type #TMPL_TYPE_LITERAL to #TMPL_TYPE_DATA of type #PW_TYPE_STRING
*
* @param vpt to add. ``tmpl_da`` pointer will be updated to point to the
* #DICT_ATTR inserted into the dictionary.
- * @return true on success, false on failure.
+ * @return 0 on success, -1 on failure.
*/
-bool tmpl_define_unknown_attr(value_pair_tmpl_t *vpt)
+int tmpl_define_unknown_attr(value_pair_tmpl_t *vpt)
{
DICT_ATTR const *da;
- if (!vpt) return false;
+ if (!vpt) return -1;
VERIFY_TMPL(vpt);
if ((vpt->type != TMPL_TYPE_ATTR) &&
(vpt->type != TMPL_TYPE_DATA)) {
- return true;
+ return 0;
}
- if (!vpt->tmpl_da->flags.is_unknown) return true;
+ if (!vpt->tmpl_da->flags.is_unknown) return 0;
da = dict_unknown_add(vpt->tmpl_da);
- if (!da) return false;
+ if (!da) return -1;
vpt->tmpl_da = da;
- return true;
+ return 0;
}
/* @} **/
* Convert literal to a type appropriate for
* the VP.
*/
- if (!tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da)) goto error;
+ if (tmpl_cast_in_place(map->rhs, map->lhs->tmpl_da->type, map->lhs->tmpl_da) < 0) goto error;
vp = pairalloc(c, map->lhs->tmpl_da);
len = value_data_copy(vp, &vp->data, map->rhs->tmpl_data_type,