home *** CD-ROM | disk | FTP | other *** search
- /*
- * incremental isam file open
- *
- * This program is the CONFIDENTIAL and PROPRIETARY property
- * of FairCom(R) Corporation. Any unauthorized use, reproduction or
- * transfer of this program is strictly prohibited.
- *
- * Copyright (c) 1987, 1988, 1989 FairCom Corporation
- * (Subject to limited distribution and
- * restricted disclosure only.)
- * *** ALL RIGHTS RESERVED ***
- *
- * 4006 West Broadway
- * Columbia, MO 65203
- *
- *
- * c-tree(R) Version 4.3
- * Release C
- * February 7, 1989 17:30
- *
- */
-
- #include "ctstdr.h"
- #include "ctoptn.h"
- #include "ctstrc.h"
- #include "ctgvar.h"
- #include "ctisam.h"
- #include "ctifil.h"
- #include "cterrc.h"
-
- #ifdef RTREE
- #include "rtpars.h"
- #include "rtstrc.h"
-
- EXTERN RDAT usrdat[];
- #endif
-
-
- COUNT OPNIFIL(ifilptr)
- PFAST IFIL *ifilptr;
- {
- FAST COUNT i;
- COUNT filno;
- TEXT nambuf[MAX_NAME + 4];
- COUNT ierr(),filrng(),setimap(),OPNFIL(),CLSFIL();
-
- isam_err = 0;
- if ((filno = filrng(ifilptr)) < 0)
- return(-filno);
- else if (ifilptr->dnumidx > MAX_DAT_KEY)
- return(ierr(IDRK_ERR,filno));
- if ((i = strlen(ifilptr->pfilnam)) > MAX_NAME)
- i = MAX_NAME;
- cpybuf(nambuf,ifilptr->pfilnam,i);
- cpybuf(nambuf + i,DAT_EXTENT,strlen(DAT_EXTENT) + 1);
- if (OPNFIL(filno,nambuf,ifilptr->dfilmod))
- return(ierr(uerr_cod,filno));
-
- if (ifilptr->dnumidx > 0) {
- cpybuf(nambuf + i,IDX_EXTENT,strlen(IDX_EXTENT) + 1);
- i = OPNFIL(filno + 1,nambuf,ifilptr->ifilmod);
- if (i) {
- CLSFIL(filno,ifilptr->dfilmod);
- return(ierr(i,filno + 1));
- }
- if ((ct_key + filno + 1)->nmem != ifilptr->dnumidx - 1) {
- ierr(INIX_ERR,filno);
- goto err_opnifil;
- }
- ct_dtmap[filno + 1] = YES + 2;
- }
- ct_dtmap[filno] = YES + 2;
-
- #ifdef RTREE
- usrdat[filno].fldnam[1] = ifilptr->rfstfld;
- usrdat[filno].fldnam[2] = ifilptr->rlstfld;
- #endif
-
- ifilptr->tfilno = filno;
- for (i = 0; i < ifilptr->dnumidx; i++)
- if (setimap(i,ifilptr))
- goto err_opnifil;
- if (i < MAX_DAT_KEY)
- ct_kymap[filno][i] = -1;
-
- return(NO_ERROR);
-
- err_opnifil:
- ct_dtmap[filno] = ct_dtmap[filno + 1] = NO;
- ifilptr->tfilno = -1;
- CLSFIL(filno,ifilptr->dfilmod);
- CLSFIL(filno + 1,ifilptr->ifilmod);
- return(isam_err);
- }
-
- /* end of ctiopn.c */
-