1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2001, 2003-2008, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <common/ac/assert.h>
21
22 #include <common/trace.h>
23 #include <libaegis/change/branch.h>
24
25
26 void
change_branch_administrator_add(change::pointer cp,string_ty * usr_name)27 change_branch_administrator_add(change::pointer cp, string_ty *usr_name)
28 {
29 cstate_ty *cstate_data;
30 meta_type *type_p;
31 string_ty **spp;
32 cstate_branch_administrator_list_ty *lp;
33 size_t j;
34
35 trace(("change_branch_administrator_add(cp = %p, "
36 "usr_name = \"%s\")\n{\n", cp, usr_name->str_text));
37 cstate_data = cp->cstate_get();
38 assert(cstate_data->branch);
39 if (!cstate_data->branch->administrator)
40 cstate_data->branch->administrator =
41 (cstate_branch_administrator_list_ty *)
42 cstate_branch_administrator_list_type.alloc();
43 lp = cstate_data->branch->administrator;
44
45 //
46 // make sure we don't have her already
47 //
48 for (j = 0; j < lp->length; ++j)
49 {
50 if (str_equal(usr_name, lp->list[j]))
51 {
52 trace(("}\n"));
53 return;
54 }
55 }
56
57 //
58 // append her to the list
59 //
60 spp =
61 (string_ty **)
62 cstate_branch_administrator_list_type.list_parse
63 (
64 cstate_data->branch->administrator,
65 &type_p
66 );
67 assert(type_p == &string_type);
68 *spp = str_copy(usr_name);
69 trace(("}\n"));
70 }
71
72
73 // vim: set ts=8 sw=4 et :
74