Functions: [def] section

Functions can be used in any logical expressions; however, each function must be predefined in the [def] section before use. In one section, several functions can be defined. Moreover, you can specify several [def] sections in the configuration file (functions defined in different sections are combined into one list while reading configuration).

Function definition syntax:

func_name_1 = { BOOL_EXPR }

where BOOL_EXPR is a logical expression.

All functions return a Boolean value, arguments are not supported. In fact, a function is just a shorthand notation for an expression.

Example:

Definition of the is_localhost and local_ip functions: these functions are to be true if the request was sent from one of the specified IP addresses or from one of the IP addresses listed in the file.

[def]
is_localhost = { request_ip <<= "127.0.0.0/8" }
local_ip = {
 request_ip <<= "127.0.0.0/8"
 || request_ip <<= "192.168.0.0/16"
 || request_ip <<= "172.16.0.0/12"
 || request_ip <<= file:"/tmp/icapd/other_local_ips.txt"
}

Definition of a worktime() function: if the current system time is between 9:30 and 13:00 or 14:00 and 18:15, the function is to be true.

[def]
worktime = {
(system_time>="9:30" && system_time<="13:00")
||
(system_time>="14:00" && system_time<"18:15")
}