1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* ==========================================================================
Licensed under BSD 2clause license. See LICENSE file for more information
Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
========================================================================== */
#ifndef EL_VALID_H
#define EL_VALID_H 1
#include <errno.h>
/* ==========================================================================
If expression 'x' evaluates to false, macro will set errno value to 'e'
and will force function to return with code '-1'
========================================================================== */
#define VALID(e, x) do { if (!(x)) { errno = (e); return -1; } } while (0)
/* ==========================================================================
Same as VALID but when expression fails, message is printed to default
embedlog facility
========================================================================== */
#define VALIDP(e, x) if (!(x)) { el_print(ELW, "VALID FAILED "#x); \
errno = (e); return -1; }
/* ==========================================================================
Same as VALIDP but message is printed to default option, defined by
EL_OPTIONS_OBJECT
========================================================================== */
#define VALIDOP(e, x) if (!(x)) { el_oprint(OELW, "VALID FAILED "#x); \
errno = (e); return -1; }
/* ==========================================================================
If expression 'x' evaluates to false, macro will set errno value to 'e'
and will force function to return value 'v'
========================================================================== */
#define VALIDR(e, v, x) if (!(x)) { errno = (e); return (v); }
/* ==========================================================================
If expression 'x' evaluates to false, macro will set errno value to 'e'
and will jump to lable 'l'
========================================================================== */
#define VALIDGO(e, l, x) if (!(x)) { errno = (e); goto l; }
#endif
|