Goahead2.5 source code analysis-9 CGI processing handle (CGI. c)

Source: Internet
Author: User
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 -----------------------------------------------------------------------------------------------------------------

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.