examples/ex_httpgetvar.c File Reference

#include "projdefs.h"
#include "net\http.h"

Functions

WORD HTTPGetVar (HTTP_INFO *httpInfo, BYTE *val)

Variables

ROM char SerialNumberStr [] = "123456SER"


Function Documentation

WORD HTTPGetVar ( HTTP_INFO httpInfo,
BYTE val 
)

This is a callback function from the HTTPServer() to the main application. This function must be implemented by the user somewhere in the code. Whenever a variable substitution is required (the parsed web pages contains a "\%nxx" tag) on any *.cgi pages, HTTPServer calls this function. This function is responsible for replacing this variable ("\%nxx" tag") with a user defined string. For example, the user might want to replace any "\%a00" tag found on a web page with the value of channel 0 of the analog input. When the "\%a00" is found on a web page, the HTTPServer will call this function, and the user can then return a string representing the value of channel 0 of the analog input.

The given HTTP_INFO structure contains a 8-bit variable reference (httpInfo->VarRef), a 8-bit variable group (httpInfo->var.get.tagGroup) and a 16-bit variable value (httpInfo->var.get.tagVal).
The variable reference indicates whether this is a first call or not.
The variable group and variable value give the group and value of the tag found on the web page.

Applications should return one character at a time as a variable value. If there are no more characters, or the requeseted variable is not found, this function must set val to NULL. Since this function only allows one character to be returned at a time as part of the variable value, HTTPServer() calls this function multiple times until the user application indicates that there are no more values left for this variable. On begining, HTTPGetVar() is called with the variable reference (httpInfo->var.get.varRef) = HTTP_START_OF_VAR to indicate that this is a first call. Applications should use this reference to start the variable value extraction and return updated reference. If there are no more values left for this variable the application should send HTTP_END_OF_VAR and set var to NULL. If there are any bytes left to be sent, the application should return a value other than HTTP_START_OF_VAR or HTTP_END_OF_VAR.

Pre-Condition:
HTTPInit() must already be called.
Parameters:
httpInfo HTTP_INFO structure of HTTP connection requesting this Variable.
val Buffer for value storage.
Returns:
Variable reference as required by application.


Variable Documentation

ROM char SerialNumberStr[] = "123456SER"

Examples:
ex_httpgetvar.c, and ex_httpgetvar2.c.


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