summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/rcs.c40
-rw-r--r--usr.bin/cvs/rcs.h10
2 files changed, 48 insertions, 2 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index af239c2408c..64f40bbb3eb 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.29 2005/03/04 18:21:00 jfb Exp $ */
+/* $OpenBSD: rcs.c,v 1.30 2005/03/05 03:30:29 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -596,6 +596,44 @@ rcs_sym_getrev(RCSFILE *file, const char *sym)
/*
+ * rcs_lock_getmode()
+ *
+ * Retrieve the locking mode of the RCS file <file>.
+ */
+int
+rcs_lock_getmode(RCSFILE *file)
+{
+ return (file->rf_flags & RCS_SLOCK) ? RCS_LOCK_STRICT : RCS_LOCK_LOOSE;
+}
+
+
+/*
+ * rcs_lock_setmode()
+ *
+ * Set the locking mode of the RCS file <file> to <mode>, which must either
+ * be RCS_LOCK_LOOSE or RCS_LOCK_STRICT.
+ * Returns the previous mode on success, or -1 on failure.
+ */
+int
+rcs_lock_setmode(RCSFILE *file, int mode)
+{
+ int pmode;
+ pmode = rcs_lock_getmode(file);
+
+ if (mode == RCS_LOCK_STRICT)
+ file->rf_flags |= RCS_SLOCK;
+ else if (mode == RCS_LOCK_LOOSE)
+ file->rf_flags &= ~RCS_SLOCK;
+ else {
+ cvs_log(LP_ERRNO, "invalid lock mode %d", mode);
+ return (-1);
+ }
+
+ return (pmode);
+}
+
+
+/*
* rcs_desc_get()
*
* Retrieve the description for the RCS file <file>.
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index b2d2d37ea4d..08430b8fe66 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.11 2005/03/04 18:21:00 jfb Exp $ */
+/* $OpenBSD: rcs.h,v 1.12 2005/03/05 03:30:29 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -42,6 +42,12 @@
#define RCS_HEAD_INIT "1.1"
+
+/* lock types */
+#define RCS_LOCK_LOOSE 0
+#define RCS_LOCK_STRICT 1
+
+
/* RCS keyword expansion modes (kflags) */
#define RCS_KWEXP_NONE 0x00
#define RCS_KWEXP_NAME 0x01 /* include keyword name */
@@ -160,6 +166,8 @@ int rcs_access_check (RCSFILE *, const char *);
int rcs_sym_add (RCSFILE *, const char *, RCSNUM *);
int rcs_sym_remove (RCSFILE *, const char *);
RCSNUM* rcs_sym_getrev (RCSFILE *, const char *);
+int rcs_lock_getmode (RCSFILE *);
+int rcs_lock_setmode (RCSFILE *, int);
BUF* rcs_getrev (RCSFILE *, RCSNUM *);
BUF* rcs_gethead (RCSFILE *);
RCSNUM* rcs_getrevbydate (RCSFILE *, struct tm *);