home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 3.ddi / AZ / CTCLIB.C next >
Encoding:
C/C++ Source or Header  |  1989-04-18  |  4.1 KB  |  217 lines

  1. /*
  2.  *    low level support 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) 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. #undef   EXTERN
  25. #define  EXTERN /* */
  26. #include "ctoptn.h"        /* c-tree configuration options */
  27. #include "cterrc.h"        /* c-tree error codes        */
  28. #include "ctstrc.h"        /* c-tree data structures    */
  29. #include "ctgvar.h"        /* c-tree global variables    */
  30.    
  31. RNDFILE mbopen(ctnum,opmode)
  32. PFAST CTFILE *ctnum;
  33. COUNT opmode;    /* EXCLUSIVE or SHARED */
  34. {
  35.     RNDFILE retval;
  36.  
  37.     COUNT vtclose();
  38.  
  39.     ctnum->sekpos = DRNZERO;
  40.     if (!(opmode & PERMANENT) && ct_numvfil >= MAXVFIL)
  41.         vtclose();
  42.  
  43.     if ((retval = open(ctnum->flname,BUPDATE)) < 0)
  44.         if (vtclose() == YES)
  45.             retval = open(ctnum->flname,BUPDATE);
  46.  
  47.     if (!(opmode & PERMANENT) && retval >= 0)
  48.         ct_numvfil++;
  49.  
  50.     return(retval);
  51. }
  52.  
  53. /* ------------------------------------------------------------ */
  54.  
  55. RNDFILE mbcrat(ctnum)
  56. PFAST CTFILE *ctnum;
  57. {
  58.     RNDFILE retval;
  59.  
  60.     COUNT vtclose();
  61.  
  62.     if (!(ctnum->flmode & PERMANENT) && ct_numvfil >= MAXVFIL)
  63.         vtclose();
  64.  
  65.     if ((retval = creat(ctnum->flname,BCREATE)) < 0)
  66.         if (vtclose() == YES)
  67.             retval = creat(ctnum->flname,BCREATE);
  68.  
  69.     if (!(ctnum->flmode & PERMANENT) && retval >= 0)
  70.         ct_numvfil++;
  71.  
  72.     return(retval);
  73. }
  74.  
  75. COUNT mbsave(ctnum)
  76. PFAST CTFILE *ctnum;
  77.  
  78. {
  79.     COUNT   uerr(),mbclos();
  80.     RNDFILE mbopen();
  81.  
  82.     if (mbclos(ctnum,ctnum->flmode))
  83.         return(uerr(FSAV_ERR));
  84.     else if ((ctnum->fd = mbopen(ctnum,ctnum->flmode)) < 0)
  85.         return(uerr(FSAV_ERR));
  86.     else
  87.         return(NO_ERROR);
  88. }
  89.  
  90. VOID flushdos(datno)
  91. COUNT         datno;
  92. {
  93.     bdos(13,0,0);
  94. }
  95.  
  96. #ifndef CTSERVER
  97.  
  98. /* --------------------------------------------------------------------
  99.    LOCK index node
  100.  */
  101.  
  102. COUNT LOCK(node,knum)    /* node == 0  => header */
  103. LONG node;
  104. PFAST KEYFILE *knum;
  105. {
  106.  
  107. #ifdef FPUTFGET
  108.     knum -= knum->kmem;    /* adjust for member # */
  109.     if (!(knum->flmode & NONEXCLUSIVE))
  110.         return(NO_ERROR);
  111.  
  112.     /* then execute a LOCKing procedure */
  113.         ???????????????
  114.     /* if lock is successful, increment lock count used by vtclose */
  115.     knum->lokcnt++;
  116.     return(NO_ERROR);
  117. #else
  118.     return(NO_ERROR);
  119. #endif
  120.  
  121. }
  122.  
  123. /* --------------------------------------------------------------------
  124.    UNLOCK index file node
  125. */
  126.  
  127. COUNT UNLOCK(node,knum)
  128. LONG node;
  129. PFAST KEYFILE *knum;
  130. {
  131.  
  132. #ifdef FPUTFGET
  133.     knum -= knum->kmem;    /* adjust for member # */
  134.     if (!(knum->flmode & NONEXCLUSIVE))
  135.         return(NO_ERROR);
  136.     if (knum->lokcnt)
  137.         knum->lokcnt--;
  138.     /* UNLOCK node */
  139.         ??????????????/
  140.     return(NO_ERROR);
  141. #else
  142.     return(NO_ERROR);
  143. #endif
  144.  
  145. }
  146.  
  147.  
  148. /* --------------------------------------------------------------------
  149.    LOCK data record
  150.  */
  151.  
  152. COUNT DLOCK(recbyt,dnum)
  153. POINTER        recbyt;
  154. PFAST DATFILE  *dnum;
  155. {
  156.     COUNT uerr();
  157.  
  158. #ifdef FPUTFGET
  159.  
  160.     if (!(dnum->flmode & NONEXCLUSIVE))
  161.         return(NO_ERROR);
  162.  
  163.     /*  execute a LOCKing procedure: if lock fails, 
  164.      *  return uerr(DLOK_ERR) else return NO_ERROR;
  165.      *  Be sure that lock length is at least one byte.    
  166.      */
  167.  
  168.         ?????????????
  169.  
  170.     /* if successful, increment lokcnt */
  171.     dnum->lokcnt++;
  172.     return(NO_ERROR);
  173. #else
  174.  
  175.     return(NO_ERROR);
  176.  
  177. #endif
  178.  
  179. }
  180.  
  181.  
  182. COUNT RLOCK(recbyt,dnum)
  183. POINTER        recbyt;
  184. PFAST DATFILE  *dnum;
  185. {
  186.     return(NO_ERROR);
  187. }
  188.  
  189. /* --------------------------------------------------------------------
  190.    UNLOCK data record
  191. */
  192.  
  193. COUNT UDLOCK(recbyt,dnum)
  194. POINTER        recbyt;
  195. PFAST DATFILE  *dnum;
  196. {
  197.  
  198. #ifdef FPUTFGET
  199.     if (!(dnum->flmode & NONEXCLUSIVE))
  200.         return(NO_ERROR);
  201.     if (dnum->lokcnt)
  202.         dnum->lokcnt--;
  203.  
  204.     /* UNLOCK record */
  205.         ????????????
  206.  
  207.     return(NO_ERROR);
  208. #else
  209.     return(NO_ERROR);
  210. #endif
  211.  
  212. }
  213.  
  214. #endif
  215.  
  216. /* end of ctclib.c */
  217.