• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

WRITING A CGI IN C

Could you someone tell me the logic and the initial code to get the variables in a POST case and how I can test it under DOS. I am confused by what is an environment variable and what is not.
Thx for your help.

0
toulon
Asked:
toulon
  • 2
1 Solution
 
szetoaCommented:
In the form if you use POST, you have to read your data from stdin.  Using GET you have to read from an environment variable.  Here's the example of using POST:

char buffer[BUFSIZ];
long len;

len = atol(getenv("CONTENT_LENGTH"));
fread(buffer, len,1,stdin);
0
 
shiversCommented:
further to szetoa's comment...

the data you read in from stdin takes the form of a list of identifier/value pairs.  Each pair is separated by a '&' sign, and the id and vlue are seperated by a '=' sign.  note that some identifiers may not have values set

all spaces are encoded to the '+' character, and illegal characters (such as '+', '&', '=', and extended chars) are encoded using '%xx' where xx specifies the ASCII value of the character in hex.  (there may be other encodings than ASCII - but i'm unaware of the details)

shout if you need any more info
0
 
toulonAuthor Commented:
thx for the inputs. could you make it an answer so I could give you the points an close the question ?
Thx
0
 
shiversCommented:
not sure if u mean me - but i thought i'd shove this in anyways - shout if u want any more details

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now