ex_httpgetvar2.c

Consider the page "status.cgi" that is being served by the HTTP Server. It contains following HTML line:

Port Pin RA4 = %a04

During processing of this file, the HTTP Server encounters the %a04 string. After parsing it, the HTTP Server makes a callback to HTTPGetVar(httpInfo, val). The httpInfo->var.get.varRef will have the value HTTP_START_OF_VAR. The main user application implements HTTPGetVar as follows:

00001 
00018 #include "projdefs.h"
00019 #include "net\http.h"
00020 
00021 ROM char SerialNumberStr[] = "123456SER";
00022 
00023 WORD HTTPGetVar(HTTP_INFO* httpInfo, BYTE* val)
00024 {
00025     BYTE varValue, varGroup, ref;
00026 
00027     varValue = httpInfo->var.get.tagVal;        //Variable Value of requested variable
00028     varGroup = httpInfo->var.get.tagGroup;      //Variable Group of requested variable
00029     ref      = httpInfo->var.get.varRef;        //Current callback reference with respect
00030                                                 //to 'var' variable.
00031     
00032 
00033     //In case requested var not found, set it to NULL character and return HTTP_END_OF_VAR
00034     *val = '\0';    
00035     
00036     //Identify variable group
00037     if (varGroup == 'a')
00038     {
00039         // Identify variable value.
00040         // Is it RA4 ?
00041         if ( varValue == 4 )
00042         {
00043             // We will simply return 1 if RA4 is high, or 0 if low.
00044             if ( PORTB_RA4 )
00045                 *val = 1;
00046             else
00047                 *val = 0;
00048 
00049             // Tell HTTP that this is last byte of
00050             // variable value.
00051             return HTTP_END_OF_VAR;
00052         }
00053         else
00054             // Check for other variables values...
00055             //...
00056         }
00057     }
00058 }

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