]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/cmp_util.h
Reorganize public header files (part 2)
[thirdparty/openssl.git] / include / openssl / cmp_util.h
CommitLineData
7960dbec
DDO
1/*
2 * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
5 *
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 */
11
12#ifndef OSSL_HEADER_CMP_UTIL_H
13# define OSSL_HEADER_CMP_UTIL_H
14
15# include <openssl/opensslconf.h>
16# ifndef OPENSSL_NO_CMP
17
18# include <openssl/macros.h>
19# include <openssl/trace.h>
20# include <openssl/x509.h>
21
22# ifdef __cplusplus
23extern "C" {
24# endif
25
26/*
27 * convenience functions for CMP-specific logging via the trace API
28 */
29
30int OSSL_CMP_log_open(void);
31void OSSL_CMP_log_close(void);
32# define OSSL_CMP_LOG_PREFIX "CMP "
33/* in OSSL_CMP_LOG_START, cannot use OPENSSL_FUNC when expands to __func__ */
34# define OSSL_CMP_LOG_START "%s:" OPENSSL_FILE ":" \
35 OPENSSL_MSTR(OPENSSL_LINE) ":" OSSL_CMP_LOG_PREFIX
36# define OSSL_CMP_alert(msg) OSSL_CMP_log(ALERT, msg)
37# define OSSL_CMP_err(msg) OSSL_CMP_log(ERROR, msg)
38# define OSSL_CMP_warn(msg) OSSL_CMP_log(WARN, msg)
39# define OSSL_CMP_info(msg) OSSL_CMP_log(INFO, msg)
40# define OSSL_CMP_debug(msg) OSSL_CMP_log(DEBUG, msg)
41# define OSSL_CMP_log(level, msg) \
42 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": %s\n", \
43 OPENSSL_FUNC, msg))
44# define OSSL_CMP_log1(level, fmt, arg1) \
45 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
46 OPENSSL_FUNC, arg1))
47# define OSSL_CMP_log2(level, fmt, arg1, arg2) \
48 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
49 OPENSSL_FUNC, arg1, arg2))
50# define OSSL_CMP_log3(level, fmt, arg1, arg2, arg3) \
51 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
52 OPENSSL_FUNC, arg1, arg2, arg3))
53# define OSSL_CMP_log4(level, fmt, arg1, arg2, arg3, arg4) \
54 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
55 OPENSSL_FUNC, arg1, arg2, arg3, arg4))
56
57/*
58 * generalized logging/error callback mirroring the severity levels of syslog.h
59 */
60typedef int OSSL_CMP_severity;
61# define OSSL_CMP_LOG_EMERG 0
62# define OSSL_CMP_LOG_ALERT 1
63# define OSSL_CMP_LOG_CRIT 2
64# define OSSL_CMP_LOG_ERR 3
65# define OSSL_CMP_LOG_WARNING 4
66# define OSSL_CMP_LOG_NOTICE 5
67# define OSSL_CMP_LOG_INFO 6
68# define OSSL_CMP_LOG_DEBUG 7
69typedef int (*OSSL_cmp_log_cb_t)(const char *func, const char *file, int line,
70 OSSL_CMP_severity level, const char *msg);
71
72/* use of the logging callback for outputting error queue */
73void OSSL_CMP_print_errors_cb(OSSL_cmp_log_cb_t log_fn);
74
75# ifdef __cplusplus
76}
77# endif
78# endif /* !defined OPENSSL_NO_CMP */
79#endif /* !defined OSSL_HEADER_CMP_UTIL_H */