1
/** BEGIN COPYRIGHT BLOCK
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation, either version 3 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
* Additional permission under GPLv3 section 7:
17
* In the following paragraph, "GPL" means the GNU General Public
18
* License, version 3 or any later version, and "Non-GPL Code" means
19
* code that is governed neither by the GPL nor a license
20
* compatible with the GPL.
22
* You may link the code of this Program with Non-GPL Code and convey
23
* linked combinations including the two, provided that such Non-GPL
24
* Code only links to the code of this Program through those well
25
* defined interfaces identified in the file named EXCEPTION found in
26
* the source code files (the "Approved Interfaces"). The files of
27
* Non-GPL Code may instantiate templates or use macros or inline
28
* functions from the Approved Interfaces without causing the resulting
29
* work to be covered by the GPL. Only the copyright holders of this
30
* Program may make changes or additions to the list of Approved
33
* Copyright (C) 2010 Red Hat, Inc.
34
* All rights reserved.
35
* END COPYRIGHT BLOCK **/
37
#ifndef _SLAPI_PLUGINS_UTIL_H
38
#define _SLAPI_PLUGINS_UTIL_H
45
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
48
#define log_func discard_const(__func__)
50
#define LOG_PLUGIN_NAME(NAME, fmt, ...) \
51
slapi_log_error(SLAPI_LOG_PLUGIN, \
55
#define LOG(fmt, ...) \
56
LOG_PLUGIN_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
58
#define LOG_CONFIG_NAME(NAME, fmt, ...) \
59
slapi_log_error(SLAPI_LOG_CONFIG, \
63
#define LOG_CONFIG(fmt, ...) \
64
LOG_CONFIG_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
66
#define LOG_FATAL(fmt, ...) \
67
slapi_log_error(SLAPI_LOG_FATAL, log_func, \
68
"[file %s, line %d]: " fmt, \
69
__FILE__, __LINE__, ##__VA_ARGS__)
71
#define LOG_TRACE(fmt, ...) \
72
slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
74
#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
76
#endif /* _SLAPI_PLUGINS_UTIL_H */