HTTPPrint_varname Function

Microchip TCP/IP Stack

Microchip TCP/IP Stack Help
HTTPPrint_varname Function
C
void HTTPPrint_varname(
    WORD wParam1, 
    WORD wParam2, 
    ...
);
Description

Functions in this style are implemented by the application developer in CustomHTTPApp.c. These functions generate dynamic content to be inserted into web pages and other files returned by the HTTP2 server. 

Functions of this type are called when a dynamic variable is located in a web page. (ie, ~varname~ ) The name between the tilde '~' characters is appended to the base function name. In this example, the callback would be named HTTPPrint_varname. 

The function prototype is located in your project's HTTPPrint.h, which is automatically generated by the MPFS2 Utility. The prototype will have WORD parameters included for each parameter passed in the dynamic variable. For example, the variable "~myArray(2,6)~" will generate the prototype "void HTTPPrint_varname(WORD, WORD);". 

When called, this function should write its output directly to the TCP socket using any combination of TCPIsPutReady, TCPPut, TCPPutArray, TCPPutString, TCPPutROMArray, and TCPPutROMString

Before calling, the HTTP2 server guarantees that at least HTTP_MIN_CALLBACK_FREE bytes (defaults to 16 bytes) are free in the output buffer. If the function is writing less than this amount, it should simply write the data to the socket and return. 

In situations where a function needs to write more this amount, it must manage its output state using curHTTP.callbackPos. This value will be set to zero before the function is called. If the function is managing its output state, it must set this to a non-zero value before returning. Typically this is used to track how many bytes have been written, or how many remain to be written. If curHTTP.callbackPos is non-zero, the function will be called again when more buffer space is available. Once the callback completes, set this value back to zero to resume normal servicing of the request.

Preconditions

None

Parameters
Parameters 
Description 
wParam1 
first parameter passed in the dynamic variable (if any) 
wParam2 
second parameter passed in the dynamic variable (if any) 
... 
additional parameters as necessary 
Returns

None

Remarks

This function may service multiple HTTP requests simultaneously, especially when managing its output state. Exercise caution when using global or static variables inside this routine. Use curHTTP.callbackPos or curHTTP.data for storage associated with individual requests.

Microchip TCP/IP Stack 5.42.08 - June 15, 2013
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.