1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * rewindpdb() rewinds a database unless it has been opened for writing
   9:  * or appending only.
  10:  */
  11: #include <stdio.h>
  12: #include "path.h"
  13: #include "pdb.h"
  14: #include "system.h"
  15: 
  16: void
  17: rewindpdb(pdbp)
  18:     PDB *pdbp;          /* database stream */
  19: {
  20:     FILE *fopen();          /* open file stream */
  21: 
  22:     if ((pdbp->flag&_PREAD) == 0 || (pdbp->flag&_PERR) != 0)
  23:         return;
  24:     if ((pdbp->flag&_PACCESS) == (_PREAD|_PWRITE) && (pdbp->flag&_PUPDATE) != 0)
  25:         {
  26:         fclose(pdbp->fp);
  27:         fclose(pdbp->tfp);
  28:         RENAME(pdbp->tpath, pdbp->path);
  29:         pdbp->fp = fopen(pdbp->path, "r");
  30:         pdbp->tfp = fopen(pdbp->tpath, "w");
  31:         }
  32:     else
  33:         rewind(pdbp->fp);
  34:     pdbp->flag &= ~(_PUPDATE|_PEOF);
  35: }
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 608
Valid CSS Valid XHTML 1.0 Strict