使用举例:
void cgi_process_var (U8 *qs) {
/* This function is called by HTTP server to process the Querry_String */
/* for the CGI Form GET method. It is called on SUBMIT from the browser. */
/*.The Querry_String.is SPACE terminated. */
U8 *var;
int s[4];
var = (U8 *)alloc_mem (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 ((const char *)&var[3], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
LocM.IpAdr[0] = s[0];
LocM.IpAdr[1] = s[1];
LocM.IpAdr[2] = s[2];
LocM.IpAdr[3] = s[3];
}
else if (str_scomp (var, "msk=") == __TRUE) {
/* Net mask parameter. */
sscanf ((const char *)&var[4], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
LocM.NetMask[0] = s[0];
LocM.NetMask[1] = s[1];
LocM.NetMask[2] = s[2];
LocM.NetMask[3] = s[3];
}
else if (str_scomp (var, "gw=") == __TRUE) {
/* Default gateway parameter. */
sscanf ((const char *)&var[3], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
LocM.DefGW[0] = s[0];
LocM.DefGW[1] = s[1];
LocM.DefGW[2] = s[2];
LocM.DefGW[3] = s[3];
}
else if (str_scomp (var, "pdns=") == __TRUE) {
/* Default gateway parameter. */
sscanf ((const char *)&var[5], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
LocM.PriDNS[0] = s[0];
LocM.PriDNS[1] = s[1];
LocM.PriDNS[2] = s[2];
LocM.PriDNS[3] = s[3];
}
else if (str_scomp (var, "sdns=") == __TRUE) {
/* Default gateway parameter. */
sscanf ((const char *)&var[5], "%d.%d.%d.%d",&s[0],&s[1],&s[2],&s[3]);
LocM.SecDNS[0] = s[0];
LocM.SecDNS[1] = s[1];
LocM.SecDNS[2] = s[2];
LocM.SecDNS[3] = s[3];
}
}
}while (qs);
free_mem ((OS_FRAME *)var);
} |