1/*-
2 * Copyright (c) 2012 Dag-Erling Smørgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 *    products derived from this software without specific prior written
15 *    permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $Id: t.h 657 2013-03-06 22:59:05Z des $
30 */
31
32#ifndef T_H_INCLUDED
33#define T_H_INCLUDED
34
35#include <security/openpam_attr.h>
36
37struct t_test {
38	int (*func)(void *);
39	const char *desc;
40	void *arg;
41};
42
43#define T_FUNC(n, d)				\
44	static int t_ ## n ## _func(void *);	\
45	static const struct t_test t_ ## n =	\
46	    { t_ ## n ## _func, d, NULL };	\
47	static int t_ ## n ## _func(OPENPAM_UNUSED(void *arg))
48
49#define T_FUNC_ARG(n, d, a)			\
50	static int t_ ## n ## _func(void *);	\
51	static const struct t_test t_ ## n =	\
52	    { t_ ## n ## _func, d, a };		\
53	static int t_ ## n ## _func(void *arg)
54
55#define T(n)					\
56	&t_ ## n
57
58extern const char *t_progname;
59
60const struct t_test **t_prepare(int, char **);
61void t_cleanup(void);
62
63void t_verbose(const char *, ...)
64	OPENPAM_FORMAT((__printf__, 1, 2));
65
66/*
67 * Convenience functions for temp files
68 */
69struct t_file {
70	char *name;
71	FILE *file;
72	struct t_file *prev, *next;
73};
74
75struct t_file *t_fopen(const char *);
76int t_fprintf(struct t_file *, const char *, ...);
77int t_ferror(struct t_file *);
78int t_feof(struct t_file *);
79void t_frewind(struct t_file *);
80void t_fclose(struct t_file *);
81void t_fcloseall(void);
82
83#endif
84