1 //
2 // aegis - project change supervisor
3 // Copyright (C) 2002-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/trace.h>
21 #include <common/wstring/list.h>
22 #include <libaegis/change.h>
23 #include <libaegis/sub.h>
24 #include <libaegis/sub/change/integr_direc.h>
25
26
27 //
28 // NAME
29 // sub_integration_directory - the integration_directory substitution
30 //
31 // SYNOPSIS
32 // string_ty *sub_integration_directory(wstring_list_ty *arg);
33 //
34 // DESCRIPTION
35 // The sub_integration_directory function implements the
36 // integration_directory substitution. The integration_directory
37 // substitution is used to insert the absolute path of the
38 // integration_directory.
39 //
40 // ARGUMENTS
41 // arg - list of arguments, including the function name as [0]
42 //
43 // RETURNS
44 // a pointer to a string in dynamic memory;
45 // or NULL on error, setting suberr appropriately.
46 //
47
48 wstring
sub_integration_directory(sub_context_ty * scp,const wstring_list & arg)49 sub_integration_directory(sub_context_ty *scp, const wstring_list &arg)
50 {
51 trace(("sub_integration_directory()\n{\n"));
52 wstring result;
53 if (arg.size() != 1)
54 {
55 scp->error_set(i18n("requires zero arguments"));
56 }
57 else
58 {
59 change::pointer cp = sub_context_change_get(scp);
60 if (!cp)
61 {
62 yuck:
63 scp->error_set(i18n("not valid in current context"));
64 }
65 else
66 {
67 cstate_ty *cstate_data = cp->cstate_get();
68 if (cstate_data->state != cstate_state_being_integrated)
69 goto yuck;
70 nstring s(change_integration_directory_get(cp, 0));
71 result = wstring(s);
72 }
73 }
74 trace(("return %p;\n", result.get_ref()));
75 trace(("}\n"));
76 return result;
77 }
78
79
80 // vim: set ts=8 sw=4 et :
81