Using the view buffer type – HP NonStop G-Series User Manual
Page 79
/* We could just pass the FML buffer back as is, put lets */
/* store it into another FML buffer and pass it back. */
if ((fml_ptr = (FBFR *)tpalloc("FML",NULL,rqst->len))==(FBFR *)NULL) {
(void)userlog("tpalloc failed in PASSFML %s",
tpstrerror(tperrno));
tpreturn(TPFAIL, 0, rqst->data, 0L, 0);
}
if(Fadd(fml_ptr, OUTPUTSTRING, inputString, (FLDLEN)0) == -1) {
userlog("Fadd failed with error: %s", Fstrerror(Ferror));
tpfree((char *)fml_ptr);
tpreturn(TPFAIL, 0, NULL, 0L, 0);
}
if(Fadd(fml_ptr, OUTPUTINT, (char *)&inputInt, (FLDLEN)0) == -1) {
userlog("Fadd failed with error: %s", Fstrerror(Ferror));
tpfree((char *)fml_ptr);
tpreturn(TPFAIL, 0, NULL, 0L, 0);
}
if(Fadd(fml_ptr, OUTPUTFLOAT, (char *)&inputFloat, (FLDLEN)0) == -1) {
userlog("Fadd failed with error: %d\n", Fstrerror(Ferror));
tpfree((char *)fml_ptr);
tpreturn(TPFAIL, 0, NULL, 0L, 0);
}
tpreturn(TPSUCCESS, 0, (char *)fml_ptr, 0L, 0);
}
Using the VIEW Buffer Type
VIEW is a built-in TUXEDO typed buffer. The VIEW buffer provides a way to use C structures and COBOL records with the TUXEDO
system. The VIEW typed buffer enables the TUXEDO run-time system to understand the format of C structures and COBOL records
based on the view description which is read at run time.
When allocating a VIEW, your application specifies a buffer type of VIEW and a subtype that matches the name of the view (the name
that appears in the view description file). Since the TUXEDO run-time system can determine the space needed based on the structure size,
your application need not provide a buffer length. The run-time system can also automatically take care of things, like computing how
much data to send in a request or response, and handle encoding and decoding when the message transfers between different machine
types.
The following examples show the use of the VIEW buffer type with a Jolt client and its server-side application. The example consists of
three parts:
The simpview.java Jolt client that contains the code used to connect to TUXEDO and uses the VIEW buffer type
●
The simpview.v16 file that contains the TUXEDO VIEW field definitions
●
The simpview.c code sample containing the server side C code for handling the input from the Jolt client.
●
The Jolt client treats a null character in a VIEW buffer string format as an end-of-line character and truncates any part of the string that
follows the null.
simpview.java Client Code
accessing an FML service.
The code in the following listing does not catch any exceptions. Since all Jolt exceptions are derived from java.lang.RunTimeException,
the Java Virtual Machine (VM) will catch these exceptions if the application does not. (A well-written application would catch these
exceptions, and take appropriate actions.)
Before running
, you need to add the VIEW service to the SIMPAPP package using the Jolt Repository Editor and write the
simpview.c TUXEDO application. This service takes the data from the client VIEW buffer, creates a new buffer and passes it back to the
client as a new VIEW buffer. The following example assumes that a session object was already instantiated.
Example 6-7. simpview.java Source Code