[Top] [Prev] [Next] [Bottom]

Ffind (3FML)

Ffind (3FML)

Name

Ffind, Ffind32-find field occurrence in buffer

Synopsis

#include <stdio.h>  
#include "fml.h"
char *
Ffind(FBFR *fbfr, FLDID fieldid, FLDOCC oc, FLDLEN *len)
#include "fml32.h"
char *
Ffind32(FBFR32 *fbfr, FLDID32 fieldid, FLDOCC32 oc, FLDLEN32 *len)

Description

Ffind() finds the value of the specified field occurrence in the buffer. fbfr is a pointer to a fielded buffer. fieldid is a field identifier. oc is the occurrence number of the field. If the field is found, its length is set into *len, and its location is returned as the value of the function. If the value of len is NULL, then the field length is not returned. Ffind() is useful for gaining read-only access to a field. In no case should the value returned by Ffind() be used to modify the buffer.

In general, the locations of values of types FLD_LONG, FLD_FLOAT, and FLD_DOUBLE are not suitable for direct use as their stored type, since proper alignment within the buffer is not guaranteed. Such values must be copied first to a suitably aligned memory location. Accessing such fields through the conversion function CFfind(3) does guarantee the proper alignment of the found converted value. Buffer modification should only be done by the functions Fadd(3) or Fchg(3). The values returned by Ffind() and Ffindlast() are valid only so long as the buffer remains unmodified.

Ffind32 is used with 32-bit FML.

Return Values

In the SYNOPSIS section above the return value to Ffind() is described as a character pointer data type (char * in C). Actually, the pointer returned points to an object that has the same type as the stored type of the field.

This function returns a pointer to NULL on error and sets Ferror to indicate the error condition.

Errors

Under the following conditions, Ffind() fails and sets Ferror to:

[FALIGNERR]
"fielded buffer not aligned"
The buffer does not begin on the proper boundary.

[FNOTFLD]
"buffer not fielded"
The buffer is not a fielded buffer or has not been initialized by Finit().

[FNOTPRES]
"field not present"
A field occurrence is requested but the specified field and/or occurrence was not found in the fielded buffer.

[FBADFLD]

"unknown field number or type"
A field identifier is specified which is not valid.

See Also

Fintro(3fml), Ffindlast(3fml), Ffindocc(3fml), Ffinds(3fml)



[Top] [Prev] [Next] [Bottom]