Description |
The http_get_var function processes the string env,
which contains the environment variables, and identifies where the
first variable ends. The function obtains and stores the first
variable and its value into the buffer pointed by ansi, in
ansi format.
The maxlen specifies the maximum length that can be stored
in the ansi buffer. If the decoded environment variable value
is longer than this limit, the function truncates it to maxlen
to fit it into the buffer.
The http_get_var function is a system function that is in
the RL-TCPnet library. The prototype is defined in net_config.h.
Note
-
The http_get_var function can process environment
variables from the GET and POST methods.
- You can call this function from the HTTP_CGI.c module.
-
The web browser uses environment variables to return
user-entered information that is requested in the HTTP input
form.
|
Example |
void cgi_process_var (U8 *qs) {
U8 var[40];
do {
/* Loop through all the parameters. */
qs = http_get_var (qs, var, 40);
/* Check the returned string, 'qs' now points to the next. */
if (var[0] != 0) {
/* Returned string is non 0-length. */
if (str_scomp (var, "ip=") == __TRUE) {
/* My IP address parameter. */
sscanf (&var[3], "%bd.%bd.%bd.%bd",&LocM.IpAdr[0],&LocM.IpAdr[1],
&LocM.IpAdr[2],&LocM.IpAdr[3]);
}
else if (str_Scomp (var, "msk=") == __TRUE) {
/* Net mask parameter. */
sscanf (&var[4], "%bd.%bd.%bd.%bd",&LocM.NetMask[0],&LocM.NetMask[1],
&LocM.NetMask[2],&LocM.NetMask[3]);
}
else if (str_scomp (var, "gw=") == __TRUE) {
..
}
}
} while (qs);
}
|