1 /**************************************************************************//**
3 * Source module relating to EVEL_OPTION_ types.
8 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *****************************************************************************/
26 #include "evel_internal.h"
28 /**************************************************************************//**
29 * Free the underlying resources of an ::EVEL_OPTION_STRING.
31 * @param option Pointer to the ::EVEL_OPTION_STRING.
32 *****************************************************************************/
33 void evel_free_option_string(EVEL_OPTION_STRING * const option)
37 /***************************************************************************/
38 /* Check preconditions. */
39 /***************************************************************************/
40 assert(option != NULL);
46 option->is_set = EVEL_FALSE;
52 /**************************************************************************//**
53 * Initialize an ::EVEL_OPTION_STRING to a not-set state.
55 * @param option Pointer to the ::EVEL_OPTION_STRING.
56 *****************************************************************************/
57 void evel_init_option_string(EVEL_OPTION_STRING * const option)
61 /***************************************************************************/
62 /* Check preconditions. */
63 /***************************************************************************/
64 assert(option != NULL);
67 option->is_set = EVEL_FALSE;
72 /**************************************************************************//**
73 * Set the value of an ::EVEL_OPTION_STRING.
75 * @param option Pointer to the ::EVEL_OPTION_STRING.
76 * @param value The value to set.
77 * @param description Description to be used in logging.
78 *****************************************************************************/
79 void evel_set_option_string(EVEL_OPTION_STRING * const option,
80 const char * const value,
81 const char * const description)
85 /***************************************************************************/
86 /* Check preconditions. */
87 /***************************************************************************/
88 assert(option != NULL);
89 assert(value != NULL);
90 assert(description != NULL);
94 EVEL_ERROR("Ignoring attempt to update %s to %s. %s already set to %s",
95 description, value, description, option->value);
99 EVEL_DEBUG("Setting %s to %s", description, value);
100 option->value = strdup(value);
101 option->is_set = EVEL_TRUE;
107 /**************************************************************************//**
108 * Force the value of an ::EVEL_OPTION_STRING.
110 * @param option Pointer to the ::EVEL_OPTION_STRING.
111 * @param value The value to set.
112 *****************************************************************************/
113 void evel_force_option_string(EVEL_OPTION_STRING * const option,
114 const char * const value)
118 /***************************************************************************/
119 /* Check preconditions. */
120 /***************************************************************************/
121 assert(option != NULL);
122 assert(option->is_set == EVEL_FALSE);
123 assert(option->value == NULL);
125 option->value = strdup(value);
126 option->is_set = EVEL_TRUE;
131 /**************************************************************************//**
132 * Initialize an ::EVEL_OPTION_INT to a not-set state.
134 * @param option Pointer to the ::EVEL_OPTION_INT.
135 *****************************************************************************/
136 void evel_init_option_int(EVEL_OPTION_INT * const option)
140 /***************************************************************************/
141 /* Check preconditions. */
142 /***************************************************************************/
143 assert(option != NULL);
146 option->is_set = EVEL_FALSE;
151 /**************************************************************************//**
152 * Force the value of an ::EVEL_OPTION_INT.
154 * @param option Pointer to the ::EVEL_OPTION_INT.
155 * @param value The value to set.
156 *****************************************************************************/
157 void evel_force_option_int(EVEL_OPTION_INT * const option,
162 /***************************************************************************/
163 /* Check preconditions. */
164 /***************************************************************************/
165 assert(option != NULL);
167 option->value = value;
168 option->is_set = EVEL_TRUE;
173 /**************************************************************************//**
174 * Set the value of an ::EVEL_OPTION_INT.
176 * @param option Pointer to the ::EVEL_OPTION_INT.
177 * @param value The value to set.
178 * @param description Description to be used in logging.
179 *****************************************************************************/
180 void evel_set_option_int(EVEL_OPTION_INT * const option,
182 const char * const description)
186 /***************************************************************************/
187 /* Check preconditions. */
188 /***************************************************************************/
189 assert(option != NULL);
190 assert(description != NULL);
194 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
195 description, value, description, option->value);
199 EVEL_DEBUG("Setting %s to %d", description, value);
200 option->value = value;
201 option->is_set = EVEL_TRUE;
207 /**************************************************************************//**
208 * Initialize an ::EVEL_OPTION_DOUBLE to a not-set state.
210 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
211 *****************************************************************************/
212 void evel_init_option_double(EVEL_OPTION_DOUBLE * const option)
216 /***************************************************************************/
217 /* Check preconditions. */
218 /***************************************************************************/
219 assert(option != NULL);
222 option->is_set = EVEL_FALSE;
227 /**************************************************************************//**
228 * Force the value of an ::EVEL_OPTION_DOUBLE.
230 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
231 * @param value The value to set.
232 *****************************************************************************/
233 void evel_force_option_double(EVEL_OPTION_DOUBLE * const option,
238 /***************************************************************************/
239 /* Check preconditions. */
240 /***************************************************************************/
241 assert(option != NULL);
243 option->value = value;
244 option->is_set = EVEL_TRUE;
249 /**************************************************************************//**
250 * Set the value of an ::EVEL_OPTION_DOUBLE.
252 * @param option Pointer to the ::EVEL_OPTION_DOUBLE.
253 * @param value The value to set.
254 * @param description Description to be used in logging.
255 *****************************************************************************/
256 void evel_set_option_double(EVEL_OPTION_DOUBLE * const option,
258 const char * const description)
262 /***************************************************************************/
263 /* Check preconditions. */
264 /***************************************************************************/
265 assert(option != NULL);
266 assert(description != NULL);
270 EVEL_ERROR("Ignoring attempt to update %s to %lf. %s already set to %lf",
271 description, value, description, option->value);
275 EVEL_DEBUG("Setting %s to %lf", description, value);
276 option->value = value;
277 option->is_set = EVEL_TRUE;
283 /**************************************************************************//**
284 * Initialize an ::EVEL_OPTION_ULL to a not-set state.
286 * @param option Pointer to the ::EVEL_OPTION_ULL.
287 *****************************************************************************/
288 void evel_init_option_ull(EVEL_OPTION_ULL * const option)
292 /***************************************************************************/
293 /* Check preconditions. */
294 /***************************************************************************/
295 assert(option != NULL);
297 option->is_set = EVEL_FALSE;
301 /**************************************************************************//**
302 * Force the value of an ::EVEL_OPTION_ULL.
304 * @param option Pointer to the ::EVEL_OPTION_ULL.
305 * @param value The value to set.
306 *****************************************************************************/
307 void evel_force_option_ull(EVEL_OPTION_ULL * const option,
308 const unsigned long long value)
312 /***************************************************************************/
313 /* Check preconditions. */
314 /***************************************************************************/
315 assert(option != NULL);
317 option->value = value;
318 option->is_set = EVEL_TRUE;
323 /**************************************************************************//**
324 * Set the value of an ::EVEL_OPTION_ULL.
326 * @param option Pointer to the ::EVEL_OPTION_ULL.
327 * @param value The value to set.
328 * @param description Description to be used in logging.
329 *****************************************************************************/
330 void evel_set_option_ull(EVEL_OPTION_ULL * const option,
331 const unsigned long long value,
332 const char * const description)
336 /***************************************************************************/
337 /* Check preconditions. */
338 /***************************************************************************/
339 assert(option != NULL);
340 assert(description != NULL);
344 EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
345 description, value, description, option->value);
349 EVEL_DEBUG("Setting %s to %llu", description, value);
350 option->value = value;
351 option->is_set = EVEL_TRUE;
356 /**************************************************************************//**
357 * Initialize an ::EVEL_OPTION_TIME to a not-set state.
359 * @param option Pointer to the ::EVEL_OPTION_TIME.
360 *****************************************************************************/
361 void evel_init_option_time(EVEL_OPTION_TIME * const option)
365 /***************************************************************************/
366 /* Check preconditions. */
367 /***************************************************************************/
368 assert(option != NULL);
370 option->is_set = EVEL_FALSE;
374 /**************************************************************************//**
375 * Force the value of an ::EVEL_OPTION_TIME.
377 * @param option Pointer to the ::EVEL_OPTION_TIME.
378 * @param value The value to set.
379 *****************************************************************************/
380 void evel_force_option_time(EVEL_OPTION_TIME * const option,
385 /***************************************************************************/
386 /* Check preconditions. */
387 /***************************************************************************/
388 assert(option != NULL);
390 option->value = value;
391 option->is_set = EVEL_TRUE;
396 /**************************************************************************//**
397 * Set the value of an ::EVEL_OPTION_TIME.
399 * @param option Pointer to the ::EVEL_OPTION_TIME.
400 * @param value The value to set.
401 * @param description Description to be used in logging.
402 *****************************************************************************/
403 void evel_set_option_time(EVEL_OPTION_TIME * const option,
405 const char * const description)
409 /***************************************************************************/
410 /* Check preconditions. */
411 /***************************************************************************/
412 assert(option != NULL);
413 assert(description != NULL);
417 EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
418 description, value, description, option->value);
422 EVEL_DEBUG("Setting %s to %d", description, value);
423 option->value = value;
424 option->is_set = EVEL_TRUE;