]> Dogcows Code - chaz/p5-File-KDBX-XS/blob - libtomcrypt/src/headers/tomcrypt_argchk.h
initial commit
[chaz/p5-File-KDBX-XS] / libtomcrypt / src / headers / tomcrypt_argchk.h
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3
4 /* Defines the LTC_ARGCHK macro used within the library */
5 /* ARGTYPE is defined in tomcrypt_cfg.h */
6
7 /* ARGTYPE is per default defined to 0 */
8 #if ARGTYPE == 0
9
10 #include <signal.h>
11
12 LTC_NORETURN void crypt_argchk(const char *v, const char *s, int d);
13 #define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
14 #define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
15
16 #elif ARGTYPE == 1
17
18 /* fatal type of error */
19 #define LTC_ARGCHK(x) assert((x))
20 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
21
22 #elif ARGTYPE == 2
23
24 #define LTC_ARGCHK(x) if (!(x)) { fprintf(stderr, "\nwarning: ARGCHK failed at %s:%d\n", __FILE__, __LINE__); }
25 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
26
27 #elif ARGTYPE == 3
28
29 #define LTC_ARGCHK(x) LTC_UNUSED_PARAM(x)
30 #define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
31
32 #elif ARGTYPE == 4
33
34 #define LTC_ARGCHK(x) if (!(x)) return CRYPT_INVALID_ARG;
35 #define LTC_ARGCHKVD(x) if (!(x)) return;
36
37 #endif
38
This page took 0.033725 seconds and 4 git commands to generate.