Fproj, Fproj32 - projection on buffer
#include <stdio.h> #include "fml.h" int Fproj(FBFR *fbfr, FLDID *fieldid) #include "fml32.h" int Fproj32(FBFR32 *fbfr, FLDID32 *fieldid)
Fproj() is used to update a buffer so as to keep only the desired fields. fbfr is a pointer to a fielded buffer. The desired fields are specified in an array of field identifiers pointed to by fieldid. The last entry in the array must be BADFLDID. The update is done in-place; fields that are not in the result of the projection are deleted from the fielded buffer. The array of field identifiers may be re-arranged (if they are not already in numeric order, they are sorted).
Fproj32 is used with 32-bit FML.
This function returns -1 on error and sets Ferror to indicate the error condition.
Under the following conditions, Fproj() fails and sets Ferror to:
#include "fld.tbl.h" FBFR *fbfr; FLDID fieldid[20]; fieldid[0] = A; /* field id for field A */ fieldid[1] = D; /* field id for field D */ fieldid[2] = BADFLDID; /* sentinel value */ if(Fproj(fbfr, fieldid) 0) F_error("pgm_name");
If the buffer has fields A, B, C, and D, the example results in a buffer that contains only occurrences of fields A and D. The entries in the array of field identifiers do not need to be in any specific order, but the last value in the array of field identifiers must be field identifier 0 (BADFLDID).