| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#pragma once |
| 4 |
|
| 5 |
#include "cryptsetup-util.h" |
| 6 |
#include "shared-forward.h" |
| 7 |
|
| 8 |
/* crypt_dump() internal indentation magic */ |
| 9 |
#define CRYPT_DUMP_LINE_SEP "\n\t " |
| 10 |
|
| 11 |
#define crypt_log_debug(cd, ...) sym_crypt_logf(cd, CRYPT_LOG_DEBUG, __VA_ARGS__) |
| 12 |
#define crypt_log_error(cd, ...) sym_crypt_logf(cd, CRYPT_LOG_ERROR, __VA_ARGS__) |
| 13 |
#define crypt_log_verbose(cd, ...) sym_crypt_logf(cd, CRYPT_LOG_VERBOSE, __VA_ARGS__) |
| 14 |
#define crypt_log(cd, ...) sym_crypt_logf(cd, CRYPT_LOG_NORMAL, __VA_ARGS__) |
| 15 |
|
| 16 |
#define crypt_log_full_errno(cd, e, lvl, ...) ({ \ |
| 17 |
int _e = ABS(e), _s = errno; \ |
| 18 |
errno = _e; \ |
| 19 |
sym_crypt_logf(cd, lvl, __VA_ARGS__); \ |
| 20 |
errno = _s; \ |
| 21 |
-_e; \ |
| 22 |
}) |
| 23 |
|
| 24 |
#define crypt_log_debug_errno(cd, e, ...) \ |
| 25 |
crypt_log_full_errno(cd, e, CRYPT_LOG_DEBUG, __VA_ARGS__) |
| 26 |
|
| 27 |
#define crypt_log_error_errno(cd, e, ...) \ |
| 28 |
crypt_log_full_errno(cd, e, CRYPT_LOG_ERROR, __VA_ARGS__) |
| 29 |
|
| 30 |
#define crypt_log_oom(cd) crypt_log_error_errno(cd, ENOMEM, "Not enough memory.") |
| 31 |
|
| 32 |
int crypt_dump_buffer_to_hex_string( |
| 33 |
const char *buf, |
| 34 |
size_t buf_size, |
| 35 |
char **ret_dump_str); |
| 36 |
|
| 37 |
int crypt_normalize_pin(const void *pin, size_t pin_size, char **ret_pin_string); |