~ubuntu-branches/debian/sid/freeipa/sid

« back to all changes in this revision

Viewing changes to daemons/ipa-slapi-plugins/common/util.h

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-10-25 02:43:59 UTC
  • Revision ID: package-import@ubuntu.com-20141025024359-to6c607ln0lmzwik
Tags: upstream-4.0.4
ImportĀ upstreamĀ versionĀ 4.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
6
 *
 
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.
 
11
 *
 
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/>.
 
14
 *
 
15
 * Additional permission under GPLv3 section 7:
 
16
 *
 
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.
 
21
 *
 
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
 
31
 * Interfaces.
 
32
 *
 
33
 * Copyright (C) 2010 Red Hat, Inc.
 
34
 * All rights reserved.
 
35
 * END COPYRIGHT BLOCK **/
 
36
 
 
37
#ifndef _SLAPI_PLUGINS_UTIL_H
 
38
#define _SLAPI_PLUGINS_UTIL_H
 
39
 
 
40
#define EOK 0
 
41
#define EFAIL -1
 
42
 
 
43
#include <stdint.h>
 
44
#ifndef discard_const
 
45
#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
 
46
#endif
 
47
 
 
48
#define log_func discard_const(__func__)
 
49
 
 
50
#define LOG_PLUGIN_NAME(NAME, fmt, ...) \
 
51
    slapi_log_error(SLAPI_LOG_PLUGIN, \
 
52
                    NAME, \
 
53
                    fmt, ##__VA_ARGS__)
 
54
 
 
55
#define LOG(fmt, ...) \
 
56
    LOG_PLUGIN_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
 
57
 
 
58
#define LOG_CONFIG_NAME(NAME, fmt, ...) \
 
59
    slapi_log_error(SLAPI_LOG_CONFIG, \
 
60
                    NAME, \
 
61
                    fmt, ##__VA_ARGS__)
 
62
 
 
63
#define LOG_CONFIG(fmt, ...) \
 
64
    LOG_CONFIG_NAME(IPA_PLUGIN_NAME, fmt, ##__VA_ARGS__)
 
65
 
 
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__)
 
70
 
 
71
#define LOG_TRACE(fmt, ...) \
 
72
    slapi_log_error(SLAPI_LOG_TRACE, log_func, fmt, ##__VA_ARGS__)
 
73
 
 
74
#define LOG_OOM() LOG_FATAL("Out of Memory!\n")
 
75
 
 
76
#endif /* _SLAPI_PLUGINS_UTIL_H */