home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c004 / 3.ddi / AZ / CTCLIB.MAC < prev    next >
Encoding:
Text File  |  1989-04-18  |  4.0 KB  |  218 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.     if (!(opmode & PERMANENT) && ct_numvfil >= MAXVFIL)
  40.         vtclose();
  41.  
  42.     if ((retval = open(ctnum->flname,BUPDATE)) < 0)
  43.         if (vtclose() == YES)
  44.             retval = open(ctnum->flname,BUPDATE);
  45.  
  46.     if (!(opmode & PERMANENT) && retval >= 0)
  47.         ct_numvfil++;
  48.  
  49.     return(retval);
  50. }
  51.  
  52. /* ------------------------------------------------------------ */
  53.  
  54. RNDFILE mbcrat(ctnum)
  55. PFAST CTFILE *ctnum;
  56. {
  57.     RNDFILE retval;
  58.  
  59.     COUNT vtclose();
  60.  
  61.     if (!(ctnum->flmode & PERMANENT) && ct_numvfil >= MAXVFIL)
  62.         vtclose();
  63.  
  64.     if ((retval = creat(ctnum->flname,BCREATE)) < 0)
  65.         if (vtclose() == YES)
  66.             retval = creat(ctnum->flname,BCREATE);
  67.  
  68.     if (!(ctnum->flmode & PERMANENT) && retval >= 0)
  69.         ct_numvfil++;
  70.  
  71.     return(retval);
  72. }
  73.  
  74. COUNT mbsave(ctnum)
  75. PFAST CTFILE *ctnum;
  76.  
  77. {
  78.     COUNT   uerr(),mbclos();
  79.     RNDFILE mbopen();
  80.  
  81.     if (mbclos(ctnum,ctnum->flmode))
  82.         return(uerr(FSAV_ERR));
  83.     else if ((ctnum->fd = mbopen(ctnum,ctnum->flmode)) < 0)
  84.         return(uerr(FSAV_ERR));
  85.     else
  86.         return(NO_ERROR);
  87. }
  88.  
  89. VOID flushdos(datno)
  90. COUNT         datno;
  91. {
  92.     /* no action */
  93. }
  94.  
  95. #ifndef CTSERVER
  96.  
  97. /* --------------------------------------------------------------------
  98.    LOCK index node
  99.  */
  100.  
  101. COUNT LOCK(node,knum)    /* node == 0  => header */
  102. LONG node;
  103. PFAST KEYFILE *knum;
  104. {
  105.  
  106. #ifdef FPUTFGET
  107.     knum -= knum->kmem;    /* adjust for member # */
  108.     if (!(knum->flmode & NONEXCLUSIVE))
  109.         return(NO_ERROR);
  110.  
  111.     /* then execute a LOCKing procedure */
  112.         ???????????????
  113.     /* if lock is successful, increment lock count used by vtclose */
  114.     knum->lokcnt++;
  115.     return(NO_ERROR);
  116. #else
  117.     return(NO_ERROR);
  118. #endif
  119.  
  120. }
  121.  
  122. /* --------------------------------------------------------------------
  123.    UNLOCK index file node
  124. */
  125.  
  126. COUNT UNLOCK(node,knum)
  127. LONG node;
  128. PFAST KEYFILE *knum;
  129. {
  130.  
  131. #ifdef FPUTFGET
  132.     knum -= knum->kmem;    /* adjust for member # */
  133.     if (!(knum->flmode & NONEXCLUSIVE))
  134.         return(NO_ERROR);
  135.  
  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.  
  202.     if (dnum->lokcnt)
  203.         dnum->lokcnt--;
  204.  
  205.     /* UNLOCK record */
  206.         ????????????
  207.  
  208.     return(NO_ERROR);
  209. #else
  210.     return(NO_ERROR);
  211. #endif
  212.  
  213. }
  214.  
  215. #endif
  216.  
  217. /* end of ctclib.c */
  218.