| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef _SEPOL_INTERNAL_DEBUG_H_ |
| 20 |
#define _SEPOL_INTERNAL_DEBUG_H_ |
| 21 |
|
| 22 |
#include <stdio.h> |
| 23 |
#include <sepol/debug.h> |
| 24 |
#include "dso.h" |
| 25 |
#include "handle.h" |
| 26 |
|
| 27 |
#define STATUS_SUCCESS 0 |
| 28 |
#define STATUS_ERR -1 |
| 29 |
#define STATUS_NODATA 1 |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
#define msg_write(handle_arg, level_arg, \ |
| 37 |
channel_arg, func_arg, ...) do { \ |
| 38 |
sepol_handle_t *_sepol_h = (handle_arg) ?: &sepol_compat_handle; \ |
| 39 |
if (_sepol_h->msg_callback) { \ |
| 40 |
_sepol_h->msg_fname = func_arg; \ |
| 41 |
_sepol_h->msg_channel = channel_arg; \ |
| 42 |
_sepol_h->msg_level = level_arg; \ |
| 43 |
\ |
| 44 |
_sepol_h->msg_callback( \ |
| 45 |
_sepol_h->msg_callback_arg, \ |
| 46 |
_sepol_h, __VA_ARGS__); \ |
| 47 |
} \ |
| 48 |
} while(0) |
| 49 |
|
| 50 |
#define ERR(handle, ...) \ |
| 51 |
msg_write(handle, SEPOL_MSG_ERR, "libsepol", \ |
| 52 |
__FUNCTION__, __VA_ARGS__) |
| 53 |
|
| 54 |
#define INFO(handle, ...) \ |
| 55 |
msg_write(handle, SEPOL_MSG_INFO, "libsepol", \ |
| 56 |
__FUNCTION__, __VA_ARGS__) |
| 57 |
|
| 58 |
#define WARN(handle, ...) \ |
| 59 |
msg_write(handle, SEPOL_MSG_WARN, "libsepol", \ |
| 60 |
__FUNCTION__, __VA_ARGS__) |
| 61 |
|
| 62 |
#ifdef __GNUC__ |
| 63 |
__attribute__ ((format(printf, 3, 4))) |
| 64 |
#endif |
| 65 |
extern void hidden sepol_msg_default_handler(void *varg, |
| 66 |
sepol_handle_t * msg, |
| 67 |
const char *fmt, ...); |
| 68 |
|
| 69 |
extern struct sepol_handle sepol_compat_handle; |
| 70 |
|
| 71 |
hidden_proto(sepol_msg_get_channel) |
| 72 |
hidden_proto(sepol_msg_get_fname) |
| 73 |
hidden_proto(sepol_msg_get_level) |
| 74 |
#endif |