CGI. C (CGI)
Int webscgihandler (webs_t WP, char_t * urlprefix, char_t * webdir, int Arg, char_t * URL, char_t * path, char_t * query)
Function: Process CGI requests.
Note:
1. Extract the CGI program name called in form on the page and build the complete path/ata0/webs/www /*
2. Go to the directory where the CGI program is located, that is,/ata0/webs/www.
3. allocate memory and create CGI program parameters, which are extracted from qurey, which is also separated by spaces.
4. Build name and value pairs from CGI environment variables.
5. Determine the standard input and output. The standard output is a temporary file.
6. Call webslaunchcgiproc to create a CGI handler.
Bytes -----------------------------------------------------------------------------------------------------------------
Void webscgigatheroutput (cgirec * cgip)
Function: outputs the content in the temporary file to the browser.
Note: this refers to the Memory output from the cgi program prinf to the temporary file, and then the content of the temporary file is read to the browser.
Bytes -----------------------------------------------------------------------------------------------------------------
Void webscgicleanup ()
Function: Call webscgigatheroutput to process the output and clear the resources occupied by CGI.
Note:
Bytes -----------------------------------------------------------------------------------------------------------------
Char_t * websgetcgicommname ()
Function: temporary file name
Note:
Bytes -----------------------------------------------------------------------------------------------------------------
Int webslaunchcgiproc (char_t * cgipath, char_t ** argp, char_t ** envp, char_t * stdin, char_t * stdout)
Function: CGI processing program.
Note:
1. Uninstall the existing module according to cgipath
2. Find the corresponding value of _ www_cgientry, and assign the value to entryaddr to generate the task vxwebscgientry.
3. If not found, load cgipath and generate the task vxwebscgientry.
Bytes -----------------------------------------------------------------------------------------------------------------
Static void vxwebscgientry (void * entryaddr (INT argc, char_t ** argv), char_t ** argp, char_t ** envp, char_t * stdin, char_t * stdout)
Function: the CGI program shell is called by calling it to call the CGI program.
Note: set the standard input and output of the task to stdin and stdout, create environment variables, assign values to environment variables using envp, and call the CGI processing function entryaddr.
Bytes -----------------------------------------------------------------------------------------------------------------
Int webscheckcgiproc (INT handle)
Function: Check whether the CGI task exists.
Note:
Bytes -----------------------------------------------------------------------------------------------------------------