ftp.nice.ch/pub/next/unix/developer/rcvs.0.7.9.s.tar.gz#/src/create_adm.c

This is create_adm.c in view mode; [Download] [Up]

/*
 * Copyright (c) 1992, Brian Berliner and Jeff Polk
 * Copyright (c) 1989-1992, Brian Berliner
 * 
 * You may distribute under the terms of the GNU General Public License as
 * specified in the README file that comes with the CVS 1.3 kit.
 * 
 * Create Administration.
 * 
 * Creates a CVS administration directory based on the argument repository; the
 * "Entries" file is prefilled from the "initrecord" argument.
 */

#include "cvs.h"
/* rcvs: */
#include "rcvs.h"

#ifndef lint
static char rcsid[] = "@(#)create_adm.c 1.24 92/03/31";
#endif

void
Create_Admin (dir, repository, tag, date)
    char *dir;
    char *repository;
    char *tag;
    char *date;
{
    FILE *fout;
    char *cp;
    char tmp[PATH_MAX];
    int exist = FALSE;  /* rcvs: */

    if (noexec)
	return;

    if (!isdir (repository))
	error (1, 0, "there is no repository %s", repository);

    if (dir != NULL)
	(void) sprintf (tmp, "%s/%s", dir, CVSADM);
    else
	(void) strcpy (tmp, CVSADM);

    /* rcvs: -c or -C option, CVS exist ok */
    if (isfile (tmp))
    {
        if (!(rcvs_Copt_change_repos || rcvs_copt_change_repos))
	    error (1, 0, "there is a version here already");
        else
	    exist = TRUE;
    }	
    else
    {
	if (dir != NULL)
	    (void) sprintf (tmp, "%s/%s", dir, OCVSADM);
	else
	    (void) strcpy (tmp, OCVSADM);

	if (isfile (tmp))
	    error (1, 0, "there is a version here already");

	if (dir != NULL)
	    (void) sprintf (tmp, "%s/%s", dir, CVSADM);
	else
	    (void) strcpy (tmp, CVSADM);
	make_directory (tmp);
    }

    if (dir != NULL)
	(void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
    else
	(void) strcpy (tmp, CVSADM_REP);
    fout = open_file (tmp, "w+");
    cp = repository;
    strip_path (cp);

#ifdef RELATIVE_REPOS
    /*
     * If the Repository file is to hold a relative path, try to strip off
     * the leading CVSroot argument.
     */
    if (CVSroot != NULL)
    {
	char path[PATH_MAX];

	(void) sprintf (path, "%s/", CVSroot);
	if (strncmp (repository, path, strlen (path)) == 0)
	    cp = repository + strlen (path);
    }
#endif

    if (fprintf (fout, "%s\n", cp) == EOF)
	error (1, errno, "write to %s failed", tmp);
    if (fclose (fout) == EOF)
	error (1, errno, "cannot close %s", tmp);

    /* now, do the Entries file */
    if (dir != NULL)
	(void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
    else
	(void) strcpy (tmp, CVSADM_ENT);

    /* rcvs: -c or -C option, CVS exist ok */
    if (isfile (tmp))
    {
        if (!(rcvs_Copt_change_repos || rcvs_copt_change_repos))
	    error (1, 0, "there is a version here already");
    }
    else
    {  
        fout = open_file (tmp, "w+");
	if (fclose (fout) == EOF)
	    error (1, errno, "cannot close %s", tmp);
    }	

    /* Create a new CVS/Tag file */
    if (!exist)   /* rcvs: */
        WriteTag (dir, tag, date);

    /* rcvs: create CVS/Remote */
    if (rcvs_inshell)
       (void) rcvs_create_adm (dir, repository);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.