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

  1. /*
  2.  *    incremental rebuild routines
  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. /**********************************************/
  24. /* RBLIFIL assumes that c-tree file is closed */
  25. /**********************************************/
  26.  
  27. #include "ctstdr.h"        /* standard i/o header         */
  28. #include "ctoptn.h"        /* c-tree configuration options */
  29. #include "cterrc.h"        /* c-tree error codes        */
  30. #include "ctstrc.h"        /* c-tree data structures    */
  31. #include "ctgvar.h"        /* c-tree global variables    */
  32. #include "ctisam.h"        /* c-tree isam header        */
  33. #include "ctifil.h"
  34.  
  35. #ifdef FPUTFGET
  36.  
  37. COUNT RBLIFIL(ifilptr)
  38. PFAST IFIL   *ifilptr;
  39. {
  40.     printf(
  41. "\n CTIBLD should not be compiled with the FPUTFGET option!\n");
  42.     exit(2);
  43. }
  44.  
  45. #else
  46.  
  47. #define SORT_SPACE    16000
  48.  
  49. EXTERN COUNT    rerr_cod,rerr_fil,ct_fp,ct_redom;
  50. EXTERN TEXT    *ct_rbuf;
  51. EXTERN POINTER *ct_pbuf;
  52. EXTERN VRLEN    ct_bsz;
  53. EXTERN LONG    ct_spc;
  54.  
  55. COUNT        ierr(),rerr();
  56.  
  57. COUNT RBLIFIL(ifilptr)
  58. PFAST IFIL   *ifilptr;
  59. {
  60.     COUNT      RBLDAT(),RBLIDX(),RBLMEM(),filrng(),setimap();
  61.     TEXT      *mballc();
  62.     VOID       mbfree();
  63.  
  64.     COUNT       filno,i;
  65.     FAST COUNT k;
  66.     FAST IIDX *idxp;
  67.     TEXT       datname[MAX_NAME + 4],idxname[MAX_NAME + 4];
  68.  
  69.     if ((filno = filrng(ifilptr)) < 0)
  70.         return(rerr(-filno,ifilptr->dfilno));
  71.  
  72.     if ((ct_pbuf = (POINTER *) mballc(1,(unsigned int) (ct_spc = SORT_SPACE))) == NULL)
  73.         return(rerr(RSPC_ERR,0));
  74.  
  75.     if ((ct_rbuf = mballc(1,ifilptr->dreclen)) != NULL)
  76.         ct_bsz = ifilptr->dreclen;
  77.     else {
  78.         mbfree(ct_pbuf);
  79.         return(rerr(RRLN_ERR,0));
  80.     }
  81.  
  82.     if ((i = strlen(ifilptr->pfilnam)) > MAX_NAME)
  83.         i = MAX_NAME;
  84.     cpybuf(datname,ifilptr->pfilnam,i);
  85.     cpybuf(datname + i,DAT_EXTENT,strlen(DAT_EXTENT) + 1);
  86.     ifilptr->tfilno = filno;
  87.  
  88.     ct_fp = YES;    /* force rebuild */
  89.     if (RBLDAT(filno,datname,ifilptr->dreclen,ifilptr->dxtdsiz,
  90.         ifilptr->dfilmod))
  91.         goto err_ibuild;
  92.  
  93.     (ct_key + filno)->srlpos = 0;
  94.     if (ifilptr->dnumidx > 0) {
  95.         cpybuf(idxname,datname,i);
  96.         cpybuf(idxname + i,IDX_EXTENT,strlen(IDX_EXTENT) + 1);
  97.         idxp = ifilptr->ix;
  98.         if (setimap(0,ifilptr)) {
  99.             rerr(isam_err,isam_fil);
  100.             goto err_ibuild;
  101.         }
  102.         if (RBLIDX(filno,datname,idxname,filno + 1,idxp->ikeylen,
  103.             idxp->ikeytyp,idxp->ikeydup,ifilptr->dnumidx - 1,
  104.             ifilptr->ixtdsiz,ifilptr->ifilmod))
  105.             goto err_ibuild;
  106.  
  107.         for (k = 1; k < ifilptr->dnumidx; k++) {
  108.             if (setimap(k,ifilptr)) {
  109.                 rerr(isam_err,isam_fil);
  110.                 goto err_ibuild;
  111.             }
  112.             idxp = &ifilptr->ix[k];
  113.             if (ct_redom && RBLMEM(filno,datname,idxname,filno + 1,
  114.                 idxp->ikeylen,idxp->ikeytyp,idxp->ikeydup,k))
  115.                 goto err_ibuild;
  116.         }
  117.     }
  118.  
  119.     rerr_cod = NO_ERROR;
  120.  
  121. err_ibuild:
  122.     mbfree(ct_rbuf);
  123.     mbfree(ct_pbuf);
  124.     ct_rbuf        = NULL;
  125.     ct_pbuf        = NULL;
  126.     ifilptr->tfilno = -1;
  127.     return(ierr(rerr_cod,rerr_fil));
  128. }
  129.  
  130. #endif
  131.  
  132. /* end of ctibld.c */
  133.