From 05a3bbbe420e4afc76e0eea24ce32f859405dc4a Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 12 Nov 2006 00:23:24 +0100 Subject: [PATCH] move debug.c Signed-off-by: Pierre Habouzit --- alias.c | 2 +- attach.c | 21 ++++----- commands.c | 21 ++++----- complete.c | 20 ++++---- compress.c | 13 +++--- copy.c | 13 +++--- from.c | 9 ++-- handler.c | 2 +- hcache.c | 3 +- headers.c | 11 ++--- imap/auth.c | 2 +- imap/auth_anon.c | 2 +- imap/auth_cram.c | 2 +- imap/auth_gss.c | 2 +- imap/auth_login.c | 2 +- imap/auth_sasl.c | 2 +- imap/browse.c | 2 +- imap/command.c | 2 +- imap/imap.c | 2 +- imap/message.c | 2 +- imap/util.c | 2 +- init.c | 2 +- init.h | 3 +- lib-crypt/crypt-gpgme.c | 2 +- lib-crypt/gnupgparse.c | 2 +- lib-crypt/pgp.c | 2 +- lib-crypt/pgpinvoke.c | 2 +- lib-crypt/pgpkey.c | 2 +- lib-crypt/pgpmicalg.c | 3 +- lib-crypt/smime.c | 2 +- lib-lib/Makefile.am | 4 +- lib-lib/buffer.c | 3 +- lib-lib/debug.c | 95 ++++++++++++++++++++++++++++++++++++++ lib-lib/debug.h | 97 +++++++++++++++++++++++++++++++++++++++ lib-lib/file.c | 3 +- lib-mime/rfc822parse.c | 2 +- lib-network/mutt_socket.c | 2 +- lib-network/mutt_ssl.c | 2 +- lib-ui/color.c | 11 ++--- lib-ui/curs_lib.c | 29 ++++++------ lib-ui/curs_main.c | 19 ++++---- lib.c | 2 +- lib/Makefile.am | 5 +- lib/debug.c | 76 ------------------------------ lib/debug.h | 73 ----------------------------- main.c | 19 ++++---- mbox.c | 21 ++++----- mh.c | 33 +++++++------ mutt_idna.c | 3 +- mutt_sasl.c | 16 +++---- muttlib.c | 27 ++++++----- mx.c | 24 +++++----- nntp/newsrc.c | 17 ++++--- nntp/nntp.c | 2 +- pager.c | 18 ++++---- pop/pop.c | 9 ++-- pop/pop_auth.c | 2 +- pop/pop_lib.c | 11 ++--- postpone.c | 13 +++--- query.c | 11 ++--- rfc1524.c | 21 ++++----- rfc3676.c | 3 +- send.c | 27 ++++++----- sendlib.c | 25 +++++----- state.c | 4 +- 65 files changed, 450 insertions(+), 436 deletions(-) create mode 100644 lib-lib/debug.c create mode 100644 lib-lib/debug.h delete mode 100644 lib/debug.c delete mode 100644 lib/debug.h diff --git a/alias.c b/alias.c index e8f109b..cf4dc5e 100644 --- a/alias.c +++ b/alias.c @@ -20,13 +20,13 @@ #include #include #include +#include #include #include #include #include "lib/rx.h" -#include "lib/debug.h" #include "mutt.h" #include "mutt_idna.h" diff --git a/attach.c b/attach.c index 3fbe7d2..67f2aa4 100644 --- a/attach.c +++ b/attach.c @@ -12,11 +12,21 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include +#include #include @@ -33,17 +43,6 @@ #include "mx.h" #include -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include - int mutt_get_tmp_attachment (BODY * a) { char type[STRING]; diff --git a/commands.c b/commands.c index b1ae870..3ad59c8 100644 --- a/commands.c +++ b/commands.c @@ -12,10 +12,20 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include @@ -42,17 +52,6 @@ #include "buffy.h" #endif -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include - /* The folder the user last saved to. Used by ci_save_message() */ static char LastSaveFolder[_POSIX_PATH_MAX] = ""; diff --git a/complete.c b/complete.c index 5e66da8..b9d1088 100644 --- a/complete.c +++ b/complete.c @@ -11,6 +11,16 @@ # include "config.h" #endif +#include +#include +#include +#include +#include + +#include +#include +#include + #include "mutt.h" #include "mx.h" #include @@ -18,16 +28,6 @@ #include "nntp.h" #endif -#include -#include -#include "lib/debug.h" - -#include -#include -#include -#include -#include - /* given a partial pathname, this routine fills in as much of the rest of the * path as is unique. * diff --git a/compress.c b/compress.c index dcf6143..fd8b97d 100644 --- a/compress.c +++ b/compress.c @@ -7,10 +7,16 @@ * please see the file GPL in the top level source directory. */ +#include +#include +#include +#include + #include #include #include #include +#include #include @@ -19,13 +25,6 @@ #include "mx.h" #include "mbox.h" -#include "lib/debug.h" - -#include -#include -#include -#include - typedef struct { const char *close; /* close-hook command */ const char *open; /* open-hook command */ diff --git a/copy.c b/copy.c index 97b73c0..2c653e1 100644 --- a/copy.c +++ b/copy.c @@ -11,11 +11,17 @@ # include "config.h" #endif +#include +#include +#include +#include + #include #include #include #include #include +#include #include @@ -26,13 +32,6 @@ #include #include "mutt_idna.h" -#include "lib/debug.h" - -#include -#include -#include -#include /* needed for SEEK_SET under SunOS 4.1.4 */ - static int address_header_decode (char **str); static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout, char *date); diff --git a/from.c b/from.c index 64686fc..eafdfe6 100644 --- a/from.c +++ b/from.c @@ -11,17 +11,16 @@ # include "config.h" #endif +#include +#include + #include #include #include +#include #include "mutt.h" -#include "lib/debug.h" - -#include -#include - static const char *next_word(const char *s) { while (*s && !ISSPACE(*s)) diff --git a/handler.c b/handler.c index a2b3e9d..1c5d6fa 100644 --- a/handler.c +++ b/handler.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -41,7 +42,6 @@ #include "attach.h" #include "lib.h" -#include "lib/debug.h" typedef int handler_f (BODY *, STATE *); typedef handler_f *handler_t; diff --git a/hcache.c b/hcache.c index e089bf1..af044b9 100644 --- a/hcache.c +++ b/hcache.c @@ -42,6 +42,7 @@ #include #include +#include #include @@ -50,8 +51,6 @@ #include "mx.h" #include "lib.h" -#include "lib/debug.h" - static struct header_cache { #if defined(HAVE_QDBM) VILLA *db; diff --git a/headers.c b/headers.c index e4709ac..ecb5756 100644 --- a/headers.c +++ b/headers.c @@ -11,20 +11,19 @@ # include "config.h" #endif +#include +#include +#include + #include #include #include +#include #include "mutt.h" #include #include "mutt_idna.h" -#include "lib/debug.h" - -#include -#include -#include - void mutt_edit_headers (const char *editor, const char *body, HEADER * msg, char *fcc, size_t fcclen) diff --git a/imap/auth.c b/imap/auth.c index 04fe671..74aee4c 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -16,10 +16,10 @@ #endif #include +#include #include #include -#include "lib/debug.h" #include "mutt.h" #include "imap_private.h" diff --git a/imap/auth_anon.c b/imap/auth_anon.c index 2c5b3fa..7c2dfba 100644 --- a/imap/auth_anon.c +++ b/imap/auth_anon.c @@ -18,7 +18,7 @@ #include "auth.h" #include -#include "lib/debug.h" +#include /* this is basically a stripped-down version of the cram-md5 method. */ imap_auth_res_t imap_auth_anon (IMAP_DATA * idata, const char *method) diff --git a/imap/auth_cram.c b/imap/auth_cram.c index 14772b0..0438a82 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -21,8 +21,8 @@ #define MD5_DIGEST_LEN 16 #include +#include #include -#include "lib/debug.h" /* forward declarations */ static void hmac_md5 (const char *password, char *challenge, diff --git a/imap/auth_gss.c b/imap/auth_gss.c index ff51d89..197a18e 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -18,7 +18,7 @@ #include "auth.h" #include -#include "lib/debug.h" +#include #include diff --git a/imap/auth_login.c b/imap/auth_login.c index 27e2156..a6b78dc 100644 --- a/imap/auth_login.c +++ b/imap/auth_login.c @@ -14,7 +14,7 @@ #endif #include -#include "lib/debug.h" +#include #include "mutt.h" #include "imap_private.h" diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 4d9df26..b8b1e3c 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -22,7 +22,7 @@ #include "auth.h" #include -#include "lib/debug.h" +#include #include #include diff --git a/imap/browse.c b/imap/browse.c index 03586bc..65f94f2 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -21,10 +21,10 @@ #include #include #include +#include #include -#include "lib/debug.h" #include "mutt.h" #include "imap_private.h" diff --git a/imap/command.c b/imap/command.c index af4c2b2..6968334 100644 --- a/imap/command.c +++ b/imap/command.c @@ -19,8 +19,8 @@ #include #include #include +#include -#include "lib/debug.h" #include "mutt.h" #include "message.h" diff --git a/imap/imap.c b/imap/imap.c index 005c15f..48f1dc4 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "mutt.h" #include "mx.h" @@ -33,7 +34,6 @@ #include "buffy.h" #include -#include "lib/debug.h" #include #include diff --git a/imap/message.c b/imap/message.c index 525f008..ba49cd1 100644 --- a/imap/message.c +++ b/imap/message.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -36,7 +37,6 @@ #include #include -#include "lib/debug.h" #if HAVE_STDINT_H #include diff --git a/imap/util.c b/imap/util.c index 8c294d2..6088321 100644 --- a/imap/util.c +++ b/imap/util.c @@ -23,7 +23,7 @@ #include #include -#include "lib/debug.h" +#include #include #include diff --git a/init.c b/init.c index ce6054e..d7eef24 100644 --- a/init.c +++ b/init.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -46,7 +47,6 @@ #include "lib/rx.h" #include "lib/list.h" -#include "lib/debug.h" #include #include diff --git a/init.h b/init.h index d76776e..1c93283 100644 --- a/init.h +++ b/init.h @@ -17,10 +17,11 @@ # include "sort.h" #endif +#include + #include "buffy.h" #include "mutt.h" #include "version.h" -#include "lib/debug.h" #ifndef _MAKEDOC #define DT_MASK 0x0f diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index f20d052..8d8fb96 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -38,7 +39,6 @@ #include "recvattach.h" #include "sort.h" -#include "lib/debug.h" #include #include diff --git a/lib-crypt/gnupgparse.c b/lib-crypt/gnupgparse.c index dff28ca..6b3a7d9 100644 --- a/lib-crypt/gnupgparse.c +++ b/lib-crypt/gnupgparse.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -43,7 +44,6 @@ #include "pgp.h" #include "charset.h" -#include "lib/debug.h" /**************** * Read the GNUPG keys. For now we read the complete keyring by diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index b69bc9b..e90943d 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "mutt.h" #include "handler.h" @@ -39,7 +40,6 @@ #include "copy.h" #include "attach.h" -#include "lib/debug.h" #include #include diff --git a/lib-crypt/pgpinvoke.c b/lib-crypt/pgpinvoke.c index 0314412..f5d45e9 100644 --- a/lib-crypt/pgpinvoke.c +++ b/lib-crypt/pgpinvoke.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -38,7 +39,6 @@ #include "mutt_idna.h" #include "pgp.h" -#include "lib/debug.h" /* * The actual command line formatter. diff --git a/lib-crypt/pgpkey.c b/lib-crypt/pgpkey.c index b8ceda5..ae3e49b 100644 --- a/lib-crypt/pgpkey.c +++ b/lib-crypt/pgpkey.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -30,7 +31,6 @@ #include "pager.h" #include "sort.h" -#include "lib/debug.h" #include #include diff --git a/lib-crypt/pgpmicalg.c b/lib-crypt/pgpmicalg.c index 1c322be..959ac36 100644 --- a/lib-crypt/pgpmicalg.c +++ b/lib-crypt/pgpmicalg.c @@ -27,11 +27,10 @@ #include #include +#include #include -#include "lib/debug.h" - static struct { short id; const char *name; diff --git a/lib-crypt/smime.c b/lib-crypt/smime.c index 78d360d..5c4cf77 100644 --- a/lib-crypt/smime.c +++ b/lib-crypt/smime.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -28,7 +29,6 @@ #include "handler.h" #include "copy.h" -#include "lib/debug.h" #include #include diff --git a/lib-lib/Makefile.am b/lib-lib/Makefile.am index 716d64b..dd9b5b8 100644 --- a/lib-lib/Makefile.am +++ b/lib-lib/Makefile.am @@ -3,8 +3,8 @@ noinst_LIBRARIES = liblib.a liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h \ str.c ascii.c buffer.c hash.c list.c file.c mapping.c \ \ - date.h \ - date.c + date.h debug.h \ + date.c debug.c noinst_HEADERS = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h \ date.c diff --git a/lib-lib/buffer.c b/lib-lib/buffer.c index 47e58ba..6feb958 100644 --- a/lib-lib/buffer.c +++ b/lib-lib/buffer.c @@ -35,8 +35,7 @@ #include "ascii.h" #include "buffer.h" #include "file.h" - -#include "lib/debug.h" +#include "debug.h" #include "mutt.h" diff --git a/lib-lib/debug.c b/lib-lib/debug.c new file mode 100644 index 0000000..bdf8b0c --- /dev/null +++ b/lib-lib/debug.c @@ -0,0 +1,95 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ +/* + * written for mutt-ng by: + * Rocco Rutte + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#if DEBUG + +#include +#include +#include + +#include "str.h" +#include "file.h" +#include "debug.h" + +#include "mutt.h" +#include "globals.h" + +short DebugLevel = -1; +FILE* DebugFile = NULL; + +void debug_setlevel(short level) { + DebugLevel = level; +} + +void debug_start(const char* basedir) { + time_t t; + int i; + char buf[_POSIX_PATH_MAX]; + char buf2[_POSIX_PATH_MAX]; + + if (DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL + || !basedir || !*basedir) + return; + /* rotate the old debug logs */ + for (i = 3; i >= 0; i--) { + snprintf(buf, sizeof (buf), "%s/.madmuttdebug%d", NONULL(basedir), i); + snprintf(buf2, sizeof (buf2), "%s/.madmuttdebug%d", NONULL(basedir), i + 1); + rename (buf, buf2); + } + + if ((DebugFile = safe_fopen (buf, "w")) != NULL) { + t = time (NULL); + setbuf(DebugFile, NULL); /* don't buffer the debugging output! */ + fprintf(DebugFile, + "Madmutt %s started at %s\nDebugging at level %d\n\n", + MUTT_VERSION, asctime (localtime (&t)), DebugLevel); + } +} + +void _debug_print_intro(const char* file, int line, const char *function, int level) { + if (!DebugFile || DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL) + return; + fprintf(DebugFile, "[%d:%s:%d", level, NONULL(file), line); + if (function && *function) + fprintf(DebugFile, ":%s()", function); + fprintf(DebugFile, "] "); +} + +void _debug_print_msg (const char* fmt, ...) { + va_list ap; + + if (!DebugFile || DebugLevel < 0) + return; + va_start(ap, fmt); + vfprintf(DebugFile, fmt, ap); + va_end(ap); +} + +#endif /* DEBUG */ diff --git a/lib-lib/debug.h b/lib-lib/debug.h new file mode 100644 index 0000000..ece3823 --- /dev/null +++ b/lib-lib/debug.h @@ -0,0 +1,97 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Copyright © 2006 Pierre Habouzit + */ +/* + * written for mutt-ng by: + * Rocco Rutte + * + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. + */ + +/* generic interface for debug messages */ + +#ifndef _LIB_DEBUG_H +#define _LIB_DEBUG_H + +#include + +#define DEBUG_MIN_LEVEL 1 +#define DEBUG_MIN_LEVEL_S "1" +#define DEBUG_MAX_LEVEL 5 +#define DEBUG_MAX_LEVEL_S "5" + +#ifdef DEBUG + +extern short DebugLevel; +extern FILE* DebugFile; + +void debug_setlevel (short); +void debug_start (const char*); + +void _debug_print_intro (const char*, int, const char*, int); +void _debug_print_msg (const char*, ...); + +/* + * the debug_print() macro will (in the end) print debug messages of the + * following format: + * + * (file:line:function:level): message + * + * for GCC and: + * + * (file:line:level): message + * + * otherwise + */ +#ifdef __GNUC__ + +#define debug_print(level,msg) \ + do { \ + if (DebugLevel >= level) { \ + _debug_print_intro (__FILE__,__LINE__,__func__,level); \ + _debug_print_msg msg; \ + } \ + } while(0) + +#else /* __GNUC__ */ + +#define debug_print(level,msg) \ + do { \ + if (DebugLevel >= level) { \ + _debug_print_intro (__FILE__,__LINE__,NULL,level); \ + _debug_print_msg msg; \ + } \ + } while(0) + +#endif /* !__GNUC__ */ + +#else /* DEBUG */ + +/* + * without debug support, we don't need these + * (this also kills the dozens of #ifdef for debug... + */ +#define debug_start(basedir) +#define debug_setlevel(level) +#define debug_print(level,msg) + +#endif /* !DEBUG */ + +#endif /* !_LIB_DEBUG_H */ diff --git a/lib-lib/file.c b/lib-lib/file.c index 7809db3..22bb68c 100644 --- a/lib-lib/file.c +++ b/lib-lib/file.c @@ -37,8 +37,7 @@ #include "mem.h" #include "str.h" #include "file.h" - -#include "../lib/debug.h" +#include "debug.h" #ifndef O_NOFOLLOW # define O_NOFOLLOW 0 diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index 35df8d1..732a046 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -38,11 +38,11 @@ #include #include #include +#include #include "recvattach.h" #include "url.h" -#include "lib/debug.h" #include "mime.h" diff --git a/lib-network/mutt_socket.c b/lib-network/mutt_socket.c index 664f61f..e3874d1 100644 --- a/lib-network/mutt_socket.c +++ b/lib-network/mutt_socket.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "mutt.h" #include "globals.h" @@ -27,7 +28,6 @@ #include "mutt_idna.h" -#include "lib/debug.h" #include #include diff --git a/lib-network/mutt_ssl.c b/lib-network/mutt_ssl.c index 315ba52..b247377 100644 --- a/lib-network/mutt_ssl.c +++ b/lib-network/mutt_ssl.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,6 @@ #include "mutt_socket.h" #include "mutt_ssl.h" -#include "lib/debug.h" #if OPENSSL_VERSION_NUMBER >= 0x00904000L #define READ_X509_KEY(fp, key) PEM_read_X509(fp, key, NULL, NULL) diff --git a/lib-ui/color.c b/lib-ui/color.c index 20fb8b0..2f286f4 100644 --- a/lib-ui/color.c +++ b/lib-ui/color.c @@ -11,23 +11,22 @@ # include "config.h" #endif +#include +#include +#include + #include #include #include #include #include #include +#include #include "curses.h" #include "mutt.h" -#include "lib/debug.h" - -#include -#include -#include - /* globals */ int *ColorQuote; int ColorQuoteUsed; diff --git a/lib-ui/curs_lib.c b/lib-ui/curs_lib.c index 2eb7415..318ee85 100644 --- a/lib-ui/curs_lib.c +++ b/lib-ui/curs_lib.c @@ -15,21 +15,6 @@ # include "config.h" #endif -#include -#include -#include -#include - -#include "curses.h" -#include "menu.h" -#include "enter.h" - -#include "mutt.h" -#include "pager.h" -#include "mbyte.h" - -#include "lib/debug.h" - #include #include #include @@ -44,6 +29,20 @@ #include #endif +#include +#include +#include +#include +#include + +#include "curses.h" +#include "menu.h" +#include "enter.h" + +#include "mutt.h" +#include "pager.h" +#include "mbyte.h" + /* not possible to unget more than one char under some curses libs, and it * is impossible to unget function keys in SLang, so roll our own input * buffering routines. diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 1d2be6d..0fd125a 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -14,10 +14,19 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include @@ -46,16 +55,6 @@ #include "mutt_sasl.h" #endif -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include - static const char *No_mailbox_is_open = N_("No mailbox is open."); static const char *There_are_no_messages = N_("There are no messages."); static const char *Mailbox_is_read_only = N_("Mailbox is read-only."); diff --git a/lib.c b/lib.c index 33d377f..2d0ec11 100644 --- a/lib.c +++ b/lib.c @@ -37,10 +37,10 @@ #include #include #include +#include #include "lib.h" -#include "lib/debug.h" static struct sysexits { diff --git a/lib/Makefile.am b/lib/Makefile.am index 775d21e..e76c232 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,9 +5,8 @@ AR=@AR@ AUTOMAKE_OPTIONS = foreign noinst_LIBRARIES = libsane.a -noinst_HEADERS = list.h rx.h debug.h +noinst_HEADERS = list.h rx.h -libsane_a_SOURCES = list.c rx.h debug.h \ - list.h rx.c debug.c +libsane_a_SOURCES = list.c rx.h list.h rx.c -include ../cflags.mk diff --git a/lib/debug.c b/lib/debug.c deleted file mode 100644 index 4d4d393..0000000 --- a/lib/debug.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * written for mutt-ng by: - * Rocco Rutte - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#if DEBUG - -#include -#include -#include - -#include -#include -#include "debug.h" - -#include "mutt.h" -#include "globals.h" - -short DebugLevel = -1; -FILE* DebugFile = NULL; - -void debug_setlevel (short level) { - DebugLevel = level; -} - -void debug_start (const char* basedir) { - time_t t; - int i; - char buf[_POSIX_PATH_MAX]; - char buf2[_POSIX_PATH_MAX]; - - if (DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL - || !basedir || !*basedir) - return; - /* rotate the old debug logs */ - for (i = 3; i >= 0; i--) { - snprintf (buf, sizeof (buf), "%s/.madmuttdebug%d", NONULL (basedir), i); - snprintf (buf2, sizeof (buf2), "%s/.madmuttdebug%d", NONULL (basedir), i + 1); - rename (buf, buf2); - } - if ((DebugFile = safe_fopen (buf, "w")) != NULL) { - t = time (NULL); - setbuf (DebugFile, NULL); /* don't buffer the debugging output! */ - fprintf (DebugFile, - "Madmutt %s started at %s\nDebugging at level %d\n\n", - MUTT_VERSION, asctime (localtime (&t)), DebugLevel); - } -} - -void _debug_print_intro (const char* file, int line, const char* function, int level) { - if (!DebugFile || DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL) - return; - fprintf (DebugFile, "[%d:%s:%d", level, NONULL(file), line); - if (function && *function) - fprintf (DebugFile, ":%s()", function); - fprintf (DebugFile, "] "); -} - -void _debug_print_msg (const char* fmt, ...) { - va_list ap; - - if (!DebugFile || DebugLevel < 0) - return; - va_start (ap, fmt); - vfprintf (DebugFile, fmt, ap); - va_end (ap); -} - -#endif /* DEBUG */ diff --git a/lib/debug.h b/lib/debug.h deleted file mode 100644 index 61a1411..0000000 --- a/lib/debug.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * written for mutt-ng by: - * Rocco Rutte - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ - -/* generic interface for debug messages */ - -#ifndef _LIB_DEBUG_H -#define _LIB_DEBUG_H - -#include - -#define DEBUG_MIN_LEVEL 1 -#define DEBUG_MIN_LEVEL_S "1" -#define DEBUG_MAX_LEVEL 5 -#define DEBUG_MAX_LEVEL_S "5" - -#ifdef DEBUG - -extern short DebugLevel; -extern FILE* DebugFile; - -void debug_setlevel (short); -void debug_start (const char*); - -void _debug_print_intro (const char*, int, const char*, int); -void _debug_print_msg (const char*, ...); - -/* - * the debug_print() macro will (in the end) print debug messages of the - * following format: - * - * (file:line:function:level): message - * - * for GCC and: - * - * (file:line:level): message - * - * otherwise - */ -#ifdef __GNUC__ -#define debug_print(level,msg) do { \ - if (DebugLevel >= level) { \ - _debug_print_intro (__FILE__,__LINE__,__FUNCTION__,level); \ - _debug_print_msg msg; \ - } \ -} while(0) -#else /* __GNUC__ */ -#define debug_print(level,msg) do { \ - if (DebugLevel >= level) { \ - _debug_print_intro (__FILE__,__LINE__,NULL,level); \ - _debug_print_msg msg; \ - } \ -} while(0) -#endif /* !__GNUC__ */ - -#else /* DEBUG */ - -/* - * without debug support, we don't need these - * (this also kills the dozens of #ifdef for debug... - */ -#define debug_start(basedir) -#define debug_setlevel(level) -#define debug_print(level,msg) - -#endif /* !DEBUG */ - -#endif /* !_LIB_DEBUG_H */ diff --git a/main.c b/main.c index 4ea396f..29197df 100644 --- a/main.c +++ b/main.c @@ -19,10 +19,19 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include @@ -36,16 +45,6 @@ #include "mutt_idna.h" #include "xterm.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include - #ifdef HAVE_GETOPT_H #include #else diff --git a/mbox.c b/mbox.c index 267cd7b..d4d3a08 100644 --- a/mbox.c +++ b/mbox.c @@ -13,10 +13,20 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include "mutt.h" #include "mx.h" @@ -27,17 +37,6 @@ #include "copy.h" #include "compress.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include - /* struct used by mutt_sync_mailbox() to store new offsets */ struct m_update_t { short valid; diff --git a/mh.c b/mh.c index f108bf9..5a68171 100644 --- a/mh.c +++ b/mh.c @@ -17,23 +17,6 @@ # include "config.h" #endif -#include -#include -#include -#include - -#include "mutt.h" -#include "mx.h" -#include "mh.h" -#include "mbox.h" -#include "copy.h" -#include "buffy.h" -#include "sort.h" -#include "thread.h" -#include "hcache.h" - -#include "lib/debug.h" - #include #include #include @@ -52,6 +35,22 @@ #include #endif +#include +#include +#include +#include +#include + +#include "mutt.h" +#include "mx.h" +#include "mh.h" +#include "mbox.h" +#include "copy.h" +#include "buffy.h" +#include "sort.h" +#include "thread.h" +#include "hcache.h" + struct maildir { HEADER *h; char *canon_fname; diff --git a/mutt_idna.c b/mutt_idna.c index 1419dd9..bab9f8f 100644 --- a/mutt_idna.c +++ b/mutt_idna.c @@ -15,13 +15,12 @@ #include #include #include +#include #include "mutt.h" #include "charset.h" #include "mutt_idna.h" -#include "lib/debug.h" - /* The low-level interface we use. */ #ifndef HAVE_LIBIDN diff --git a/mutt_sasl.c b/mutt_sasl.c index d5738b6..bb91271 100644 --- a/mutt_sasl.c +++ b/mutt_sasl.c @@ -13,22 +13,20 @@ # include "config.h" #endif +#include +#include +#include +#include +#include + #include +#include #include "mutt.h" #include "account.h" #include "mutt_sasl.h" #include -#include "lib/debug.h" - -#include -#include -#include - -#include -#include - static int getnameinfo_err (int ret) { int err; diff --git a/muttlib.c b/muttlib.c index c8339ef..f901549 100644 --- a/muttlib.c +++ b/muttlib.c @@ -12,12 +12,25 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include #include +#include #include @@ -36,20 +49,6 @@ #include -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #define SW (option(OPTMBOXPANE)?SidebarWidth:0) BODY *mutt_new_body (void) diff --git a/mx.c b/mx.c index a63b28f..5f18ac1 100644 --- a/mx.c +++ b/mx.c @@ -12,11 +12,23 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include +#include #include @@ -51,18 +63,6 @@ #include #include "lib/list.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include static list2_t* MailboxFormats = NULL; #define MX_COMMAND(idx,cmd) ((mx_t*) MailboxFormats->data[idx])->cmd diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 40160c1..97703d7 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -13,10 +13,18 @@ #include #endif +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include @@ -28,15 +36,6 @@ #include "nntp.h" #include "rfc1524.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include - void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d) { LIST *l; diff --git a/nntp/nntp.c b/nntp/nntp.c index 00ba407..159d2e1 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -33,7 +34,6 @@ #include -#include "lib/debug.h" #include #include diff --git a/pager.c b/pager.c index 044d2dc..f0d366d 100644 --- a/pager.c +++ b/pager.c @@ -15,10 +15,19 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include +#include #include #include @@ -41,15 +50,6 @@ #include #include "lib/rx.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include #define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT) diff --git a/pop/pop.c b/pop/pop.c index 999d3b1..572c79e 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -11,10 +11,14 @@ # include "config.h" #endif +#include +#include + #include #include #include #include +#include #include @@ -23,11 +27,6 @@ #include "pop.h" #include -#include "lib/debug.h" - -#include -#include - /* write line to file */ static int fetch_message (char *line, void *file) { diff --git a/pop/pop_auth.c b/pop/pop_auth.c index fdea7c3..adb47d7 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -15,12 +15,12 @@ #include #include #include +#include #include "mutt.h" #include "mx.h" #include "pop.h" -#include "lib/debug.h" #include #include diff --git a/pop/pop_lib.c b/pop/pop_lib.c index e462a6a..a8dfe5c 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -11,10 +11,15 @@ # include "config.h" #endif +#include +#include +#include + #include #include #include #include +#include #include "mutt.h" #include "mx.h" @@ -24,12 +29,6 @@ # include #endif -#include "lib/debug.h" - -#include -#include -#include - /* given an POP mailbox name, return host, port, username and password */ int pop_parse_path (const char *path, ACCOUNT * acct) { diff --git a/postpone.c b/postpone.c index 311ea28..945a704 100644 --- a/postpone.c +++ b/postpone.c @@ -12,12 +12,18 @@ # include "config.h" #endif +#include +#include +#include +#include + #include #include #include #include #include #include +#include #include @@ -35,13 +41,6 @@ #include #include -#include "lib/debug.h" - -#include -#include -#include -#include - static struct mapping_t PostponeHelp[] = { {N_("Exit"), OP_EXIT}, {N_("Del"), OP_DELETE}, diff --git a/query.c b/query.c index 5509aac..c3fe53c 100644 --- a/query.c +++ b/query.c @@ -11,11 +11,16 @@ # include "config.h" #endif +#include +#include +#include + #include #include #include #include #include +#include #include @@ -23,12 +28,6 @@ #include "mutt_idna.h" #include "sort.h" -#include "lib/debug.h" - -#include -#include -#include - typedef struct query { address_t *addr; char *name; diff --git a/rfc1524.c b/rfc1524.c index 9b745b4..cd089fc 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -21,27 +21,26 @@ # include "config.h" #endif +#include +#include +#include + +#include +#include +#include +#include + #include #include #include #include #include +#include #include "mutt.h" #include "rfc1524.h" #include "attach.h" -#include "lib/debug.h" - -#include -#include -#include - -#include -#include -#include -#include - /* The command semantics include the following: * %s is the filename that contains the mail body data * %t is the content type, like text/plain diff --git a/rfc3676.c b/rfc3676.c index f1cd2e3..d578190 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -33,8 +34,6 @@ #include "state.h" #include "lib.h" -#include "lib/debug.h" - #define FLOWED_MAX 77 static int get_quote_level (char *line) diff --git a/send.c b/send.c index 613be76..2cf6550 100644 --- a/send.c +++ b/send.c @@ -11,11 +11,24 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include +#include #include @@ -32,20 +45,6 @@ #include "url.h" #include "attach.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef USE_NNTP #include "nntp.h" #endif diff --git a/sendlib.c b/sendlib.c index 8aad968..2afe601 100644 --- a/sendlib.c +++ b/sendlib.c @@ -13,11 +13,23 @@ # include "config.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include +#include #include @@ -33,19 +45,6 @@ #include #include "mutt_idna.h" -#include "lib/debug.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef USE_LIBESMTP # include "mutt_libesmtp.h" #endif /* USE_LIBESMTP */ diff --git a/state.c b/state.c index 656f816..c4e2997 100644 --- a/state.c +++ b/state.c @@ -13,12 +13,12 @@ #include #include +#include + #include "mutt.h" #include "state.h" #include "rfc3676.h" -#include "lib/debug.h" - static void state_prefix_put (const char *d, size_t dlen, STATE * s) { if (s->prefix) -- 2.20.1