1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 2004-2008, 2012 Peter Miller
4 //      Copyright (C) 2006, 2008 Walter Franzini
5 //
6 //      This program is free software; you can redistribute it and/or modify
7 //      it under the terms of the GNU General Public License as published by
8 //      the Free Software Foundation; either version 3 of the License, or
9 //      (at your option) any later version.
10 //
11 //      This program is distributed in the hope that it will be useful,
12 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //      GNU General Public License for more details.
15 //
16 //      You should have received a copy of the GNU General Public License
17 //      along with this program. If not, see
18 //      <http://www.gnu.org/licenses/>.
19 //
20 
21 #ifndef LIBAEGIS_ATTRIBUTE_H
22 #define LIBAEGIS_ATTRIBUTE_H
23 
24 #include <libaegis/common.fmtgen.h>
25 
26 #define AEIPASS_ASSIGN_FILE_UUID        "aeipass-option:assign-file-uuid"
27 
28 #define HISTORY_GET_COMMAND             "aegis:history_get_command"
29 
30 /**
31   * The attributes_list_find function is used to find a specific
32   * attribute in an attribute list.
33   *
34   * \param alp
35   *     The attribute list to be searched.
36   * \param name
37   *     The name of the attribute to search for; not case sensitive.
38   */
39 attributes_ty *attributes_list_find(attributes_list_ty *alp, const char *name);
40 
41 /**
42   * The attributes_list_find_boolean function is used to find a specific
43   * attribute in an attribute list.
44   *
45   * \param alp
46   *     The attribute list to be searched.
47   * \param name
48   *     The name of the attribute to search for; not case sensitive.
49   * \param default_value
50   *     The value to use of the attribute is not present.
51   * \returns
52   *     bool; the value of the attribute as a boolean (it understands
53   *     "yes", "no", "true" and "false"), or the default value if not
54   *     present or indecipherable.
55   */
56 bool attributes_list_find_boolean(attributes_list_ty *alp, const char *name,
57     bool default_value = false);
58 
59 /**
60   * The attributes_list_find_read function is used to find a specific
61   * attribute in an attribute list.
62   *
63   * \param alp
64   *     The attribute list to be searched.
65   * \param name
66   *     The name of the attribute to search for; not case sensitive.
67   * \param default_value
68   *     The value to use of the attribute is not present.
69   * \returns
70   *     double; the value of the attribute as a floating point(real)
71   *     number, or the default value if not present or indecipherable.
72   */
73 double attributes_list_find_real(attributes_list_ty *alp, const char *name,
74     double default_value = 0);
75 
76 /**
77   * The attributes_list_find_integer function is used to find a specific
78   * attribute in an attribute list.
79   *
80   * \param alp
81   *     The attribute list to be searched.
82   * \param name
83   *     The name of the attribute to search for; not case sensitive.
84   * \param default_value
85   *     The value to use of the attribute is not present.
86   * \returns
87   *     long; the value of the attribute as an integer number, or the
88   *     default value if not present or indecipherable.
89   */
90 long attributes_list_find_integer(attributes_list_ty *alp, const char *name,
91     long default_value = 0);
92 
93 /**
94   * The attributes_list_extract function is used to find a specific
95   * attribute in an attribute list, and remove it.
96   *
97   * \param alp
98   *     The attribute list to be searched.
99   * \param name
100   *     The name of the attribute to search for; not case sensitive.
101   * \returns
102   *     NULL if the attribute is not present, otherwise it returns a
103   *     pointer to the attribute removed from the list.
104   */
105 attributes_ty *attributes_list_extract(attributes_list_ty *alp,
106     const char *name);
107 
108 /**
109   * The attributes_list_remove function is used to find a specific
110   * attribute in an attribute list, and remove it.
111   *
112   * \param alp
113   *     The attribute list to be searched.
114   * \param name
115   *     The name of the attribute to search for; not case sensitive.
116   */
117 void attributes_list_remove(attributes_list_ty *alp, const char *name);
118 
119 /**
120   * The attributes_list_insert function is used to find a specific
121   * attribute in an attribute list, and replace its value with the one
122   * given.  If there is not attribute with the given name, this name and
123   * value will be appended.
124   *
125   * \param alp
126   *     The attribute list to be searched.
127   * \param name
128   *     The name of the attribute to modify; not case sensitive.
129   * \param value
130   *     The value of the attribute to be set.
131   */
132 void attributes_list_insert(attributes_list_ty *alp, const char *name,
133     const char *value);
134 
135 /**
136   * The attributes_list_append function is used to add a specific
137   * attribute name and value pair to the end of an attribute list.  It
138   * is possible to get duplicate attributes with the same name by using
139   * this function; use attributes_list_insert function if you don't want
140   * duplicates.
141   *
142   * \param alp
143   *     The attribute list to be searched.
144   * \param name
145   *     The name of the attribute to append; not case sensitive.
146   * \param value
147   *     The value of the attribute to be set.
148   */
149 void attributes_list_append(attributes_list_ty *alp, const char *name,
150     const char *value);
151 
152 /**
153   * The attributes_list_append_unique function is used to add a specific
154   * attribute name and value pair to the end of an attribute list
155   * <b>if</b> that name and value pair is not already present.  It is
156   * possible to get duplicate attributes with the same name by using
157   * this function; use the attributes_list_insert function if you don't
158   * want duplicates.
159   *
160   * \param alp
161   *     The attribute list to be searched.
162   * \param name
163   *     The name of the attribute to append; not case sensitive.
164   * \param value
165   *     The value of the attribute to be set.
166   */
167 void attributes_list_append_unique(attributes_list_ty *alp, const char *name,
168     string_ty *value);
169 
170 /**
171   * The attributes_list_append_unique function is used to add a specific
172   * attribute name and value pair to the end of an attribute list
173   * <b>if</b> that name and value pair is not already present.  It is
174   * possible to get duplicate attributes with the same name by using
175   * this function; use the attributes_list_insert function if you don't
176   * want duplicates.
177   *
178   * \param alp
179   *     The attribute list to be searched.
180   * \param name
181   *     The name of the attribute to append; not case sensitive.
182   * \param value
183   *     The value of the attribute to be set.
184   */
185 void attributes_list_append_unique(attributes_list_ty *alp, const char *name,
186     const char *value);
187 
188 #endif // LIBAEGIS_ATTRIBUTE_H
189 // vim: set ts=8 sw=4 et :
190