Program start and configuration
When the "canal" interpreter starts, it checks for several files and variables takes action based on them. This has grown over time, and this is an attempt to document the code as is, rather than a specification!
- it changes the QUERY_STRING environmental variable by truncating it at the first ?. This is to avoid problems with bots creating malformed URLS (the comment blames bingbot for the need for this)
- it uses ClearSilver's cgi_init function to read the CGI variables and cookies into memory
- it creates and output stream (for "print") and an error stream (for "debug") and connects them to stdout and stderr
- it sets up signal trapping, context for errors, default comment character etc.
- if there is no command line argument it sets up to read from stdin, otherwise it opens it
- it seeds the random number generator
- it runs Act_On_Environment, which returns an integer bitmask
- reads any file called "config.xml" in the current directory and sets up configuration from it [see below]
- it overrides any values from here with those of the following environmental variables: * CANALPLAN_TRACE - sets "trace" * CANALPLAN_COMMENT - sets "comment" * CANALPLAN_SECONDS - sets "alarm" * CANALPLAN_PROFILE - sets "profile" * CANALPLAN_TRADITIONAL - sets "alarm"
- it puts character codes into system.pragma_flags * 'C' if setupflag_nocgi is set
- it then goes into the interactive loop (only one pass in batch mode)
- if setupflag_autorun is set ...
Reading Setup
There is a function in setup.c which turns various things on and off when called.
