1 /**************************************************************************//**
3 * Source module relating to EVEL_OPTION_ types.
8 * Copyright(c) <2016>, AT&T Intellectual Property. All other rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement: This product includes
20 * software developed by the AT&T.
21 * 4. Neither the name of AT&T nor the names of its contributors may be used to
22 * endorse or promote products derived from this software without specific
23 * prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY
26 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *****************************************************************************/
41 #include "evel_internal.h"
43 /**************************************************************************//**
44 * Free the underlying resources of an ::EVEL_OPTION_STRING.
46 * @param option Pointer to the ::EVEL_OPTION_STRING.
47 *****************************************************************************/
48 void evel_free_option_string(EVEL_OPTION_STRING * const option)
52 /***************************************************************************/
53 /* Check preconditions. */
54 /***************************************************************************/
55 assert(option != NULL);
61 option->is_set = EVEL_FALSE;
67 /**************************************************************************//**
68 * Initialize an ::EVEL_OPTION_STRING to a not-set state.
70 * @param option Pointer to the ::EVEL_OPTION_STRING.
71 *****************************************************************************/
72 void evel_init_option_string(EVEL_OPTION_STRING * const option)
76 /***************************************************************************/
77 /* Check preconditions. */
78 /***************************************************************************/
79 assert(option != NULL);
82 option->is_set = EVEL_FALSE;
87 /**************************************************************************//**
88 * Set the value of an ::EVEL_OPTION_STRING.
90 * @param option Pointer to the ::EVEL_OPTION_STRING.
91 * @param value The value to set.
92 * @param description Description to be used in logging.
93 *****************************************************************************/
94 void evel_set_option_string(EVEL_OPTION_STRING * const option,
95 const char * const value,
96 const char * const description)
100 /***************************************************************************/
101 /* Check preconditions. */
102 /***************************************************************************/
103 assert(option != NULL);
104 assert(value != NULL);
105 assert(description != NULL);
109 EVEL_ERROR("Ignoring attempt to update %s to %s. %s already set to %s",
110 description, value, description, option->value);
114 EVEL_DEBUG("Setting %s to %s", description, value);
115 option->value = strdup(value);
116 option->is_set = EVEL_TRUE;
122 /**************************************************************************//**
123 * Force the value of an ::EVEL_OPTION_STRING.
125 * @param option Pointer to the ::EVEL_OPTION_STRING.
126 * @param value The value to set.
127 *****************************************************************************/
128 void evel_force_option_string(EVEL_OPTION_STRING * const option,
129 const char * const value)
133 /***************************************************************************/
134 /* Check preconditions. */
135 /***************************************************************************/
136 assert(option != NULL);
137 assert(option->is_set == EVEL_FALSE);
138 assert(option->value == NULL);
140 option->value = strdup(value);
141 option->is_set = EVEL_TRUE;
146 /**************************************************************************//**
147 * Initialize an ::EVEL_OPTION_INT to a not-set state.
149 * @param option Pointer to the ::EVEL_OPTION_INT.
150 *****************************************************************************/
151 void evel_init_option_int(EVEL_OPTION_INT * const option)
155 /***************************************************************************/
156 /* Check preconditions. */
157 /***************************************************************************/
158 assert(option != NULL);
161 option->is_set = EVEL_FALSE;
166 /**************************************************************************//**
167 * Force the value of an ::EVEL_OPTION_INT.
169 * @param option Pointer to the ::EVEL_OPTION_INT.
170 * @param value The value to set.
171 *****************************************************************************/
172 void evel_force_option_int(EVEL_OPTION_INT * const option,
177 /***************************************************************************/
178 /* Check preconditions. */
179 /***************************************************************************/
180 assert(option != NULL);
182 option->value = value;
183 option->is_set = EVEL_TRUE;
188 /**************************************************************************//**
189 * Set the value of an ::EVEL_OPTION_INT.
191 * @param option Pointer to the ::EVEL_OPTION_INT.
192 * @param value The value to set.
193 * @param description Description to be used in logging.
194 *****************************************************************************/
195 void evel_set_option_int(EVEL_OPTION_INT * const option,
197 const char * const description)
201 /***************************************************************************/
202 /* Check preconditions. */
203 /***************************************************************************/
204 assert(option != NULL);
205 assert(description != NULL);
209 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
210 description, value, description, option->value);
214 EVEL_DEBUG("Setting %s to %d", description, value);
215 option->value = value;
216 option->is_set = EVEL_TRUE;
222 /**************************************************************************//**
223 * Initialize an ::EVEL_OPTION_DOUBLE to a not-set state.
225 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
226 *****************************************************************************/
227 void evel_init_option_double(EVEL_OPTION_DOUBLE * const option)
231 /***************************************************************************/
232 /* Check preconditions. */
233 /***************************************************************************/
234 assert(option != NULL);
237 option->is_set = EVEL_FALSE;
242 /**************************************************************************//**
243 * Force the value of an ::EVEL_OPTION_DOUBLE.
245 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
246 * @param value The value to set.
247 *****************************************************************************/
248 void evel_force_option_double(EVEL_OPTION_DOUBLE * const option,
253 /***************************************************************************/
254 /* Check preconditions. */
255 /***************************************************************************/
256 assert(option != NULL);
258 option->value = value;
259 option->is_set = EVEL_TRUE;
264 /**************************************************************************//**
265 * Set the value of an ::EVEL_OPTION_DOUBLE.
267 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
268 * @param value The value to set.
269 * @param description Description to be used in logging.
270 *****************************************************************************/
271 void evel_set_option_double(EVEL_OPTION_DOUBLE * const option,
273 const char * const description)
277 /***************************************************************************/
278 /* Check preconditions. */
279 /***************************************************************************/
280 assert(option != NULL);
281 assert(description != NULL);
285 EVEL_ERROR("Ignoring attempt to update %s to %lf. %s already set to %lf",
286 description, value, description, option->value);
290 EVEL_DEBUG("Setting %s to %lf", description, value);
291 option->value = value;
292 option->is_set = EVEL_TRUE;
298 /**************************************************************************//**
299 * Initialize an ::EVEL_OPTION_ULL to a not-set state.
301 * @param option Pointer to the ::EVEL_OPTION_ULL.
302 *****************************************************************************/
303 void evel_init_option_ull(EVEL_OPTION_ULL * const option)
307 /***************************************************************************/
308 /* Check preconditions. */
309 /***************************************************************************/
310 assert(option != NULL);
312 option->is_set = EVEL_FALSE;
316 /**************************************************************************//**
317 * Force the value of an ::EVEL_OPTION_ULL.
319 * @param option Pointer to the ::EVEL_OPTION_ULL.
320 * @param value The value to set.
321 *****************************************************************************/
322 void evel_force_option_ull(EVEL_OPTION_ULL * const option,
323 const unsigned long long value)
327 /***************************************************************************/
328 /* Check preconditions. */
329 /***************************************************************************/
330 assert(option != NULL);
332 option->value = value;
333 option->is_set = EVEL_TRUE;
338 /**************************************************************************//**
339 * Set the value of an ::EVEL_OPTION_ULL.
341 * @param option Pointer to the ::EVEL_OPTION_ULL.
342 * @param value The value to set.
343 * @param description Description to be used in logging.
344 *****************************************************************************/
345 void evel_set_option_ull(EVEL_OPTION_ULL * const option,
346 const unsigned long long value,
347 const char * const description)
351 /***************************************************************************/
352 /* Check preconditions. */
353 /***************************************************************************/
354 assert(option != NULL);
355 assert(description != NULL);
359 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
360 description, value, description, option->value);
364 EVEL_DEBUG("Setting %s to %llu", description, value);
365 option->value = value;
366 option->is_set = EVEL_TRUE;
371 /**************************************************************************//**
372 * Initialize an ::EVEL_OPTION_TIME to a not-set state.
374 * @param option Pointer to the ::EVEL_OPTION_TIME.
375 *****************************************************************************/
376 void evel_init_option_time(EVEL_OPTION_TIME * const option)
380 /***************************************************************************/
381 /* Check preconditions. */
382 /***************************************************************************/
383 assert(option != NULL);
385 option->is_set = EVEL_FALSE;
389 /**************************************************************************//**
390 * Force the value of an ::EVEL_OPTION_TIME.
392 * @param option Pointer to the ::EVEL_OPTION_TIME.
393 * @param value The value to set.
394 *****************************************************************************/
395 void evel_force_option_time(EVEL_OPTION_TIME * const option,
400 /***************************************************************************/
401 /* Check preconditions. */
402 /***************************************************************************/
403 assert(option != NULL);
405 option->value = value;
406 option->is_set = EVEL_TRUE;
411 /**************************************************************************//**
412 * Set the value of an ::EVEL_OPTION_TIME.
414 * @param option Pointer to the ::EVEL_OPTION_TIME.
415 * @param value The value to set.
416 * @param description Description to be used in logging.
417 *****************************************************************************/
418 void evel_set_option_time(EVEL_OPTION_TIME * const option,
420 const char * const description)
424 /***************************************************************************/
425 /* Check preconditions. */
426 /***************************************************************************/
427 assert(option != NULL);
428 assert(description != NULL);
432 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
433 description, value, description, option->value);
437 EVEL_DEBUG("Setting %s to %d", description, value);
438 option->value = value;
439 option->is_set = EVEL_TRUE;