From: Alan T. DeKok Date: Wed, 9 May 2012 13:47:21 +0000 (+0200) Subject: Added module configuration X-Git-Tag: release_3_0_0_beta0~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2f64c9c46d88be0fd7ad02c49e3fb86b5ee6e22;p=thirdparty%2Ffreeradius-server.git Added module configuration --- diff --git a/src/main/xlat.c b/src/main/xlat.c index 118a3590dd8..f9b7ff2d601 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -560,6 +560,18 @@ static size_t xlat_hex(UNUSED void *instance, REQUEST *request, } +/** + * @brief Prints the current module processing the request + */ +static size_t xlat_module(UNUSED void *instance, REQUEST *request, + UNUSED char *fmt, char *out, size_t outlen, + UNUSED RADIUS_ESCAPE_STRING func) +{ + strlcpy(out, request->module, outlen); + + return strlen(out); +} + #ifdef WITH_UNLANG /** * @brief Implements the Foreach-Variable-X @@ -872,20 +884,15 @@ int xlat_register(const char *module, RAD_XLAT_FUNC func, void *instance) rad_assert(c != NULL); c->internal = TRUE; - xlat_register("integer", xlat_integer, NULL); - c = xlat_find("integer"); - rad_assert(c != NULL); - c->internal = TRUE; - - xlat_register("hex", xlat_hex, NULL); - c = xlat_find("hex"); - rad_assert(c != NULL); - c->internal = TRUE; +#define XLAT_REGISTER(_x) xlat_register(Stringify(_x), xlat_ ## _x, NULL); \ + c = xlat_find(Stringify(_x)); \ + rad_assert(c != NULL); \ + c->internal = TRUE - xlat_register("string", xlat_string, NULL); - c = xlat_find("string"); - rad_assert(c != NULL); - c->internal = TRUE; + XLAT_REGISTER(integer); + XLAT_REGISTER(hex); + XLAT_REGISTER(string); + XLAT_REGISTER(module); #ifdef HAVE_REGEX_H /*