1 =pod 2 3 =head1 NAME 4 5 ossl_cmp_print_log, 6 ossl_cmp_alert, 7 ossl_cmp_err, 8 ossl_cmp_warn, 9 ossl_cmp_info, 10 ossl_cmp_debug, 11 ossl_cmp_log, 12 ossl_cmp_log1, 13 ossl_cmp_log2, 14 ossl_cmp_log3, 15 ossl_cmp_log4, 16 ossl_cmp_log_parse_metadata, 17 ossl_cmp_add_error_data, 18 ossl_cmp_add_error_line 19 - logging and error reporting support for CMP 20 21 =head1 SYNOPSIS 22 23 #include "cmp_local.h" 24 25 int ossl_cmp_print_log(OSSL_CMP_severity level, const OSSL_CMP_CTX *ctx, 26 const char *func, const char *file, int line, 27 const char *level_str, const char *format, ...); 28 #define ossl_cmp_alert(ctx, msg) 29 #define ossl_cmp_err(ctx, msg) 30 #define ossl_cmp_warn(ctx, msg) 31 #define ossl_cmp_info(ctx, msg) 32 #define ossl_cmp_debug(ctx, (msg) 33 #define ossl_cmp_log(level, ctx, msg) 34 #define ossl_cmp_log1(level, ctx, fmt, arg1) 35 #define ossl_cmp_log2(level, ctx, fmt, arg1, arg2) 36 #define ossl_cmp_log3(level, ctx, fmt, arg1, arg2, arg3) 37 #define ossl_cmp_log4(level, ctx, fmt, arg1, arg2, arg3, arg4) 38 const char *ossl_cmp_log_parse_metadata(const char *buf, 39 OSSL_CMP_severity *level, char **func, 40 char **file, int *line); 41 42 #define ossl_cmp_add_error_data(txt) 43 #define ossl_cmp_add_error_line(txt) 44 45 =head1 DESCRIPTION 46 47 ossl_cmp_print_log() prints CMP log messages (i.e., diagnostic info) via the 48 log callback of the B<ctx> if present and the severity level is sufficient. 49 If the trace API if enabled the function uses it, prepending the function name, 50 filename, line number, and severity information to the message being output. 51 In any case the B<level>, B<func>, B<file>, and B<line> parameters 52 and the message constructed using the given B<format> and variable further 53 argument list are passed to the log callback function (unless it is NULL). 54 The B<ctx>, B<func>, B<file>, and B<level_str> arguments may be NULL. 55 56 ossl_cmp_alert(), ossl_cmp_err(), ossl_cmp_warn(), ossl_cmp_info(), and 57 ossl_cmp_debug() output a simple alert/error/warning/info/debug message 58 via ossl_cmp_print_log(). 59 60 ossl_cmp_log(), ossl_cmp_log1(), ossl_cmp_log2(), ossl_cmp_log3(), and 61 ossl_cmp_log4() output a log message with the given severity, 62 constructing the message text from the given format and arguments. 63 64 ossl_cmp_log_parse_metadata() parses the given message buffer I<buf> populated 65 by ossl_cmp_log() etc. 66 according to the pattern OSSL_CMP_LOG_START#level ": %s\n", filling in 67 the variable pointed to by I<level> with the severity level or -1, 68 the variable pointed to by I<func> with the function name string or NULL, 69 the variable pointed to by I<file> with the filename string or NULL, and 70 the variable pointed to by I<line> with the line number or -1. 71 Any string returned via I<*func> and I<*file> must be freed by the caller. 72 73 ossl_cmp_add_error_data() is a macro calling 74 L<ERR_add_error_txt(3)> with the separator being ":". 75 76 ossl_cmp_add_error_line() is a macro calling 77 L<ERR_add_error_txt(3)> with the separator being "\n". 78 79 =head1 RETURN VALUES 80 81 ossl_cmp_log_parse_metadata() returns the pointer to the actual message text 82 after the OSSL_CMP_LOG_PREFIX and level and ':' if found in the buffer, 83 else the beginning of the buffer. 84 85 ossl_cmp_add_error_data() and 86 ossl_cmp_add_error_line() 87 do not return anything. 88 89 All other functions return 1 on success, 0 on error. 90 91 =head1 SEE ALSO 92 93 L<ERR_add_error_txt(3)> 94 95 =head1 HISTORY 96 97 The OpenSSL CMP support was added in OpenSSL 3.0. 98 99 =head1 COPYRIGHT 100 101 Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved. 102 103 Licensed under the Apache License 2.0 (the "License"). You may not use 104 this file except in compliance with the License. You can obtain a copy 105 in the file LICENSE in the source distribution or at 106 L<https://www.openssl.org/source/license.html>. 107 108 =cut 109