-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtagcryptlog.h
73 lines (66 loc) · 2.42 KB
/
tagcryptlog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* tagcrypt/include/tagcryptlog.h
* Copyright (C) 2006-2012 Opersys inc., All rights reserved.
*
* tagcrypt logging utilities.
*
* @author Kristian Benoit
*/
#ifndef __TAGCRYPTLOG_H__
#define __TAGCRYPTLOG_H__
/**
* library names
*/
#define TC_PREFIX "TAGCRYPT"
#define GCRY_PREFIX "LIBGCRYPT"
/** Macros to log tagcrypt errors.
* \see logging.h in klib.
*/
#if 0
#define TC_DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define TC_INFO(...) fprintf(stderr, __VA_ARGS__)
#define TC_WARNING(...) fprintf(stderr, __VA_ARGS__)
#define TC_ERROR(...) fprintf(stderr, __VA_ARGS__)
#define TC_CRITICAL(...) fprintf(stderr, __VA_ARGS__)
#else
#define TC_DEBUG(...)
#define TC_INFO(...)
#define TC_WARNING(...)
#define TC_ERROR(...)
#define TC_CRITICAL(...)
#endif
/** Macros to log libgcrypt errors.
* \see logging.h in klib.
*/
#define GCRY_DEBUG(...) TC_DEBUG (__VA_ARGS__)
#define GCRY_INFO(...) TC_INFO (__VA_ARGS__)
#define GCRY_WARNING(...) TC_INFO (__VA_ARGS__)
#define GCRY_ERROR(...) TC_ERROR (__VA_ARGS__)
#define GCRY_CRITICAL(...) TC_CRITICAL(__VA_ARGS__)
#define MAX_STRERROR_SIZE 1024
#define LIBC_DEBUG() { \
char buf[MAX_STRERROR_SIZE]; \
strerror_r(errno, buf, MAX_STRERROR_SIZE); \
TC_CRITICAL(buf); \
}
#define LIBC_ERROR() { \
char buf[MAX_STRERROR_SIZE]; \
strerror_r(errno, buf, MAX_STRERROR_SIZE); \
TC_CRITICAL(buf); \
}
#define LIBC_INFO { \
char buf[MAX_STRERROR_SIZE]; \
strerror_r(errno, buf, MAX_STRERROR_SIZE); \
TC_CRITICAL(buf); \
}
#define LIBC_WARN { \
char buf[MAX_STRERROR_SIZE]; \
strerror_r(errno, buf, MAX_STRERROR_SIZE); \
TC_CRITICAL(buf); \
}
#define LIBC_CRITICAL { \
char buf[MAX_STRERROR_SIZE]; \
strerror_r(errno, buf, MAX_STRERROR_SIZE); \
TC_CRITICAL(buf); \
}
#endif /* __TAGCRYPTLOG_H__ */