dfmbuf_copy: Copy a z/TPFDF multiple LREC buffer

Use this general function to copy the data of a z/TPFDF multiple LREC buffer to another z/TPFDF multiple LREC buffer.

Last updated

Added for PUT11.

Format

#include <cdf.h>

void dfmbuf_copy(dft_buf *buf_ptr, dft_buf *target_ptr, dft_opt options);
Options parameter values
Read syntax diagramSkip visual syntax diagram|DFMBUF_BEGINDFMBUF_NOKEYDFMBUF_NOTARGETKEY0
buf_ptr
is a pointer to a z/TPFDF multiple LREC buffer that specifies the source of the copy.
target_ptr
is a pointer to a z/TPFDF multiple LREC buffer that specifies the target of the copy.
options
are the processing options for this function. Use the following values:
DFMBUF_BEGIN
copies LRECs starting with the first LREC of the source buffer. If this value is not specified, LRECs are copied starting with the current LREC.
DFMBUF_NOKEY
deactivates any currently active keys in the source buffer.
DFMBUF_NOTARGETKEY
deactivates any currently active keys in the target buffer. All LRECs are appended to the end of the target buffer.
0
specifies that you do not want to use any processing options.

Entry requirements

  • The z/TPFDF multiple LREC buffers that the buf_ptr and target_ptr parameters reference must both be allocated and previously initialized by using the dfmbuf_init or dfmbuf_init_v2 function.
  • The z/TPFDF multiple LREC buffer that the target_ptr parameter references must not be a local copy of the buffer header and must not be previously published.

Return conditions

None.

Error return

For information about how to check the error indicators, see Identifying return indicators and errors.

Programming considerations

  • You can copy data between different header versions of a z/TPFDF multiple LREC buffer.
  • If the source buffer or the target buffer was initialized with header version 1, the dfmbuf_copy function ignores any active keys for both source and target buffers and appends all data from the source buffer at the end of the target buffer.
  • If both the source and target buffers were initialized with header version 2, keys can be used as the following conditions:
    • If active keys exist in the source buffer and the DFMBUF_NOKEY value is not specified, the keys are used as a selection criteria for the data that needs to be copied.
    • If active keys exist in the target buffer and the DFMBUF_NOTARGETKEY value is not specified, the keys are used as organization keys to determine where data gets added into the target buffer.
  • If space in the target buffer is not enough for all LRECs, the following actions occur:
    • The current LREC in the source buffer is set to the first LREC that was not copied.
    • The return value is set to DF_MBUF_NO_SPACE.
    To copy the rest of the LRECs, you can take the following actions:
    1. Allocate a larger size for the target buffer.
    2. Call the dfmbuf_resize function for the target buffer.
    3. Repeat the dfmbuf_copy function without the DFMBUF_BEGIN value specified to continue to copy the remaining LRECs.

Examples

In the following example, LRECs are copied from a source buffer to a target buffer. Any currently active keys in the source buffer are ignored but possibly active keys of the target buffer are used.
 * 
         dfmbuf_copy(buffer_ptr, target_ptr, DFMBUF_NOKEY);
 *