// -*- c-basic-offset: 4 -*- #ifndef CLICK_SCRIPT_HH #define CLICK_SCRIPT_HH #include #include #include CLICK_DECLS /* =c Script(INSTRUCTIONS...) =s control script a Click router configuration =d The Script element implements a simple scripting language useful for controlling Click configurations. Scripts can set variables, call handlers, wait for prodding from other elements, and stop the router. =head1 INSTRUCTIONS Each configuration argument is an I (except for optional keywords; see below). Script generally processes these instructions sequentially. =head2 Handler Instructions In all cases, text arguments are subject to substitutions; see below. =over 8 =item 'C VAR TEXT' Sets the script variable $VAR to TEXT. =item 'C VAR TEXT' Initializes the script variable $VAR to TEXT. This assignment happens exactly once, when the Script element is initialized; later the instruction has no effect. =item 'C [>FILE | >>FILE] [TEXT | HANDLER]' Prints text, or the result of calling a read handler, followed by a newline. At user level, the text is written to the standard output, except that if the argument begins with > or >>, then the text is written or appended to the specified FILE. In the kernel, the text is written to the system log. If C's argument starts with a letter, '@', or '_', then it is treated as a read handler. Otherwise, it is treated as quoted text; Script prints the unquoted version. For example, assuming the 'c.count' read handler returns "0": print c.count => 0 print "c.count" => c.count print '"c.count"' => "c.count" set x c.count print $x => c.count print $($x) => 0 =item 'C HANDLER [ARG...]' Call a read handler and print the handler name and result to standard error. (In the kernel, the result is printed to the system log.) For example, the configuration 'Idle -> c::Counter -> Idle; Script(read c.count)' would print print this to standard error: c.count: 0 Contrast the 'C' instruction. =item 'C HANDLER [ARG...]' Call a write handler. The handler's return status is available in following instructions as the '$?' variable. =back =head2 Blocking Instructions =over 8 =item 'C [COUNT]' Block until the Script element's 'step' handler is called COUNT times. COUNT defaults to 1. =item 'C TIME' Wait for TIME seconds, or until a step, whichever comes first; then go to the next instruction. TIME has microsecond precision. =back =head2 Control Instructions =over 8 =item 'C