diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-03-05 03:30:30 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-03-05 03:30:30 +0000 |
commit | 3d77c62b895d9645ed4227a96831d4911ac2d538 (patch) | |
tree | 4cc089da27097ffc21146ce0cf528aabc47a498c /usr.bin/cvs/rcs.c | |
parent | f2c8b3648ae5dc8e00d81644e0e628434f00252e (diff) |
functions to manage the locking mode of RCS file
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r-- | usr.bin/cvs/rcs.c | 40 |
1 files changed, 39 insertions, 1 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>. |