FairCom Corporation


F.9 AvailableFileNbr


Return next available c-tree Plus file number.

SHORT NAME

AVLFILNUM

TYPE

Low level data file function

DECLARATION

COUNT AvailableFileNbr(COUNT numfils)

DESCRIPTION

AvailableFileNbr returns a valid c-tree Plus file number that is available for use (i.e., not presently assigned to a file). numfils is the number of consecutive file numbers required. If numfils consecutive file numbers are not available, AvailableFileNbr returns -1.

This function does not consume the file number(s) returned. The file number is consumed only if you subsequently create or open a file with the returned file number. Therefore, two calls in succession to AvailableFileNbr, without any intervening creates, opens, or closes, will return the same file number. However, the scope is local to your application. No multi-user interference is possible, since each application only references file numbers internally.

If used for a host superfile, remember to use an argument of 2.

RETURN

AvailableFileNbr returns the first file number in the series requested. If the requested block of file numbers is not available, it returns -1. Check uerr_cod for the error value.

Value
Symbolic Constant
Explanation
46
FUSE_ERR
No file number is available.
47
ISDP_ERR
c-tree Plus is not initialized.

See Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

EXAMPLE

COUNT super_number,retval;
super_number = AvailableFileNbr(2);
if (super_number == -1) {
printf("\nNot enough file numbers available");
exit(1);
}
retval = OpenCtFile(super_number,"superfil",
ctPERMANENT | ctEXCLUSIVE | ctSUPERFILE);

FairCom Corporation
www.faircom.com