PURPOSE

CFgetalloc, CFgetalloc32 - get field, space, & convert

SYNOPSIS

#include <stdio.h>
#include "fml.h"
char *
CFgetalloc(FBFR *fbfr, FLDID fieldid, FLDOCC oc, int type, FLDLEN *extralen)
#include "fml32.h"
char *
CFgetalloc32(FBFR32 *fbfr, FLDID32 fieldid, FLDOCC32 oc, int type,
  FLDLEN32 *extralen)

DESCRIPTION

CFgetalloc(|) gets a specified field from a buffer, allocates space, converts the field to the type specified by the user and returns a pointer to its location. fbfr is a pointer to a fielded buffer. fieldid is a field identifier. oc is the occurrence number of the field. type is the data type the user wants the field to be converted to. On call, extralen is a pointer to the length of additional space that may be allocated to receive the value; on return, it is a pointer actual amount of space used. If extralen is NULL, then no additional space is allocated and the actual length is not returned. The user is responsible for freeing the returned (converted) value.

CFgetalloc32 is used with 32-bit FML.

RETURN VALUES

On success, CFgetalloc() returns a pointer to the converted value. On error, the function returns NULL and sets Ferror to indicate the error condition.

ERRORS

Under the following conditions, CFgetalloc() 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().
 
[FMALLOC]
-- malloc failed
Allocation of space dynamically using malloc(3) failed.
 
[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.
 
[FTYPERR]
-- invalid field type
A field identifier is specified which is not valid.

SEE ALSO

Fintro(3fml),
Fgetalloc(3fml)