util.h revision 9ca0071db0e226e4e65b2a80fdeddd5048ca8990
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos Simo Sorce <ssorce@redhat.com>
e0a79e452974c14e353e70a43b5beb1afba5342fJason Vincent Copyright (C) 2009 Red Hat
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos This program is free software; you can redistribute it and/or modify
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos it under the terms of the GNU General Public License as published by
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos the Free Software Foundation; either version 3 of the License, or
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos (at your option) any later version.
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos This program is distributed in the hope that it will be useful,
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos but WITHOUT ANY WARRANTY; without even the implied warranty of
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos GNU General Public License for more details.
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos You should have received a copy of the GNU General Public License
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos along with this program. If not, see <http://www.gnu.org/licenses/>.
e0a79e452974c14e353e70a43b5beb1afba5342fJason Vincent#define SSS_ATTRIBUTE_PRINTF(a1, a2) __attribute__ ((format (printf, a1, a2)))
93f381e5d31053932f4ffbf07d97b6d8dce32caeJason Vincentextern const char *debug_prg_name;
9c8c2c05a3d08f94d29b4a42b8a0506a4e97e4faLaszlo Hordosextern const char *debug_log_file;
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos const char *format, ...) SSS_ATTRIBUTE_PRINTF(5,6);
d591ab7a9428501f88bdb3456151ab9018c646e9Laszlo Hordos#define SSSDBG_FATAL_FAILURE 0x0010 /* level 0 */
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define SSSDBG_CRIT_FAILURE 0x0020 /* level 1 */
d591ab7a9428501f88bdb3456151ab9018c646e9Laszlo Hordos#define SSSDBG_MINOR_FAILURE 0x0080 /* level 3 */
904cb62bed9852642ea1d7699cb0515f4f62794aJon Branch#define SSSDBG_TRACE_INTERNAL 0x2000 /* level 8 */
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define SSSDBG_IMPORTANT_INFO SSSDBG_OP_FAILURE
aa26d20912b59f80d1b06b9c0a34c2d4de507a4fLaszlo Hordos#define SSSDBG_MASK_ALL 0xFFF0 /* enable all debug levels */
d591ab7a9428501f88bdb3456151ab9018c646e9Laszlo Hordos {"debug-level", 'd', POPT_ARG_INT, &debug_level, 0, \
0bfa6b040942fa10868f2a7c82555652b605a280Travis Hall {"debug-to-files", 'f', POPT_ARG_NONE, &debug_to_file, 0, \
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos _("Send the debug output to files instead of stderr"), NULL }, \
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos {"debug-to-stderr", 0, POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, &debug_to_stderr, 0, \
9c4d05edc8e0887d3aad788027d46d5afedb3ee0Travis Hall _("Send the debug output to stderr directly."), NULL }, \
aa26d20912b59f80d1b06b9c0a34c2d4de507a4fLaszlo Hordos {"debug-timestamps", 0, POPT_ARG_INT, &debug_timestamps, 0, \
aa26d20912b59f80d1b06b9c0a34c2d4de507a4fLaszlo Hordos {"debug-microseconds", 0, POPT_ARG_INT, &debug_microseconds, 0, \
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos/** \def DEBUG(level, format, ...)
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos \brief macro to generate debug messages
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos \param level the debug level, please use one of the SSSDBG_* macros
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan \param format the debug message format string, should result in a
aa26d20912b59f80d1b06b9c0a34c2d4de507a4fLaszlo Hordos newline-terminated message
aa26d20912b59f80d1b06b9c0a34c2d4de507a4fLaszlo Hordos \param ... the debug message format arguments
154001a7695db48f5e59bd2978bf3254210feed4Jason Vincent/** \def DEBUG_IS_SET(level)
154001a7695db48f5e59bd2978bf3254210feed4Jason Vincent \brief checks whether level is set in debug_level
154001a7695db48f5e59bd2978bf3254210feed4Jason Vincent \param level the debug level, please use one of the SSSDBG*_ macros
52ac627fd3ec7d31990e454143b1a476284fb3d5Jason Lemay#define DEBUG_IS_SET(level) (debug_level & (level) || \
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan debug_level = debug_convert_old_level(dbg_lvl); \
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos/* CLI tools shall debug to stderr even when SSSD was compiled with journald
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__)
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__)
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
47196c962e3caf7cdf7ea5d00ccdefc9f208bdceLaszlo Hordos#define talloc_zfree(ptr) do { talloc_free(discard_const(ptr)); ptr = NULL; } while(0)
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
d3bd4c99b4d249234086d3e694d9c8fb649dcc3ePaul Bryan# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr)))
return TRROEerr; \
return ERR_INTERNAL; \
#include "util/dlinklist.h"
/* From debug.c */
int open_debug_file(void);
int rotate_debug_files(void);
/* From sss_log.c */
/* from server.c */
struct main_context {
int die_if_parent_died(void);
const char *conf_entry,
/* from signal.c */
#include <signal.h>
/* from memory.c */
typedef int (void_destructor_fn_t)(void *);
struct mem_holder {
void *mem;
void *ptr,
/* from usertools.c */
struct sss_names_ctx {
char *re_pattern;
char *fq_fmt;
const char *re_pattern,
const char *fq_fmt,
const char *domain,
const char *default_domain,
bool case_sensitive);
const char *name);
/* from backup-file.c */
/* from util.c */
#define SSS_NO_SPECIAL \
const char * const * get_known_services(void);
unsigned long count,
unsigned long count,
unsigned int directory_bits,
unsigned int segment_bits,
unsigned long min_load_factor,
unsigned long max_load_factor,
void *delete_private_data);
char **string1,
char **string2,
char ***string1_only,
char ***string2_only,
char ***both_strings);
const char *input,
char **sanitized);
const char *input,
char **sanitized,
char **lc_sanitized);
char ***list_p);
/* from nscd.c */
enum nscd_db {
/* from sss_tc_utf8.c */
uint8_t *
struct sized_string {
const char *str;
/* from domain_info.c */
bool descend);
const char *name,
bool match_any);
const char *sid);
struct sss_domain_info*
const char* sid);
struct sss_domain_info *
const char *object_name);
const char *sd_name);
const char *name,
const char *realm,
const char *flat_name,
const char *id,
bool mpg,
bool enumerate,
const char *forest);
const char *domain_name,
const char *db_path,
bool add_capaths);
/* from util_lock.c */
#include "io.h"
#ifdef HAVE_PAC_RESPONDER
#define BUILD_WITH_PAC_RESPONDER true
#define BUILD_WITH_PAC_RESPONDER false
/* from well_known_sids.c */
const char **name);
const char **sid);