<html><body>
<FORM METHOD=GET action=POWER.CGI>
<table>
<tr>
<td>Power Level:</td>
<td><input type=text size=2 maxlength=1 name=P value=%p07></td>
</tr>
<tr>
<td>Low Power Setting:</td>
<td><input type=text size=2 maxlength=1 name=L value=%p08></td>
</tr>
<tr>
<td>High Power Setting:</td>
<td><input type=text size=2 maxlength=1 name=H value=%p09></td>
</tr>
<tr>
<td colspan=2><input type=submit name=B value=Apply></td>
</tr>
</table>
</form>
</body></html>
This page displays a table with labels in the first column and text box values in the second column. The first row, first column cell contains the string "Power Level". The second column is a text box to display and modify the power level value. The last row contains a button labelled "Apply". A user viewing this page has the ability to modify the value in the Power Level text box and click on "Apply" button to submit the new power level value to the Modtronix SBC65EC Web Server. Assume that a user enters values of ‘5’, ‘1’ and ‘9’ in Power Level, Low Power Setting and High Power Setting text boxes respectively, then clicks on the "Apply" button. The browser would create a HTTP request string "POWER.CGI?P=5&L=1&H=9" and send it to the HTTP server. The server in turn calls the HTTPExecGetCmd() callback function.
The main application implements HTTPExecGetCmd as below:
00001 00042 #include "projdefs.h" 00043 #include "net\http.h" 00044 00045 00055 void HTTPExecGetCmd(HTTP_INFO* httpInfo, BYTE* rqstRes) 00056 { 00057 BYTE param[20]; 00058 int PowerLevel, LowPowerSetting, HighPowerSetting; 00059 00060 //Used as input AND output parameter for HTTPGetParams. 00061 // - Input parameter indicates size of param buffer 00062 // - On return of HTTPGerParam() valueIdx will contain index of value string in param 00063 BYTE valueIdx; 00064 BYTE moreParams; 00065 00066 //Get next name-value parameter until we have retrieved them all 00067 do { 00068 valueIdx = (BYTE)sizeof(param); //Input parameter is size of param buffer 00069 00070 //Get name-value parameters. Returns true if there are more name-value 00071 //parameters to follow 00072 //- Pointer to Name parameter = ¶m[0] 00073 //- Pointer to Value parameter = ¶m[valueIdx] 00074 moreParams = HTTPGetParam(httpInfo->socket, param, &valueIdx); 00075 00076 //Identify parameter - param[0] contains the first character of the name part 00077 if ( param[0] == 'P') // Is this power level? 00078 { 00079 //The value is the Power level value. The value string is = ¶m[valueIdx] 00080 PowerLevel = atoi((char*)¶m[valueIdx]); 00081 } 00082 else if ( param[0] == 'L') // Is this Low Power Setting? 00083 LowPowerSetting = atoi((char*)¶m[valueIdx]); 00084 else if ( param[0] == 'H' ) // Is this High Power Setting? 00085 HighPowerSetting = atoi((char*)¶m[valueIdx]); 00086 } while (moreParams); 00087 00088 00089 // If another page is to be displayed as a result of this command, copy 00090 // its upper case name into rqstRes. 00091 //strcpy(rqstRes, "RESULTS.CGI"); 00092 } 00093
1.4.7