AT&T ECOMP Vendor Event Listener library  0.1
evel_option.c
Go to the documentation of this file.
1 /**************************************************************************/
37 #include <assert.h>
38 #include <stdlib.h>
39 #include <string.h>
40 
41 #include "evel_internal.h"
42 
43 /**************************************************************************/
49 {
50  EVEL_ENTER();
51 
52  /***************************************************************************/
53  /* Check preconditions. */
54  /***************************************************************************/
55  assert(option != NULL);
56 
57  if (option->is_set)
58  {
59  free(option->value);
60  option->value = NULL;
61  option->is_set = EVEL_FALSE;
62  }
63 
64  EVEL_EXIT();
65 }
66 
67 /**************************************************************************/
73 {
74  EVEL_ENTER();
75 
76  /***************************************************************************/
77  /* Check preconditions. */
78  /***************************************************************************/
79  assert(option != NULL);
80 
81  option->value = NULL;
82  option->is_set = EVEL_FALSE;
83 
84  EVEL_EXIT();
85 }
86 
87 /**************************************************************************/
95  const char * const value,
96  const char * const description)
97 {
98  EVEL_ENTER();
99 
100  /***************************************************************************/
101  /* Check preconditions. */
102  /***************************************************************************/
103  assert(option != NULL);
104  assert(value != NULL);
105  assert(description != NULL);
106 
107  if (option->is_set)
108  {
109  EVEL_ERROR("Ignoring attempt to update %s to %s. %s already set to %s",
110  description, value, description, option->value);
111  }
112  else
113  {
114  EVEL_DEBUG("Setting %s to %s", description, value);
115  option->value = strdup(value);
116  option->is_set = EVEL_TRUE;
117  }
118 
119  EVEL_EXIT();
120 }
121 
122 /**************************************************************************/
129  const char * const value)
130 {
131  EVEL_ENTER();
132 
133  /***************************************************************************/
134  /* Check preconditions. */
135  /***************************************************************************/
136  assert(option != NULL);
137  assert(option->is_set == EVEL_FALSE);
138  assert(option->value == NULL);
139 
140  option->value = strdup(value);
141  option->is_set = EVEL_TRUE;
142 
143  EVEL_EXIT();
144 }
145 
146 /**************************************************************************/
152 {
153  EVEL_ENTER();
154 
155  /***************************************************************************/
156  /* Check preconditions. */
157  /***************************************************************************/
158  assert(option != NULL);
159 
160  option->value = 0;
161  option->is_set = EVEL_FALSE;
162 
163  EVEL_EXIT();
164 }
165 
166 /**************************************************************************/
173  const int value)
174 {
175  EVEL_ENTER();
176 
177  /***************************************************************************/
178  /* Check preconditions. */
179  /***************************************************************************/
180  assert(option != NULL);
181 
182  option->value = value;
183  option->is_set = EVEL_TRUE;
184 
185  EVEL_EXIT();
186 }
187 
188 /**************************************************************************/
196  const int value,
197  const char * const description)
198 {
199  EVEL_ENTER();
200 
201  /***************************************************************************/
202  /* Check preconditions. */
203  /***************************************************************************/
204  assert(option != NULL);
205  assert(description != NULL);
206 
207  if (option->is_set)
208  {
209  EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
210  description, value, description, option->value);
211  }
212  else
213  {
214  EVEL_DEBUG("Setting %s to %d", description, value);
215  option->value = value;
216  option->is_set = EVEL_TRUE;
217  }
218 
219  EVEL_EXIT();
220 }
221 
222 /**************************************************************************/
228 {
229  EVEL_ENTER();
230 
231  /***************************************************************************/
232  /* Check preconditions. */
233  /***************************************************************************/
234  assert(option != NULL);
235 
236  option->value = 0.0;
237  option->is_set = EVEL_FALSE;
238 
239  EVEL_EXIT();
240 }
241 
242 /**************************************************************************/
249  const double value)
250 {
251  EVEL_ENTER();
252 
253  /***************************************************************************/
254  /* Check preconditions. */
255  /***************************************************************************/
256  assert(option != NULL);
257 
258  option->value = value;
259  option->is_set = EVEL_TRUE;
260 
261  EVEL_EXIT();
262 }
263 
264 /**************************************************************************/
272  const double value,
273  const char * const description)
274 {
275  EVEL_ENTER();
276 
277  /***************************************************************************/
278  /* Check preconditions. */
279  /***************************************************************************/
280  assert(option != NULL);
281  assert(description != NULL);
282 
283  if (option->is_set)
284  {
285  EVEL_ERROR("Ignoring attempt to update %s to %lf. %s already set to %lf",
286  description, value, description, option->value);
287  }
288  else
289  {
290  EVEL_DEBUG("Setting %s to %lf", description, value);
291  option->value = value;
292  option->is_set = EVEL_TRUE;
293  }
294 
295  EVEL_EXIT();
296 }
297 
298 /**************************************************************************/
304 {
305  EVEL_ENTER();
306 
307  /***************************************************************************/
308  /* Check preconditions. */
309  /***************************************************************************/
310  assert(option != NULL);
311  option->value = 0;
312  option->is_set = EVEL_FALSE;
313  EVEL_EXIT();
314 }
315 
316 /**************************************************************************/
323  const unsigned long long value)
324 {
325  EVEL_ENTER();
326 
327  /***************************************************************************/
328  /* Check preconditions. */
329  /***************************************************************************/
330  assert(option != NULL);
331 
332  option->value = value;
333  option->is_set = EVEL_TRUE;
334 
335  EVEL_EXIT();
336 }
337 
338 /**************************************************************************/
346  const unsigned long long value,
347  const char * const description)
348 {
349  EVEL_ENTER();
350 
351  /***************************************************************************/
352  /* Check preconditions. */
353  /***************************************************************************/
354  assert(option != NULL);
355  assert(description != NULL);
356 
357  if (option->is_set)
358  {
359  EVEL_ERROR("Ignoring attempt to update %s to %llu. %s already set to %llu",
360  description, value, description, option->value);
361  }
362  else
363  {
364  EVEL_DEBUG("Setting %s to %llu", description, value);
365  option->value = value;
366  option->is_set = EVEL_TRUE;
367  }
368  EVEL_EXIT();
369 }
370 
371 /**************************************************************************/
377 {
378  EVEL_ENTER();
379 
380  /***************************************************************************/
381  /* Check preconditions. */
382  /***************************************************************************/
383  assert(option != NULL);
384  option->value = 0;
385  option->is_set = EVEL_FALSE;
386  EVEL_EXIT();
387 }
388 
389 /**************************************************************************/
396  const time_t value)
397 {
398  EVEL_ENTER();
399 
400  /***************************************************************************/
401  /* Check preconditions. */
402  /***************************************************************************/
403  assert(option != NULL);
404 
405  option->value = value;
406  option->is_set = EVEL_TRUE;
407 
408  EVEL_EXIT();
409 }
410 
411 /**************************************************************************/
419  const time_t value,
420  const char * const description)
421 {
422  EVEL_ENTER();
423 
424  /***************************************************************************/
425  /* Check preconditions. */
426  /***************************************************************************/
427  assert(option != NULL);
428  assert(description != NULL);
429 
430  if (option->is_set)
431  {
432  EVEL_ERROR("Ignoring attempt to update %s to %d. %s already set to %d",
433  description, value, description, option->value);
434  }
435  else
436  {
437  EVEL_DEBUG("Setting %s to %d", description, value);
438  option->value = value;
439  option->is_set = EVEL_TRUE;
440  }
441  EVEL_EXIT();
442 }
void evel_set_option_time(EVEL_OPTION_TIME *const option, const time_t value, const char *const description)
Set the value of an EVEL_OPTION_TIME.
Definition: evel_option.c:418
#define EVEL_DEBUG(FMT,...)
Definition: evel.h:3621
double value
Definition: evel.h:360
Optional parameter holder for unsigned long long.
Definition: evel.h:385
Optional parameter holder for double.
Definition: evel.h:358
Optional parameter holder for string.
Definition: evel.h:367
void evel_init_option_time(EVEL_OPTION_TIME *const option)
Initialize an EVEL_OPTION_TIME to a not-set state.
Definition: evel_option.c:376
#define EVEL_EXIT()
Definition: evel.h:3631
#define EVEL_ENTER()
Definition: evel.h:3626
EVEL_BOOLEAN is_set
Definition: evel.h:379
void evel_free_option_string(EVEL_OPTION_STRING *const option)
Free the underlying resources of an EVEL_OPTION_STRING.
Definition: evel_option.c:48
void evel_init_option_ull(EVEL_OPTION_ULL *const option)
Initialize an EVEL_OPTION_ULL to a not-set state.
Definition: evel_option.c:303
EVEL_BOOLEAN is_set
Definition: evel.h:370
void evel_set_option_int(EVEL_OPTION_INT *const option, const int value, const char *const description)
Set the value of an EVEL_OPTION_INT.
Definition: evel_option.c:195
void evel_force_option_string(EVEL_OPTION_STRING *const option, const char *const value)
Force the value of an EVEL_OPTION_STRING.
Definition: evel_option.c:128
time_t value
Definition: evel.h:396
void evel_set_option_string(EVEL_OPTION_STRING *const option, const char *const value, const char *const description)
Set the value of an EVEL_OPTION_STRING.
Definition: evel_option.c:94
Optional parameter holder for int.
Definition: evel.h:376
#define EVEL_ERROR(FMT,...)
Definition: evel.h:3624
void evel_force_option_ull(EVEL_OPTION_ULL *const option, const unsigned long long value)
Force the value of an EVEL_OPTION_ULL.
Definition: evel_option.c:322
unsigned long long value
Definition: evel.h:387
void evel_init_option_double(EVEL_OPTION_DOUBLE *const option)
Initialize an EVEL_OPTION_DOUBLE to a not-set state.
Definition: evel_option.c:227
void evel_set_option_ull(EVEL_OPTION_ULL *const option, const unsigned long long value, const char *const description)
Set the value of an EVEL_OPTION_ULL.
Definition: evel_option.c:345
void evel_force_option_int(EVEL_OPTION_INT *const option, const int value)
Force the value of an EVEL_OPTION_INT.
Definition: evel_option.c:172
EVEL_BOOLEAN is_set
Definition: evel.h:388
void evel_init_option_string(EVEL_OPTION_STRING *const option)
Initialize an EVEL_OPTION_STRING to a not-set state.
Definition: evel_option.c:72
char * value
Definition: evel.h:369
void evel_init_option_int(EVEL_OPTION_INT *const option)
Initialize an EVEL_OPTION_INT to a not-set state.
Definition: evel_option.c:151
EVEL_BOOLEAN is_set
Definition: evel.h:397
void evel_force_option_double(EVEL_OPTION_DOUBLE *const option, const double value)
Force the value of an EVEL_OPTION_DOUBLE.
Definition: evel_option.c:248
EVEL internal definitions.
EVEL_BOOLEAN is_set
Definition: evel.h:361
void evel_force_option_time(EVEL_OPTION_TIME *const option, const time_t value)
Force the value of an EVEL_OPTION_TIME.
Definition: evel_option.c:395
Optional parameter holder for time_t.
Definition: evel.h:394
void evel_set_option_double(EVEL_OPTION_DOUBLE *const option, const double value, const char *const description)
Set the value of an EVEL_OPTION_DOUBLE.
Definition: evel_option.c:271