[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] Rewrite Symbols

A symbol is a lexical token. The following symbols are recognized:

Arithmetical operators

These are ‘+’, ‘-’, ‘*’, ‘/’ representing the basic arithmetical operations, and ‘%’ meaning remainder.

Comparison operators

These are: ‘==’, ‘!=’, ‘<’, ‘<=’, ‘>’, ‘>=’ with the same meaning they have in C. Special operators are provided for regular-expression matching. The binary operator ‘=~’ returns true if its left-hand-side operand matches the regular expression on its right-hand side (see section Regular Expressions). ‘!~’ returns true if its left-hand-side operand does not match the regexp on its right-hand side. The right-hand-side operand of ‘!~’ or ‘=~’ must be a literal string, i.e., the regular expression must be known at compile time.

Unary operators

The unary operators are ‘-’ and ‘+’ for unary plus and minus, ‘!’ for boolean negation, and ‘*’ for testing for the existence of an attribute.

Boolean operators

These are ‘&&’ and ‘||’.

Parentheses ‘(’ and ‘)

These are used to change the precedence of operators, to introduce type casts (type coercions), to declare functions, and to pass actual arguments to functions.

Curly braces (‘{’ and ‘}’)

These are used to delimit blocks of code.


Numbers follow the usual C convention for integers. A number consisting of a sequence of digits is taken to be octal if it begins with ‘0’ (digit zero), and decimal otherwise. If the sequence of digits is preceded by ‘0x’ or ‘0X’, it is taken to be a hexadecimal integer.

IP Numbers

IP numbers are represented by a standard numbers-and-dots notation. IP numbers do not constitute a separate data type, rather they are in all respects similar to initeger numbers.


These follow the usual C convention for characters, i.e., they consist either of an ASCII character itself or of its value, enclosed in a pair of singlequotes. The character value begins with ‘\’ (backslash) and consists either of three octal or of two hexadecimal digits. A character does not form a special data type; it is represented internally by an integer.

Quoted strings

These follow slightly modified C conventions for strings. A string is a sequence of characters surrounded by double quotes, as in ‘"..."’. In a string, the double quote character ‘"’ must be preceeded by a backslash ‘\’. A ‘\’ and an immediately following newline are ignored. Following escape sequences have special meaning:


Audible bell character (ASCII 7)


Backspace (ASCII 8)


Escape character (ASCII 27)


Form feed (ASCII 12)


Newline (ASCII 10)


Carriage return (ASCII 13)


Horizontal tab (ASCII 9)




(‘o’ represents an octal digit) A character whose ASCII value is represented by the octal number ‘ooo’.


(‘H’ represents a hex digit) A character whose ASCII value is represented by the hex number ‘HH’.


Two characters ‘\(’.


Two characters ‘\)’.

If the character following the backslash is not one of those specified, the backslash is ignored.

Attribute values

The incoming request is passed implicitly to functions invoked via the Rewrite-Function attribute. It is kept as an associative array, whose entries can be accessed using the following syntax:

‘%[attribute-name]’ ‘(n)

The first form returns the value of the attribute attribute-name. Here attribute-name should be a valid Radius dictionary name (see section Dictionary of Attributes — ‘raddb/dictionary).

The second form returns the value of the nth attribute of type attribute-name. The index n is counted from zero, so


is equivalent to


Identifiers represent functions and variables. These are described in the next sub-subsection.

Regexp group references

A sequence of characters in the form


refers to the contents of parenthesized group number number obtained as a result of the last executed ‘=~’ command. The regexp group reference has always string data type. For example:

basename(string arg)
    if (arg =~ ".*/\(.*\)\..*")
        return \1;
        return arg;

This function strips from arg all leading components up to the last slash character, and all trailing components after the last dot character. It returns arg unaltered if it does not contain slashes and dots. It is roughly analogous to the system basename utility.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Sergey Poznyakoff on December, 6 2008 using texi2html 1.78.