Writing a converter program

Top  Previous  Next

You can write your analyzer in C, COBOL, or PL/I. Language-dependent header files, include files, and copy books are
described in "Reference information for converter programs".

The converter must run in the same XCICS region as the TCPIPSERVICE which receives the request.

The size and contents of the COMMAREA that is passed from the converter program to the user application program are governed by the design of the XCICS application program that is invoked for the HTTP request. When you use a converter program with XCICS Web support, you can:

Issue a GETMAIN command to obtain storage for the COMMAREA.
Use storage acquired in an earlier stage of processing (such as the analyzer program) for the COMMAREA
Use the storage which contains the HTTP request for the COMMAREA.

Input parameters for the decode function
Input parameters are passed to the decode function in a COMMAREA. The parameters include:

The IP address of the Web client
A pointer to the HTTP version
A pointer to the method
A pointer to the path component of the URL
A pointer to the request headers
A pointer to the entity body
The name of the XCICS application program that will service the request (as set by the analyzer)
An eight byte user token, used to share information between the analyzer and converter programs. See "Sharing data between analyzer and converter programs".
An iteration counter that records the number of times the decode function has been entered for each HTTP request. The counter is set to 1 before the decode function is called for the first time, and is incremented before it is called on each subsequent occasion.
An indication of whether the address of the entity body can be the target of a FREEMAIN command.

Output parameters for the decode function

The decode function must provide the following outputs in its COMMAREA:

A response code (optionally qualified by a reason code).
If the decode function returns a response code of URP_OK, processing continues with the next step.
If the decode function returns any other value, the HTTP request is rejected..
The address and length of the COMMAREA passed to the XCICS application program. If no application program is called, the COMMAREA is passed unchanged to the encode function.

It may also provide the following outputs:

The name of the XCICS application program that is to service the request. If the analyzer supplied a name, the converter can change it, or specify that no application program should be called.
An eight byte user token, used to share information between the analyzer and converter programs. See "Sharing data between analyzer and converter programs".

Input parameters for the encode function

Input parameters are passed to the encode function in a COMMAREA. The parameters include:

The address and length of the COMMAREA returned by the XCICS application program. If no application program was called, the
COMMAREA is passed unchanged from the decode function.
An eight byte user token, used to share information between the analyzer and converter programs. See "Sharing data between analyzer and converter programs" .
An iteration counter that records the number of times the encode function has been entered for each HTTP request. The counter is set to 1 before the encode function is called for the first time, and is incremented before it is called on each subsequent occasion.

Output parameters for the encode function

The encode function can provide the following outputs:

A response code (optionally qualified by a reason):
If the encode function returns a response code of URP_OK, an HTTP response is sent to the Web client.
If the encode function returns any other value, the HTTP request is rejected.
If the response code is URP_OK, the address of a buffer containing the HTTP response to be sent to the Web client, and the length of the HTTP response. The first word of the buffer must contain the length of the data (that is, the length of the HTTP response plus 4).
An eight byte user token, used to share information between the analyzer and converter programs. See "Sharing data between analyzer and converter programs".