home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rcs / sources / scratch_.c < prev    next >
C/C++ Source or Header  |  1992-01-19  |  1KB  |  40 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Id: scratch_entry.c,v 1.5 89/11/19 23:20:24 berliner Exp $";
  3. #endif 
  4.  
  5. /*
  6.  *    Copyright (c) 1989, Brian Berliner
  7.  *
  8.  *    You may distribute under the terms of the GNU General Public License
  9.  *    as specified in the README file that comes with the CVS 1.0 kit.
  10.  *
  11.  * Scratch Entry
  12.  *
  13.  * Removes the argument file from the Entries file.  A backup of the previous
  14.  * Entries file is placed in Entries.backup.
  15.  */
  16.  
  17. #include <stdlib.h>
  18. #include "cvs.h"
  19.  
  20. Scratch_Entry(fname)
  21.     char *fname;
  22. {
  23.     FILE *fpin, *fpout;
  24.     char line[MAXLINELEN];
  25.     char *cp, *cpend;
  26.  
  27.     rename_file(CVSADM_ENT, CVSADM_ENTBAK);
  28.     fpin = open_file(CVSADM_ENTBAK, "r");
  29.     fpout = open_file(CVSADM_ENT, "w+");
  30.     while (fgets(line, sizeof(line), fpin) != NULL) {
  31.     if ((cpend = rindex(line, '|')) && (cp = rindex(line, ' ')) &&
  32.         (cp++) && strncmp(fname, cp, max((cpend-cp), strlen(fname))) == 0)
  33.         continue;
  34.     if (fputs(line, fpout) == EOF)
  35.         error(1, "cannot write file %s", CVSADM_ENT);
  36.     }
  37.     (void) fclose(fpin);
  38.     (void) fclose(fpout);
  39. }
  40.