home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 1.ddi / CTISMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  2.9 KB  |  126 lines

  1. /*
  2.  *    isam parameter file open routine
  3.  *
  4.  *    This program is the CONFIDENTIAL and PROPRIETARY property 
  5.  *    of FairCom(R) Corporation. Any unauthorized use, reproduction or
  6.  *    transfer of this program is strictly prohibited.
  7.  *
  8.  *      Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989 FairCom Corporation
  9.  *    (Subject to limited distribution and
  10.  *     restricted disclosure only.)
  11.  *    *** ALL RIGHTS RESERVED ***
  12.  *
  13.  *    4006 West Broadway
  14.  *    Columbia, MO 65203
  15.  *
  16.  *
  17.  *    c-tree(R)    Version 4.3
  18.  *            Release C
  19.  *            February 7, 1989 17:30
  20.  *
  21.  */
  22.  
  23. #include "ctstdr.h"        /* standard i/o header         */
  24. #include "ctoptn.h"        /* c-tree configuration options */
  25. #include "cterrc.h"        /* c-tree error codes        */
  26. #include "ctstrc.h"        /* c-tree data structures    */
  27. #include "ctgvar.h"        /* c-tree global variables    */
  28. #include "ctisam.h"        /* c-tree isam header        */
  29.  
  30. #ifdef PARMFILE
  31. COUNT OPNFIL(),getintr(),getdatr(),getidxr(),getambr(),ierr(),INTREE();
  32. #endif
  33.  
  34. COUNT OPNISAM(filnam)
  35. TEXT         *filnam;
  36. {
  37. #ifdef PARMFILE
  38.     FILE      *ifd;
  39.     FAST COUNT i,j,k;
  40.     COUNT      nbufs,nkeys,nsecs,dkeys;
  41.     COUNT      nomemb,datno,filemd,keyno,klen,ktyp,dflg;
  42.     UCOUNT       datlen,xtdsiz;
  43.     TEXT       isam_nam[MAX_NAME];
  44.     LOKS      *lp;
  45.  
  46.     FILE *fopen();
  47.  
  48.     isam_err = NO_ERROR;
  49.     if ((ifd = fopen(filnam,"r")) == NULL)
  50.         return(ierr(INOD_ERR,0));
  51.  
  52.     if (getintr(ifd,&nbufs,&nkeys,&nsecs,&ct_isdats)) {
  53.         fclose(ifd);
  54.         return(isam_err);
  55.     }
  56.     if (INTREE(nbufs,nkeys + ct_isdats,nsecs)) {
  57.         fclose(ifd);
  58.         return(ierr(uerr_cod,0));
  59.     }
  60.  
  61.     for (i = 0; i < ct_mxfil; ) {
  62.         ct_dtmap[i]      = NO;
  63.         ct_rvmap[i]      = -1;
  64.         cur_recno[i]   = DRNZERO;
  65.         ct_kymap[i++][0] = -1;
  66.     }
  67.  
  68.     for (i = 0; i < ct_isdats; i++) {
  69.         if (getdatr(ifd,&datno,isam_nam,&datlen,&dkeys,&xtdsiz,
  70.             &filemd))
  71.             goto close_up;
  72.  
  73.         if (OPNFIL(datno,isam_nam,filemd)) {
  74.             ierr(uerr_cod,datno);
  75.             goto close_up;
  76.         }
  77.  
  78.         for (j = 0; j < dkeys; j++) {
  79.             if (getidxr(ifd,datno,j,&keyno,isam_nam,&klen,&ktyp,
  80.                 &dflg,&nomemb,&xtdsiz,&filemd))
  81.                 goto close_up;
  82.  
  83.                 if (OPNFIL(keyno,isam_nam,filemd)) {
  84.                 ierr(uerr_cod,keyno);
  85.                 goto close_up;
  86.             }
  87.  
  88.             for (k = 1; k <= nomemb; k++)
  89.                 if (getambr(ifd,datno,j + k,keyno + k,&klen,
  90.                     &ktyp,&dflg))
  91.                     goto close_up;
  92.             j += nomemb;
  93.         }
  94.         if (j < MAX_DAT_KEY)
  95.             ct_kymap[datno][j] = -1;
  96.     }
  97.  
  98. close_up:
  99.     fclose(ifd);
  100.     if (isam_err) {
  101.         for (i = 0; i < ct_mxfil; i++)
  102.             if (ct_dtmap[i] == YES) {
  103.                 CLSFIL(i,COMPLETE);
  104.                 ct_dtmap[i] = NO;
  105.             }
  106.         mbfree(ct_origin);
  107.         ct_origin = NULL;
  108.         mbfree(ct_key);
  109.         ct_key    = ct_dat = ct_vat = NULL;
  110.         mbfree(ct_btree);
  111.         ct_btree  = NULL;
  112.         ct_mxfil = 0;
  113.         return(isam_err);
  114.     }
  115.     for (i = 0,lp = ct_locks; i < MAX_LOCKS; i++,lp++)
  116.         lp->datfnm = -1;
  117.  
  118.     return(NO_ERROR);
  119. #else
  120.     printf("\n\nPARMFILE SUPPORT DISABLED IN CTOPTN.H\n\n");
  121.     return(FVER_ERR);
  122. #endif
  123. }
  124.  
  125. /* end of ctismo.c */
  126.