2
* sanitize a string into a printable format.
4
* Copyright (C) 1998-2002 D. Hugh Redelmeier.
5
* Copyright (C) 2003 Michael Richardson <mcr@freeswan.org>
7
* This library is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Library General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or (at your
10
* option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
12
* This library is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15
* License for more details.
17
* RCSID $Id: passert.h,v 1.7 2004/10/21 18:44:42 mcr Exp $
22
#ifndef _OPENSWAN_PASSERT_H
23
#define _OPENSWAN_PASSERT_H
24
/* our versions of assert: log result */
28
typedef void (*openswan_passert_fail_t)(const char *pred_str,
30
unsigned long line_no) NEVER_RETURNS;
32
openswan_passert_fail_t openswan_passert_fail;
34
extern void pexpect_log(const char *pred_str
35
, const char *file_str, unsigned long line_no);
37
# define impossible() do { \
38
if(openswan_passert_fail) { \
39
(*openswan_passert_fail)("impossible", __FILE__, __LINE__); \
42
extern void switch_fail(int n
43
, const char *file_str, unsigned long line_no) NEVER_RETURNS;
45
# define bad_case(n) switch_fail((int) n, __FILE__, __LINE__)
47
# define passert(pred) do { \
49
if(openswan_passert_fail) { \
50
(*openswan_passert_fail)(#pred, __FILE__, __LINE__); \
54
# define pexpect(pred) do { \
56
pexpect_log(#pred, __FILE__, __LINE__); \
59
/* assert that an err_t is NULL; evaluate exactly once */
63
if(openswan_passert_fail) { (*openswan_passert_fail)(ugh, __FILE__, __LINE__); } \
68
# define impossible() abort()
69
# define bad_case(n) abort()
70
# define passert(pred) { } /* do nothing */
71
# define happy(x) { (void) x; } /* evaluate non-judgementally */
75
#endif /* _OPENSWAN_PASSERT_H */