home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume22 / cvs-berliner / part01 / src / create_admin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.3 KB  |  49 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Id: create_admin.c,v 1.7 89/11/19 23:19:55 berliner Exp $";
  3. #endif !lint
  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.  * Create Administration.
  12.  *
  13.  *    Creates a CVS administration directory based on the argument
  14.  *    repository; the "Entries" file is prefilled from the "initrecord"
  15.  *    argument.
  16.  */
  17.  
  18. #include <sys/param.h>
  19. #include "cvs.h"
  20.  
  21. Create_Admin(repository, initrecord)
  22.     register char *repository;
  23.     register char *initrecord;
  24. {
  25.     register FILE *fout;
  26.     char *cp;
  27.  
  28.     if (!isdir(repository))
  29.     error(0, "there is no repository %s", repository);
  30.     if (!isfile(initrecord))
  31.     error(0, "there is no file %s", initrecord);
  32.     if (isfile(CVSADM))
  33.     error(0, "there is a version here already");
  34.     make_directory(CVSADM);
  35.     fout = open_file(CVSADM_REP, "w+");
  36.     cp = repository;
  37.     if (CVSroot != NULL) {
  38.     char path[MAXPATHLEN];
  39.  
  40.     (void) sprintf(path, "%s/", CVSroot);
  41.     if (strncmp(repository, path, strlen(path)) == 0)
  42.         cp = repository + strlen(path);
  43.     }
  44.     if (fprintf(fout, "%s\n", cp) == EOF)
  45.     error(1, "write to %s failed", CVSADM_REP);
  46.     (void) fclose(fout);
  47.     copy_file(initrecord, CVSADM_ENT);
  48. }
  49.