Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

OpenIFile

Incremental ISAM open.

Short Name

OPNIFIL()

Type

ISAM function

Declaration

COUNT OpenIFile(pIFIL ifilptr)

Description

OpenIFile() opens the data file and (optional) index file referenced by the IFIL structure pointed to by ifilptr. The file name pointed to by the IFIL structure, ifilptr->pfilnam, should NOT include an extension: .dat and .idx are automatically appended to the file name for the data file and index file, respectively. The extended version of this function, OpenIFileXtd(), can change the file extensions at run time.

If you desire the files to be opened in directories that are not specified until run-time, then ifilptr->pfilnam should not be finalized until run-time.

Consecutive file numbers are assigned to the data file and any (optional) indexes associated with the data file. The IFIL structure contains two file numbers: a permanent file number (dfilno), and a temporary file number (tfilno). If dfilno is less than zero, c-tree finds the first available block of sufficient consecutive file numbers. If such a block of numbers is found, then the first number in the block is assigned to the data file and to tfilno. If dfilno is greater than or equal to zero, then dfilno is assigned to the data file and to tfilno.

Note: This function supports EXCLUSIVE file opens. For more information, please refer to Multi-user File Mode.

Return

Upon successful open, ifilptr->tfilno contains the file number assigned to the data file; and the associated indexes are assigned consecutive index numbers starting one (1) greater than the data file number.

On a successful open when a differently named file matches the file ID of an open file, the error return will be NO_ERROR (0) but sysiocod will be set to MFID_COD (-586). If the files are detected to actually be different, then the file ID is changed as discussed above and sysiocod is not set to MFID_COD.

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful open of ISAM files.

12

FNOP_ERR

Could not open file(s). Check isam_fil for the specific file number.

14

FCRP_ERR

File appears corrupt at open: rebuild.

20

KMIN_ERR

Key length too large for node size.

22

FNUM_ERR

File number is out of range.

45

KLEN_ERR

Key length exceeds MAXLEN parameter in ctoptn.h.

46

FUSE_ERR

File number is already in use or no available block of numbers.

47

FINT_ERR

c-tree has not been initialized. Call InitISAM() before the first call to OpenIFile().

107

IDRK_ERR

Too many index files for one data file. Increase MAX_DAT_KEY parameter in ctoptn.h or keyword in ctsrvr.cfg.

109

IKRS_ERR

Too many key segments. Increase MAX_KEY_SEG parameter in ctoptn.h.

115

ISLN_ERR

Key segments do not equal key length.

See c-tree Error Codes for a complete listing of valid c-tree error values.

Example

extern IFIL myfile;

COUNT retval;


if (retval = InitISAM(6,7,4))

printf("\nCould not close files. Error %d.", retval);

else {

if (CreateIFile(&myfile))

printf( "\nCould not create %s (%d,%d)\n",

myfile.pfilnam, isam_err, isam_fil );

else if (CloseIFile(&myfile))

printf("\nCould not close files.");

if (OpenIFile(&myfile))

printf("\nCould not open files.");

else if (CloseIFile(&myfile))

printf("\nCould not close files.");


if (CloseISAM())

printf("\nCould not close ISAM.");

}

Limitations

The index files will be numbered consecutively following the data file. See “File numbering” in the index for additional information.

See also

InitISAM(), CreateIFile(), CloseISAM(), OpenIFileXtd(), OpenFileWithResource(), GetIFile() and ISAM Functions (ISAM Database Technology, /doc/ctreeplus/30841.htm) in the c-tree Programmer’s Reference Guide, which describes the ISAM parameters.

TOCIndex