*/
+static xlat_arg_parser_t const xlat_func_debug_args[] = {
+ { .single = true, .type = FR_TYPE_INT8 },
+ XLAT_ARG_PARSER_TERMINATOR
+};
+
/** Dynamically change the debugging level for the current request
*
* Example:
@verbatim
-"%{debug:3}"
+"%(debug:3)"
@endverbatim
*
* @ingroup xlat_functions
*/
-static ssize_t xlat_func_debug(UNUSED TALLOC_CTX *ctx, char **out, size_t outlen,
- UNUSED void const *mod_inst, UNUSED void const *xlat_inst,
- request_t *request, char const *fmt)
+static xlat_action_t xlat_func_debug(TALLOC_CTX *ctx, fr_dcursor_t *out,
+ request_t *request, UNUSED void const *xlat_inst,
+ UNUSED void *xlat_thread_inst, fr_value_box_list_t *in)
{
int level = 0;
+ fr_value_box_t *vb;
+ fr_value_box_t *in_head = fr_dlist_head(in);
/*
* Expand to previous (or current) level
*/
- snprintf(*out, outlen, "%d", request->log.lvl);
+ MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_INT8, NULL, false));
+ vb->vb_int8 = request->log.lvl;
+ fr_dcursor_append(out, vb);
/*
* Assume we just want to get the current value and NOT set it to 0
*/
- if (!*fmt)
+ if (!in_head)
goto done;
- level = atoi(fmt);
+ level = in_head->vb_int8;
if (level == 0) {
request->log.lvl = RAD_REQUEST_LVL_NONE;
} else {
}
done:
- return strlen(*out);
+ return XLAT_ACTION_DONE;
}
#define XLAT_REGISTER(_x) xlat = xlat_register_legacy(NULL, STRINGIFY(_x), xlat_func_ ## _x, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN); \
xlat_internal(xlat);
- xlat = xlat_register_legacy(NULL, "debug", xlat_func_debug, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN);
- xlat_internal(xlat);
XLAT_REGISTER(debug_attr);
xlat_register_legacy(NULL, "explode", xlat_func_explode, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN);
XLAT_REGISTER(integer);
xlat_func_args(xlat, _args); \
} while (0)
+ XLAT_REGISTER_ARGS("debug", xlat_func_debug, xlat_func_debug_args);
XLAT_REGISTER_ARGS("hmacmd5", xlat_func_hmac_md5, xlat_hmac_args);
XLAT_REGISTER_ARGS("hmacsha1", xlat_func_hmac_sha1, xlat_hmac_args);
XLAT_REGISTER_ARGS("concat", xlat_func_concat, xlat_func_concat_args);
# Set debug to something high, recording the old level
update request {
- &Tmp-Integer-0 := "%{debug:4}"
+ &Tmp-Integer-0 := "%(debug:4)"
}
# Check debug level is now 4
-if ("%{debug:4}" != 4) {
+if ("%(debug:4)" != 4) {
fail
}
# Set debug back to the original level
-"%{debug:%{Tmp-Integer-0}}"
+"%(debug:%{Tmp-Integer-0})"
# Read out the current debug level to verify it changed
-if ("%{debug:%{Tmp-Integer-0}}" != "%{Tmp-Integer-0}") {
+if ("%(debug:%{Tmp-Integer-0})" != "%{Tmp-Integer-0}") {
fail
}