Consider the HTML page "power.cgi", as displayed by a remote browser:

            <td>Power Level:</td>
            <td><input type=text size=2 maxlength=1 name=P value=%p07></td>
            <td>Low Power Setting:</td>
            <td><input type=text size=2 maxlength=1 name=L value=%p08></td>
            <td>High Power Setting:</td>
            <td><input type=text size=2 maxlength=1 name=H value=%p09></td>
            <td colspan=2><input type=submit name=B value=Apply></td>

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:

00042 #include "projdefs.h"
00043 #include "net\http.h"
00055 void HTTPExecGetCmd(HTTP_INFO* httpInfo, BYTE* rqstRes)
00056 {
00057     BYTE param[20];
00058     int PowerLevel, LowPowerSetting, HighPowerSetting;
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;
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
00070         //Get name-value parameters. Returns true if there are more name-value
00071         //parameters to follow
00072         //- Pointer to Name parameter = &param[0]
00073         //- Pointer to Value parameter = &param[valueIdx]
00074         moreParams = HTTPGetParam(httpInfo->socket, param, &valueIdx);
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 = &param[valueIdx]
00080             PowerLevel = atoi((char*)&param[valueIdx]);
00081         }
00082         else if ( param[0] == 'L') // Is this Low Power Setting?
00083             LowPowerSetting = atoi((char*)&param[valueIdx]);
00084         else if ( param[0] == 'H' ) // Is this High Power Setting?
00085             HighPowerSetting = atoi((char*)&param[valueIdx]);
00086     } while (moreParams);
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 }

Generated on Mon Oct 9 13:22:06 2006 for SBC65EC Web Server by  doxygen 1.4.7