From 4d1a4e8e7ce047f70113d9fa52f7961c0fee6557 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 23 Sep 2006 19:15:27 +0000 Subject: r18848: Save the json library before I start hacking on it. I'm going to be converting it to natively use ejs objects, instead of its own internal format. (This used to be commit 119db8924a6e9c40a94c76c57198877875c53afc) --- source4/lib/json/debug.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 source4/lib/json/debug.c (limited to 'source4/lib/json/debug.c') diff --git a/source4/lib/json/debug.c b/source4/lib/json/debug.c new file mode 100644 index 0000000000..eaa6fca33c --- /dev/null +++ b/source4/lib/json/debug.c @@ -0,0 +1,94 @@ +/* + * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $ + * + * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. + * Michael Clark + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the MIT license. See COPYING for details. + * + */ + +#include "config.h" + +#include +#include +#include +#include + +#if HAVE_SYSLOG_H +# include +#endif /* HAVE_SYSLOG_H */ + +#if HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ + +#if HAVE_SYS_PARAM_H +#include +#endif /* HAVE_SYS_PARAM_H */ + +#include "debug.h" + +static int _syslog = 0; +static int _debug = 0; + +void mc_set_debug(int debug) { _debug = debug; } +int mc_get_debug() { return _debug; } + +extern void mc_set_syslog(int syslog) +{ + _syslog = syslog; +} + +void mc_abort(const char *msg, ...) +{ + va_list ap; + va_start(ap, msg); +#if HAVE_VSYSLOG + if(_syslog) { + vsyslog(LOG_ERR, msg, ap); + } else +#endif + vprintf(msg, ap); + exit(1); +} + + +void mc_debug(const char *msg, ...) +{ + va_list ap; + if(_debug) { + va_start(ap, msg); +#if HAVE_VSYSLOG + if(_syslog) { + vsyslog(LOG_DEBUG, msg, ap); + } else +#endif + vprintf(msg, ap); + } +} + +void mc_error(const char *msg, ...) +{ + va_list ap; + va_start(ap, msg); +#if HAVE_VSYSLOG + if(_syslog) { + vsyslog(LOG_ERR, msg, ap); + } else +#endif + vfprintf(stderr, msg, ap); +} + +void mc_info(const char *msg, ...) +{ + va_list ap; + va_start(ap, msg); +#if HAVE_VSYSLOG + if(_syslog) { + vsyslog(LOG_INFO, msg, ap); + } else +#endif + vfprintf(stderr, msg, ap); +} -- cgit From c2781df0d5477be58c3189c6d3c17b261d7b8b89 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 1 Jun 2007 12:01:53 +0000 Subject: r23289: Provide support for GCC attributes _PURE_, _NONNULL_, _DEPRECATED_, _NORETURN_ and _WARN_UNUSED_RESULT_. (This used to be commit 44248f662f0b609dad6a7b437948f12d661a28f7) --- source4/lib/json/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/json/debug.c') diff --git a/source4/lib/json/debug.c b/source4/lib/json/debug.c index eaa6fca33c..a315b0e2a4 100644 --- a/source4/lib/json/debug.c +++ b/source4/lib/json/debug.c @@ -41,7 +41,7 @@ extern void mc_set_syslog(int syslog) _syslog = syslog; } -void mc_abort(const char *msg, ...) +_NORETURN_ void mc_abort(const char *msg, ...) { va_list ap; va_start(ap, msg); -- cgit