dfred: Read one or more logical records
Use this group of functions to read logical records.
- Read a logical record (LREC)
- Read a T-type LREC
- Read a block header
- Get the address where a record is stored
- Read the next LREC in sequence
- Read an LREC by specifying details of the LREC that you want
- Read an LREC by using buffered access mode (BAM)
- Read multiple LRECs from a subfile into a buffer.
Last updated
- Changed in 2022 (information only; no code change).
- Changed in 2021.
- Changed for PUT13.
- Changed for PUT12.
- Changed for PUT11.
- Changed for PUT10.
- Changed for PUT09.
- Changed for PUT07.
- Changed for PUT06.
- Changed for PUT05.
- Changed for PUT04.
- Changed for PUT03.
- Changed for PUT02.
- Changed for PUT01.
- Changed for PUT00.
Format
dft_rec *dfred(dft_fil *file, dft_opt options); dft_rec *dfred_acc(dft_fil *file, dft_opt access, dft_opt options, dft_xxx acc); dft_rec *dfred_nbr(dft_fil *file, dft_opt nbr_type, dft_opt options, dft_xxx nbr); dft_rec *dfred_are(dft_fil *file, dft_opt options, dft_are *are); dft_rec *dfred_pth(dft_fil *file, dft_opt options, dft_pth pth); dft_rec *dfred_acc_nbr(dft_fil *file, dft_opt nbr_type, dft_opt access, dft_opt options,
dft_xxx acc, dft_xxx nbr); dft_rec *dfred_acc_are(dft_fil *file, dft_opt access, dft_opt options, dft_xxx acc,
dft_are *are); dft_rec *dfred_acc_pth(dft_fil *file, dft_opt access, dft_opt options, dft_xxx acc,
dft_pth pth); dft_rec *dfred_nbr_are(dft_fil *file, dft_opt nbr_type, dft_opt options, dft_nbr nbr,
dft_are *are); dft_rec *dfred_nbr_pth(dft_fil *file, dft_opt nbr_type, dft_opt options, dft_xxx nbr,
dft_pth pth); dft_rec *dfred_are_pth(dft_fil *file, dft_opt options, dft_are *are,dft_pth pth); dft_rec *dfred_acc_nbr_are(dft_fil *file, dft_opt nbr_type, dft_opt access,
dft_opt options, dft_xxx acc, dft_xxx nbr, dft_are *are); dft_rec *dfred_acc_nbr_pth(dft_fil *file, dft_opt nbr_type, dft_opt access,
dft_opt options, dft_xxx acc, dft_xxx nbr, dft_pth pth); dft_rec *dfred_acc_are_pth(dft_fil *file, dft_opt access, dft_opt options, dft_xxx acc,
dft_are *are, dft_pth pth); dft_rec *dfred_nbr_are_pth(dft_fil *file, dft_opt nbr_type, dft_opt options, dft_xxx nbr,
dft_are *are, dft_pth pth); dft_rec *dfred_acc_nbr_are_pth(dft_fil *file, dft_opt nbr_type, dft_opt access,
dft_opt options, dft_xxx acc, dft_xxx nbr, dft_are *are, dft_pth pth);void dfred_multi(dft_fil *file, dft_opt options, dft_buf *buf_ptr);dft_rec *dfred_ttype(dft_ref *tref_name, dft_ref *wref_name);
- file
- A pointer to the base address of the SW00SR slot (defined in c_sw00sr.h) of the file that you want to access and is returned by the dfifb or dfopn function. Use the acc parameter to specify a particular subfile to access. If you do not specify the acc parameter, the last subfile accessed with this SW00SR slot will be accessed.
- acc
- An ordinal number, a file address, or a pointer to an algorithm string that specifies the subfile you want to access. The type for this parameter is determined by the value you specify for the access parameter.
- access
- The method you want to use to access the subfile. Use one of the
following values:
- DFRED_ALG
- Specifies that you are providing a pointer to an algorithm argument
in the acc parameter. The acc parameter
is of type
dft_alg.Notes:- The z/TPFDF product uses the algorithm argument to determine the subfile (ordinal number) that is to be accessed. Specify the algorithm argument based on the type of algorithm that is defined in the DSECT or DBDEF macro for the file. If the DSECT or DBDEF macro defines the #TPFDB04 or the #TPFDB0D algorithm, do not use this parameter.
- If the subfile you are accessing is contained in a detail file or intermediate index file defined with the #TPFDBFF algorithm, the z/TPFDF product uses the algorithm argument to locate the subfile. For more information about how the z/TPFDF product uses the algorithm argument to locate the subfile, see z/TPFDF Database Administration.
- Any active keys are ignored when you use the #TPFDB0D algorithm.
- The area of storage that contains the algorithm argument must not be modified and must be accessible to the z/TPFDF product until the subfile is closed and the SW00SR is released.
- DFRED_FADDR
- Specifies that you are providing a 4-byte file address for the acc parameter.
A file address is in integer format. The acc parameter
is of type
dft_fad. - DFRED_FADDR8
- Specifies that you are providing a pointer to an 8-byte file address
for the acc parameter. The acc parameter
is of type
* dft_fad8. - DFRED_ORD
- Specifies that you are providing an ordinal number in the acc parameter.
Ordinal numbers in a file start at zero and are in integer format.
The acc parameter is of type
dft_ord.If the file is partitioned or interleaved, specify the relative ordinal number within the partition or interleave. If the file is not partitioned or interleaved, specify the file address compute program (FACE) ordinal number.
- are
- A pointer to an area to which the z/TPFDF product copies user data from the index LREC referencing the detail subfile you are accessing. This user data is defined in the DBDEF macro of the detail subfile. For more information about defining this user data, see data extraction parameter information in z/TPFDF Database Administration.
- nbr
- A variable containing one of the following based on the value
of the nbr_type parameter:
- A single LREC number (type
dft_nbr) if the nbr_type parameter is set to DFRED_LRECNBR. - A pointer to a list of LRECs (type
dft_rcl) if the nbr_type parameter is set to DFRED_LIST.Note:Specify the LRECs in this list as character array. For example:char nbrs[] = "2/3-6/LAST";The list contains one or more LREC sequence numbers separated by a slash (⁄). You also can specify a range of sequence numbers by separating the beginning and end of the range by a hyphen (-). You can use LAST to mean the last LREC of the subfile and ALL to mean all the remaining LRECs. The LREC list must be ended with either a nonnumeric character or LAST/ALL.Notes:- The ranges must be in ascending order; if one is found out of
order, that range and all subsequent ranges are ignored. For example, if there are 41 LRECs in a subfile, all of the following lists have the same effect:
20/31/32/33/37/38/39/40/41 20/31/32/33/37-41 20/31-33/37-LAST 20/31-33/37/ALL - You cannot specify the value zero in the list of LREC numbers.
- The ranges must be in ascending order; if one is found out of
order, that range and all subsequent ranges are ignored.
- A stack reference number (type
dft_srn) if the nbr_type parameter is set to the DFRED_STACKREF option. - A pointer to a stack area (type
dft_stk) if the nbr_type parameter is set to the DFRED_STACK option.
Notes:- If you use the #TPFDB0D algorithm, you must specify a specific LREC number for the value of nbr.
- LRECs are numbered in increasing order from the start of the subfile (the first LREC in the prime block has sequence number 1).
- If you specify this parameter with active keys, only those LRECs that match the key conditions are included in the sequence numbering; LRECs that do not match are ignored.
- A single LREC number (type
- nbr_type
- One of the following values:
- DFRED_LIST
- Specifies that you are supplying a pointer to a list of LREC numbers
(type
dft_rcl) in the nbr parameter. The z/TPFDF product reads these LRECs in sequence on subsequent dfred function calls (unless you change the dfred parameters). - DFRED_LRECNBR
- Specifies that you are supplying the sequence number of a single
LREC (type
dft_nbr) in the nbr parameter. The z/TPFDF product reads the LREC with this sequence number. - DFRED_STACK
- Specifies that you are supplying a pointer to a 10-byte stack
area (type
dft_stk) in the nbr parameter.Note: Where possible, use the DFRED_STACKREF option. - DFRED_STACKREF
- Specifies that you are supplying a stack reference number (type
dft_srn) in the nbr parameter. You must specify the DFRED_PREVIOUS option with the DFRED_STACKREF option.
The DFRED_STACK and DFRED_STACKREF options allow you to read an LREC that you have retained with an earlier dfret function.
- options
- The processing options for this function. Use the following values:
- DFRED_BAM
- Reads an LREC by using buffered access mode (BAM). Before you call this function, you must have defined the BAM parameters previously by using the dfsetbam function. For more information about how to set up BAM parameters for use with the dfred function, see dfsetbam: Set buffered access mode (BAM) parameters.
- DFRED_FULLFILE
- Reads an LREC from any of the subfiles in the file. If you do
not specify this value, you can only read an LREC in the current subfile.Note: This option only processes subfiles in the current partition or interleave. In order to process all subfiles in all partitions or interleaves, you must call the dfopt function with the DFOPT_PARTITION or DFOPT_INTERLEAVE option and the DFOPT_ALL value.
- DFRED_INDEX_HOLD
- Potentially holds any index files that reference the subfiles
you are accessing and prevents two or more application programs from
modifying the index files at the same time. Holding occurs if bits
4 and 5 in the &SW00OP2 global set symbol in the DSECT macro,
or the OP2 parameter in the DBDEF macro, have
been set appropriately. Subsequent z/TPFDF calls by other
ECBs to modify the index file will not occur until the index file
is no longer held. If more than one application can update the same
index file, or the file is processed in full file mode, you must specify
this value to ensure the updates are synchronized.
For information about how bits 4 and 5 in the &SW00OP2 global set symbol in the DSECT macro or the OP2 parameter in the DBDEF macro affect hold processing, see z/TPFDF Database Administration.
- DFRED_NODUMP
- Specifies that you do not want the z/TPFDF product to issue
system errors with return while the z/TPFDF product is processing
this function. Note: Use the DFRED_NODUMP value with caution because it can prevent the z/TPFDF system errors that indicate a critical problem from being issued.
- DFRED_NOKEY
- Deactivates any currently active keys.
- DFRED_USR
- Returns a pointer to the userLREC. Use this option when working with extended LRECs. For more information about extended LRECs, see Using extended logical records.
- DFRED_BACKWARD
- Reads backward through the subfile; that is, the z/TPFDF product reads the
LREC immediately before the current LREC position. Notes:
- Any active keys and the DFRED_LRECNBR option are ignored when stepping backward through the subfile.
- SW00REC must contain the address of a valid LREC when the DFRED_BACKWARD option is used. Do not use the DFRED_BACKWARD option if the subfile is not yet retrieved.
- If you use the DFRED_BACKWARD option and also use the dfret function, you must specify DFRET_STACK or DFRET_STACKREF with the dfret function. For more information about these values and the dfret function, see dfret: Retain a logical record position.
- If you use DFRED_BACKWARD, the default and recommended setting for symbol &DB013A in the DBLCL macro is 0. This setting requires files to use full backward chaining (bit 0 of &SW00OP1 is set) to read backward. For more information about defining full backward chaining, see z/TPFDF Database Administration.
Exception: If the file uses add current processing (bit 2 of &SW00OP1 is set) with no chains (&SW00NOC = 0), you can specify DFRED_BACKWARD regardless of how bit 0 of &SW00OP1 is set. - DFRED_BEGIN
- Reads LRECs from the start of the subfile.
- DFRED_CURRENT
- Reads the current LREC. Use this option for one of the following
reasons:
- The current record is an LLR and the previous operation did not use buffered access mode (BAM).
- The previous dfred function used BAM, but the required buffer size was not known or the buffer specified was not large enough.
This option is only valid when using BAM (the DFRED_BAM option is specified). The only other value compatible with this option is the DFRED_NODUMP option.
- DFRED_LAST
- Reads the last LREC from the subfile. If you have specified keys with the read, the z/TPFDF product reads the last LREC that matches the keys. You may also want to specify the DFRED_BEGIN option in case the current LREC is beyond the last LREC that matches the search arguments.
- DFRED_PREVIOUS
- Reads the LREC saved with the last dfret function that used a DFRET_CURRENT option for the ret_type parameter.
- DFRED_FAST
- Used for migration purposes only; use the DFRED_INLINE or DFRED_NOKEY option instead. If you specify DFRED_FAST, the DFRED_NOKEY option is used during processing; that is, keys that are currently active are deactivated.
- DFRED_HEADER
- Locates the subfile header in the prime block and returns the
address in field SW00REC rather than the address of an LREC.
If you specify the DFRED_HEADER and DFRED_FULLFILE options on an open subfile, the dfred function retrieves the header of the next subfile.
- DFRED_INLINE
- Provides more efficient processing for this function. You can
use this value only if you are reading LRECs sequentially, without
any key parameters. This value also deactivates any keys that are
currently active; that is, any previous key arguments are set to zero. Notes:
- This option cannot be used if the DFRED_BACKWARD, DFRED_BAM, or DFRED_LRECNBR option is specified.
- You cannot use this option with P-type files.
- 0
- Specifies that you do not want to use any processing options.
- pth
- The path number for a detail subfile using index support. The
value is defined in the DBDEF macro and is a decimal number (0, 1,
2, and so on). The default path number is 0.
For more information about path indexes, see z/TPFDF Database Administration.
- buf_ptr
- A pointer to a z/TPFDF multiple LREC buffer. All LRECs matching the active search criteria (if any) will be appended onto the end of the z/TPFDF multiple LREC buffer.
- tref_name
- The address of a variable that contains the 8-byte reference name of the T-type LREC. If less than 8 bytes are provided, it must be null-terminated. The z/TPFDF product pads it with blanks (X'40') to build an 8-byte T-type reference name.
- wref_name
- The address of a variable that contains the 8-byte reference name of the underlying file of a T-type LREC. If less than 8 bytes are provided, it must be null-terminated. The z/TPFDF product pads it with blanks (X'40') to build an 8-byte T-type reference name. If you are using the default underlying W-type file (GW01SR), you can specify NULL.
Entry requirements
- If you specify the DFRED_PREVIOUS, DFRED_STACK, or DFRED_STACKREF options, you must first open the subfile using the DFOPN_DETAC or DFOPN_HOLD value for the options parameter on the dfopn function. If this is not done, the retrieved LREC location may not be the one that was retained previously, and a DB017B system error may result, depending on the setting of DBLCL symbol &DB017B.
- Before using the dfred_multi function, you must first initialize a z/TPFDF multiple LREC buffer by using the dfmbuf_init or dfmbuf_init_v2 function.
Return conditions
- If you specify the DFRED_USR option, a pointer to the userLREC portion of the extended LREC is returned.
- If you specify the DFRED_HEADER option, a pointer to the standard header of the block is returned.
- If you specify DFRED_BAM, a pointer to the main large LREC (MLL) part of the LLR is returned. The user part of the LREC (including a 2-byte reserved field and 1-byte primary key) is placed in the buffer that you provided.
- If you used BAM and the buffer was not large enough to read the
LREC, the following situations occur:
- No data is copied into the buffer.
- SW00RT3 bit 0 is turned on. If the error is a serious error, SW00RTN bit 0 is also turned on.
- The LLR found indicator (SW00RT3 bit 7) is turned on when an LLR has been located. If you did not use BAM, you can check whether the LLR found indicator is turned on by using the DF_LLR function. For more information about what to do if you do not know the length of the LREC to be read, see Programming considerations.
- If you are using the dfred_multi function, the return value is set in SW00SR field SW00RT4. For information about how to check the return value, see Identifying return indicators and errors.
- If you specify the dfred_multi function,
one of the following situations might occur:
- If the entire subfile was processed, the SW00REC field contains 0.
- If processing was not completed successfully, the SW00REC field contains the address of the next LREC to be read into the buffer, and the SW00NXT field contains the size of that LREC.
- In all other cases, a pointer to the LREC that is read is returned.
Error return
For information about how to check the error indicators, see Identifying return indicators and errors.
Programming considerations
- The type definitions (for example,
dft_fil,dft_ref, anddft_kyl) are defined in the c_cdfapi.h header file. - If the acc parameter contains an address above 2 GB in storage when the access parameter is set to the DFRED_ALG (pointer to an algorithm) option, performance can be affected.
- Some parameters can be of different types
based on the value you specify for that parameter or a related parameter.
In the function format, the type of these parameters is shown as
dft_xxx. For more information, see the description of the specific parameter for information about what type definition to use for that parameter. - If you are reading an LLR, you must use BAM by specifying the DFRED_BAM value. For more information about how to set up BAM parameters for use with the dfred function, see dfsetbam: Set buffered access mode (BAM) parameters.
- After opening a file, if you use fullfile processing to access or update records, you must
continue to use fullfile processing on any subsequent functions when available until the file is
closed. Accessing or updating subfiles using fullfile processing cannot be mixed with functions that
access or update records without using fullfile processing. Note: The DFRED_HEADER option can be used with the DFRED_FULLFILE option to move from subfile to subfile, which can then be accessed using the dfred functions that do not use the DFRED_FULLFILE.
- If you have set up keys with the file you are reading (using the dfkey function), the z/TPFDF product ignores LRECs where the LREC key does not match the keys.
- If you specify the DFRED_FULLFILE option, and the end-of-file indicator is set, you cannot issue additional z/TPFDF functions until the file is closed. However, you can specify the DFCLS_REUSE option on the dfcls function. For information about the end-of-file indicator, see Identifying return indicators and errors.
- Any active keys are ignored when you use the #TPFDB0D algorithm.
- To ensure that a retained LREC is retrieved correctly when you use the dfred or dfret function, you must use only one of the following methods while a file is open:
- Specify the DFRED_STACK or DFRET_STACK parameter value
- Specify the DFRED_STACKREF or DFRET_STACKREF parameter value
- Do not specify the DFRED_STACK, DFRET_STACK, DFRED_STACKREF, or DFRET_STACKREF parameter value
If you want to change the method to work with retained LRECs, you must close and reopen the file.
- If you specify the DFRET_STACK parameter value on a dfret function for the currently open file, you cannot use the DFRED_PREVIOUS and DFRED_STACK parameter values if the dfadd, dfdel, or dfrep function was called after the dfret function call.
- If you receive an error indication that you tried to read an LLR and a replace of the LLR is in progress (SW00RT3 bit 6), you can attempt the operation again.
- If you do not know the length of an LREC to be read, you can
use the following method to determine the length:
- Issue the dfred function without the DFRED_BAM parameter value specified, and then issue the dfgetsz function to obtain the length of the LREC.
- Create a buffer with the correct length.
- Issue the dfsetbam function.
- Issue the dfred function with the DFRED_BAM and DFRED_CURRENT parameter values to read the LREC.
- If the file you are reading from is defined as a B+Tree file, dfred processing uses the B+Tree, as appropriate, to locate the target LREC when the
required search key information is specified and one of the following actions occurs:
- An initial read was not performed done after the subfile was opened
- The DFRED_BEGIN option is specified.
Otherwise, a sequential search is performed and the B+Tree is not used.
- If the dfred_multi function is specified:
- Do not use the following options with the dfred_multi function: DFRED_BACKWARD, DFRED_BAM, DFRED_CURRENT, DFRED_FAST, DFRED_HEADER, DFRED_INLINE, DFRED_LAST, DFRED_LIST, DFRED_LRECNBR, DFRED_PREVIOUS, DFRED_STACK, and DFRED_STACKREF.
- The active keys will be used as selection criteria to determine which LRECs are read into the specified buffer.
- LRECs will be read beginning with the current position in the subfile, or from the beginning of the subfile if the DFRED_BEGIN option is specified.
- Access parameters and other parameters to control which LRECs are processed (DFxxx_ALG, DFxxx_FADDR, DFxxx_FADDR8, DFxxx_FULLFILE, DFxxx_INTERLV, DFxxx_ORD, and DFxxx_PARTITN) can be specified on previous z/TPFDF function calls.
- All supported LREC and file formats can be used, except for P-type files.
- If a read is performed using search keys with organizations that match that file's database
organization, and if no matching LRECs are found, the z/TPFDF product optimizes a subsequent search that uses the same
criteria as follows:
- The optimized search checks the position of the current LREC (which is the position where a matching LREC would have been located) against the search keys. If the search key values are after the current LREC, the search will start from the current position and continue forward.
- Otherwise, the first LREC of the current block is checked and if the search key values are after the checked LREC, the search will start in the current block from this LREC.
- Otherwise, the search will start from the beginning of the prime data block.
- When adding a T-type LREC and not using the default underlying W-type file (GW01SR), the underlying file must be opened in advance or must be included in the list of files to open automatically in uak0.asm.
Examples
- The following example reads an LREC from the current subfile. The new LREC goes into lrec_ptr.
dft_fil *file_ptr; struct gr95sr *lrec_ptr; ⋮ lrec_ptr = dfred(file_ptr, 0); - The following example reads an LREC retained from a subfile. The subfile is specified with an
algorithm. (The program has set up a pointer to the algorithm argument in member_number.)
dft_fil *file_ptr; char member_number[10]; ⋮ lrec_ptr = dfred_acc(file_ptr, DFRED_ALG, DFRED_PREVIOUS, member_number); - The following example shows how to read a file using keys, without
using default keys.
struct gr95sr lrec_def; struct gr95sr *lrec_ptr; dft_kyl select_keylist; df_nbrkeys(&select_keylist,4); df_setkey(&select_keylist,1,offsetof(lrec_def,lrec_id), member_size(lrec_def,lrec_id),DF_EQ,NULL,X'80', DF_UPORG,DF_CONST); df_setkey(&select_keylist,2,offsetof(lrec_def,key1), member_size(lrec_def,key1),DF_EQ,search_name,0, DF_UPORG,DF_CHAR); df_setkey(&select_keylist,3,offsetof(lrec_def,key2), member_size(lrec_def,key2),DF_EQ,search_city,0, DF_UPORG,DF_CHAR); df_setkey(&select_keylist,4,offsetof(lrec_def,key3), member_size(lrec_def,key3),DF_EQ,search_sal,0, DF_UPORG,DF_CHAR); dfkey(file_ptr,&select_keylist); lrec_ptr = dfred(file_ptr, 0); - The following example shows how to read a file using read-only
and read-write default keys. After the prototype LREC is initialized
to zeros, each of the selection key values (including the primary
key) is copied into the prototype LREC. A call to the df_setkey_dbdef function sets
up the selection key list structure and a call to the dfkey function copies
the default key values from the key list into the SW00SR. Finally,
a call to the dfred function
returns the next LREC that matches the default keys. For more information,
see df_setkey: Setting up a key in a key list.
struct gr95sr proto_lrec; dft_kyl select_keylist; memset(&proto_lrec, 0x00, sizeof(proto_lrec)); proto_lrec.lrec_id = 0x80; memcpy(proto_lrec.key1,search_name,sizeof(proto_lrec.key1)); memcpy(proto_lrec.key2,search_city,sizeof(proto_lrec.key2)); memcpy(proto_lrec.key3,search_sal,sizeof(proto_lrec.key3)); df_setkey_dbdef(&select_keylist,&proto_lrec,0x80); dfkey(file_ptr,&select_keylist); lrec_ptr = dfred(file_ptr,0); df_setkey_dbdef(&select_keylist,&proto_lrec,0x06); dfkey(file_ptr,&select_keylist); lrec_ptr = dfred(file_ptr,0); - The following example shows how to read a file using Boolean logic.
It sets up a key list containing three Boolean logic keys before reading
the LREC. The logic used is equivalent to:
For more information about setting up a key list for Boolean logic, see df_setkey: Setting up a key in a key list.gr95key AND (gr95nam OR gr95adr).dft_rec *lrec91; dft_pky pky = 0x80; dft_pky name1 = "Smith"; dft_pky addr1 = "Main Street"; dft_kyl keys; /* set up the keys */ df_nbrkeys(&keys, 3); df_setkey_bool(&keys, 1, offsetof(struct gr95sr, gr95key), 1, DF_EQ, &pky, 0, DF_UPORG, DF_CHAR, DF_ANDIF); df_setkey_bool(&keys, 2, offsetof(struct gr95sr, gr95nam), 10, DF_EQ, &name1, 0, DF_UPORG, DF_CHAR, DF_OR); df_setkey(&keys, 3, offsetof(struct gr95sr, gr95adr), 10, DF_EQ, &addr1, 0, DF_UPORG, DF_CHAR); /* activate the key list */ dfkey(file_ptr, &keys); /* read an LREC with matching primary key and either matching */ /* the name or the address. */ /* (start at the beginning of the subfile) */ lrec91 = dfred(file_ptr, DFRED_BEGIN); - The following example shows how to read an LREC from a detail
file using index support. First, open the detail file normally, specifying
a DSECT name as the first parameter and then use a dfred function to read
the LREC by providing an index key string as an algorithm argument.
dbptr = dfopn ("GR44DF ",.........) alg_string="ALDER"; dfred_acc (dbptr,DFRED_ALG,alg_string); - The following example shows how you can read an LREC by using
buffered access mode (BAM).
dfsetbam(online_file_ptr,bam_struct); llr_ptr = dfred(online_file_ptr,DFRED_BAM); - The following example shows you how to read the first LLR with
a key of X'80' from a file without knowing how large to make the buffer.
dft_bam bam_parameters; dft_bam *bam_parameters_ptr = &bam_parameters; gr00_sw_ptr = dfopn("GR00DF ",GR00DFI,0); df_nbrkeys(&key_list, 1); df_setkey(&key_list,1,offsetof(GR00DF, GR00KEY), member_size(GR00DF, GR00KEY),DF_EQ,0,GR00K80, DF_UPORG,DF_CONST); dfkey(gr00_sw_ptr, &key_list); do { gr00_lrec_ptr = dfred(gr00_sw_ptr, 0); /* this dfred determines how big the buffer must be */ /* SW00RT3 #BIT7 is set to 1 if LLR */ /* SW00REC contains LREC location (copied to gr00_lrec_ptr) */ if (DF_LLR(gr00_sw_ptr) AND !DF_ER(gr00_sw_ptr)) /* LLR found and no serious error*/ { lrec_size = dfgetsz(gr00_sw_ptr); /* get current LREC size */ buffer_ptr = (char*)malloc(lrec_size); /* allocate buffer */ if (!buffer_ptr) { /* MALOC ERROR */ } bam_parameters_ptr->buf_ptr = buffer_ptr; bam_parameters_ptr->buf_siz = &lrec_size; bam_parameters_ptr->lrec_siz = NULL; dfsetbam(gr00_sw_ptr,bam_parameters_ptr); /* SW00LRP contains buffer pointer (from buf_ptr) */ /* SW00LRB contains buffer size (from buf_siz) */ gr00_lrec_ptr = dfred(gr00_sw_ptr,DFRED_BAM|DFRED_CURRENT); /* SW00BAM #BIT0 is set to 1 (set to 0 upon return) */ /* SW00RT3 #BIT7 is set to 1 if LLR */ if (DF_ER(gr00_sw_ptr)) { /* serious error occurred */ } else /* no serious error */ { if(DF_ERBAM(gr00_sw_ptr)) { /* BAM error, not serious */ /* SW00RT3 #BIT0 is set to 1 -or- */ /* SW00RT3 #BIT1 is set to 1 */ } else { /* now the user has the LLR available in the buffer */ /* SW00REC contains open MLL pointer (copied to gr00_lrec_ptr) */ } } } else /* LLR not found or serious error */ { if (DF_ER(gr00_sw_ptr)) { /* serious error occurred */ } } } while (DF_OK(gr00_sw_ptr)); /* do while more Key 80 LRECs */ dfcls(gr00_sw_ptr,0); free((void *)buffer_ptr); /* release buffer */ - The following example reads all LRECs that match the active search
criteria into the z/TPFDF multiple LREC buffer specified.
/*----------------------------------------------------------------* * Read Multiple the input subfile * *----------------------------------------------------------------*/ dfred_multi(input_sw_ptr,0,buffer_ptr); if (DFMULTI_NOTHING_READ(input_sw_ptr)) { wtopc_text("NO LRECS READ INTO BUFFER"); }For more examples of using z/TPFDF multiple LREC buffer, see dfmbuf_init: Initializing a z/TPFDF multiple LREC buffer.
- The following example shows you how to read a T-type LREC that
is contained in the common underlying W-type file GW01SR. If a different
underlying W-type file is being used, its reference name must be provided
as second parameter; for example, IW00DF.
dft_rec *t_rec_ptr; t_rec_ptr = dfred_ttype("IT00DF ", NULL); /* Process only if T-type LREC present */ if (t_rec_ptr != NULL); { .. } t_rec_ptr = dfred_ttype("IT00DF ","IW00DF ");
