bdfp1m0lProgramming Concepts and Reference

Checking for Errors Using C Functions

Table 6 lists a set of C functions that you can use to test a particular condition when you have called a C function.

Note:
Do not use any of these functions after a dfcls function.

Table 6. C Functions for Detecting Errors

Function Condition
DF_OK No errors indicated in SW00RTN.
DF_EMPTY Test if a subfile is empty. This function is available only after a delete operation that does not use fullfile processing and before the next TPFDF call.
DF_ER Any serious error indicated in SW00RTN.
DF_ERBTR B+Tree index error.
DF_ERX Any serious error indicated in SW00RTN except indexing errors.
DF_NR Record not found (any error indicated in SW00RTN requiring remedial action).
DF_EF End of file (any error indicated in SW00RTN requiring remedial action).
DF_ERCNT Numbers of errors detected during fullfile processing.
DF_ERLST Error in list of logical record numbers.
DF_ERDSP Error with the dfdsp function.
DF_SERRC System error issued by the TPFDF product.
DF_TEST Test specified bits in SW00RTN.

The following describes the format, parameters, and normal return for these functions. In addition, there is an example of how you can use these functions.

Format

int DF_OK(dft_fil *file);
int DF_EMPTY(dft_fil *file);
int DF_ER(dft_fil *file);
int DF_ERBTR(dft_fil *file);
int DF_ERX(dft_fil *file);
int DF_NR(dft_fil *file);
int DF_EF(dft_fil *file);
int DF_ERCNT(dft_fil *file);
int DF_ERLST(dft_fil *file);
int DF_ERDSP(dft_fil *file);
int DF_SERRC(dft_fil *file);
int DF_TEST(dft_fil *file, char cond);



cond Parameter Values
 
   .-|-------------.
   V               |
|----+-DFC_IOERR-+-+--------------------------------------------|
     +-DFC_RCDNF-+
     +-DFC_FACE--+
     +-DFC_ALG---+
     +-DFC_BLOCK-+
     +-DFC_EOF---+
     +-DFC_SEQ---+
     '-DFC_SM----'
 
 

file
is a pointer to the base address of the SW00SR slot (defined in c$sw00sr.h) of the subfile that you want to access and is returned by the dfopn function.

cond
is the condition that you want to test. Table 7 describes the values you can specify:

Table 7. Values for the cond Parameter

Value SW00RTN Bit Tested Condition
DFC_IOERR Bit 0 I/O or B+Tree index error.
DFC_RCDNF Bit 1 One of the following:
  • The LREC was not found when using a dfred or dfdel function.
  • An LREC was found with the same keys as the LREC being added by one of the following:
    • dfadd function with the DFADD_UNIQUE value specified for the options parameter
    • dfadd function for a file with UNIQUE=YES specified on the DBDEF macro for the file.
DFC_FACE Bit 2 File address compute program (FACE) error.
DFC_ALG Bit 3 One of the following:
  • Subfile does not exist in detail file or intermediate index file.
  • Incorrect algorithm argument.
DFC_BLOCK Bit 4 Data in block is corrupt.
DFC_EOF Bit 5 End of file occurred during fullfile processing.
DFC_SEQ Bit 6 Sequence error using dfrst function.
DFC_SM Bit 7 Sort or merge error.

Normal Return

Function DF_ERCNT returns the count of errors detected during fullfile processing. All other functions return a nonzero value if the tested condition is true; otherwise, the return is zero. Table 8 lists the conditions tested for each function.

Table 8. Normal Return Values for Error Detection C Functions

Function Tested Condition
DF_OK All SW00RTN bits are zero.
DF_ER One of the following SW00RTN bits is set to 1:
  • #BIT0
  • #BIT2
  • #BIT3
  • #BIT4
  • #BIT6
  • #BIT7.
DF_ERBTR Both SW00RTN #BIT0 and SW00RT2 #BIT4 are set to 1.
DF_ERX One of the following SW00RTN bits is set to 1:
  • #BIT0
  • #BIT2
  • #BIT4
  • #BIT6
  • #BIT7.
DF_NR One of the following SW00RTN bits is set to 1:
  • #BIT1
  • #BIT5.
DF_EF One of the following SW00RTN bits is set to 1:
  • #BIT1
  • #BIT5.
DF_ERLST Both SW00RTN #BIT1 and SW00RT2 #BIT0 are set to 1.
DF_ERDSP Both SW00RTN #BIT0 and SW00RT2 #BIT1 are set to 1.
DF_SERRC One of the following SW00RTN bits is set to 1:
  • #BIT0
  • #BIT2
  • #BIT4
  • #BIT7.

Examples

The following example:

psgr_lrec = dfred_acc(psgr_file, DFRED_ALG, 0, in_mess);
 
if (DF_ERX(psgr_file))                /* if error from read       */
  subfile_error();                    /* perform error processing */
 
if (DF_TEST(psgr_file, DFC_ALG))      /* if subfile doesn't exist */
  printf("INVALID NUMBER\n");         /* send message to operator */