ALP GateCGI configuration
GateCGI component can handle particular file extensions. You can use configuration section formatted as described below for every file type that must be executed as a CGI.

Depending on the way the CGI is executed you can think that there are two types of CGI - directly executed and scripts processed by a processor (such as language interpreters - perl, awk, php, cmd and many others). See notes after section description for more details.

{ extension: (CG.newObjects.GateCGI)
    ; These are the standard entries for the Execution map - see Execution map in the alp.application
    (int)Timeout=60
    (int)RequireAsynch=2
    (int)CheckThatFileExists=2
    (int)IsScriptEngine=1
    ; Specific GateCGI entries
    ; Engine entry can appear in 3 forms - Engine :Engine or .Engine but most useful
    ; is the first one. This record entry can be omitted.
    (string)Engine=cmd.exe /Q /C ""%r\cgi\lister.cmd" "%s" %q"
    ; Useful for developers - instead of returning error to the core if set to 1 GateCGI
    ; Displays beginning of the CGI output in plain text format if error occurs.
    (int)ShowErrOutputSample=1
    ; Optional section that defines custom environment variables for the executed
    ; application
    { ENVIRONMENT:
    	(string)MYVARIABLE=Value
    } ENVIRONMENT;
} extension;
  • extension - specifies a file extension to be handled. If the file extension determines a file type directly executed by the system Engine section can be omitted. Files of that type will be executed directly - ALP ships with exe files allowed for CGI execution in the global/default alp.application file. If the extension specifies some other file type Engine entry must present in order to determine how to execute the file.
    • Engine - Specifies how to execute the file. this record entry allows many options. GateCGI uses this string in order to determine what program to use and what parameters to pass. First for a similarity with another ALP options syntax it supports 3 forms:
      • Engine, .Engine and :Engine - The form with "." appends in the beginning of the string the path containing the GateCGI module (dll), The form with ":" appends in the beginning site physical path and allows writing of the pats relative to the site root, additionally if the path does not begin with "\" current directory path is appended. It is recommended to use only the Engine form (without additional characters in the beginning) and the %<char> escapements listed below
      • GateCGI supports several %<char> escape entries that are replaced with the corresponding content as follows:
        • %m - is replaced with the full physical path containing the GateCGI module (dll)
        • %r - is replaced with the full physical path of the ALP site root
        • %p - is replaced with the full physical path from the URL - i.e. physical path corresponding to the current URL
        • %s - is replaced with the full physical path of the script file - i.e. physical equivalent of the URL
        • %q - is replaced with the query string

        This string becomes after processing a command line passed to the system API function thus if the executable being started requires quotes to close the file names containing spaces you must specify them in the right places and usually close at least %s in quotes. Fore example to register a cmd file as a processor for some kind of file extensions you will need line like this:
        cmd.exe /Q /C ""%r\cgi\lister.cmd" "%s" %q"
        Of course other forms are possible but if you are going to rely on the system association of the cmd files you will have some problems with the paths containing spaces.
        This extended syntax is intended to give you ability to call any program without meaning how the program accepts input files.

    • ShowErrOutputSample - Developers can set this in order to receive plain text output containing the output of the program executed when it fails to return enough headers. Very useful in case if mistake in the command line parameters and options passed to it.
    • ENVIRONMENT - this subsection (if not omitted) can be used to add or replace environment variables in the environment passed to the executed application. You may specify any (string)Name=Value record entry here and it will be available in the environment. Variables found here will replace standard variables generated by the GateCGI if their names are equal but will not replace variables found in the initial environment (of the executable running ALP). From ALP version 1.2 you can use also extended syntax for the values:
      You can include %NAME% values which will be expanded when placed in the environment. The NAME can be one of the already defined ALP variables - a previous variable specified in this section or ALP internal variable see the GateCGI Content Generator for their list and contents.
newObjects Copyright 2001-2006 newObjects [ ]