xref: /freebsd/crypto/krb5/src/ccapi/test/test_ccapi_log.c (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
1 #ifndef _TEST_CCAPI_LOG_C_
2 #define _TEST_CCAPI_LOG_C_
3 
4 #include "test_ccapi_log.h"
5 
6 void _log_error_v(const char *file, int line, const char *format, va_list ap)
7 {
8 	fprintf(stdout, "\n\t%s:%d: ", file, line);
9 	if (!format) {
10 		fprintf(stdout, "An unknown error occurred");
11 	} else {
12 		vfprintf(stdout, format, ap);
13 	}
14 	fflush(stdout);
15 }
16 
17 void _log_error(const char *file, int line, const char *format, ...)
18 {
19 	va_list ap;
20 	va_start(ap, format);
21 	_log_error_v(file, line, format, ap);
22 	va_end(ap);
23 }
24 
25 void test_header(const char *msg) {
26 	if (msg != NULL) {
27 		fprintf(stdout, "\nChecking %s... ", msg);
28 		fflush(stdout);
29 	}
30 }
31 
32 void test_footer(const char *msg, int err) {
33 	if (msg != NULL) {
34 		if (!err) {
35 			fprintf(stdout, "OK\n");
36 		}
37 		else {
38 			fprintf(stdout, "\n*** %d failure%s in %s ***\n", err, (err == 1) ? "" : "s", msg);
39 		}
40 	}
41 }
42 
43 
44 
45 #endif /* _TEST_CCAPI_LOG_C_ */
46