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

  1. /*
  2.  *    incremental isam file open
  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) 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"
  24. #include "ctoptn.h"
  25. #include "ctstrc.h"
  26. #include "ctgvar.h"
  27. #include "ctisam.h"
  28. #include "ctifil.h"
  29. #include "cterrc.h"
  30.  
  31. #ifdef RTREE
  32. #include "rtpars.h"
  33. #include "rtstrc.h"
  34.  
  35. EXTERN RDAT  usrdat[];
  36. #endif
  37.  
  38.  
  39. COUNT OPNIFIL(ifilptr)
  40. PFAST IFIL  *ifilptr;
  41. {
  42.     FAST COUNT   i;
  43.     COUNT         filno;
  44.     TEXT         nambuf[MAX_NAME + 4];
  45.     COUNT         ierr(),filrng(),setimap(),OPNFIL(),CLSFIL();
  46.  
  47.     isam_err = 0;
  48.     if ((filno = filrng(ifilptr)) < 0)
  49.         return(-filno);
  50.     else if (ifilptr->dnumidx > MAX_DAT_KEY)
  51.         return(ierr(IDRK_ERR,filno));
  52.     if ((i = strlen(ifilptr->pfilnam)) > MAX_NAME)
  53.         i = MAX_NAME;
  54.     cpybuf(nambuf,ifilptr->pfilnam,i);
  55.     cpybuf(nambuf + i,DAT_EXTENT,strlen(DAT_EXTENT) + 1);
  56.     if (OPNFIL(filno,nambuf,ifilptr->dfilmod))
  57.         return(ierr(uerr_cod,filno));
  58.  
  59.     if (ifilptr->dnumidx > 0) {
  60.         cpybuf(nambuf + i,IDX_EXTENT,strlen(IDX_EXTENT) + 1);
  61.         i = OPNFIL(filno + 1,nambuf,ifilptr->ifilmod);
  62.         if (i) {
  63.             CLSFIL(filno,ifilptr->dfilmod);
  64.             return(ierr(i,filno + 1));
  65.         }
  66.         if ((ct_key + filno + 1)->nmem != ifilptr->dnumidx - 1) {
  67.             ierr(INIX_ERR,filno);
  68.             goto err_opnifil;
  69.         }
  70.         ct_dtmap[filno + 1] = YES + 2;
  71.     }
  72.     ct_dtmap[filno] = YES + 2;
  73.  
  74. #ifdef RTREE
  75.     usrdat[filno].fldnam[1] = ifilptr->rfstfld;
  76.     usrdat[filno].fldnam[2] = ifilptr->rlstfld;
  77. #endif
  78.  
  79.     ifilptr->tfilno = filno;
  80.     for (i = 0; i < ifilptr->dnumidx; i++)
  81.         if (setimap(i,ifilptr))
  82.             goto err_opnifil;
  83.     if (i < MAX_DAT_KEY)
  84.         ct_kymap[filno][i] = -1;
  85.  
  86.     return(NO_ERROR);
  87.  
  88. err_opnifil:
  89.     ct_dtmap[filno]   = ct_dtmap[filno + 1] = NO;
  90.     ifilptr->tfilno = -1;
  91.     CLSFIL(filno,ifilptr->dfilmod);
  92.     CLSFIL(filno + 1,ifilptr->ifilmod);
  93.     return(isam_err);
  94. }
  95.  
  96. /* end of ctiopn.c */
  97.