BEA Logo BEA Tuxedo Release 7.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   Tuxedo Doc Home   |   Programming   |   Topic List   |   Previous   |   Next   |   Contents

   Programming a BEA Tuxedo Application Using FML

Input/Output Functions

The functions described in this section support input and output of fielded buffers to standard I/O or to file streams.

Fread and Fwrite

The I/O functions Fread and Fwrite work with the standard I/O library.

int Fread(FBFR *fbfr, FILE *iop)
int Fwrite(FBFR *fbfr, FILE *iop)

The stream to which-or from which-I/O is directed is determined by a FILE pointer argument. This argument must be set up using the normal standard I/O library functions.

A fielded buffer may be written into a standard I/O stream with the function Fwrite, as follows.

if (Fwrite(fbfr, iop) < 0)
F_error("pgm_name");

A buffer written with Fwrite may be read with Fread, as follows.

if(Fread(fbfr, iop) < 0)
F_error("pgm_name");

Although the contents of the fielded buffer pointed to by fbfr are replaced by the fielded buffer read in, the capacity of the fielded buffer (that is, the size of the buffer) remains unchanged.

Fwrite discards the buffer index, writing only as much of the fielded buffer as has been used (as returned by Fused).

Fread restores the index of a buffer by calling Findex. The buffer is indexed with the same indexing interval with which it was written by Fwrite. Fread32 ignores the FLD_PTR field type.

For more information, refer to Fread, Fread32(3fml) and Fwrite, Fwrite32(3fml) in the BEA Tuxedo FML Function Reference.

Fchksum

A checksum may be calculated for verifying I/O, as follows.

long chk;
. . .
chk = Fchksum(fbfr);

The user is responsible for calling Fchksum, writing the checksum value out, along with the fielded buffer, and checking it on input. Fwrite does not write the checksum automatically. For pointer fields (FLD_PTR), the name of the pointer field in the checksum calculation (rather than the pointer or the data referenced by the pointer) is included.

For more information, refer to Fchksum, Fchksum32(3fml) in the BEA Tuxedo FML Function Reference.

Fprint and Ffprint

The Fprint function prints a fielded buffer on the standard output in text format.

Fprint(FBFR *fbfr)

Here fbfr is a pointer to a fielded buffer.

Ffprint is similar to Fprint, except that it sends text to a specified output stream, as in the following line.

Ffprint(FBFR *fbfr, FILE *iop)

Here:

Each of these print functions prints, for each field occurrence, the field name and the field value, separated by a tab and followed by a new-line. Fname is used to determine the field name. If the field name cannot be determined, then the field identifier is printed. Non-printable characters in the field values for strings and character arrays are represented by a backslash followed by their two-character hexadecimal value. Backslashes occurring in the text are escaped with an extra backslash. A blank line is printed following the output of the printed buffer.

For values of type FLD_PTR, Fprint32 prints the field name or field identifier and the pointer value in hexadecimal. Although this function prints pointer information, the Fextread32 function ignores the FLD_PTR field type.

For values of type FLD_FML32, Fprint32 recursively prints the FML32 buffer, with leading tabs added for each level of nesting. For values of type FLD_VIEW32, this function prints the VIEW32 field name and structure member name/value pairs.

For more information, refer to Fprint, Fprint32(3fml) in the BEA Tuxedo FML Function Reference.

Fextread

Fextread may be used to construct a fielded buffer from its printed format, that is, from the output of Fprint (hexadecimal values output by Fprint are interpreted properly).

int
Fextread(FBFR *fbfr, FILE *iop)

Fextread accepts an optional flag preceding the field-name/field-identifier specification in the output of Fprint, as shown in the following table.

Fextread Flags

Flag

Indicates

+

Field should be changed in the buffer

-

Field should be deleted from the buffer

=

One field should be assigned to another

#

Comment line; ignored

If no flag is specified, the default action is to Fadd the field to the buffer.

Field values may be extended across lines by beginning each overflow line with a tab (which is later discarded). A single blank line signals the end of the buffer; successive blank lines yield a null buffer. For embedded buffers (FLD_FML32 and FLD_VIEW32), Fextread generates nested FML32 buffers and VIEW32 fields, respectively. Fextread32 ignores the FLD_PTR field type.

If an error has occurred, -1 is returned, and Ferror is set accordingly. If the end of the file is reached before a blank line, Ferror is set to FSYNTAX.

For more information, refer to Fextread, Fextread32(3fml) in the BEA Tuxedo FML Function Reference.