home *** CD-ROM | disk | FTP | other *** search
- /*
- * incremental isam file create
- *
- * 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 CREIFIL(ifilptr)
- PFAST IFIL *ifilptr;
- {
- COUNT filno,i;
- TEXT nambuf[MAX_NAME + 4];
- FAST IIDX *idxp;
- COUNT ierr(),filrng(),setimap(),CREDAT(),CREIDX();
- COUNT CREMEM(),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 (CREDAT(filno,nambuf,ifilptr->dreclen,ifilptr->dxtdsiz,
- ifilptr->dfilmod))
- return(ierr(uerr_cod,filno));
- ifilptr->tfilno = filno;
-
- if (ifilptr->dnumidx > 0) {
- cpybuf(nambuf + i,IDX_EXTENT,strlen(IDX_EXTENT) + 1);
- idxp = ifilptr->ix;
- i = CREIDX(filno + 1,nambuf,idxp->ikeylen,idxp->ikeytyp,
- idxp->ikeydup,ifilptr->dnumidx - 1,ifilptr->ixtdsiz,
- ifilptr->ifilmod);
- if (i) {
- ifilptr->tfilno = -1;
- cpybuf(nambuf,(ct_key + filno)->flname,MAX_NAME);
- CLSFIL(filno,ifilptr->dfilmod);
- remove(nambuf);
- return(ierr(i,filno + 1));
- }
- /* host index */
- if (setimap(0,ifilptr))
- goto err_creifil;
- ct_dtmap[filno + 1] = YES + 2;
- } else
- ct_kymap[filno][0] = -1;
-
- ct_dtmap[filno] = YES + 2;
-
- #ifdef RTREE
- usrdat[filno].fldnam[1] = ifilptr->rfstfld;
- usrdat[filno].fldnam[2] = ifilptr->rlstfld;
- #endif
-
- /* index members */
- for (i = 1; i < ifilptr->dnumidx; i++) {
- idxp = &ifilptr->ix[i];
- if (CREMEM(filno + 1,idxp->ikeylen,idxp->ikeytyp,
- idxp->ikeydup,i)) {
- ierr(uerr_cod,filno + i + 1);
- goto err_creifil;
- } else if (setimap(i,ifilptr))
- goto err_creifil;
- }
- if (i < MAX_DAT_KEY)
- ct_kymap[filno][i] = -1;
-
- return(NO_ERROR);
-
- err_creifil:
- ifilptr->tfilno = -1;
- for (i = filno; i <= filno + 1; i++) {
- ct_dtmap[i] = NO;
- cpybuf(nambuf,(ct_key + i)->flname,MAX_NAME);
- CLSFIL(i,ifilptr->dfilmod);
- remove(nambuf);
- }
- return(isam_err);
- }
-
- /* end of cticre.c */
-