home *** CD-ROM | disk | FTP | other *** search
- /*
- * incremental rebuild routines
- *
- * 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
- *
- */
-
- /**********************************************/
- /* RBLIFIL assumes that c-tree file is closed */
- /**********************************************/
-
- #include "ctstdr.h" /* standard i/o header */
- #include "ctoptn.h" /* c-tree configuration options */
- #include "cterrc.h" /* c-tree error codes */
- #include "ctstrc.h" /* c-tree data structures */
- #include "ctgvar.h" /* c-tree global variables */
- #include "ctisam.h" /* c-tree isam header */
- #include "ctifil.h"
-
- #ifdef FPUTFGET
-
- COUNT RBLIFIL(ifilptr)
- PFAST IFIL *ifilptr;
- {
- printf(
- "\n CTIBLD should not be compiled with the FPUTFGET option!\n");
- exit(2);
- }
-
- #else
-
- #define SORT_SPACE 16000
-
- EXTERN COUNT rerr_cod,rerr_fil,ct_fp,ct_redom;
- EXTERN TEXT *ct_rbuf;
- EXTERN POINTER *ct_pbuf;
- EXTERN VRLEN ct_bsz;
- EXTERN LONG ct_spc;
-
- COUNT ierr(),rerr();
-
- COUNT RBLIFIL(ifilptr)
- PFAST IFIL *ifilptr;
- {
- COUNT RBLDAT(),RBLIDX(),RBLMEM(),filrng(),setimap();
- TEXT *mballc();
- VOID mbfree();
-
- COUNT filno,i;
- FAST COUNT k;
- FAST IIDX *idxp;
- TEXT datname[MAX_NAME + 4],idxname[MAX_NAME + 4];
-
- if ((filno = filrng(ifilptr)) < 0)
- return(rerr(-filno,ifilptr->dfilno));
-
- if ((ct_pbuf = (POINTER *) mballc(1,(unsigned int) (ct_spc = SORT_SPACE))) == NULL)
- return(rerr(RSPC_ERR,0));
-
- if ((ct_rbuf = mballc(1,ifilptr->dreclen)) != NULL)
- ct_bsz = ifilptr->dreclen;
- else {
- mbfree(ct_pbuf);
- return(rerr(RRLN_ERR,0));
- }
-
- if ((i = strlen(ifilptr->pfilnam)) > MAX_NAME)
- i = MAX_NAME;
- cpybuf(datname,ifilptr->pfilnam,i);
- cpybuf(datname + i,DAT_EXTENT,strlen(DAT_EXTENT) + 1);
- ifilptr->tfilno = filno;
-
- ct_fp = YES; /* force rebuild */
- if (RBLDAT(filno,datname,ifilptr->dreclen,ifilptr->dxtdsiz,
- ifilptr->dfilmod))
- goto err_ibuild;
-
- (ct_key + filno)->srlpos = 0;
- if (ifilptr->dnumidx > 0) {
- cpybuf(idxname,datname,i);
- cpybuf(idxname + i,IDX_EXTENT,strlen(IDX_EXTENT) + 1);
- idxp = ifilptr->ix;
- if (setimap(0,ifilptr)) {
- rerr(isam_err,isam_fil);
- goto err_ibuild;
- }
- if (RBLIDX(filno,datname,idxname,filno + 1,idxp->ikeylen,
- idxp->ikeytyp,idxp->ikeydup,ifilptr->dnumidx - 1,
- ifilptr->ixtdsiz,ifilptr->ifilmod))
- goto err_ibuild;
-
- for (k = 1; k < ifilptr->dnumidx; k++) {
- if (setimap(k,ifilptr)) {
- rerr(isam_err,isam_fil);
- goto err_ibuild;
- }
- idxp = &ifilptr->ix[k];
- if (ct_redom && RBLMEM(filno,datname,idxname,filno + 1,
- idxp->ikeylen,idxp->ikeytyp,idxp->ikeydup,k))
- goto err_ibuild;
- }
- }
-
- rerr_cod = NO_ERROR;
-
- err_ibuild:
- mbfree(ct_rbuf);
- mbfree(ct_pbuf);
- ct_rbuf = NULL;
- ct_pbuf = NULL;
- ifilptr->tfilno = -1;
- return(ierr(rerr_cod,rerr_fil));
- }
-
- #endif
-
- /* end of ctibld.c */
-