1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 ****************************************************************************/
17 /**************************************************************************//**
19 * Source module relating to EVEL_OPTION_ types.
21 ****************************************************************************/
27 #include "evel_internal.h"
29 /**************************************************************************//**
30 * Free the underlying resources of an ::EVEL_OPTION_STRING.
32 * @param option Pointer to the ::EVEL_OPTION_STRING.
33 *****************************************************************************/
34 void evel_free_option_string(EVEL_OPTION_STRING * const option)
38 /***************************************************************************/
39 /* Check preconditions. */
40 /***************************************************************************/
41 assert(option != NULL);
47 option->is_set = EVEL_FALSE;
53 /**************************************************************************//**
54 * Initialize an ::EVEL_OPTION_STRING to a not-set state.
56 * @param option Pointer to the ::EVEL_OPTION_STRING.
57 *****************************************************************************/
58 void evel_init_option_string(EVEL_OPTION_STRING * const option)
62 /***************************************************************************/
63 /* Check preconditions. */
64 /***************************************************************************/
65 assert(option != NULL);
68 option->is_set = EVEL_FALSE;
73 /**************************************************************************//**
74 * Set the value of an ::EVEL_OPTION_STRING.
76 * @param option Pointer to the ::EVEL_OPTION_STRING.
77 * @param value The value to set.
78 * @param description Description to be used in logging.
79 *****************************************************************************/
80 void evel_set_option_string(EVEL_OPTION_STRING * const option,
81 const char * const value,
82 const char * const description)
86 /***************************************************************************/
87 /* Check preconditions. */
88 /***************************************************************************/
89 assert(option != NULL);
90 assert(value != NULL);
91 assert(description != NULL);
95 EVEL_ERROR("Ignoring attempt to update %s to %s. %s already set to %s",
96 description, value, description, option->value);
100 EVEL_DEBUG("Setting %s to %s", description, value);
101 option->value = strdup(value);
102 option->is_set = EVEL_TRUE;
108 /**************************************************************************//**
109 * Force the value of an ::EVEL_OPTION_STRING.
111 * @param option Pointer to the ::EVEL_OPTION_STRING.
112 * @param value The value to set.
113 *****************************************************************************/
114 void evel_force_option_string(EVEL_OPTION_STRING * const option,
115 const char * const value)
119 /***************************************************************************/
120 /* Check preconditions. */
121 /***************************************************************************/
122 assert(option != NULL);
123 assert(option->is_set == EVEL_FALSE);
124 assert(option->value == NULL);
126 option->value = strdup(value);
127 option->is_set = EVEL_TRUE;
132 /**************************************************************************//**
133 * Initialize an ::EVEL_OPTION_INT to a not-set state.
135 * @param option Pointer to the ::EVEL_OPTION_INT.
136 *****************************************************************************/
137 void evel_init_option_int(EVEL_OPTION_INT * const option)
141 /***************************************************************************/
142 /* Check preconditions. */
143 /***************************************************************************/
144 assert(option != NULL);
147 option->is_set = EVEL_FALSE;
152 /**************************************************************************//**
153 * Force the value of an ::EVEL_OPTION_INT.
155 * @param option Pointer to the ::EVEL_OPTION_INT.
156 * @param value The value to set.
157 *****************************************************************************/
158 void evel_force_option_int(EVEL_OPTION_INT * const option,
163 /***************************************************************************/
164 /* Check preconditions. */
165 /***************************************************************************/
166 assert(option != NULL);
168 option->value = value;
169 option->is_set = EVEL_TRUE;
174 /**************************************************************************//**
175 * Set the value of an ::EVEL_OPTION_INT.
177 * @param option Pointer to the ::EVEL_OPTION_INT.
178 * @param value The value to set.
179 * @param description Description to be used in logging.
180 *****************************************************************************/
181 void evel_set_option_int(EVEL_OPTION_INT * const option,
183 const char * const description)
187 /***************************************************************************/
188 /* Check preconditions. */
189 /***************************************************************************/
190 assert(option != NULL);
191 assert(description != NULL);
195 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
196 description, value, description, option->value);
200 EVEL_DEBUG("Setting %s to %d", description, value);
201 option->value = value;
202 option->is_set = EVEL_TRUE;
208 /**************************************************************************//**
209 * Initialize an ::EVEL_OPTION_DOUBLE to a not-set state.
211 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
212 *****************************************************************************/
213 void evel_init_option_double(EVEL_OPTION_DOUBLE * const option)
217 /***************************************************************************/
218 /* Check preconditions. */
219 /***************************************************************************/
220 assert(option != NULL);
223 option->is_set = EVEL_FALSE;
228 /**************************************************************************//**
229 * Force the value of an ::EVEL_OPTION_DOUBLE.
231 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
232 * @param value The value to set.
233 *****************************************************************************/
234 void evel_force_option_double(EVEL_OPTION_DOUBLE * const option,
239 /***************************************************************************/
240 /* Check preconditions. */
241 /***************************************************************************/
242 assert(option != NULL);
244 option->value = value;
245 option->is_set = EVEL_TRUE;
250 /**************************************************************************//**
251 * Set the value of an ::EVEL_OPTION_DOUBLE.
253 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
254 * @param value The value to set.
255 * @param description Description to be used in logging.
256 *****************************************************************************/
257 void evel_set_option_double(EVEL_OPTION_DOUBLE * const option,
259 const char * const description)
263 /***************************************************************************/
264 /* Check preconditions. */
265 /***************************************************************************/
266 assert(option != NULL);
267 assert(description != NULL);
271 EVEL_ERROR("Ignoring attempt to update %s to %lf. %s already set to %lf",
272 description, value, description, option->value);
276 EVEL_DEBUG("Setting %s to %lf", description, value);
277 option->value = value;
278 option->is_set = EVEL_TRUE;
284 /**************************************************************************//**
285 * Initialize an ::EVEL_OPTION_ULL to a not-set state.
287 * @param option Pointer to the ::EVEL_OPTION_ULL.
288 *****************************************************************************/
289 void evel_init_option_ull(EVEL_OPTION_ULL * const option)
293 /***************************************************************************/
294 /* Check preconditions. */
295 /***************************************************************************/
296 assert(option != NULL);
298 option->is_set = EVEL_FALSE;
302 /**************************************************************************//**
303 * Force the value of an ::EVEL_OPTION_ULL.
305 * @param option Pointer to the ::EVEL_OPTION_ULL.
306 * @param value The value to set.
307 *****************************************************************************/
308 void evel_force_option_ull(EVEL_OPTION_ULL * const option,
309 const unsigned long long value)
313 /***************************************************************************/
314 /* Check preconditions. */
315 /***************************************************************************/
316 assert(option != NULL);
318 option->value = value;
319 option->is_set = EVEL_TRUE;
324 /**************************************************************************//**
325 * Set the value of an ::EVEL_OPTION_ULL.
327 * @param option Pointer to the ::EVEL_OPTION_ULL.
328 * @param value The value to set.
329 * @param description Description to be used in logging.
330 *****************************************************************************/
331 void evel_set_option_ull(EVEL_OPTION_ULL * const option,
332 const unsigned long long value,
333 const char * const description)
337 /***************************************************************************/
338 /* Check preconditions. */
339 /***************************************************************************/
340 assert(option != NULL);
341 assert(description != NULL);
345 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
346 description, value, description, option->value);
350 EVEL_DEBUG("Setting %s to %llu", description, value);
351 option->value = value;
352 option->is_set = EVEL_TRUE;
358 /**************************************************************************//**
359 * Initialize an ::EVEL_OPTION_INTHEADER_FIELDS to a not-set state.
361 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
362 *****************************************************************************/
363 void evel_init_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option)
367 /***************************************************************************/
368 /* Check preconditions. */
369 /***************************************************************************/
370 assert(option != NULL);
371 option->object = NULL;
372 option->is_set = EVEL_FALSE;
376 /**************************************************************************//**
377 * Force the value of an ::EVEL_OPTION_INTHEADER_FIELDS.
379 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
380 * @param value The value to set.
381 *****************************************************************************/
382 void evel_force_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option,
387 /***************************************************************************/
388 /* Check preconditions. */
389 /***************************************************************************/
390 assert(option != NULL);
392 option->object = value;
393 option->is_set = EVEL_TRUE;
398 /**************************************************************************//**
399 * Set the value of an ::EVEL_OPTION_INTHEADER_FIELDS.
401 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
402 * @param value The value to set.
403 * @param description Description to be used in logging.
404 *****************************************************************************/
405 void evel_set_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option,
407 const char * const description)
411 /***************************************************************************/
412 /* Check preconditions. */
413 /***************************************************************************/
414 assert(option != NULL);
415 assert(description != NULL);
419 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
420 description, value, description, option->object);
424 EVEL_DEBUG("Setting %s to %llu", description, value);
425 option->object = value;
426 option->is_set = EVEL_TRUE;
431 /**************************************************************************//**
432 * Free the underlying resources of an ::EVEL_OPTION_INTHEADER_FIELDS.
434 * @param option Pointer to the ::EVEL_OPTION_INTHEADER_FIELDS.
435 *****************************************************************************/
436 void evel_free_option_intheader(EVEL_OPTION_INTHEADER_FIELDS * const option)
440 /***************************************************************************/
441 /* Check preconditions. */
442 /***************************************************************************/
443 assert(option != NULL);
447 free(option->object);
448 option->object = NULL;
449 option->is_set = EVEL_FALSE;
455 /**************************************************************************//**
456 * Initialize an ::EVEL_OPTION_TIME to a not-set state.
458 * @param option Pointer to the ::EVEL_OPTION_TIME.
459 *****************************************************************************/
460 void evel_init_option_time(EVEL_OPTION_TIME * const option)
464 /***************************************************************************/
465 /* Check preconditions. */
466 /***************************************************************************/
467 assert(option != NULL);
469 option->is_set = EVEL_FALSE;
473 /**************************************************************************//**
474 * Force the value of an ::EVEL_OPTION_TIME.
476 * @param option Pointer to the ::EVEL_OPTION_TIME.
477 * @param value The value to set.
478 *****************************************************************************/
479 void evel_force_option_time(EVEL_OPTION_TIME * const option,
484 /***************************************************************************/
485 /* Check preconditions. */
486 /***************************************************************************/
487 assert(option != NULL);
489 option->value = value;
490 option->is_set = EVEL_TRUE;
495 /**************************************************************************//**
496 * Set the value of an ::EVEL_OPTION_TIME.
498 * @param option Pointer to the ::EVEL_OPTION_TIME.
499 * @param value The value to set.
500 * @param description Description to be used in logging.
501 *****************************************************************************/
502 void evel_set_option_time(EVEL_OPTION_TIME * const option,
504 const char * const description)
508 /***************************************************************************/
509 /* Check preconditions. */
510 /***************************************************************************/
511 assert(option != NULL);
512 assert(description != NULL);
516 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
517 description, value, description, option->value);
521 EVEL_DEBUG("Setting %s to %d", description, value);
522 option->value = value;
523 option->is_set = EVEL_TRUE;