1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Unless otherwise specified, all software contained herein is
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
17 ****************************************************************************/
18 /**************************************************************************//**
20 * Source module relating to EVEL_OPTION_ types.
22 ****************************************************************************/
28 #include "evel_internal.h"
30 /**************************************************************************//**
31 * Free the underlying resources of an ::EVEL_OPTION_STRING.
33 * @param option Pointer to the ::EVEL_OPTION_STRING.
34 *****************************************************************************/
35 void evel_free_option_string(EVEL_OPTION_STRING * const option)
39 /***************************************************************************/
40 /* Check preconditions. */
41 /***************************************************************************/
42 assert(option != NULL);
48 option->is_set = EVEL_FALSE;
54 /**************************************************************************//**
55 * Initialize an ::EVEL_OPTION_STRING to a not-set state.
57 * @param option Pointer to the ::EVEL_OPTION_STRING.
58 *****************************************************************************/
59 void evel_init_option_string(EVEL_OPTION_STRING * const option)
63 /***************************************************************************/
64 /* Check preconditions. */
65 /***************************************************************************/
66 assert(option != NULL);
69 option->is_set = EVEL_FALSE;
74 /**************************************************************************//**
75 * Set the value of an ::EVEL_OPTION_STRING.
77 * @param option Pointer to the ::EVEL_OPTION_STRING.
78 * @param value The value to set.
79 * @param description Description to be used in logging.
80 *****************************************************************************/
81 void evel_set_option_string(EVEL_OPTION_STRING * const option,
82 const char * const value,
83 const char * const description)
87 /***************************************************************************/
88 /* Check preconditions. */
89 /***************************************************************************/
90 assert(option != NULL);
91 assert(value != NULL);
92 assert(description != NULL);
96 EVEL_ERROR("Ignoring attempt to update %s to %s. %s already set to %s",
97 description, value, description, option->value);
101 EVEL_DEBUG("Setting %s to %s", description, value);
102 option->value = strdup(value);
103 option->is_set = EVEL_TRUE;
109 /**************************************************************************//**
110 * Force the value of an ::EVEL_OPTION_STRING.
112 * @param option Pointer to the ::EVEL_OPTION_STRING.
113 * @param value The value to set.
114 *****************************************************************************/
115 void evel_force_option_string(EVEL_OPTION_STRING * const option,
116 const char * const value)
120 /***************************************************************************/
121 /* Check preconditions. */
122 /***************************************************************************/
123 assert(option != NULL);
124 assert(option->is_set == EVEL_FALSE);
125 assert(option->value == NULL);
127 option->value = strdup(value);
128 option->is_set = EVEL_TRUE;
133 /**************************************************************************//**
134 * Initialize an ::EVEL_OPTION_INT to a not-set state.
136 * @param option Pointer to the ::EVEL_OPTION_INT.
137 *****************************************************************************/
138 void evel_init_option_int(EVEL_OPTION_INT * const option)
142 /***************************************************************************/
143 /* Check preconditions. */
144 /***************************************************************************/
145 assert(option != NULL);
148 option->is_set = EVEL_FALSE;
153 /**************************************************************************//**
154 * Force the value of an ::EVEL_OPTION_INT.
156 * @param option Pointer to the ::EVEL_OPTION_INT.
157 * @param value The value to set.
158 *****************************************************************************/
159 void evel_force_option_int(EVEL_OPTION_INT * const option,
164 /***************************************************************************/
165 /* Check preconditions. */
166 /***************************************************************************/
167 assert(option != NULL);
169 option->value = value;
170 option->is_set = EVEL_TRUE;
175 /**************************************************************************//**
176 * Set the value of an ::EVEL_OPTION_INT.
178 * @param option Pointer to the ::EVEL_OPTION_INT.
179 * @param value The value to set.
180 * @param description Description to be used in logging.
181 *****************************************************************************/
182 void evel_set_option_int(EVEL_OPTION_INT * const option,
184 const char * const description)
188 /***************************************************************************/
189 /* Check preconditions. */
190 /***************************************************************************/
191 assert(option != NULL);
192 assert(description != NULL);
196 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
197 description, value, description, option->value);
201 EVEL_DEBUG("Setting %s to %d", description, value);
202 option->value = value;
203 option->is_set = EVEL_TRUE;
209 /**************************************************************************//**
210 * Initialize an ::EVEL_OPTION_DOUBLE to a not-set state.
212 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
213 *****************************************************************************/
214 void evel_init_option_double(EVEL_OPTION_DOUBLE * const option)
218 /***************************************************************************/
219 /* Check preconditions. */
220 /***************************************************************************/
221 assert(option != NULL);
224 option->is_set = EVEL_FALSE;
229 /**************************************************************************//**
230 * Force the value of an ::EVEL_OPTION_DOUBLE.
232 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
233 * @param value The value to set.
234 *****************************************************************************/
235 void evel_force_option_double(EVEL_OPTION_DOUBLE * const option,
240 /***************************************************************************/
241 /* Check preconditions. */
242 /***************************************************************************/
243 assert(option != NULL);
245 option->value = value;
246 option->is_set = EVEL_TRUE;
251 /**************************************************************************//**
252 * Set the value of an ::EVEL_OPTION_DOUBLE.
254 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
255 * @param value The value to set.
256 * @param description Description to be used in logging.
257 *****************************************************************************/
258 void evel_set_option_double(EVEL_OPTION_DOUBLE * const option,
260 const char * const description)
264 /***************************************************************************/
265 /* Check preconditions. */
266 /***************************************************************************/
267 assert(option != NULL);
268 assert(description != NULL);
272 EVEL_ERROR("Ignoring attempt to update %s to %lf. %s already set to %lf",
273 description, value, description, option->value);
277 EVEL_DEBUG("Setting %s to %lf", description, value);
278 option->value = value;
279 option->is_set = EVEL_TRUE;
285 /**************************************************************************//**
286 * Initialize an ::EVEL_OPTION_ULL to a not-set state.
288 * @param option Pointer to the ::EVEL_OPTION_ULL.
289 *****************************************************************************/
290 void evel_init_option_ull(EVEL_OPTION_ULL * const option)
294 /***************************************************************************/
295 /* Check preconditions. */
296 /***************************************************************************/
297 assert(option != NULL);
299 option->is_set = EVEL_FALSE;
303 /**************************************************************************//**
304 * Force the value of an ::EVEL_OPTION_ULL.
306 * @param option Pointer to the ::EVEL_OPTION_ULL.
307 * @param value The value to set.
308 *****************************************************************************/
309 void evel_force_option_ull(EVEL_OPTION_ULL * const option,
310 const unsigned long long value)
314 /***************************************************************************/
315 /* Check preconditions. */
316 /***************************************************************************/
317 assert(option != NULL);
319 option->value = value;
320 option->is_set = EVEL_TRUE;
325 /**************************************************************************//**
326 * Set the value of an ::EVEL_OPTION_ULL.
328 * @param option Pointer to the ::EVEL_OPTION_ULL.
329 * @param value The value to set.
330 * @param description Description to be used in logging.
331 *****************************************************************************/
332 void evel_set_option_ull(EVEL_OPTION_ULL * const option,
333 const unsigned long long value,
334 const char * const description)
338 /***************************************************************************/
339 /* Check preconditions. */
340 /***************************************************************************/
341 assert(option != NULL);
342 assert(description != NULL);
346 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
347 description, value, description, option->value);
351 EVEL_DEBUG("Setting %s to %llu", description, value);
352 option->value = value;
353 option->is_set = EVEL_TRUE;
359 /**************************************************************************//**
360 * Initialize an ::EVEL_OPTION_INTHEADER_FIELDS to a not-set state.
362 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
363 *****************************************************************************/
364 void evel_init_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option)
368 /***************************************************************************/
369 /* Check preconditions. */
370 /***************************************************************************/
371 assert(option != NULL);
372 option->object = NULL;
373 option->is_set = EVEL_FALSE;
377 /**************************************************************************//**
378 * Force the value of an ::EVEL_OPTION_INTHEADER_FIELDS.
380 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
381 * @param value The value to set.
382 *****************************************************************************/
383 void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option,
388 /***************************************************************************/
389 /* Check preconditions. */
390 /***************************************************************************/
391 assert(option != NULL);
393 option->object = value;
394 option->is_set = EVEL_TRUE;
399 /**************************************************************************//**
400 * Set the value of an ::EVEL_OPTION_INTHEADER_FIELDS.
402 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
403 * @param value The value to set.
404 * @param description Description to be used in logging.
405 *****************************************************************************/
406 void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option,
408 const char * const description)
412 /***************************************************************************/
413 /* Check preconditions. */
414 /***************************************************************************/
415 assert(option != NULL);
416 assert(description != NULL);
420 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
421 description, value, description, option->object);
425 EVEL_DEBUG("Setting %s to %llu", description, value);
426 option->object = value;
427 option->is_set = EVEL_TRUE;
432 /**************************************************************************//**
433 * Free the underlying resources of an ::EVEL_OPTION_INTHEADER_FIELDS.
435 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
436 *****************************************************************************/
437 void evel_free_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option)
441 /***************************************************************************/
442 /* Check preconditions. */
443 /***************************************************************************/
444 assert(option != NULL);
448 free(option->object);
449 option->object = NULL;
450 option->is_set = EVEL_FALSE;
456 /**************************************************************************//**
457 * Initialize an ::EVEL_OPTION_TIME to a not-set state.
459 * @param option Pointer to the ::EVEL_OPTION_TIME.
460 *****************************************************************************/
461 void evel_init_option_time(EVEL_OPTION_TIME * const option)
465 /***************************************************************************/
466 /* Check preconditions. */
467 /***************************************************************************/
468 assert(option != NULL);
470 option->is_set = EVEL_FALSE;
474 /**************************************************************************//**
475 * Force the value of an ::EVEL_OPTION_TIME.
477 * @param option Pointer to the ::EVEL_OPTION_TIME.
478 * @param value The value to set.
479 *****************************************************************************/
480 void evel_force_option_time(EVEL_OPTION_TIME * const option,
485 /***************************************************************************/
486 /* Check preconditions. */
487 /***************************************************************************/
488 assert(option != NULL);
490 option->value = value;
491 option->is_set = EVEL_TRUE;
496 /**************************************************************************//**
497 * Set the value of an ::EVEL_OPTION_TIME.
499 * @param option Pointer to the ::EVEL_OPTION_TIME.
500 * @param value The value to set.
501 * @param description Description to be used in logging.
502 *****************************************************************************/
503 void evel_set_option_time(EVEL_OPTION_TIME * const option,
505 const char * const description)
509 /***************************************************************************/
510 /* Check preconditions. */
511 /***************************************************************************/
512 assert(option != NULL);
513 assert(description != NULL);
517 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
518 description, value, description, option->value);
522 EVEL_DEBUG("Setting %s to %d", description, value);
523 option->value = value;
524 option->is_set = EVEL_TRUE;