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

  1. #ifndef lint
  2. static char rcsid[] = "$Id: entries_file.c,v 1.6 89/11/19 23:20:00 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.  * Entries file to Files file
  12.  *
  13.  * Creates the file Files containing the names that comprise
  14.  * the project, from the Entries file.
  15.  */
  16.  
  17. #include "cvs.h"
  18.  
  19. Entries2Files()
  20. {
  21.     register FILE *fpin, *fpout;
  22.     register int num = 0;
  23.     register char *cp;
  24.     char line[MAXLINELEN];
  25.     char *fnames[MAXFILEPERDIR];
  26.  
  27.     fpin = open_file(CVSADM_ENT, "r");
  28.     fpout = open_file(CVSADM_FILE, "w+");
  29.     while (fgets(line, sizeof(line), fpin) != NULL) {
  30.     if ((cp = rindex(line, '|')) == NULL)
  31.         continue;
  32.     *cp = '\0';
  33.     if ((cp = rindex(line, ' ')) == NULL)
  34.         continue;
  35.     cp++;
  36.     fnames[num] = xmalloc(strlen(cp) + 1);
  37.     (void) strcpy(fnames[num++], cp);
  38.     if (num >= MAXFILEPERDIR)
  39.         error(0, "more than %d files is too many", MAXFILEPERDIR);
  40.     }
  41.     if (num) {
  42.     qsort((char *)&fnames[0], num, sizeof(fnames[0]), ppstrcmp_files);
  43.     while (num--) {
  44.         if (fprintf(fpout, "%s\n", fnames[num]) == EOF)
  45.         error(1, "cannot write %s", CVSADM_FILE);
  46.         free(fnames[num]);
  47.     }
  48.     }
  49.     (void) fclose(fpin);
  50.     (void) fclose(fpout);
  51. }
  52.