Similar to a Unix shell, there are ways to reference string lengths,
and the second or more instance of an attribute in a list. If you
need more than this functionality, we suggest using a real language.
-.IP %{strlen:string}
-The number of characters in "string". If "string" does not exist,
-then the length also does not exist, instead of being zero.
-
-The "string" is expanded before the length is taken.
-
-.IP %(integer:Value)
-The integer value of the Value.
-
-e.g. If a request contains "Service-Type = Login-User", the expansion
-of %(integer:%{Service-Type}) will yield "1".
-
-.IP %{hex:Attribute-Name}
-The hex value of the Attribute-Name, as a series of hex digits.
e.g. If a request contains "Framed-IP-Address = 127.0.0.1", the expansion
of %{hex:Framed-IP-Address} will yield "0x7f000001".
test_fail
}
-&Tmp-String-8 := "%{string:%{Tmp-Octets-0}}"
+&Tmp-String-8 := "%{(string) %{Tmp-Octets-0}}"
if (!(&Tmp-String-8 == "i have scary embedded things\000 inside me")) {
test_fail
}
test_fail
}
-&Tmp-String-8 := "%{string:%{Tmp-Octets-1}}"
+&Tmp-String-8 := "%{(string) %{Tmp-Octets-1}}"
if (!(&Tmp-String-8 == "0x01\0010x07\0070x0A\n0x0D\r\"\"0xb0\260°")) {
test_fail
}
#
# Other data types
#
-&Tmp-String-0 := "%{string:&Tmp-IP-Address-0}"
-if (!("%(length:%{Tmp-String-0})" == 17)) {
+&Tmp-String-0 := "%{(string) &Tmp-IP-Address-0}"
+if (!(%(length:%{Tmp-String-0}) == 9)) {
test_fail
}
-
success
# This next assignment fails, so it can't go into the above list. If
# it was there, then the entire list assignment would fail.
#
-&Tmp-String-0 := "%{randstr:%{Tmp-String-0}}"
+&Tmp-String-0 := "%randstr(%{Tmp-String-0})"
#
# Empty output on empty input
#
# Check length of output
#
-if (!(%{strlen:%{Tmp-String-1}} == 3)) {
+if (!(%length(%{Tmp-String-1}) == 3)) {
test_fail
}
-if (!(%{strlen:%{Tmp-String-2}} == 24)) {
+if (!(%length(%{Tmp-String-2}) == 24)) {
test_fail
}
#
# Check maximum repetition
#
-if (!(%{strlen:%{Tmp-String-3}} == 1025)) {
+if (!(%length(%{Tmp-String-3}) == 1025)) {
test_fail
}
#
# Check repetition of binary output
#
-if (!(%(length:%{Tmp-String-5}) == 10)) {
+if (!(%length(%{Tmp-String-5}) == 10)) {
test_fail
}