SSI.cgi: A standalone Server Side Includes parser

Supported directives

Conditional expressions

This is intended to be similar to the conditional expressions that Apache's SSI module (mod_include) implements. The BNF grammer is as follows:

alnum  := number | digit
quote  := "'"
string := alnum+ | (quote (!quote)* quote)+
cond   := (string)+          |
          string '='  string |
          string '==' string |
          string '!=' string |
          string '<=' string |
          string '>=' string |
          string '<'  string |
          string '>'  string |
          ( cond )           |
          '!' cond           |
          cond '&&' cond     |
          cond '||' cond

A string on its own evaluates to true if it is non-empty (ie not ''). '==' is an extension not present in Apache, and <= & >= use strcmp to decide which string is 'smaller'. Whitespace outside of string is ignored. Note that Boolean expressions (|| and &&) are right-associative, so

expr1 || expr2 || expr 3 || expr4

is treated as

expr1 || (expr2 || (expr 3 || expr4))

which might not be how Apache does things (Apache's documentation doesn't specify which associatively and it uses, and it simply advises people to bracket defensively to avoid ambiguity when using both && and ||.

NOTE: Apache's Regular Expression feature is not yet supported.

Special echo variables

Unsupported directives