1 /*
2 * pf-add.cc: Part of GNU CSSC.
3 *
4 * Copyright (C) 1997, 2001, 2005, 2007, 2008, 2009, 2010, 2011, 2014,
5 * 2019 Free Software Foundation, Inc.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * CSSC was originally Based on MySC, by Ross Ridge, which was
21 * placed in the Public Domain.
22 *
23 * Members of the class sccs_pfile for adding an edit lock to the file.
24 *
25 */
26
27 #include <config.h>
28
29 #include "cssc.h"
30 #include "pfile.h"
31 #include "except.h"
32 #include "file.h"
33
34
35 bool
add_lock(sid got,sid delta,sid_list & included,sid_list & excluded)36 sccs_pfile::add_lock(sid got, sid delta,
37 sid_list &included, sid_list &excluded) {
38 ASSERT(mode == APPEND);
39 struct edit_lock new_lock;
40 bool pfile_already_exists;
41
42
43 if (edit_locks.empty())
44 pfile_already_exists = false;
45 else
46 pfile_already_exists = true;
47
48 new_lock.got = got;
49 new_lock.delta = delta;
50 new_lock.user = get_user_name();
51 new_lock.date = sccs_date::now();
52 new_lock.include = included;
53 new_lock.exclude = excluded;
54
55 edit_locks.push_back(new_lock);
56
57 return update( pfile_already_exists );
58 }
59
60 /* Local variables: */
61 /* mode: c++ */
62 /* End: */
63