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

  1. #ifndef lint
  2. static char rcsid[] = "$Id: name_repository.c,v 1.9 89/11/19 23:20:13 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.  * Name of Repository
  12.  *
  13.  *    Determine the name of the RCS repository and sets "Repository"
  14.  *    accordingly.
  15.  */
  16.  
  17. #include "cvs.h"
  18.  
  19. Name_Repository()
  20. {
  21.     FILE *fpin;
  22.     char path[MAXPATHLEN];
  23.     char *cp;
  24.  
  25.     if (!isdir(CVSADM))
  26.     error(0, "there is no version here; do '%s checkout' first", progname);
  27.     if (!isreadable(CVSADM_REP) || !isreadable(CVSADM_ENT))
  28.     error(0, "*PANIC* administration files missing");
  29.     /*
  30.      * The assumption here is the the repository is always contained
  31.      * in the first line of the "Repository" file.
  32.      */
  33.     fpin = open_file(CVSADM_REP, "r");
  34.     if (fgets(Repository, MAXPATHLEN, fpin) == NULL)
  35.     error(1, "cannot read %s", CVSADM_REP);
  36.     (void) fclose(fpin);
  37.     if ((cp = rindex(Repository, '\n')) != NULL)
  38.     *cp = '\0';            /* strip the newline */
  39.     /*
  40.      * If this is a relative repository pathname, turn it into
  41.      * an absolute one by tacking on the CVSROOT environment variable.
  42.      * If the CVSROOT environment variable is not set, die now.
  43.      */
  44.     if (!ISDIRSEP(Repository[0])) {
  45.     if (CVSroot == NULL) {
  46.         (void) fprintf(stderr,
  47.                "%s: must set the CVSROOT environment variable\n",
  48.                progname);
  49.         error(0, "or specify the '-d' option to %s", progname);
  50.     }
  51.     (void) strcpy(path, Repository);
  52.     (void) sprintf(Repository, "%s%c%s", CVSroot, DIRSEP, path);
  53.     }
  54.     if (!isdir(Repository))
  55.     error(0, "there is no repository %s", Repository);
  56. }
  57.