TCPIP_HTTP_Print_varname Function

C

void TCPIP_HTTP_Print_varname(
    HTTP_CONN_HANDLE connHandle, 
    uint16_t wParam1, 
    uint16_t wParam2, 
    ...
);

Description

Functions in this style are implemented by the application developer. These functions generate dynamic content to be inserted into web pages and other files returned by the HTTP server. Functions of this type are called when a dynamic variable is located in a web page. (i.e., varname) The name between the tilde '~' characters is appended to the base function name. In this example, the callback would be name TCPIP_HTTP_Print_varname.

The function prototype is located in your project's http_print.h, which is automatically generated by the pmfs2.jar utility. The prototype will have uint16_t parameters included for each parameter passed in the dynamic variable. For example, the variable "myArray(2,6)" will generate the prototype "void TCPIP_HTTP_Print_varname(uint16_t, uint16_t);".

When called, this function should write its output directly to the TCP socket using any combination of TCPIP_TCP_PutIsReady, TCPIP_TCP_Put, TCPIP_TCP_ArrayPut, TCPIP_TCP_StringPut, TCPIP_TCP_ArrayPut, and TCPIP_TCP_StringPut.

Before calling, the HTTP serber gaurantees 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 than this amoutn, it must manage its output state using the connection callbackPos (TCPIP_HTTP_CurrentConnectionCallbackPosGet/TCPIP_HTTP_CurrentConnectionCallbackPosS). 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 the connection 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 or the request.

Preconditions

None.

Parameters

ParametersDescription
connHandleHTTP connection handle.
wParam1First parameter passed in the dynamic variable (if any).
wParam2Second 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 the connection callbackPos or the connection data buffer for storage associated with individual requests.