As an example, let’s consider the function for analyzing a
line of output from a standard UNIX finger
service. In each line of finger output, the first field
contains the user name; the third field, the
tty number (port ID); and the seventh field, the session ID.
The function must return 1 if the three fields match the input
user name, as well as its port and session IDs:
integer
check_unix(string str, string name, integer pid, string sid)
{
return field(str, 1) == name
&& field(str, 3) == pid
&& field(str, 7) == sid;
}
The next example is a function to analyze a line of output from an SNMP query returning a user name. This function must return 1 if the entire input line matches the user name:
integer
check_username(string str, string name, integer pid, string sid)
{
return str == name;
}