home *** CD-ROM | disk | FTP | other *** search
- /*
- * create isam files
- *
- * 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) 1984, 1985, 1986, 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" /* 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 */
-
- COUNT INTREE(),CREIDX(),CREDAT(),getidxr(),getintr(),getdatr(),ierr();
- COUNT getambr(),CREMEM();
- FILE *fopen();
-
-
- COUNT CREISAM(filnam)
- TEXT *filnam;
-
- {
- #ifdef PARMFILE
- FILE *ifd;
- FAST COUNT i,j,k;
- COUNT nbufs,nkeys,nsecs,dkeys;
- COUNT nomemb,datno,filemd,keyno,klen,ktyp,dflg;
- UCOUNT datlen,xtdsiz;
- TEXT isam_nam[MAX_NAME];
- LOKS *lp;
-
- isam_err = NO_ERROR;
- if ((ifd = fopen(filnam,"r")) == NULL)
- return(ierr(INOD_ERR,0));
-
- if (getintr(ifd,&nbufs,&nkeys,&nsecs,&ct_isdats)) {
- fclose(ifd);
- return(isam_err);
- }
- if (INTREE(nbufs,nkeys + ct_isdats,nsecs)) {
- fclose(ifd);
- return(ierr(uerr_cod,0));
- }
-
- for (i = 0; i < ct_mxfil; ) {
- ct_dtmap[i] = NO;
- ct_rvmap[i] = -1;
- cur_recno[i] = DRNZERO;
- ct_kymap[i++][0] = -1;
- }
-
- for (i = 0; i < ct_isdats; i++) {
- if (getdatr(ifd,&datno,isam_nam,&datlen,&dkeys,&xtdsiz,
- &filemd))
- goto close_up;
-
- if (CREDAT(datno,isam_nam,datlen,xtdsiz,filemd)) {
- ierr(uerr_cod,datno);
- goto close_up;
- }
-
- for (j = 0; j < dkeys; j++) {
- if (getidxr(ifd,datno,j,&keyno,isam_nam,&klen,&ktyp,
- &dflg,&nomemb,&xtdsiz,&filemd))
- goto close_up;
-
- if (CREIDX(keyno,isam_nam,klen,ktyp,dflg,
- nomemb,xtdsiz,filemd)) {
- ierr(uerr_cod,keyno);
- goto close_up;
- }
-
- for (k = 1; k <= nomemb; k++) {
- if (getambr(ifd,datno,j + k,keyno + k,&klen,
- &ktyp,&dflg))
- return(isam_err);
- if (CREMEM(keyno,klen,ktyp,dflg,k)) {
- ierr(uerr_cod,keyno + k);
- goto close_up;
- }
- }
- j += nomemb;
-
- }
- if (j < MAX_DAT_KEY)
- ct_kymap[datno][j] = -1;
- }
-
- close_up:
- fclose(ifd);
- if (isam_err) {
- for (i = 0; i < ct_mxfil; i++)
- if (ct_dtmap[i] == YES) {
- CLSFIL(i,COMPLETE);
- ct_dtmap[i] = NO;
- }
- mbfree(ct_origin);
- ct_origin = NULL;
- mbfree(ct_key);
- ct_key = ct_dat = ct_vat = NULL;
- mbfree(ct_btree);
- ct_btree = NULL;
- ct_mxfil = 0;
- return(isam_err);
- }
- for (i = 0,lp = ct_locks; i < MAX_LOCKS; i++,lp++)
- lp->datfnm = -1;
- #endif
- return(NO_ERROR);
- }
-
- /* end of ctismc.c */
-