summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-05-16 00:12:16 +0000
committerpeter <peter@FreeBSD.org>1997-05-16 00:12:16 +0000
commit12c4ced9facdc83ee17709502465428fa1b4c5ed (patch)
treeab25349316e3f8b6fc83e348fb28c42825927caf /contrib/cvs/src
parent174a377378c64117a2cf5eaf7b0b7116dcd2dded (diff)
downloadFreeBSD-src-12c4ced9facdc83ee17709502465428fa1b4c5ed.zip
FreeBSD-src-12c4ced9facdc83ee17709502465428fa1b4c5ed.tar.gz
Initial round of support for a local $Id$ keyword in cvs, eg: $FreeBSD$.
This is not complete yet in that it doesn't drive our version of RCS completely, but it does work fine when you do the appropriate magic. Obtained from: OpenBSD source tree
Diffstat (limited to 'contrib/cvs/src')
-rw-r--r--contrib/cvs/src/cvs.h3
-rw-r--r--contrib/cvs/src/main.c82
-rw-r--r--contrib/cvs/src/rcs.c12
-rw-r--r--contrib/cvs/src/server.c1
4 files changed, 96 insertions, 2 deletions
diff --git a/contrib/cvs/src/cvs.h b/contrib/cvs/src/cvs.h
index 81659f3..20a4c9f 100644
--- a/contrib/cvs/src/cvs.h
+++ b/contrib/cvs/src/cvs.h
@@ -182,6 +182,7 @@ extern int errno;
#define CVSROOTADM_READERS "readers"
#define CVSROOTADM_WRITERS "writers"
#define CVSROOTADM_PASSWD "passwd"
+#define CVSROOTADM_OPTIONS "options"
#define CVSNULLREPOS "Emptydir" /* an empty directory */
@@ -360,6 +361,7 @@ extern int really_quiet, quiet;
extern int use_editor;
extern int cvswrite;
extern mode_t cvsumask;
+extern char *RCS_citag;
/* Access method specified in CVSroot. */
typedef enum {
@@ -449,6 +451,7 @@ int isabsolute PROTO((const char *filename));
char *last_component PROTO((char *path));
char *get_homedir PROTO ((void));
char *cvs_temp_name PROTO ((void));
+void parseopts PROTO ((const char *root));
int numdots PROTO((const char *s));
int unlink_file PROTO((const char *f));
diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c
index 21400ea..095a36d 100644
--- a/contrib/cvs/src/main.c
+++ b/contrib/cvs/src/main.c
@@ -42,6 +42,7 @@ int trace = FALSE;
int noexec = FALSE;
int logoff = FALSE;
mode_t cvsumask = UMASK_DFLT;
+char *RCS_citag = NULL;
char *CurDir;
@@ -736,6 +737,7 @@ main (argc, argv)
error (1, save_errno, "%s", path);
}
free (path);
+ parseopts(CVSroot_directory);
}
#ifdef HAVE_PUTENV
@@ -791,6 +793,12 @@ main (argc, argv)
(void) putenv (env);
/* do not free env, as putenv has control of it */
}
+ {
+ char *env;
+ env = xmalloc (sizeof "CVS_PID=" + 32); /* XXX pid < 10^32 */
+ (void) sprintf (env, "CVS_PID=%ld", (long) getpid ());
+ (void) putenv (env);
+ }
#endif
/*
@@ -907,3 +915,77 @@ usage (cpp)
(void) fprintf (stderr, *cpp);
error_exit ();
}
+
+void
+parseopts(root)
+ const char *root;
+{
+ char path[PATH_MAX];
+ int save_errno;
+ char buf[1024];
+ const char *p;
+ char *q;
+ FILE *fp;
+
+ if (root == NULL) {
+ printf("no CVSROOT in parseopts\n");
+ return;
+ }
+ p = strchr (root, ':');
+ if (p)
+ p++;
+ else
+ p = root;
+ if (p == NULL) {
+ printf("mangled CVSROOT in parseopts\n");
+ return;
+ }
+ (void) sprintf (path, "%s/%s/%s", p, CVSROOTADM, CVSROOTADM_OPTIONS);
+ if ((fp = fopen(path, "r")) != NULL) {
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ if (buf[0] == '#')
+ continue;
+ q = strrchr(buf, '\n');
+ if (q)
+ *q = '\0';
+
+ if (!strncmp(buf, "tag=", 4)) {
+ char *what;
+
+ RCS_citag = strdup(buf+4);
+ if (RCS_citag == NULL) {
+ printf("no memory for local tag\n");
+ return;
+ }
+ what = malloc(sizeof("RCSLOCALID")+1+strlen(RCS_citag)+1);
+ if (what == NULL) {
+ printf("no memory for local tag\n");
+ return;
+ }
+ sprintf(what, "RCSLOCALID=%s", RCS_citag);
+ putenv(what);
+ }
+#if 0 /* not yet.. gotta rethink the implications */
+ else if (!strncmp(buf, "umask=", 6)) {
+ mode_t mode;
+
+ cvsumask = (mode_t)(strtol(buf+6, NULL, 8) & 0777);
+ }
+ else if (!strncmp(buf, "dlimit=", 7)) {
+#ifdef BSD
+#include <sys/resource.h>
+ struct rlimit rl;
+
+ if (getrlimit(RLIMIT_DATA, &rl) != -1) {
+ rl.rlim_cur = atoi(buf+7);
+ rl.rlim_cur *= 1024;
+
+ (void) setrlimit(RLIMIT_DATA, &rl);
+ }
+#endif /* BSD */
+ }
+#endif /* 0 */
+ }
+ fclose(fp);
+ }
+}
diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c
index 1f73c82..663365b 100644
--- a/contrib/cvs/src/rcs.c
+++ b/contrib/cvs/src/rcs.c
@@ -2176,7 +2176,7 @@ struct rcs_keyword
size_t len;
};
#define KEYWORD_INIT(s) (s), sizeof (s) - 1
-static const struct rcs_keyword keywords[] =
+static struct rcs_keyword keywords[] =
{
{ KEYWORD_INIT ("Author") },
{ KEYWORD_INIT ("Date") },
@@ -2189,6 +2189,7 @@ static const struct rcs_keyword keywords[] =
{ KEYWORD_INIT ("Revision") },
{ KEYWORD_INIT ("Source") },
{ KEYWORD_INIT ("State") },
+ { NULL, 0 },
{ NULL, 0 }
};
enum keyword
@@ -2203,7 +2204,8 @@ enum keyword
KEYWORD_RCSFILE,
KEYWORD_REVISION,
KEYWORD_SOURCE,
- KEYWORD_STATE
+ KEYWORD_STATE,
+ KEYWORD_LOCALID
};
/* Convert an RCS date string into a readable string. This is like
@@ -2340,6 +2342,11 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen)
return;
}
+ if (RCS_citag != NULL && keywords[KEYWORD_LOCALID].string == NULL) {
+ keywords[KEYWORD_LOCALID].string = RCS_citag;
+ keywords[KEYWORD_LOCALID].len = strlen(RCS_citag);
+ }
+
/* If we are using -kkvl, dig out the locker information if any. */
locker = NULL;
if (expand == KFLAG_KVL && rcs->other != NULL)
@@ -2464,6 +2471,7 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen)
case KEYWORD_HEADER:
case KEYWORD_ID:
+ case KEYWORD_LOCALID:
{
char *path;
int free_path;
diff --git a/contrib/cvs/src/server.c b/contrib/cvs/src/server.c
index 65b1dd3..432e9f9 100644
--- a/contrib/cvs/src/server.c
+++ b/contrib/cvs/src/server.c
@@ -565,6 +565,7 @@ Sorry, you don't have read/write access to the history file %s", path);
(void) putenv (env);
/* do not free env, as putenv has control of it */
#endif
+ parseopts(CVSroot_directory);
}
static int max_dotdot_limit = 0;
OpenPOWER on IntegriCloud