set, then the length is not set.
e.g. %{#Junk-junk:-foo} will yeild the string "foo".
+.IP %{Attribute-Name#}
+Will print the integer value of the attribute, rather than a decoded
+VALUE or date. This feature applies only to attributes of type
+"date", "integer", "byte", and "short". It has no effect on any other
+attributes. It is used when the numerical value is needed (e.g. Unix
+seconds), rather than a humanly-readable string.
+
+e.g. If a request contains "Service-Type = Login-User", the expansion
+of %{Service-Type#} will yeild "1".
.IP %{Attribute-Name[index]}
Reference the N'th occurance of the given attribute. The syntax
%{<list>:Attribute-Name[index]} may also be used. The indexes start
*/
da = dict_attrbyname(fmt);
if (!da) {
+ int do_number = FALSE;
size_t count;
- const char *p = strchr(fmt, '[');
+ const char *p;
char buffer[256];
- if (!p) return 0;
if (strlen(fmt) > sizeof(buffer)) return 0;
+ DEBUG("GOT SHIT %s", fmt);
+
+ p = strchr(fmt, '[');
+ if (!p) {
+ p = strchr(fmt, '#');
+ if (!p) return 0;
+ do_number = TRUE;
+ }
+
strlcpy(buffer, fmt, p - fmt + 1);
da = dict_attrbyname(buffer);
if (!da) return 0;
+ if (do_number) {
+ vp = pairfind(vps, da->attr);
+ if (!vp) return 0;
+
+ switch (da->type) {
+ default:
+ break;
+
+ case PW_TYPE_INTEGER:
+ case PW_TYPE_DATE:
+ case PW_TYPE_SHORT:
+ case PW_TYPE_BYTE:
+ snprintf(out, outlen, "%u", vp->lvalue);
+ return strlen(out);
+ }
+
+ goto just_print;
+ }
+
/*
* %{Attribute-Name[#]} returns the count of
* attributes of that name in the list.
* Non-existent array reference.
*/
if (!vp) return 0;
-
+ just_print:
return valuepair2str(out, outlen, vp, da->type, func);
}
* Look for dictionary attributes first.
*/
if ((dict_attrbyname(module) != NULL) ||
- (strchr(module, '[') != NULL)) {
+ (strchr(module, '[') != NULL) ||
+ (strchr(module, '#') != NULL)) {
module = "request";
}