[couchdb-glib] Add configure option to enable/disable debug messages
- From: Rodrigo Moya <rodrigo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [couchdb-glib] Add configure option to enable/disable debug messages
- Date: Fri, 15 Jan 2010 10:10:04 +0000 (UTC)
commit 915494baf9063b60bf33032dea044b2a01e45bc1
Author: Adi Roiban <adiroiban ubuntu com>
Date: Fri Jan 15 11:09:48 2010 +0100
Add configure option to enable/disable debug messages
configure.ac | 9 ++++++++-
couchdb-glib/oauth.c | 15 ++++++++-------
couchdb-glib/utils.c | 1 -
couchdb-glib/utils.h | 5 +++++
couchdb-glib/xmalloc.c | 3 ++-
5 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6fda41d..909c4e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,13 +20,20 @@ AC_PROG_LIBTOOL
dnl glib-genmarshal
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+AC_ARG_ENABLE([debug-messages],
+ AS_HELP_STRING([--disable-debug-messages],[disable all debug messages]))
+
+AS_IF([test "x$enable_debug_messages" != "xno"], [
+ AC_DEFINE(DEBUG_MESSAGES, 1, [Define if debug messages are enabled.])
+])
+
+
dnl Check for oAuth dependencies
have_oauth="no"
AC_CHECK_HEADERS(unistd.h time.h string.h alloca.h stdio.h stdarg.h math.h openssl/hmac.h, have_oauth_headers="yes", have_oauth_headers="no")
AC_CHECK_LIB(crypto, CRYPTO_free, have_oauth_libs="yes", have_oauth_libs="no")
if test "x$have_oauth_headers" = "xyes" -a "x$have_oauth_libs" = "xyes"; then
AC_DEFINE(HAVE_OAUTH, 1, [Define to build OAUTH signing code])
- AC_DEFINE(DEBUG_OAUTH, 1, [Define to enable OAuth debugging])
have_oauth="yes"
OAUTH_LIBS="-lm -lcrypto"
AC_SUBST(OAUTH_LIBS)
diff --git a/couchdb-glib/oauth.c b/couchdb-glib/oauth.c
index ee852d3..41a1f50 100644
--- a/couchdb-glib/oauth.c
+++ b/couchdb-glib/oauth.c
@@ -41,6 +41,7 @@
#include <ctype.h> // isxdigit
#include <openssl/hmac.h>
+#include "utils.h"
#include "xmalloc.h"
#include "oauth.h"
@@ -338,7 +339,7 @@ char *oauth_sign_rsa_sha1 (const char *m, const char *k) {
BIO_free(in);
if (pkey == NULL) {
- //fprintf(stderr, "liboauth/ssl: can not read private key\n");
+ g_debug("liboauth/ssl: can not read private key\n");
return xstrdup("liboauth/ssl: can not read private key");
}
@@ -387,7 +388,7 @@ int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) {
}
BIO_free(in);
if (pkey == NULL) {
- //fprintf(stderr, "could not read cert/pubkey.\n");
+ g_debug("liboauth/ssl: could not read cert/pubkey.\n");
return -2;
}
@@ -492,8 +493,8 @@ int oauth_split_post_paramters(const char *url, char ***argv, short qesc) {
if (slash && strchr(slash,'@')) slash=strchr(slash,'@');
#endif
if (slash && !strchr(slash,'/')) {
-#ifdef DEBUG_OAUTH
- fprintf(stderr, "\nliboauth: added trailing slash to URL: '%s'\n\n", token);
+#ifdef DEBUG_MESSAGES
+ g_debug ("\nliboauth: added trailing slash to URL: '%s'\n\n", token);
#endif
free((*argv)[argc]);
(*argv)[argc]= (char*) xmalloc(sizeof(char)*(2+strlen(token)));
@@ -842,9 +843,9 @@ char *oauth_sign_array2 (int *argcp, char***argvp,
okey = oauth_catenc(2, c_secret, t_secret);
odat = oauth_catenc(3, http_request_method, (*argvp)[0], query);
free(http_request_method);
-#ifdef DEBUG_OAUTH
- fprintf (stderr, "\nliboauth: data to sign='%s'\n\n", odat);
- fprintf (stderr, "\nliboauth: key='%s'\n\n", okey);
+#ifdef DEBUG_MESSAGES
+ g_debug ("\nliboauth: data to sign='%s'\n\n", odat);
+ g_debug ("\nliboauth: key='%s'\n\n", okey);
#endif
switch(method) {
case OA_RSA:
diff --git a/couchdb-glib/utils.c b/couchdb-glib/utils.c
index 296be5e..7452c59 100644
--- a/couchdb-glib/utils.c
+++ b/couchdb-glib/utils.c
@@ -45,6 +45,5 @@ generate_uuid (void)
uuid_generate_random (uuid);
uuid_unparse (uuid, uuid_string);
- g_print ("Generated %s uuid", uuid_string);
return g_strdup (uuid_string);
}
diff --git a/couchdb-glib/utils.h b/couchdb-glib/utils.h
index ca857a2..14fbfdc 100644
--- a/couchdb-glib/utils.h
+++ b/couchdb-glib/utils.h
@@ -27,6 +27,11 @@
#include "config.h"
#include "couchdb-session.h"
+#ifndef DEBUG_MESSAGES
+#undef g_debug
+#define g_debug(...)
+#endif
+
#define COUCHDB_ERROR couchdb_error_quark()
GQuark couchdb_error_quark (void);
diff --git a/couchdb-glib/xmalloc.c b/couchdb-glib/xmalloc.c
index a7e340f..a190d5a 100644
--- a/couchdb-glib/xmalloc.c
+++ b/couchdb-glib/xmalloc.c
@@ -36,6 +36,7 @@ char *xstrdup (const char *p) {return strdup(p);}
#endif
#include <stdio.h> /* for stderr */
+#include "utils.h"
#if STDC_HEADERS
@@ -85,7 +86,7 @@ fixup_null_alloc (n)
{
/* possible revisions: release some memory and re-try, print
more information (e.g. line number of input file) */
- fprintf(stderr, _("liboauth: Memory exhausted"));
+ g_debug(_("liboauth: Memory exhausted"));
exit(1);
}
return p;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]