Commit 10b6c2cc 10b6c2ccdcc056a8584ad0ada471cfaba38cec13 by Sergey Poznyakoff

Introduce "global debug settings". Mailutils objects are supposed

to set their default mu_debug_t objects basing on these settings.

* include/mailutils/Makefile.am: Add debug.hin. Build debug.h from
it.
* include/mailutils/debug.hm4: New file.
* include/mailutils/debug.h: Remove generated file.
* scripts/Makefile.am (EXTRA_DIST): Add debugdef.m4
* scripts/debugdef.m4: New file.

* include/mailutils/gocs.h (struct mu_gocs_debug): New data type.
(mu_gocs_register_std): Argument is const.
(mu_gocs_debug_init): New function.
* include/mailutils/libargp.h (mu_debug_cmdline): New extern.
* include/mailutils/libcfg.h (mu_debug_cfg_capa): New extern.
* libargp/cmdline.c: Add mu_debug_cmdline
* libargp/common.c: Add debug settings.
* libargp/mu_argp.c (struct cap_buf.capa): Remove const qualifier.
* libcfg/common.c (mu_locking_param): Remove superfluous `lock-'
prefix from the statement names.
(mu_debug_param): New parameter group.
* libcfg/init.c: Add mu_debug_param.
* mailbox/gocs.c (mu_gocs_debug_init): New function.

* mailbox/Makefile.am (libmailutils_la_SOURCES): Add gdebug.c
* mailbox/gdebug.c: New file
* mailbox/debug.c (mu_debug_printf, mu_debug_vprintf)
(mu_debug_check_level): New functions.
(mu_debug_printv, mu_debug_print): Rewrite using new basic calls.

* comsat/comsat.c, dotlock/dotlock.c, examples/muauth.c,
mail.remote/mail.remote.c: Add debug capability.
* frm/frm.c, frm/from.c, guimb/main.c, imap4d/imap4d.c,
mail/mail.c, mail.local/main.c, messages/messages.c,
pop3d/pop3d.c, readmsg/readmsg.c: Add locking and debug capabilities.

* examples/mimetest.c, examples/msg-send.c, frm/common.c,
libargp/auth.c, libmu_scm/mu_message.c, mail/send.c, mh/send.c,
mimeview/mimeview.c, movemail/movemail.c, sieve/sieve.c: Update
invocation of mu_debug_set_level.

* libproto/imap/folder.c, libproto/imap/mbox.c,
libproto/include/folder0.h, libproto/include/mailbox0.h,
libproto/include/mailer0.h, libproto/mailer/sendmail.c,
libproto/mailer/smtp.c, libproto/mbox/mbox.c,
libproto/nntp/folder.c, libproto/nntp/nntp_debug.c,
libproto/pop/mbox.c, libproto/pop/pop3_debug.c, mailbox/amd.c,
mailbox/mailer.c, mailbox/message.c, mailbox/mu_auth.c: Use
MU_DEBUG[0-9] for debugging.

* mailbox/muerror.c: Include string.h
* mailbox/syslog.c (syslog_to_n): Remove unused variable.
* mailbox/assoc.c (struct _mu_assoc_elem): name is not const.
* mailbox/cfg_lexer.c: Quoted strings can be continued to the
following line either by using a trailing backslash or by
concatenating strings together, as in C.
* mailbox/mailbox.c (_create_mailbox): Initialize debug object
using global "mailbox" level.
(mu_mailbox_create): Fix bug introduced on 2007-11-26.

* include/mailutils/libsieve.h (mu_sieve_set_debug_level): Change
prototype.
(mu_sieve_set_debug_object): New prototype.
* libsieve/sieve.y (mu_sieve_machine_init): Initialize debug
object from "sieve" global level.
(mu_sieve_set_debug_level): Set only debug_level.
(mu_sieve_set_debug_object): New function.

* maidag/maidag.c: Remove explicit setting of debug object. Add
"debug" group, which provides the required functionality.
(set_debug_flags): Likewise. This function and the corresponding
command line option are fading out in favor of global debug
settings.
1 parent 61c80aef
2007-11-28 Sergey Poznyakoff <gray@gnu.org.ua>
Introduce "global debug settings". Mailutils objects are supposed
to set their default mu_debug_t objects basing on these settings.
* include/mailutils/Makefile.am: Add debug.hin. Build debug.h from
it.
* include/mailutils/debug.hm4: New file.
* include/mailutils/debug.h: Remove generated file.
* scripts/Makefile.am (EXTRA_DIST): Add debugdef.m4
* scripts/debugdef.m4: New file.
* include/mailutils/gocs.h (struct mu_gocs_debug): New data type.
(mu_gocs_register_std): Argument is const.
(mu_gocs_debug_init): New function.
* include/mailutils/libargp.h (mu_debug_cmdline): New extern.
* include/mailutils/libcfg.h (mu_debug_cfg_capa): New extern.
* libargp/cmdline.c: Add mu_debug_cmdline
* libargp/common.c: Add debug settings.
* libargp/mu_argp.c (struct cap_buf.capa): Remove const qualifier.
* libcfg/common.c (mu_locking_param): Remove superfluous `lock-'
prefix from the statement names.
(mu_debug_param): New parameter group.
* libcfg/init.c: Add mu_debug_param.
* mailbox/gocs.c (mu_gocs_debug_init): New function.
* mailbox/Makefile.am (libmailutils_la_SOURCES): Add gdebug.c
* mailbox/gdebug.c: New file
* mailbox/debug.c (mu_debug_printf, mu_debug_vprintf)
(mu_debug_check_level): New functions.
(mu_debug_printv, mu_debug_print): Rewrite using new basic calls.
* comsat/comsat.c, dotlock/dotlock.c, examples/muauth.c,
mail.remote/mail.remote.c: Add debug capability.
* frm/frm.c, frm/from.c, guimb/main.c, imap4d/imap4d.c,
mail/mail.c, mail.local/main.c, messages/messages.c,
pop3d/pop3d.c, readmsg/readmsg.c: Add locking and debug capabilities.
* examples/mimetest.c, examples/msg-send.c, frm/common.c,
libargp/auth.c, libmu_scm/mu_message.c, mail/send.c, mh/send.c,
mimeview/mimeview.c, movemail/movemail.c, sieve/sieve.c: Update
invocation of mu_debug_set_level.
* libproto/imap/folder.c, libproto/imap/mbox.c,
libproto/include/folder0.h, libproto/include/mailbox0.h,
libproto/include/mailer0.h, libproto/mailer/sendmail.c,
libproto/mailer/smtp.c, libproto/mbox/mbox.c,
libproto/nntp/folder.c, libproto/nntp/nntp_debug.c,
libproto/pop/mbox.c, libproto/pop/pop3_debug.c, mailbox/amd.c,
mailbox/mailer.c, mailbox/message.c, mailbox/mu_auth.c: Use
MU_DEBUG[0-9] for debugging.
* mailbox/muerror.c: Include string.h
* mailbox/syslog.c (syslog_to_n): Remove unused variable.
* mailbox/assoc.c (struct _mu_assoc_elem): name is not const.
* mailbox/cfg_lexer.c: Quoted strings can be continued to the
following line either by using a trailing backslash or by
concatenating strings together, as in C.
* mailbox/mailbox.c (_create_mailbox): Initialize debug object
using global "mailbox" level.
(mu_mailbox_create): Fix bug introduced on 2007-11-26.
* include/mailutils/libsieve.h (mu_sieve_set_debug_level): Change
prototype.
(mu_sieve_set_debug_object): New prototype.
* libsieve/sieve.y (mu_sieve_machine_init): Initialize debug
object from "sieve" global level.
(mu_sieve_set_debug_level): Set only debug_level.
(mu_sieve_set_debug_object): New function.
* maidag/maidag.c: Remove explicit setting of debug object. Add
"debug" group, which provides the required functionality.
(set_debug_flags): Likewise. This function and the corresponding
command line option are fading out in favor of global debug
settings.
2007-11-26 Sergey Poznyakoff <gray@gnu.org.ua>
* configure.ac (MU_APP_LIBRARIES): Load libmuaux after libmuargp
......
......@@ -77,8 +77,10 @@ static struct argp argp = {
static const char *comsat_argp_capa[] = {
"daemon",
"common",
"debug",
"logging",
"mailbox",
"locking",
"license",
NULL
};
......
......@@ -134,6 +134,7 @@ struct mu_cfg_param dotlock_cfg_param[] = {
const char *dotlock_capa[] = {
"license",
"common",
"debug",
NULL
};
......
......@@ -100,7 +100,7 @@ main (int argc, char **argv)
{
mu_debug_t debug;
mu_mailbox_get_debug (mbox, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
/* Open the mailbox for reading only. */
......
......@@ -121,7 +121,7 @@ main (int argc, char *argv[])
{
mu_debug_t debug;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
C (mu_mailer_open (mailer, 0));
......
......@@ -36,6 +36,7 @@ static const char *capa[] = {
"auth",
"license",
"common",
"debug",
NULL
};
......
......@@ -554,7 +554,7 @@ frm_scan (char *mailbox_name, frm_select_t fun, size_t *total)
{
mu_debug_t debug;
mu_mailbox_get_debug (mbox, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
mu_mailbox_get_url (mbox, &url);
......
......@@ -218,6 +218,8 @@ static const char *frm_argp_capa[] = {
"common",
"license",
"mailbox",
"locking",
"debug",
NULL
};
......
......@@ -71,8 +71,10 @@ static struct argp argp = {
static const char *capa[] = {
"common",
"debug",
"license",
"mailbox",
"locking",
#ifdef WITH_TLS
"tls",
#endif
......
......@@ -139,7 +139,9 @@ static struct argp argp = {
static const char *guimb_argp_capa[] = {
"common",
"debug",
"mailbox",
"locking",
"license",
NULL
};
......
......@@ -89,7 +89,9 @@ static const char *imap4d_capa[] = {
"daemon",
"auth",
"common",
"debug",
"mailbox",
"locking",
"logging",
"license",
NULL
......
......@@ -18,11 +18,14 @@
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
BUILT_SOURCES=errno.h
EXTRA_DIST=errno.hin types.hin
BUILT_SOURCES=errno.h debug.h
EXTRA_DIST=errno.hin debug.hm4 types.hin
errno.h: $(top_srcdir)/mailbox/errors errno.hin
$(AWK) -f $(top_srcdir)/scripts/generr.awk $^ > $@
debug.h: $(top_srcdir)/scripts/debugdef.m4 debug.hm4
m4 $(top_srcdir)/scripts/debugdef.m4 debug.hm4 > debug.h
types.h: $(top_srcdir)/include/mailutils/types.hin Makefile
sed 's/MU_OFF_TYPE/$(MU_OFF_TYPE)/' $(top_srcdir)/include/mailutils/types.hin > $@
DISTCLEANFILES = types.h
......
/* GNU Mailutils -- a suite of utilities for electronic mail
/* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*-
Copyright (C) 1999, 2000, 2005, 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
......@@ -23,24 +23,50 @@
#include <mailutils/types.h>
#define MU_DEBUG(d,l,s) MU_DEBUG1(d,l,"%s",s)
#ifdef __cplusplus
extern "C" {
#endif
#define MU_DEBUG_ERROR 0x0001
#define MU_DEBUG_TRACE 0x0002
#define MU_DEBUG_PROT 0x0004
#define MU_DEBUG_ERROR 0
#define MU_DEBUG_TRACE0 1
#define MU_DEBUG_TRACE MU_DEBUG_TRACE0
#define MU_DEBUG_TRACE1 2
#define MU_DEBUG_TRACE2 3
#define MU_DEBUG_TRACE3 4
#define MU_DEBUG_TRACE4 5
#define MU_DEBUG_TRACE5 6
#define MU_DEBUG_TRACE6 7
#define MU_DEBUG_TRACE7 8
#define MU_DEBUG_PROT 9
#define MU_DEBUG_LEVEL_MASK(lev) (1 << (lev))
#define MU_DEBUG_LEVEL_UPTO(lev) ((1 << ((lev)+1)) - 1)
extern int mu_debug_create (mu_debug_t *, void *owner);
extern void mu_debug_destroy (mu_debug_t *, void *owner);
extern void * mu_debug_get_owner (mu_debug_t);
extern int mu_debug_set_level (mu_debug_t, size_t level);
extern int mu_debug_get_level (mu_debug_t, size_t *plevel);
extern int mu_debug_print (mu_debug_t debug, size_t level,
const char *format, ...) MU_PRINTFLIKE(3,4);
extern int mu_debug_printv (mu_debug_t debug, size_t level,
const char *format, va_list argp);
#define MU_DEBUG_INHERIT 0xf0000
#define MU_DEBUG_EXTRACT_LEVEL(s) ((s) & ~MU_DEBUG_INHERIT)
int mu_debug_create (mu_debug_t *, void *owner);
void mu_debug_destroy (mu_debug_t *, void *owner);
void *mu_debug_get_owner (mu_debug_t);
int mu_debug_set_level (mu_debug_t, size_t level);
int mu_debug_get_level (mu_debug_t, size_t *plevel);
int mu_debug_print (mu_debug_t debug, size_t level,
const char *format, ...) MU_PRINTFLIKE(3,4);
int mu_debug_printv (mu_debug_t debug, size_t level,
const char *format, va_list ap);
int mu_debug_check_level (mu_debug_t debug, size_t level);
int mu_debug_printf (mu_debug_t debug, size_t level, const char *format, ...)
MU_PRINTFLIKE(3,4);
int mu_debug_vprintf (mu_debug_t debug, size_t level, const char *format,
va_list ap);
extern int mu_debug_line_info;
typedef int (*mu_debug_printer_fp) (mu_debug_t, size_t level, const char *buf);
extern int mu_debug_set_print (mu_debug_t,
......@@ -50,7 +76,14 @@ extern mu_debug_printer_fp mu_debug_default_printer;
int mu_debug_syslog_printer (mu_debug_t, size_t, const char *);
int mu_debug_stderr_printer (mu_debug_t, size_t, const char *);
unsigned mu_global_debug_level (const char *object_name);
int mu_global_debug_set_level (const char *object_name, unsigned level);
int mu_global_debug_clear_level (const char *object_name);
int mu_global_debug_from_string (const char *string, const char *errpfx);
forloop(`i',1,11,`MKDEBUG(i)')
#ifdef __cplusplus
}
#endif
......
......@@ -41,7 +41,14 @@ struct mu_gocs_logging
int facility;
char *tag;
};
struct mu_gocs_debug
{
char *string;
char *errpfx;
int line_info;
};
struct mu_gocs_mailbox
{
char *mail_spool;
......@@ -84,7 +91,7 @@ extern int log_facility; /* FIXME: 1. Belongs elsewhere;
typedef int (*gocs_init_fp) (void *data);
void mu_gocs_register (char *capa, gocs_init_fp init);
void mu_gocs_register_std (char *name);
void mu_gocs_register_std (const char *name);
void mu_gocs_store (char *capa, void *data);
void mu_gocs_flush (void);
int mu_gocs_enumerate (mu_list_action_t action, void *data);
......@@ -95,7 +102,8 @@ int mu_gocs_daemon_init (void *data);
int mu_gocs_source_email_init (void *data);
int mu_gocs_mailer_init (void *data);
int mu_gocs_logging_init (void *data);
int mu_gocs_debug_init (void *data);
#ifdef __cplusplus
}
#endif
......
......@@ -51,6 +51,7 @@ extern struct mu_cmdline_capa mu_address_cmdline;
extern struct mu_cmdline_capa mu_mailer_cmdline;
extern struct mu_cmdline_capa mu_daemon_cmdline;
extern struct mu_cmdline_capa mu_sieve_cmdline;
extern struct mu_cmdline_capa mu_debug_cmdline;
extern struct mu_cmdline_capa mu_pam_cmdline;
extern struct mu_cmdline_capa mu_gsasl_cmdline;
......
......@@ -86,6 +86,7 @@ extern struct mu_cfg_capa mu_locking_cfg_capa;
extern struct mu_cfg_capa mu_address_cfg_capa;
extern struct mu_cfg_capa mu_mailer_cfg_capa;
extern struct mu_cfg_capa mu_logging_cfg_capa;
extern struct mu_cfg_capa mu_debug_cfg_capa;
extern struct mu_cfg_capa mu_gsasl_cfg_capa;
extern struct mu_cfg_capa mu_pam_cfg_capa;
extern struct mu_cfg_capa mu_radius_cfg_capa;
......
......@@ -227,8 +227,8 @@ void mu_sieve_set_error (mu_sieve_machine_t mach,
void mu_sieve_set_parse_error (mu_sieve_machine_t mach,
mu_sieve_parse_error_t p);
void mu_sieve_set_debug (mu_sieve_machine_t mach, mu_sieve_printf_t debug);
void mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg,
int level);
void mu_sieve_set_debug_object (mu_sieve_machine_t mach, mu_debug_t dbg);
void mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level);
void mu_sieve_set_logger (mu_sieve_machine_t mach,
mu_sieve_action_log_t logger);
void mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket);
......
......@@ -71,7 +71,7 @@ auth_set_debug ()
mu_debug_t debug = NULL, prev;
mu_debug_create (&debug, NULL);
mu_debug_set_level (debug, MU_DEBUG_TRACE);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_TRACE7));
prev = mu_auth_set_debug (debug);
if (prev)
mu_debug_destroy (&prev, mu_debug_get_owner (prev));
......
......@@ -30,6 +30,7 @@ static struct mu_cmdline_capa *all_cmdline_capa[] = {
&mu_address_cmdline,
&mu_mailer_cmdline,
&mu_daemon_cmdline,
&mu_debug_cmdline,
&mu_pam_cmdline,
&mu_gsasl_cmdline,
&mu_tls_cmdline,
......
......@@ -30,6 +30,7 @@ static struct mu_gocs_logging logging_settings;
static struct mu_gocs_mailbox mailbox_settings;
static struct mu_gocs_source_email source_email_settings;
static struct mu_gocs_mailer mailer_settings;
static struct mu_gocs_debug debug_settings;
void
......@@ -75,7 +76,9 @@ enum {
OPT_LOCK_EXPIRE_TIMEOUT,
OPT_LOCK_EXTERNAL_PROGRAM,
OPT_LICENSE,
OPT_MAILBOX_TYPE
OPT_MAILBOX_TYPE,
OPT_DEBUG_LEVEL,
OPT_LINE_INFO
};
static struct argp_option mu_common_argp_options[] =
......@@ -485,41 +488,51 @@ static struct argp_option mu_daemon_argp_option[] = {
static error_t
mu_daemon_argp_parser (int key, char *arg, struct argp_state *state)
{
static int options_given = 0;
switch (key)
{
case 'd':
options_given = 1;
daemon_settings.mode = MODE_DAEMON;
if (arg)
daemon_settings.maxchildren = strtoul (arg, NULL, 10);
break;
case 'i':
options_given = 1;
daemon_settings.mode = MODE_INTERACTIVE;
break;
case 'p':
options_given = 1;
daemon_settings.mode = MODE_DAEMON;
daemon_settings.port = strtoul (arg, NULL, 10); /*FIXME: overflow */
break;
case 'P':
options_given = 1;
assign_string (&daemon_settings.pidfile, arg);
break;
case 't':
options_given = 1;
daemon_settings.timeout = strtoul (arg, NULL, 10);
break;
case 'x':
options_given = 1;
daemon_settings.transcript = 1;
break;
case ARGP_KEY_INIT:
options_given = 0;
daemon_settings = mu_gocs_daemon;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("daemon", &daemon_settings);
if (options_given)
mu_gocs_store ("daemon", &daemon_settings);
break;
default:
......@@ -544,3 +557,56 @@ struct mu_cmdline_capa mu_daemon_cmdline = {
"daemon", &mu_daemon_argp_child
};
static struct argp_option mu_debug_argp_options[] =
{
{ "debug-level", OPT_DEBUG_LEVEL, N_("LEVEL"), 0,
N_("Set Mailutils debugging level"), 0 },
{ "debug-line-info", OPT_LINE_INFO, NULL, 0,
N_("Show source info with debugging messages"), 0 },
{ NULL }
};
static error_t
mu_debug_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_DEBUG_LEVEL:
debug_settings.string = arg;
debug_settings.errpfx = strdup ("command line");
break;
case OPT_LINE_INFO:
debug_settings.line_info = 1;
break;
case ARGP_KEY_INIT:
debug_settings.line_info = -1;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("debug", &debug_settings);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
struct argp mu_debug_argp = {
mu_debug_argp_options,
mu_debug_argp_parser,
};
struct argp_child mu_debug_argp_child = {
&mu_debug_argp,
0,
N_("Global debugging settings"),
0
};
struct mu_cmdline_capa mu_debug_cmdline = {
"debug", &mu_debug_argp_child
};
......
......@@ -139,7 +139,7 @@ mu_build_argp (const struct argp *template, const char *capa[])
struct cap_buf
{
const char **capa;
char **capa;
size_t numcapa;
size_t maxcapa;
};
......
......@@ -18,9 +18,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mailutils/libcfg.h"
#include <stdlib.h>
#include <string.h>
#include "mailutils/libcfg.h"
#include <mailutils/daemon.h>
#include <mailutils/debug.h>
#include <mailutils/syslog.h>
#include <mu_umaxtostr.h>
static struct mu_gocs_daemon daemon_settings;
static struct mu_gocs_locking locking_settings;
......@@ -28,6 +32,7 @@ static struct mu_gocs_logging logging_settings;
static struct mu_gocs_mailbox mailbox_settings;
static struct mu_gocs_source_email address_settings;
static struct mu_gocs_mailer mailer_settings;
static struct mu_gocs_debug debug_settings;
/* ************************************************************************* */
......@@ -48,11 +53,10 @@ DCL_CFG_CAPA (mailbox);
/* ************************************************************************* */
static struct mu_cfg_param mu_locking_param[] = {
{ "lock-flags", mu_cfg_string, &locking_settings.lock_flags },
{ "lock-retry-timeout", mu_cfg_ulong, &locking_settings.lock_retry_timeout },
{ "lock-retry-count", mu_cfg_ulong, &locking_settings.lock_retry_count },
{ "lock-expire-timeout", mu_cfg_ulong,
&locking_settings.lock_expire_timeout },
{ "flags", mu_cfg_string, &locking_settings.lock_flags },
{ "retry-timeout", mu_cfg_ulong, &locking_settings.lock_retry_timeout },
{ "retry-count", mu_cfg_ulong, &locking_settings.lock_retry_count },
{ "expire-timeout", mu_cfg_ulong, &locking_settings.lock_expire_timeout },
{ "external-locker", mu_cfg_string, &locking_settings.external_locker },
{ NULL, }
};
......@@ -160,3 +164,39 @@ struct mu_cfg_capa mu_daemon_cfg_capa = {
"daemon", mu_daemon_param, mu_daemon_section_parser
};
/* ************************************************************************* */
/* Debug */
/* ************************************************************************* */
static int
cb_debug_level (mu_cfg_locus_t *locus, void *data, char *arg)
{
char buf[UINTMAX_STRSIZE_BOUND];
char *p;
size_t size;
char *pfx;
debug_settings.string = arg;
p = umaxtostr (locus->line, buf);
size = strlen (locus->file) + 1 + strlen (p) + 1;
pfx = malloc (size);
if (!pfx)
{
mu_error ("%s", mu_strerror (errno));
return 1;
}
strcpy (pfx, locus->file);
strcat (pfx, ":");
strcat (pfx, p);
debug_settings.errpfx = pfx;
return 0;
}
static struct mu_cfg_param mu_debug_param[] = {
{ "level", mu_cfg_callback, NULL, &cb_debug_level },
{ "line-info", mu_cfg_bool, &debug_settings.line_info },
{ NULL }
};
DCL_CFG_CAPA (debug);
......
......@@ -39,6 +39,7 @@ struct mu_cfg_capa *cfg_capa_table[] = {
S (sieve),
S (daemon),
S (ldap),
S (debug),
NULL
};
......
......@@ -1004,7 +1004,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0,
{
mu_debug_t debug = NULL;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
status = mu_mailer_open (mailer, MU_STREAM_RDWR);
......
......@@ -169,7 +169,7 @@ authenticate_imap_login (mu_authority_t auth)
if (check_capa (f_imap, "LOGINDISABLED") == 0)
{
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, "LOGIN command disabled\n");
MU_DEBUG (folder->debug, MU_DEBUG_TRACE, "LOGIN command disabled\n");
return ENOSYS;
}
......@@ -205,9 +205,9 @@ authenticate_imap_login (mu_authority_t auth)
status = imap_writeline (f_imap, "g%u LOGIN \"%s\" \"%s\"\r\n",
f_imap->seq, f_imap->user, f_imap->passwd);
CHECK_ERROR_CLOSE(folder, f_imap, status);
FOLDER_DEBUG2 (folder, MU_DEBUG_PROT, "g%u LOGIN %s *\n",
f_imap->seq, f_imap->user);
CHECK_ERROR_CLOSE (folder, f_imap, status);
MU_DEBUG2 (folder->debug, MU_DEBUG_TRACE, "g%u LOGIN %s *\n",
f_imap->seq, f_imap->user);
f_imap->seq++;
free (f_imap->user);
f_imap->user = NULL;
......@@ -231,7 +231,7 @@ authenticate_imap_login (mu_authority_t auth)
status = imap_parse (f_imap);
if (status)
return status;
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_AUTH_DONE;
default:
......@@ -295,8 +295,8 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
if (check_capa (f_imap, "AUTH=ANONYMOUS"))
{
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT,
"ANONYMOUS capability not present\n");
MU_DEBUG (folder->debug, MU_DEBUG_PROT,
"ANONYMOUS capability not present\n");
return ENOSYS;
}
......@@ -305,8 +305,9 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
{
case IMAP_AUTH_ANON_REQ_WRITE:
{
FOLDER_DEBUG1 (folder, MU_DEBUG_PROT, "g%u AUTHENTICATE ANONYMOUS\n",
f_imap->seq);
MU_DEBUG1 (folder->debug, MU_DEBUG_PROT,
"g%u AUTHENTICATE ANONYMOUS\n",
f_imap->seq);
status = imap_writeline (f_imap, "g%u AUTHENTICATE ANONYMOUS\r\n",
f_imap->seq);
f_imap->seq++;
......@@ -322,7 +323,7 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
case IMAP_AUTH_ANON_WAIT_CONT:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
if (strncmp ("+", f_imap->buffer, 2) == 0)
{
f_imap->auth_state = IMAP_AUTH_ANON_MSG;
......@@ -334,7 +335,7 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
f_imap->auth_state = IMAP_AUTH_ANON_MSG;
case IMAP_AUTH_ANON_MSG:
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, "\n");
MU_DEBUG (folder->debug, MU_DEBUG_PROT, "\n");
status = imap_writeline (f_imap, "\r\n");
CHECK_ERROR_CLOSE (folder, f_imap, status);
f_imap->auth_state = IMAP_AUTH_ANON_MSG_SEND;
......@@ -348,7 +349,7 @@ authenticate_imap_sasl_anon (mu_authority_t auth)
case IMAP_AUTH_ANON_WAIT_RESP:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break; /* We're outta here. */
......@@ -560,7 +561,7 @@ imap_reader (void *iodata)
f_imap_t iop = iodata;
int status = imap_parse (iop);
CHECK_EAGAIN (iop, status);
FOLDER_DEBUG0 (iop->folder, MU_DEBUG_PROT, iop->buffer);
MU_DEBUG (iop->folder->debug, MU_DEBUG_PROT, iop->buffer);
return status;
}
......@@ -568,8 +569,8 @@ static int
imap_writer (void *iodata, char *buf)
{
f_imap_t iop = iodata;
FOLDER_DEBUG2 (iop->folder, MU_DEBUG_PROT, "g%s %s\n",
mu_umaxtostr (0, iop->seq), buf);
MU_DEBUG2 (iop->folder->debug, MU_DEBUG_PROT, "g%s %s\n",
mu_umaxtostr (0, iop->seq), buf);
int status = imap_writeline (iop, "g%s %s\r\n",
mu_umaxtostr (0, iop->seq++), buf);
CHECK_ERROR (iop, status);
......@@ -602,8 +603,8 @@ tls (mu_folder_t folder)
status = mu_tls_begin (f_imap, imap_reader, imap_writer,
imap_stream_ctl, keywords);
FOLDER_DEBUG1 (folder, MU_DEBUG_PROT, "TLS negotiation %s\n",
status == 0 ? "succeeded" : "failed");
MU_DEBUG1 (folder->debug, MU_DEBUG_PROT, "TLS negotiation %s\n",
status == 0 ? "succeeded" : "failed");
return status;
#else
return -1;
......@@ -696,8 +697,8 @@ folder_imap_open (mu_folder_t folder, int flags)
}
else
mu_stream_close (folder->stream);
FOLDER_DEBUG2 (folder, MU_DEBUG_PROT, "imap_open (%s:%ld)\n",
host, port);
MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "imap_open (%s:%ld)\n",
host, port);
f_imap->state = IMAP_OPEN_CONNECTION;
case IMAP_OPEN_CONNECTION:
......@@ -714,7 +715,7 @@ folder_imap_open (mu_folder_t folder, int flags)
status = imap_readline (f_imap);
CHECK_EAGAIN (f_imap, status);
f_imap->ptr = f_imap->buffer;
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
/* Are they open for business ? The server send an untagged response
for greeting. Tecnically it can be OK/PREAUTH/BYE. The BYE is
the one that we do not want, server being unfriendly. */
......@@ -783,7 +784,7 @@ folder_imap_close (mu_folder_t folder)
case IMAP_NO_STATE:
status = imap_writeline (f_imap, "g%u LOGOUT\r\n", f_imap->seq++);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_LOGOUT;
case IMAP_LOGOUT:
......@@ -795,7 +796,7 @@ folder_imap_close (mu_folder_t folder)
/* Check for "* Bye" from the imap server. */
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
/* This is done when we received the BYE in the parser code. */
/* mu_stream_close (folder->stream); */
/* f_imap->isopen = 0 ; */
......@@ -828,7 +829,7 @@ folder_imap_delete (mu_folder_t folder, const char *name)
status = imap_writeline (f_imap, "g%u DELETE %s\r\n", f_imap->seq++,
name);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_DELETE;
case IMAP_DELETE:
......@@ -839,7 +840,7 @@ folder_imap_delete (mu_folder_t folder, const char *name)
case IMAP_DELETE_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -999,7 +1000,7 @@ folder_imap_list (mu_folder_t folder, const char *ref, const char *name,
f_imap->seq++, ref, path);
free (path);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_LIST;
case IMAP_LIST:
......@@ -1010,7 +1011,7 @@ folder_imap_list (mu_folder_t folder, const char *ref, const char *name,
case IMAP_LIST_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -1046,7 +1047,7 @@ folder_imap_lsub (mu_folder_t folder, const char *ref, const char *name,
status = imap_writeline (f_imap, "g%u LSUB \"%s\" \"%s\"\r\n",
f_imap->seq++, ref, name);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_LSUB;
case IMAP_LSUB:
......@@ -1057,7 +1058,7 @@ folder_imap_lsub (mu_folder_t folder, const char *ref, const char *name,
case IMAP_LSUB_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -1091,7 +1092,7 @@ folder_imap_rename (mu_folder_t folder, const char *oldpath,
status = imap_writeline (f_imap, "g%u RENAME %s %s\r\n",
f_imap->seq++, oldpath, newpath);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_RENAME;
case IMAP_RENAME:
......@@ -1102,7 +1103,7 @@ folder_imap_rename (mu_folder_t folder, const char *oldpath,
case IMAP_RENAME_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -1129,7 +1130,7 @@ folder_imap_subscribe (mu_folder_t folder, const char *name)
status = imap_writeline (f_imap, "g%u SUBSCRIBE %s\r\n",
f_imap->seq++, name);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_SUBSCRIBE;
case IMAP_SUBSCRIBE:
......@@ -1140,7 +1141,7 @@ folder_imap_subscribe (mu_folder_t folder, const char *name)
case IMAP_SUBSCRIBE_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -1167,7 +1168,7 @@ folder_imap_unsubscribe (mu_folder_t folder, const char *name)
status = imap_writeline (f_imap, "g%u UNSUBSCRIBE %s\r\n",
f_imap->seq++, name);
CHECK_ERROR (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_UNSUBSCRIBE;
case IMAP_UNSUBSCRIBE:
......@@ -1178,7 +1179,7 @@ folder_imap_unsubscribe (mu_folder_t folder, const char *name)
case IMAP_UNSUBSCRIBE_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (folder->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -2305,8 +2306,8 @@ imap_parse (f_imap_t f_imap)
/* Is the response untagged ? */
else if (tag[0] == '*')
{
FOLDER_DEBUG2(folder, MU_DEBUG_PROT, "* %s %s\n",
response, remainder);
MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "* %s %s\n",
response, remainder);
/* Is it a Status Response. */
if (strcasecmp (response, "OK") == 0)
{
......
......@@ -317,8 +317,8 @@ mailbox_imap_open (mu_mailbox_t mailbox, int flags)
return status;
status = imap_writeline (f_imap, "g%u CREATE %s\r\n",
f_imap->seq, path);
MAILBOX_DEBUG2 (folder, MU_DEBUG_PROT, "g%u CREATE %s\n",
f_imap->seq, path);
MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "g%u CREATE %s\n",
f_imap->seq, path);
f_imap->seq++;
if (status != 0)
{
......@@ -396,7 +396,7 @@ mailbox_imap_close (mu_mailbox_t mailbox)
status = imap_writeline (f_imap, "g%s CLOSE\r\n",
mu_umaxtostr (0, f_imap->seq++));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_CLOSE;
case IMAP_CLOSE:
......@@ -409,7 +409,7 @@ mailbox_imap_close (mu_mailbox_t mailbox)
size_t i;
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
mu_monitor_wrlock (mailbox->monitor);
/* Destroy the imap messages and ressources associated to them. */
......@@ -687,7 +687,7 @@ imap_messages_count (mu_mailbox_t mailbox, size_t *pnum)
MBX_WRITABLE(mailbox) ? "SELECT" : "EXAMINE",
m_imap->name);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_SELECT;
case IMAP_SELECT:
......@@ -698,7 +698,7 @@ imap_messages_count (mu_mailbox_t mailbox, size_t *pnum)
case IMAP_SELECT_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
break;
default:
......@@ -755,7 +755,7 @@ imap_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t *pcount, int notif)
mu_umaxtostr (0, f_imap->seq++),
MU_IMAP_CACHE_HEADERS);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_SCAN;
case IMAP_SCAN:
......@@ -772,7 +772,7 @@ imap_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t *pcount, int notif)
case IMAP_SCAN_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
/* Clear the callback string structure. */
mu_stream_truncate (f_imap->string.stream, 0);
f_imap->string.offset = 0;
......@@ -830,7 +830,7 @@ imap_is_updated (mu_mailbox_t mailbox)
status = imap_writeline (f_imap, "g%s NOOP\r\n",
mu_umaxtostr (0, f_imap->seq++));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_NOOP;
case IMAP_NOOP:
......@@ -841,7 +841,7 @@ imap_is_updated (mu_mailbox_t mailbox)
case IMAP_NOOP_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
break;
default:
......@@ -887,7 +887,7 @@ imap_expunge (mu_mailbox_t mailbox)
set);
free (set);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_STORE;
}
......@@ -900,7 +900,7 @@ imap_expunge (mu_mailbox_t mailbox)
case IMAP_STORE_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_NO_STATE;
case IMAP_EXPUNGE:
......@@ -1036,7 +1036,7 @@ imap_append_message0 (mu_mailbox_t mailbox, mu_message_t msg)
mu_umaxtostr (1, size + lines));
free (abuf);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_APPEND;
}
......@@ -1048,7 +1048,7 @@ imap_append_message0 (mu_mailbox_t mailbox, mu_message_t msg)
case IMAP_APPEND_CONT:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
/* If we did not receive the continuation token, it is an error
bail out. */
if (f_imap->buffer[0] != '+')
......@@ -1089,7 +1089,7 @@ imap_append_message0 (mu_mailbox_t mailbox, mu_message_t msg)
case IMAP_APPEND_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
/* mu_error ("imap_append: unknown state\n"); */
......@@ -1129,7 +1129,7 @@ imap_copy_message (mu_mailbox_t mailbox, mu_message_t msg)
mu_umaxtostr (1, msg_imap->num),
path);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_COPY;
}
......@@ -1141,7 +1141,7 @@ imap_copy_message (mu_mailbox_t mailbox, mu_message_t msg)
case IMAP_COPY_ACK:
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
MAILBOX_DEBUG0 (mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
default:
break;
......@@ -1205,7 +1205,7 @@ imap_message_read (mu_stream_t stream, char *buffer, size_t buflen,
if (section)
free (section);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, buffer, buflen, plen);
......@@ -1287,7 +1287,7 @@ imap_message_size (mu_message_t msg, size_t *psize)
mu_umaxtostr (0, f_imap->seq++),
mu_umaxtostr (1, msg_imap->num));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, 0, 0, 0);
......@@ -1328,7 +1328,7 @@ imap_message_uid (mu_message_t msg, size_t *puid)
mu_umaxtostr (0, f_imap->seq++),
mu_umaxtostr (1, msg_imap->num));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, 0, 0, 0);
......@@ -1373,7 +1373,7 @@ imap_is_multipart (mu_message_t msg, int *ismulti)
mu_umaxtostr (0, f_imap->seq++),
mu_umaxtostr (1, msg_imap->num));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, 0, 0, 0);
......@@ -1512,7 +1512,7 @@ imap_envelope_date (mu_envelope_t envelope, char *buffer, size_t buflen,
mu_umaxtostr (0, f_imap->seq++),
mu_umaxtostr (1, msg_imap->num));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, datebuf,
......@@ -1583,7 +1583,7 @@ imap_attr_get_flags (mu_attribute_t attribute, int *pflags)
mu_umaxtostr (0, f_imap->seq++),
mu_umaxtostr (1, msg_imap->num));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = fetch_operation (f_imap, msg_imap, NULL, 0, NULL);
......@@ -1641,7 +1641,7 @@ imap_attr_set_flags (mu_attribute_t attribute, int flag)
abuf);
free (abuf);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
msg_imap->flags |= flag;
f_imap->state = IMAP_FETCH;
}
......@@ -1690,7 +1690,7 @@ imap_attr_unset_flags (mu_attribute_t attribute, int flag)
abuf);
free (abuf);
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
msg_imap->flags &= ~flag;
f_imap->state = IMAP_FETCH;
}
......@@ -1760,7 +1760,7 @@ imap_header_read (mu_header_t header, char *buffer,
msg_imap->header_lines),
mu_umaxtostr (3, buflen));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
......@@ -1875,7 +1875,7 @@ imap_body_read (mu_stream_t stream, char *buffer, size_t buflen,
msg_imap->body_lines),
mu_umaxtostr (3, buflen));
CHECK_ERROR (f_imap, status);
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
MU_DEBUG (m_imap->mailbox->debug, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
......@@ -1931,8 +1931,8 @@ fetch_operation (f_imap_t f_imap, msg_imap_t msg_imap, char *buffer,
status = imap_parse (f_imap);
CHECK_EAGAIN (f_imap, status);
if (f_imap->selected)
MAILBOX_DEBUG0 (f_imap->selected->mailbox, MU_DEBUG_PROT,
f_imap->buffer);
MU_DEBUG (f_imap->selected->mailbox->debug, MU_DEBUG_PROT,
f_imap->buffer);
default:
break;
......
......@@ -66,18 +66,6 @@ struct _mu_folder
int (*_unsubscribe) (mu_folder_t, const char *);
};
/* Moro(?)ic kluge. */
#define FOLDER_DEBUG0(folder, type, format) \
if (folder->debug) mu_debug_print (folder->debug, type, format)
#define FOLDER_DEBUG1(folder, type, format, arg1) \
if (folder->debug) mu_debug_print (folder->debug, type, format, arg1)
#define FOLDER_DEBUG2(folder, type, format, arg1, arg2) \
if (folder->debug) mu_debug_print (folder->debug, type, format, arg1, arg2)
#define FOLDER_DEBUG3(folder, type, format, arg1, arg2, arg3) \
if (folder->debug) mu_debug_print (folder->debug, type, format, arg1, arg2, arg3)
#define FOLDER_DEBUG4(folder, type, format, arg1, arg2, arg3, arg4) \
if (folder->debug) mu_debug_print (folder->debug, type, format, arg1, arg2, arg3, arg4)
#ifdef __cplusplus
}
#endif
......
......@@ -76,18 +76,6 @@ struct _mu_mailbox
int (*_quick_get_message) (mu_mailbox_t, mu_message_qid_t, mu_message_t *);
};
/* Moro(?)ic kluge. */
#define MAILBOX_DEBUG0(mbox, type, format) \
if (mbox->debug) mu_debug_print (mbox->debug, type, format)
#define MAILBOX_DEBUG1(mbox, type, format, arg1) \
if (mbox->debug) mu_debug_print (mbox->debug, type, format, arg1)
#define MAILBOX_DEBUG2(mbox, type, format, arg1, arg2) \
if (mbox->debug) mu_debug_print (mbox->debug, type, format, arg1, arg2)
#define MAILBOX_DEBUG3(mbox, type, format, arg1, arg2, arg3) \
if (mbox->debug) mu_debug_print (mbox->debug, type, format, arg1, arg2, arg3)
#define MAILBOX_DEBUG4(mbox, type, format, arg1, arg2, arg3, arg4) \
if (mbox->debug) mu_debug_print (mbox->debug, type, format, arg1, arg2, arg3, arg4)
#ifdef __cplusplus
}
#endif
......
......@@ -60,20 +60,6 @@ struct _mu_mailer
#define MAILER_NOTIFY(mailer, type) \
if (mailer->observer) observer_notify (mailer->observer, type)
/* Moro(?)ic kluge. */
#define MAILER_DEBUGV(mailer, type, format, av) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format, av)
#define MAILER_DEBUG0(mailer, type, format) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format)
#define MAILER_DEBUG1(mailer, type, format, arg1) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format, arg1)
#define MAILER_DEBUG2(mailer, type, format, arg1, arg2) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format, arg1, arg2)
#define MAILER_DEBUG3(mailer, type, format, arg1, arg2, arg3) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format, arg1, arg2, arg3)
#define MAILER_DEBUG4(mailer, type, format, arg1, arg2, arg3, arg4) \
if (mailer->debug) mu_debug_print (mailer->debug, type, format, arg1, arg2, arg3, arg4)
#ifdef __cplusplus
}
#endif
......
......@@ -143,7 +143,7 @@ sendmail_open (mu_mailer_t mailer, int flags)
}
sendmail->path = path;
sendmail->state = SENDMAIL_OPEN;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE, "sendmail (%s)\n", sendmail->path);
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE, "sendmail (%s)\n", sendmail->path);
return 0;
}
......@@ -217,9 +217,9 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
/* the address wasn't fully qualified, choke (for now) */
status = EINVAL;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"envelope from (%s) not fully qualifed\n",
emailfrom);
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"envelope from (%s) not fully qualifed\n",
emailfrom);
goto OPEN_STATE_CLEANUP;
}
......@@ -278,9 +278,9 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
/* the address wasn't fully qualified, choke (for now) */
status = EINVAL;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"envelope to (%s) not fully qualifed\n",
email);
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"envelope to (%s) not fully qualifed\n",
email);
goto OPEN_STATE_CLEANUP;
}
......@@ -308,24 +308,22 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"vfork() failed: %s\n", strerror (status));
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"vfork() failed: %s\n", strerror (status));
}
}
else
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"pipe() failed: %s\n", strerror (status));
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"pipe() failed: %s\n", strerror (status));
}
OPEN_STATE_CLEANUP:
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "exec argv:");
MU_DEBUG (mailer->debug, MU_DEBUG_TRACE, "exec argv:");
for (argc = 0; argvec && argvec[argc]; argc++)
{
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE, " %s", argvec[argc]);
}
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "\n");
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE, " %s", argvec[argc]);
MU_DEBUG (mailer->debug, MU_DEBUG_TRACE, "\n");
free (argvec);
close (tunnel[0]);
......@@ -352,7 +350,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
mu_message_get_header (msg, &hdr);
mu_header_get_stream (hdr, &stream);
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending headers...\n");
MU_DEBUG (mailer->debug, MU_DEBUG_TRACE, "Sending headers...\n");
while ((status = mu_stream_readline (stream, buffer, sizeof (buffer),
offset, &len)) == 0
&& len != 0)
......@@ -360,13 +358,12 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
if (strncasecmp (buffer, MU_HEADER_FCC,
sizeof (MU_HEADER_FCC) - 1))
{
MAILER_DEBUG1 (mailer, MU_DEBUG_PROT,
"Header: %s", buffer);
MU_DEBUG1 (mailer->debug, MU_DEBUG_PROT, "Header: %s", buffer);
if (write (sendmail->fd, buffer, len) == -1)
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"write() failed: %s\n", strerror (status));
break;
......@@ -384,7 +381,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"write() failed: %s\n", strerror (status));
}
}
......@@ -392,7 +389,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
mu_message_get_body (msg, &body);
mu_body_get_stream (body, &stream);
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE, "Sending body...\n");
MU_DEBUG (mailer->debug, MU_DEBUG_TRACE, "Sending body...\n");
offset = 0;
while ((status = mu_stream_read (stream, buffer, sizeof (buffer),
offset, &len)) == 0
......@@ -402,7 +399,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
{
status = errno;
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"write() failed: %s\n", strerror (status));
break;
......@@ -424,7 +421,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
else
{
status = errno;
MAILER_DEBUG2 (mailer, MU_DEBUG_TRACE,
MU_DEBUG2 (mailer->debug, MU_DEBUG_TRACE,
"waitpid(%d) failed: %s\n",
sendmail->pid, strerror (status));
}
......@@ -432,7 +429,7 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
else if (WIFEXITED (exit_status))
{
exit_status = WEXITSTATUS (exit_status);
MAILER_DEBUG2 (mailer, MU_DEBUG_TRACE,
MU_DEBUG2 (mailer->debug, MU_DEBUG_TRACE,
"%s exited with: %d\n",
sendmail->path, exit_status);
status = (exit_status == 0) ? 0 : MU_ERR_PROCESS_EXITED;
......
......@@ -370,8 +370,9 @@ smtp_open (mu_mailer_t mailer, int flags)
smtp->state = SMTP_OPEN;
case SMTP_OPEN:
MAILER_DEBUG2 (mailer, MU_DEBUG_PROT, "smtp_open (host: %s port: %ld)\n",
smtp->mailhost, port);
MU_DEBUG2 (mailer->debug, MU_DEBUG_PROT,
"smtp_open (host: %s port: %ld)\n",
smtp->mailhost, port);
status = mu_stream_open (mailer->stream);
CHECK_EAGAIN (smtp, status);
smtp->state = SMTP_GREETINGS;
......@@ -536,8 +537,8 @@ smtp_starttls (smtp_t smtp)
status = mu_tls_begin (smtp, smtp_reader, smtp_writer,
smtp_stream_ctl, keywords);
MAILER_DEBUG1 (mailer, MU_DEBUG_PROT, "TLS negotiation %s\n",
status == 0 ? "succeeded" : "failed");
MU_DEBUG1 (mailer->debug, MU_DEBUG_PROT, "TLS negotiation %s\n",
status == 0 ? "succeeded" : "failed");
return status;
#else
......@@ -761,7 +762,7 @@ smtp_send_message (mu_mailer_t mailer, mu_message_t argmsg, mu_address_t argfrom
smtp->state = SMTP_SEND;
if ((smtp->mailer->flags & MAILER_FLAG_DEBUG_DATA) == 0)
MAILER_DEBUG0 (smtp->mailer, MU_DEBUG_PROT, "> (data...)\n");
MU_DEBUG (smtp->mailer->debug, MU_DEBUG_PROT, "> (data...)\n");
case SMTP_SEND:
{
......@@ -917,8 +918,8 @@ _smtp_set_rcpt (smtp_t smtp, mu_message_t msg, mu_address_t to)
/* Use the specified mu_address_t. */
if ((status = mu_mailer_check_to (to)) != 0)
{
MAILER_DEBUG0 (smtp->mailer, MU_DEBUG_ERROR,
"mu_mailer_send_message(): explicit to not valid\n");
MU_DEBUG (smtp->mailer->debug, MU_DEBUG_ERROR,
"mu_mailer_send_message(): explicit to not valid\n");
return status;
}
smtp->rcpt_to = to;
......@@ -1034,10 +1035,8 @@ smtp_writeline (smtp_t smtp, const char *format, ...)
if ((smtp->state != SMTP_SEND && smtp->state != SMTP_SEND_DOT)
|| smtp->mailer->flags & MAILER_FLAG_DEBUG_DATA)
{
MAILER_DEBUG2 (smtp->mailer, MU_DEBUG_PROT, "> %.*s\n", len,
smtp->buffer);
}
MU_DEBUG2 (smtp->mailer->debug, MU_DEBUG_PROT, "> %.*s\n", len,
smtp->buffer);
return 0;
}
......@@ -1161,7 +1160,7 @@ smtp_readline (smtp_t smtp)
smtp->ptr = smtp->nl;
}
MAILER_DEBUG1 (smtp->mailer, MU_DEBUG_PROT, "< %s", smtp->buffer);
MU_DEBUG1 (smtp->mailer->debug, MU_DEBUG_PROT, "< %s", smtp->buffer);
return 0;
}
......
......@@ -153,7 +153,7 @@ _mailbox_mbox_init (mu_mailbox_t mailbox)
mu_property_set_value (property, "TYPE", "MBOX", 1);
}
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "mbox_init (%s)\n", mud->name);
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_init (%s)\n", mud->name);
return 0; /* okdoke */
}
......@@ -165,7 +165,7 @@ mbox_destroy (mu_mailbox_t mailbox)
{
size_t i;
mbox_data_t mud = mailbox->data;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE,
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1,
"mbox_destroy (%s)\n", mud->name);
mu_monitor_wrlock (mailbox->monitor);
for (i = 0; i < mud->umessages_count; i++)
......@@ -242,8 +242,8 @@ mbox_open (mu_mailbox_t mailbox, int flags)
return status;
}
MAILBOX_DEBUG2 (mailbox, MU_DEBUG_TRACE, "mbox_open (%s, 0x%x)\n",
mud->name, mailbox->flags);
MU_DEBUG2 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_open (%s, 0x%x)\n",
mud->name, mailbox->flags);
if (mailbox->locker == NULL)
status = mu_locker_create (&(mailbox->locker), mud->name, 0);
......@@ -259,7 +259,7 @@ mbox_close (mu_mailbox_t mailbox)
if (mud == NULL)
return EINVAL;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "mbox_close (%s)\n", mud->name);
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_close (%s)\n", mud->name);
/* Make sure that we do not hold any file locking. */
mu_locker_unlock (mailbox->locker);
......@@ -305,7 +305,7 @@ mbox_scan (mu_mailbox_t mailbox, size_t msgno, size_t *pcount)
{
size_t i;
mbox_data_t mud = mailbox->data;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "mbox_scan (%s)\n", mud->name);
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_scan (%s)\n", mud->name);
if (! mbox_is_updated (mailbox))
return mbox_scan0 (mailbox, msgno, pcount, 1);
/* Since the mailbox is already updated fake the scan. */
......@@ -438,7 +438,7 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted)
if (mud == NULL)
return EINVAL;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "mbox_expunge (%s)\n", mud->name);
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_expunge (%s)\n", mud->name);
/* Noop. */
if (mud->messages_count == 0)
......@@ -1198,7 +1198,7 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
return 0;
}
MAILBOX_DEBUG2 (mailbox, MU_DEBUG_TRACE, "mbox_get_message (%s, %d)\n",
MU_DEBUG2 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_get_message (%s, %d)\n",
mud->name, msgno);
return new_message (mailbox, mum, pmsg);
......@@ -1270,7 +1270,7 @@ mbox_append_message (mu_mailbox_t mailbox, mu_message_t msg)
if (msg == NULL || mud == NULL)
return EINVAL;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "mbox_append_message (%s)\n",
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "mbox_append_message (%s)\n",
mud->name);
switch (mud->state)
......@@ -1278,7 +1278,7 @@ mbox_append_message (mu_mailbox_t mailbox, mu_message_t msg)
case MBOX_NO_STATE:
if ((status = mu_locker_lock (mailbox->locker)) != 0)
{
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE,
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1,
"mbox_append_message: %s\n",
mu_strerror(status));
return status;
......
......@@ -127,8 +127,8 @@ nntp_folder_open (mu_folder_t folder, int flags)
return status;
/* Ask for the stream internal buffering mechanism scheme. */
mu_stream_setbufsiz (carrier, BUFSIZ);
FOLDER_DEBUG2 (folder, MU_DEBUG_PROT, "folder_nntp_open (%s:%ld)\n",
host, port);
MU_DEBUG2 (folder->debug, MU_DEBUG_PROT, "folder_nntp_open (%s:%ld)\n",
host, port);
status = mu_nntp_create (&f_nntp->nntp);
if (status == 0)
......
......@@ -35,20 +35,17 @@ mu_nntp_set_debug (mu_nntp_t nntp, mu_debug_t debug)
return 0;
}
/* FIXME: should be a macro */
int
mu_nntp_debug_cmd (mu_nntp_t nntp)
{
if (nntp->debug)
mu_debug_print(nntp->debug, MU_DEBUG_PROT, "%s", nntp->io.buf);
MU_DEBUG (nntp->debug, MU_DEBUG_PROT, nntp->io.buf);
return 0;
}
int
mu_nntp_debug_ack (mu_nntp_t nntp)
{
if (nntp->debug)
{
mu_debug_print (nntp->debug, MU_DEBUG_PROT, "%s\n", nntp->ack.buf);
}
MU_DEBUG1 (nntp->debug, MU_DEBUG_PROT, "%s\n", nntp->ack.buf);
return 0;
}
......
......@@ -278,7 +278,8 @@ do \
mu_stream_close (mbox->stream); \
CLEAR_STATE (mpd); \
mpd->func = (void *)-1; \
MAILBOX_DEBUG1(mbox, MU_DEBUG_PROT, "CHECK_ERROR_CLOSE: %s\n", mu_strerror (status));\
MU_DEBUG1 (mbox->debug, MU_DEBUG_PROT, \
"CHECK_ERROR_CLOSE: %s\n", mu_strerror (status));\
return status; \
} \
} \
......@@ -292,7 +293,8 @@ do \
{ \
CLEAR_STATE (mpd); \
mpd->func = (void*)-1; \
MAILBOX_DEBUG1(mpd->mbox, MU_DEBUG_PROT, "CHECK_ERROR: %s\n", mu_strerror (status));\
MU_DEBUG1(mpd->mbox->debug, MU_DEBUG_PROT, \
"CHECK_ERROR: %s\n", mu_strerror (status));\
return status; \
} \
} \
......@@ -308,7 +310,8 @@ do \
{ \
CLEAR_STATE (mpd); \
mpd->func = (void *)-1; \
MAILBOX_DEBUG1(mpd->mbox, MU_DEBUG_PROT, "CHECK_EAGAIN: %s\n", mu_strerror (status));\
MU_DEBUG1(mpd->mbox->debug, MU_DEBUG_PROT, \
"CHECK_EAGAIN: %s\n", mu_strerror (status));\
} \
return status; \
} \
......@@ -423,7 +426,7 @@ pop_parse_capa (pop_data_t mpd)
do
{
status = pop_read_ack (mpd);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
/* Here we check some common capabilities like TOP, USER, UIDL,
and STLS. The rest are ignored. Please note that some
......@@ -463,7 +466,7 @@ pop_capa (mu_mailbox_t mbox)
status = pop_writeline (mpd, "CAPA\r\n");
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
status = pop_write (mpd);
CHECK_EAGAIN (mpd, status);
......@@ -472,7 +475,7 @@ pop_capa (mu_mailbox_t mbox)
/* POP_CAPA_ACK */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
return pop_parse_capa (mpd);
}
......@@ -496,13 +499,13 @@ _pop_user (mu_authority_t auth)
if (status != 0 || mpd->user == NULL || mpd->user[0] == '\0')
{
pop_writeline (mpd, "QUIT\r\n");
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
pop_write (mpd);
CHECK_ERROR_CLOSE (mbox, mpd, MU_ERR_NOUSERNAME);
}
status = pop_writeline (mpd, "USER %s\r\n", mpd->user);
CHECK_ERROR_CLOSE(mbox, mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
free (mpd->user);
mpd->user = NULL;
mpd->state = POP_AUTH_USER;
......@@ -517,7 +520,7 @@ _pop_user (mu_authority_t auth)
/* Get the user ack. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
mu_observable_t observable = NULL;
......@@ -530,12 +533,12 @@ _pop_user (mu_authority_t auth)
if (status != 0 || mpd->passwd == NULL || mpd->passwd[0] == '\0')
{
pop_writeline (mpd, "QUIT\r\n");
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
pop_write (mpd);
CHECK_ERROR_CLOSE (mbox, mpd, MU_ERR_NOPASSWORD);
}
status = pop_writeline (mpd, "PASS %s\r\n", mpd->passwd);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, "PASS ***\n");
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, "PASS ***\n");
/* Leave not trail of the passwd. */
memset (mpd->passwd, '\0', strlen (mpd->passwd));
free (mpd->passwd);
......@@ -555,7 +558,7 @@ _pop_user (mu_authority_t auth)
/* Get the ack from passwd. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
mu_observable_t observable = NULL;
......@@ -606,7 +609,7 @@ _pop_apop (mu_authority_t auth)
CHECK_ERROR_CLOSE (mbox, mpd, status);
}
status = pop_writeline (mpd, "APOP %s %s\r\n", mpd->user, mpd->passwd);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
/* We have to obscure the md5 string. */
memset (mpd->passwd, '\0', strlen (mpd->passwd));
free (mpd->user);
......@@ -627,7 +630,7 @@ _pop_apop (mu_authority_t auth)
case POP_APOP_ACK:
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
mu_observable_t observable = NULL;
......@@ -657,7 +660,7 @@ pop_reader (void *iodata)
pop_data_t iop = iodata;
status = pop_read_ack (iop);
CHECK_EAGAIN (iop, status);
MAILBOX_DEBUG0 (iop->mbox, MU_DEBUG_PROT, iop->buffer);
MU_DEBUG (iop->mbox->debug, MU_DEBUG_PROT, iop->buffer);
return status;//strncasecmp (iop->buffer, "+OK", 3) == 0;
}
......@@ -665,7 +668,7 @@ static int
pop_writer (void *iodata, char *buf)
{
pop_data_t iop = iodata;
MAILBOX_DEBUG1 (iop->mbox, MU_DEBUG_PROT, "%s\n", buf);
MU_DEBUG1 (iop->mbox->debug, MU_DEBUG_PROT, "%s\n", buf);
int status = pop_writeline (iop, "%s\r\n", buf);
CHECK_ERROR (iop, status);
status = pop_write (iop);
......@@ -697,7 +700,7 @@ pop_stls (mu_mailbox_t mbox)
status = mu_tls_begin (mpd, pop_reader, pop_writer,
pop_stream_ctl, keywords);
MAILBOX_DEBUG1 (mbox, MU_DEBUG_PROT, "TLS negotiation %s\n",
MU_DEBUG1 (mbox->debug, MU_DEBUG_PROT, "TLS negotiation %s\n",
status == 0 ? "succeeded" : "failed");
if (status == 0)
......@@ -801,7 +804,7 @@ pop_open (mu_mailbox_t mbox, int flags)
case POP_OPEN_CONNECTION:
/* Establish the connection. */
MAILBOX_DEBUG2 (mbox, MU_DEBUG_PROT, "open (%s:%ld)\n", host, port);
MU_DEBUG2 (mbox->debug, MU_DEBUG_PROT, "open (%s:%ld)\n", host, port);
status = mu_stream_open (mbox->stream);
CHECK_EAGAIN (mpd, status);
/* Can't recover bailout. */
......@@ -813,7 +816,7 @@ pop_open (mu_mailbox_t mbox, int flags)
int gblen = 0;
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
CHECK_ERROR_CLOSE (mbox, mpd, EACCES);
......@@ -893,7 +896,7 @@ pop_close (mu_mailbox_t mbox)
/* Initiate the close. */
status = pop_writeline (mpd, "QUIT\r\n");
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_QUIT;
case POP_QUIT:
......@@ -906,7 +909,7 @@ pop_close (mu_mailbox_t mbox)
/* Glob the acknowledge. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
/* Now what ! and how can we tell them about errors ? So far now
lets just be verbose about the error but close the connection
anyway. */
......@@ -1182,7 +1185,7 @@ pop_messages_count (mu_mailbox_t mbox, size_t *pcount)
case POP_NO_STATE:
status = pop_writeline (mpd, "STAT\r\n");
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_STAT;
case POP_STAT:
......@@ -1195,7 +1198,7 @@ pop_messages_count (mu_mailbox_t mbox, size_t *pcount)
/* Get the ACK. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
break;
default:
......@@ -1296,7 +1299,7 @@ pop_expunge (mu_mailbox_t mbox)
mu_umaxtostr (0,
mpd->pmessages[i]->num));
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_DELE;
case POP_DELE:
......@@ -1309,7 +1312,7 @@ pop_expunge (mu_mailbox_t mbox)
/* Ack Delete. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
CHECK_ERROR (mpd, ERANGE);
......@@ -1390,7 +1393,7 @@ pop_message_size (mu_message_t msg, size_t *psize)
case POP_NO_STATE:
status = pop_writeline (mpd, "LIST %s\r\n", mu_umaxtostr (0, mpm->num));
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_LIST;
case POP_LIST:
......@@ -1403,7 +1406,7 @@ pop_message_size (mu_message_t msg, size_t *psize)
/* Resp from LIST. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
break;
default:
......@@ -1609,7 +1612,7 @@ pop_uidl (mu_message_t msg, char *buffer, size_t buflen, size_t *pnwriten)
case POP_NO_STATE:
status = pop_writeline (mpd, "UIDL %s\r\n", mu_umaxtostr (0, mpm->num));
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_UIDL;
case POP_UIDL:
......@@ -1622,7 +1625,7 @@ pop_uidl (mu_message_t msg, char *buffer, size_t buflen, size_t *pnwriten)
/* Resp from UIDL. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
break;
default:
......@@ -1705,7 +1708,7 @@ pop_top (mu_header_t header, char *buffer, size_t buflen,
status = pop_writeline (mpd, "TOP %s 0\r\n",
mu_umaxtostr (0, mpm->num));
CHECK_ERROR (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
mpd->state = POP_TOP;
}
else /* Fall back to RETR call. */
......@@ -1726,7 +1729,7 @@ pop_top (mu_header_t header, char *buffer, size_t buflen,
/* Ack from TOP. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
/* if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
mu_error ("TOP not implemented\n"); */ /* FIXME */
mpd->state = POP_TOP_RX;
......@@ -1930,7 +1933,7 @@ pop_retr (pop_message_t mpm, char *buffer, size_t buflen,
mpm->body_lines = mpm->body_size = 0;
status = pop_writeline (mpd, "RETR %s\r\n",
mu_umaxtostr (0, mpm->num));
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
CHECK_ERROR (mpd, status);
mpd->state = POP_RETR;
......@@ -1944,7 +1947,7 @@ pop_retr (pop_message_t mpm, char *buffer, size_t buflen,
/* RETR ACK. */
status = pop_read_ack (mpd);
CHECK_EAGAIN (mpd, status);
MAILBOX_DEBUG0 (mpd->mbox, MU_DEBUG_PROT, mpd->buffer);
MU_DEBUG (mpd->mbox->debug, MU_DEBUG_PROT, mpd->buffer);
if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
{
......
......@@ -35,20 +35,17 @@ mu_pop3_set_debug (mu_pop3_t pop3, mu_debug_t debug)
return 0;
}
/* FIXME: This should be a macro */
int
mu_pop3_debug_cmd (mu_pop3_t pop3)
{
if (pop3->debug)
mu_debug_print(pop3->debug, MU_DEBUG_PROT, "%s", pop3->io.buf);
MU_DEBUG (pop3->debug, MU_DEBUG_PROT, pop3->io.buf);
return 0;
}
int
mu_pop3_debug_ack (mu_pop3_t pop3)
{
if (pop3->debug)
{
mu_debug_print (pop3->debug, MU_DEBUG_PROT, "%s\n", pop3->ack.buf);
}
MU_DEBUG1 (pop3->debug, MU_DEBUG_PROT, "%s\n", pop3->ack.buf);
return 0;
}
......
......@@ -349,6 +349,7 @@ mu_sieve_machine_init (mu_sieve_machine_t *pmach, void *data)
{
int rc;
mu_sieve_machine_t mach;
size_t level;
mach = malloc (sizeof (*mach));
if (!mach)
......@@ -364,6 +365,14 @@ mu_sieve_machine_init (mu_sieve_machine_t *pmach, void *data)
mach->data = data;
mach->error_printer = _sieve_default_error_printer;
mach->parse_error_printer = _sieve_default_parse_error;
level = mu_global_debug_level ("sieve");
if (level)
{
mu_debug_create (&mach->debug, mach);
mu_debug_set_level (mach->debug, level);
}
*pmach = mach;
return 0;
}
......@@ -448,9 +457,14 @@ mu_sieve_set_debug (mu_sieve_machine_t mach, mu_sieve_printf_t debug)
}
void
mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg, int level)
mu_sieve_set_debug_object (mu_sieve_machine_t mach, mu_debug_t dbg)
{
mach->debug = dbg;
}
void
mu_sieve_set_debug_level (mu_sieve_machine_t mach, int level)
{
mach->debug_level = level;
}
......
......@@ -37,12 +37,10 @@ int log_to_stderr = -1;
/* Debuggig options */
int debug_level; /* General debugging level */
int debug_flags; /* Mailutils debugging flags */
int sieve_debug_flags; /* Sieve debugging flags */
int sieve_enable_log; /* Enables logging of executed Sieve actions */
char *message_id_header; /* Use the value of this header as message
identifier when logging Sieve actions */
mu_debug_t mudebug; /* Mailutils debugging object */
/* For LMTP mode */
int lmtp_mode;
......@@ -65,8 +63,6 @@ N_("GNU maildag -- the mail delivery agent")
"\v"
N_("Debug flags are:\n\
g - guimb stack traces\n\
T - mailutils traces (MU_DEBUG_TRACE)\n\
P - network protocols (MU_DEBUG_PROT)\n\
t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n\
i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR)\n\
l - sieve action logs\n\
......@@ -115,9 +111,11 @@ static const char *maidag_argp_capa[] = {
"daemon",
"auth",
"common",
"debug",
"license",
"logging",
"mailbox",
"locking",
"mailer",
NULL
};
......@@ -154,14 +152,6 @@ set_debug_flags (const mu_cfg_locus_t *locus, const char *arg)
sieve_enable_log = 1;
break;
case 'T':
debug_flags |= MU_DEBUG_TRACE;
break;
case 'P':
debug_flags |= MU_DEBUG_PROT;
break;
default:
if (locus)
mu_error (_("%s:%d: %c is not a valid debug flag"),
......@@ -393,7 +383,7 @@ sieve_test (struct mu_auth_data *auth, mu_mailbox_t mbx)
else
{
mu_sieve_set_debug (mach, _sieve_debug_printer);
mu_sieve_set_debug_level (mach, mudebug, sieve_debug_flags);
mu_sieve_set_debug_level (mach, sieve_debug_flags);
mu_sieve_set_parse_error (mach, _sieve_parse_error);
if (sieve_enable_log)
mu_sieve_set_logger (mach, _sieve_action_log);
......@@ -475,23 +465,6 @@ main (int argc, char *argv[])
mu_error_set_print (mu_syslog_error_printer);
}
if (debug_flags)
{
int rc;
if ((rc = mu_debug_create (&mudebug, NULL)))
{
mu_error (_("mu_debug_create failed: %s\n"), mu_strerror (rc));
exit (EX_TEMPFAIL);
}
if ((rc = mu_debug_set_level (mudebug, debug_flags)))
{
mu_error (_("mu_debug_set_level failed: %s\n"),
mu_strerror (rc));
exit (EX_TEMPFAIL);
}
}
argc -= arg_index;
argv += arg_index;
......
......@@ -55,7 +55,7 @@ N_("GNU mail.local -- the local MDA")
"\v"
N_("Debug flags are:\n\
g - guimb stack traces\n\
T - mailutils traces (MU_DEBUG_TRACE)\n\
T - mailutils traces (MU_DEBUG_TRACE0-MU_DEBUG_TRACE9)\n\
P - network protocols (MU_DEBUG_PROT)\n\
t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n\
i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR)\n\
......@@ -113,9 +113,11 @@ static struct argp argp = {
static const char *argp_capa[] = {
"auth",
"common",
"debug",
"license",
"logging",
"mailbox",
"locking",
"mailer",
NULL
};
......@@ -153,11 +155,11 @@ set_debug_flags (const mu_cfg_locus_t *locus, const char *arg)
break;
case 'T':
debug_flags |= MU_DEBUG_TRACE;
debug_flags |= MU_DEBUG_LEVEL_UPTO (MU_DEBUG_TRACE7);
break;
case 'P':
debug_flags |= MU_DEBUG_PROT;
debug_flags |= MU_DEBUG_LEVEL_MASK (MU_DEBUG_PROT);
break;
default:
......@@ -473,7 +475,8 @@ sieve_test (struct mu_auth_data *auth, mu_mailbox_t mbx)
else
{
mu_sieve_set_debug (mach, _sieve_debug_printer);
mu_sieve_set_debug_level (mach, mudebug, sieve_debug_flags);
mu_sieve_set_debug_object (mach, mudebug);
mu_sieve_set_debug_level (mach, sieve_debug_flags);
mu_sieve_set_parse_error (mach, _sieve_parse_error);
if (sieve_enable_log)
mu_sieve_set_logger (mach, _sieve_action_log);
......
......@@ -131,6 +131,7 @@ struct mu_cfg_param mail_remote_cfg_param[] = {
static const char *capa[] = {
"auth",
"common",
"debug",
"mailer",
"address",
"license",
......@@ -232,7 +233,7 @@ main (int argc, char **argv)
{
mu_debug_t debug;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
if (optdebug > 1)
mailer_flags = MAILER_FLAG_DEBUG_DATA;
......
......@@ -177,8 +177,10 @@ static struct argp argp = {
static const char *mail_capa[] = {
"common",
"debug",
"license",
"mailbox",
"locking",
NULL
};
......@@ -431,7 +433,7 @@ main (int argc, char **argv)
{
mu_debug_t debug = NULL;
mu_mailbox_get_debug (mbox, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
if ((rc = mu_mailbox_open (mbox, MU_STREAM_RDWR)) != 0 && rc != ENOENT)
......
......@@ -608,8 +608,7 @@ mail_send0 (compose_env_t * env, int save_to)
mu_debug_t debug = NULL;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug,
MU_DEBUG_TRACE |
MU_DEBUG_PROT);
MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
status = mu_mailer_open (mailer, MU_STREAM_RDWR);
if (status == 0)
......
......@@ -59,6 +59,7 @@ libmailutils_la_SOURCES = \
filter_rfc822.c\
filter_trans.c\
folder.c\
gdebug.c\
gocs.c\
header.c\
iterator.c\
......
......@@ -293,7 +293,7 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size,
mailbox->_get_size = amd_get_size;
MAILBOX_DEBUG1 (mailbox, MU_DEBUG_TRACE, "amd_init(%s)\n", amd->name);
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "amd_init(%s)\n", amd->name);
*pamd = amd;
return 0;
}
......
......@@ -44,7 +44,7 @@ static unsigned int max_rehash = sizeof (hash_size) / sizeof (hash_size[0]);
struct _mu_assoc_elem
{
const char *name;
char *name;
char data[1];
};
......@@ -212,7 +212,7 @@ assoc_lookup_or_install (struct _mu_assoc_elem **elp,
{
*install = 1;
if (assoc->flags & MU_ASSOC_COPY_KEY)
elem->name = name;
elem->name = (char *) name;
else
{
elem->name = strdup (name);
......
......@@ -139,42 +139,60 @@ copy_alpha (struct lexer_data *p)
return cbuf_finish (p);
}
static int
continuation_line_p (struct lexer_data *p, int quote)
{
skipws (p);
return *p->curp == quote;
}
static char *
copy_string (struct lexer_data *p)
{
int quote = *p->curp++;
while (*p->curp)
int quote;
do
{
if (*p->curp == '\\')
quote = *p->curp++;
while (*p->curp)
{
char c;
if (*++p->curp == 0)
if (*p->curp == '\\')
{
char c;
if (*++p->curp == 0)
{
cbuf_1grow (p, '\\');
break;
}
if (*p->curp == '\n')
{
p->curp++;
continue;
}
c = mu_argcv_unquote_char (*p->curp);
if (c == *p->curp)
{
cbuf_1grow (p, '\\');
cbuf_1grow (p, *p->curp);
}
else
cbuf_1grow (p, c);
p->curp++;
}
else if (*p->curp == quote)
{
cbuf_1grow (p, '\\');
p->curp++;
break;
}
c = mu_argcv_unquote_char (*p->curp);
if (c == *p->curp)
else
{
cbuf_1grow (p, '\\');
cbuf_1grow (p, *p->curp);
p->curp++;
}
else
cbuf_1grow (p, c);
p->curp++;
}
else if (*p->curp == quote)
{
p->curp++;
break;
}
else
{
cbuf_1grow (p, *p->curp);
p->curp++;
}
}
while (continuation_line_p (p, quote));
cbuf_1grow (p, 0);
return cbuf_finish (p);
}
......@@ -225,7 +243,7 @@ again:
if (*p->curp == 0)
return 0;
if (*p->curp == '\"')
if (*p->curp == '"' || *p->curp == '\'')
{
mu_cfg_yylval.string = copy_string (p);
return MU_CFG_STRING_TOKEN;
......@@ -262,8 +280,8 @@ again:
save_start = p->curp;
if (*p->curp != '{')
{
label = copy_alpha(p);
skipws(p);
label = copy_alpha (p);
skipws (p);
}
else
label = NULL;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -99,29 +100,12 @@ mu_debug_set_print (mu_debug_t debug, mu_debug_printer_fp printer, void *owner)
}
int
mu_debug_print (mu_debug_t debug, size_t level, const char *format, ...)
{
va_list ap;
va_start (ap, format);
mu_debug_printv (debug, level, format, ap);
va_end (ap);
return 0;
}
int
mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
va_list ap)
mu_debug_vprintf (mu_debug_t debug, size_t level,
const char *format, va_list ap)
{
if (debug == NULL || format == NULL)
return EINVAL;
if (!(debug->level & level))
return 0;
if (debug->printer)
{
mu_off_t len;
......@@ -135,7 +119,8 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
if (rc)
{
fprintf (stderr,
_("cannot create memory stream for debugging output: %s\n"),
_("cannot create memory stream for debugging "
"output: %s\n"),
mu_strerror (rc));
vfprintf (stderr, format, ap);
return rc;
......@@ -166,7 +151,7 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
if (start[len - 1] != '\n')
{
size_t s = len - (ptr - start);
memmove (start, ptr, len);
memmove (start, ptr, s);
}
else
len = 0;
......@@ -181,3 +166,42 @@ mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
return 0;
}
int
mu_debug_printf (mu_debug_t debug, size_t level, const char *format, ...)
{
va_list ap;
va_start (ap, format);
mu_debug_vprintf (debug, level, format, ap);
va_end (ap);
return 0;
}
int
mu_debug_print (mu_debug_t debug, size_t level, const char *format, ...)
{
va_list ap;
mu_debug_printv (debug, level, format, ap);
va_end (ap);
return 0;
}
int
mu_debug_printv (mu_debug_t debug, size_t level, const char *format,
va_list ap)
{
if (debug == NULL || format == NULL)
return EINVAL;
if (debug->level & MU_DEBUG_LEVEL_MASK (level))
return 0;
return mu_debug_printf (debug, level, format, ap);
}
int
mu_debug_check_level (mu_debug_t debug, size_t level)
{
if (!debug)
return 0;
return debug->level & MU_DEBUG_LEVEL_MASK (level);
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <mailutils/assoc.h>
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/argcv.h>
#include <mailutils/debug.h>
int mu_debug_line_info = 0;
struct debug_level
{
unsigned level;
};
static mu_assoc_t debug_table;
unsigned
mu_global_debug_level (const char *object_name)
{
struct debug_level *p = mu_assoc_ref (debug_table, object_name);
if (p)
return p->level;
return 0;
}
int
mu_global_debug_set_level (const char *object_name, unsigned level)
{
int rc;
struct debug_level *dbg;
if (!debug_table)
{
rc = mu_assoc_create (&debug_table, sizeof(struct debug_level), 0);
if (rc)
return rc;
}
rc = mu_assoc_ref_install (debug_table, object_name, (void**) &dbg);
if (rc == 0 || rc == MU_ERR_EXISTS)
dbg->level = level;
return rc;
}
int
mu_global_debug_clear_level (const char *object_name)
{
int rc = 0;
if (!object_name)
mu_assoc_clear (debug_table);
else
rc = mu_assoc_remove (debug_table, object_name);
return rc;
}
int
decode_debug_level (const char *p, int *lev)
{
if (strcmp (p, "error") == 0)
*lev = MU_DEBUG_ERROR;
else if (strncmp (p, "trace", 5) == 0 && isdigit (p[5]) && p[6] == 0)
*lev = MU_DEBUG_TRACE0 + atoi (p + 5);
else if (strcmp (p, "proto") == 0)
*lev = MU_DEBUG_PROT;
else
return 1;
return 0;
}
int
mu_global_debug_from_string (const char *string, const char *errpfx)
{
int rc;
size_t argc;
char **argv;
int i;
rc = mu_argcv_get (string, ";", NULL, &argc, &argv);
if (rc)
return rc;
for (i = 0; i < argc; i++)
{
char *p;
unsigned level = MU_DEBUG_INHERIT;
char *object_name = argv[i];
for (p = object_name; *p && *p != '='; p++)
;
if (*p == '=')
{
char *q;
*p++ = 0;
if (isdigit (*p))
{
level = strtoul (p, &q, 0);
if (*q)
{
mu_error ("%s: invalid debugging specification `%s': "
"expected levels or number after `=', "
"but found `%s'",
errpfx, argv[i], p);
break;
}
}
else
{
char *q;
for (q = strtok (p, ","); q; q = strtok (NULL, ","))
{
int flag;
int revert = 0;
int upto = 0;
if (*q == '!')
{
q++;
revert = 1;
}
if (*q == '<')
{
q++;
upto = 1;
}
if (decode_debug_level (q, &flag))
mu_error ("%s: invalid debugging level `%s'",
errpfx, q);
else if (revert)
{
if (upto)
level &= ~MU_DEBUG_LEVEL_UPTO (flag);
else
level &= ~MU_DEBUG_LEVEL_MASK (flag);
}
else
{
if (upto)
level |= MU_DEBUG_LEVEL_UPTO (flag);
else
level |= MU_DEBUG_LEVEL_MASK (flag);
}
}
}
}
else
level |= MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT);
if (p[-1] == ':')
{
p[-1] = 0;
level &= ~MU_DEBUG_INHERIT;
}
mu_global_debug_set_level (object_name, level);
}
mu_argcv_free (argc, argv);
return 0;
}
......@@ -218,6 +218,25 @@ mu_gocs_logging_init (void *data)
return 0;
}
int
mu_gocs_debug_init (void *data)
{
struct mu_gocs_debug *p;
if (data)
{
p = data;
if (p->string && p->errpfx)
{
mu_global_debug_from_string (p->string, p->errpfx);
free (p->errpfx);
}
if (p->line_info >= 0)
mu_debug_line_info = p->line_info;
}
return 0;
}
struct mu_gocs_entry
{
char *name;
......@@ -257,7 +276,7 @@ mu_gocs_enumerate (mu_list_action_t action, void *data)
}
static gocs_init_fp
find_init_function (struct mu_gocs_entry *tab, char *capa)
find_init_function (struct mu_gocs_entry *tab, const char *capa)
{
for (; tab->name; tab++)
if (strcmp (tab->name, capa) == 0)
......@@ -274,12 +293,13 @@ static struct mu_gocs_entry std_gocs_table[] = {
{ "address", mu_gocs_source_email_init },
{ "mailer", mu_gocs_mailer_init },
{ "logging", mu_gocs_logging_init },
{ "debug", mu_gocs_debug_init },
{ "auth", mu_gocs_dummy },
{ NULL }
};
void
mu_gocs_register_std (char *name)
mu_gocs_register_std (const char *name)
{
gocs_init_fp init = find_init_function (std_gocs_table, name);
if (!init)
......
......@@ -91,6 +91,7 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
if (mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL) == 0)
{
unsigned level;
int (*m_init) (mu_mailbox_t) = NULL;
int (*u_init) (mu_url_t) = NULL;
......@@ -138,6 +139,19 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
else
*pmbox = mbox;
level = mu_global_debug_level ("mailbox");
if (level)
{
int status = mu_debug_create (&mbox->debug, mbox);
if (status)
return 0; /* FIXME: don't want to bail out just because I
failed to create a *debug* object. But maybe
I'm wrong... */
mu_debug_set_level (mbox->debug, level);
if (level & MU_DEBUG_INHERIT)
mu_folder_set_debug (mbox->folder, mbox->debug);
}
return status;
}
}
......@@ -162,7 +176,7 @@ mu_mailbox_create (mu_mailbox_t *pmbox, const char *name)
strcpy (tmp_name, default_proto);
strcat (tmp_name, name);
rc = _create_mailbox (pmbox, name);
free (name);
free (tmp_name);
}
else
rc = _create_mailbox (pmbox, name);
......@@ -197,23 +211,23 @@ mu_mailbox_destroy (mu_mailbox_t *pmbox)
/* FIXME: Is this right, should the client be responsible
for closing the stream? */
/* mu_stream_close (mbox->stream); */
mu_stream_destroy (&(mbox->stream), mbox);
mu_stream_destroy (&mbox->stream, mbox);
}
if (mbox->url)
mu_url_destroy (&(mbox->url));
mu_url_destroy (&mbox->url);
if (mbox->locker)
mu_locker_destroy (&(mbox->locker));
mu_locker_destroy (&mbox->locker);
if (mbox->debug)
mu_debug_destroy (&(mbox->debug), mbox);
mu_debug_destroy (&mbox->debug, mbox);
if (mbox->folder)
mu_folder_destroy (&(mbox->folder));
mu_folder_destroy (&mbox->folder);
if (mbox->property)
mu_property_destroy (&(mbox->property), mbox);
mu_property_destroy (&mbox->property, mbox);
free (mbox);
*pmbox = NULL;
......@@ -553,7 +567,7 @@ mu_mailbox_get_property (mu_mailbox_t mbox, mu_property_t *pproperty)
if (mbox->property == NULL)
{
int status = mu_property_create (&(mbox->property), mbox);
int status = mu_property_create (&mbox->property, mbox);
if (status != 0)
return status;
}
......@@ -578,8 +592,9 @@ mu_mailbox_set_debug (mu_mailbox_t mbox, mu_debug_t debug)
if (mbox->debug)
mu_debug_destroy (&mbox->debug, mbox);
mbox->debug = debug;
if(!mu_folder_has_debug(mbox->folder))
mu_folder_set_debug(mbox->folder, debug);
/* FIXME: Honor MU_DEBUG_INHERIT */
if (!mu_folder_has_debug (mbox->folder))
mu_folder_set_debug (mbox->folder, debug);
return 0;
}
......@@ -592,10 +607,11 @@ mu_mailbox_get_debug (mu_mailbox_t mbox, mu_debug_t *pdebug)
return MU_ERR_OUT_PTR_NULL;
if (mbox->debug == NULL)
{
int status = mu_debug_create (&(mbox->debug), mbox);
int status = mu_debug_create (&mbox->debug, mbox);
if (status != 0)
return status;
if(!mu_folder_has_debug (mbox->folder))
/* FIXME: MU_DEBUG_INHERIT?? */
if (!mu_folder_has_debug (mbox->folder))
mu_folder_set_debug (mbox->folder, mbox->debug);
}
*pdebug = mbox->debug;
......
......@@ -330,9 +330,9 @@ _set_from (mu_address_t *pfrom, mu_message_t msg, mu_address_t from,
/* Use the From: header. */
case 0:
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"mu_mailer_send_message(): using From: %s\n",
mail_from);
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"mu_mailer_send_message(): using From: %s\n",
mail_from);
status = mu_address_create (pfrom, mail_from);
free (mail_from);
......@@ -347,16 +347,12 @@ _set_from (mu_address_t *pfrom, mu_message_t msg, mu_address_t from,
mail_from = mu_get_user_email (NULL);
if (mail_from)
{
MAILER_DEBUG1 (mailer, MU_DEBUG_TRACE,
"mu_mailer_send_message(): using user's address: %s\n",
mail_from);
}
MU_DEBUG1 (mailer->debug, MU_DEBUG_TRACE,
"mu_mailer_send_message(): using user's address: %s\n",
mail_from);
else
{
MAILER_DEBUG0 (mailer, MU_DEBUG_TRACE,
"mu_mailer_send_message(): no user's address, failing\n");
}
MU_DEBUG (mailer->debug, MU_DEBUG_ERROR,
"mu_mailer_send_message(): no user's address, failing\n");
if (!mail_from)
return errno;
......
......@@ -925,7 +925,8 @@ message_write (mu_stream_t os, const char *buf, size_t buflen,
}
static int
message_get_transport2 (mu_stream_t stream, mu_transport_t *pin, mu_transport_t *pout)
message_get_transport2 (mu_stream_t stream, mu_transport_t *pin,
mu_transport_t *pout)
{
mu_message_t msg = mu_stream_get_owner (stream);
mu_body_t body;
......@@ -1109,17 +1110,18 @@ message_body_read (mu_stream_t stream, char *buffer, size_t n, mu_off_t off,
}
int
mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket, mu_debug_t debug,
const char *toname)
mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket,
mu_debug_t debug,
const char *toname)
{
int rc = 0;
mu_mailbox_t to = 0;
if ((rc = mu_mailbox_create_default (&to, toname)))
{
mu_debug_print (debug, MU_DEBUG_TRACE,
_("mu_mailbox_create_default (%s) failed: %s\n"), toname,
mu_strerror (rc));
MU_DEBUG2 (debug, MU_DEBUG_ERROR,
"mu_mailbox_create_default (%s) failed: %s\n", toname,
mu_strerror (rc));
goto end;
}
......@@ -1148,17 +1150,17 @@ mu_message_save_to_mailbox (mu_message_t msg, mu_ticket_t ticket, mu_debug_t deb
if ((rc = mu_mailbox_open (to, MU_STREAM_WRITE | MU_STREAM_CREAT)))
{
mu_debug_print (debug, MU_DEBUG_TRACE,
_("mu_mailbox_open (%s) failed: %s\n"), toname,
mu_strerror (rc));
MU_DEBUG2 (debug, MU_DEBUG_ERROR,
"mu_mailbox_open (%s) failed: %s\n", toname,
mu_strerror (rc));
goto end;
}
if ((rc = mu_mailbox_append_message (to, msg)))
{
mu_debug_print (debug, MU_DEBUG_TRACE,
_("mu_mailbox_append_message (%s) failed: %s\n"), toname,
mu_strerror (rc));
MU_DEBUG2 (debug, MU_DEBUG_ERROR,
"mu_mailbox_append_message (%s) failed: %s\n", toname,
mu_strerror (rc));
goto end;
}
......@@ -1167,16 +1169,12 @@ end:
if (!rc)
{
if ((rc = mu_mailbox_close (to)))
{
mu_debug_print (debug, MU_DEBUG_TRACE,
_("mu_mailbox_close (%s) failed: %s\n"), toname,
mu_strerror (rc));
}
MU_DEBUG2 (debug, MU_DEBUG_ERROR,
"mu_mailbox_close (%s) failed: %s\n", toname,
mu_strerror (rc));
}
else
{
mu_mailbox_close (to);
}
mu_mailbox_close (to);
mu_mailbox_destroy (&to);
......
......@@ -52,37 +52,9 @@
static mu_debug_t mu_auth_debug;
#define DEBUG0(str) \
do \
{ \
if (mu_auth_debug) \
mu_debug_print (mu_auth_debug, MU_DEBUG_TRACE, "%s", str); \
} \
while (0)
#define DEBUG1(fmt, a) \
do \
{ \
if (mu_auth_debug) \
mu_debug_print (mu_auth_debug, MU_DEBUG_TRACE, fmt, a); \
} \
while (0)
#define DEBUG2(fmt, a, b) \
do \
{ \
if (mu_auth_debug) \
mu_debug_print (mu_auth_debug, MU_DEBUG_TRACE, fmt, a, b); \
} \
while (0)
#define S(str) ((str) ? (str) : "(none)")
#define S(s) ((s) ? (s) : "(none)")
#define DEBUG_AUTH(a) \
do \
{ \
if (mu_auth_debug) \
mu_debug_print (mu_auth_debug, MU_DEBUG_TRACE, \
MU_DEBUG11 (mu_auth_debug, MU_DEBUG_TRACE, \
"source=%s, name=%s, passwd=%s, uid=%lu, gid=%lu, " \
"gecos=%s, dir=%s, shell=%s, mailbox=%s, quota=%lu, " \
"change_uid=%d\n", \
......@@ -96,9 +68,7 @@ static mu_debug_t mu_auth_debug;
S ((a)->shell), \
S ((a)->mailbox), \
(unsigned long) (a)->quota, \
(a)->change_uid); \
} \
while (0)
(a)->change_uid)
mu_debug_t
mu_auth_set_debug (mu_debug_t debug)
......@@ -232,9 +202,10 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data,
mu_iterator_next (itr))
{
mu_iterator_current (itr, (void **)&ep);
DEBUG1 ("Trying %s...", ep->name);
MU_DEBUG1 (mu_auth_debug, MU_DEBUG_TRACE, "Trying %s...", ep->name);
rc = ep->fun (return_data, key, ep->func_data, data);
DEBUG2 ("result: %d=%s\n", rc, mu_strerror (rc));
MU_DEBUG2 (mu_auth_debug, MU_DEBUG_TRACE,
"result: %d=%s\n", rc, mu_strerror (rc));
if (rc == 0)
{
if (return_data)
......@@ -281,18 +252,22 @@ mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type,
switch (type)
{
case mu_auth_key_name:
DEBUG1 ("Getting auth info for user %s\n", (char*) key);
MU_DEBUG1 (mu_auth_debug, MU_DEBUG_TRACE,
"Getting auth info for user %s\n",
(char*) key);
list = mu_auth_by_name_list;
break;
case mu_auth_key_uid:
DEBUG1 ("Getting auth info for UID %lu\n",
(unsigned long) *(uid_t*) key);
MU_DEBUG1 (mu_auth_debug, MU_DEBUG_TRACE,
"Getting auth info for UID %lu\n",
(unsigned long) *(uid_t*) key);
list = mu_auth_by_uid_list;
break;
default:
DEBUG1 ("Unknown mu_auth_key_type: %d\n", type);
MU_DEBUG1 (mu_auth_debug, MU_DEBUG_ERROR,
"Unknown mu_auth_key_type: %d\n", type);
return EINVAL;
}
return mu_auth_runlist (list, auth, key, NULL);
......@@ -323,8 +298,9 @@ mu_authenticate (struct mu_auth_data *auth_data, char *pass)
{
if (!auth_data)
return EINVAL;
DEBUG2 ("mu_authenticate, user %s, source %s\n", auth_data->name,
auth_data->source);
MU_DEBUG2 (mu_auth_debug, MU_DEBUG_TRACE,
"mu_authenticate, user %s, source %s\n",
auth_data->name, auth_data->source);
if (!mu_authenticate_list)
mu_auth_begin_setup ();
return mu_auth_runlist (mu_authenticate_list, NULL, auth_data, pass);
......
......@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <mailutils/error.h>
const char *mu_program_name;
......
......@@ -29,8 +29,6 @@ struct kw_int
static int
syslog_to_n (struct kw_int *kw, char *str, int *pint)
{
int i;
if (strncasecmp (str, "LOG_", 4) == 0)
str += 4;
......
......@@ -46,8 +46,10 @@ static struct argp_option options[] = {
static const char *argp_capa[] = {
"common",
"debug",
"license",
"mailbox",
"locking",
NULL
};
......
......@@ -395,7 +395,7 @@ open_mailer ()
{
mu_debug_t debug = NULL;
mu_mailer_get_debug (mailer, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE | MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
WATCH ((_("Opening mailer %s"), url));
......
......@@ -164,6 +164,7 @@ struct mu_cfg_param mimeview_cfg_param[] = {
static const char *capa[] = {
"common",
"debug",
"license",
NULL
};
......
......@@ -88,7 +88,9 @@ struct mu_cfg_param movemail_cfg_param[] = {
static const char *movemail_capa[] = {
"common",
"debug",
"license",
"locking",
"mailbox",
NULL
};
......
......@@ -164,7 +164,9 @@ static const char *pop3d_argp_capa[] = {
"daemon",
"auth",
"common",
"debug",
"mailbox",
"locking",
"logging",
"license",
NULL
......
......@@ -61,7 +61,9 @@ static struct argp argp = {
static const char *readmsg_argp_capa[] = {
"common",
"debug",
"mailbox",
"locking",
NULL
};
......@@ -304,7 +306,7 @@ main (int argc, char **argv)
{
mu_debug_t debug;
mu_mailbox_get_debug (mbox, &debug);
mu_debug_set_level (debug, MU_DEBUG_TRACE|MU_DEBUG_PROT);
mu_debug_set_level (debug, MU_DEBUG_LEVEL_UPTO (MU_DEBUG_PROT));
}
status = mu_mailbox_open (mbox, MU_STREAM_READ);
......
......@@ -18,5 +18,12 @@
## 02110-1301 USA
SUBDIRS = guile-1.4 guile-1.6
EXTRA_DIST = gylwrap mailutils.spec mailutils.spec.in texify.sed sqlmod.sh generr.awk
EXTRA_DIST = \
debugdef.m4\
gylwrap\
mailutils.spec\
mailutils.spec.in\
texify.sed\
sqlmod.sh\
generr.awk
......
divert(-1)
# This file is part of Mailutils.
# Copyright (C) 2006, 2007 Sergey Poznyakoff
#
# 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 3, 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, see <http://www.gnu.org/licenses/>.
changecom(/*,*/)
define(`__arglist',`dnl
ifelse($1,$2,x$1,
`x$1, __arglist(incr($1), $2)')')
define(`MKDEBUG',`
`#define __MU_DEBUG'$1`(dbg, lev, fmt, '__arglist(1,$1)) \`
do \
{ \
if (mu_debug_line_info) \
mu_debug_printf (dbg, lev, "%s:%d:%s: " fmt, \
__FILE__, __LINE__, __FUNCTION__, \'
__arglist(1,$1)`); \
else \
mu_debug_printf (dbg, lev, fmt,'dnl
__arglist(1,$1)`); \
} \
while (0)
#define MU_DEBUG'$1`(dbg, lev, fmt, '__arglist(1,$1)`) \
do \
{ \
if (mu_debug_check_level (dbg, lev)) \
__MU_DEBUG'$1`(dbg, lev, fmt, '__arglist(1,$1)`); \
} \
while(0)
'')
define(`forloop',
`pushdef(`$1', `$2')_forloop(`$1', `$2', `$3', `$4')popdef(`$1')')
define(`_forloop',
`$4`'ifelse($1, `$3', ,
`define(`$1', incr($1))_forloop(`$1', `$2', `$3', `$4')')')
divert(0)dnl
/* -*- buffer-read-only: t -*- vi: set ro:
THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT.
*/
......@@ -54,7 +54,7 @@ N_("GNU sieve -- a mail filtering tool")
"\v"
N_("Debug flags:\n\
g - main parser traces\n\
T - mailutils traces (MU_DEBUG_TRACE)\n\
T - mailutils traces (MU_DEBUG_TRACE0-MU_DEBUG_TRACE1)\n\
P - network protocols (MU_DEBUG_PROT)\n\
t - sieve trace (MU_SIEVE_DEBUG_TRACE)\n\
i - sieve instructions trace (MU_SIEVE_DEBUG_INSTR)\n");
......@@ -130,11 +130,11 @@ set_debug_level (mu_cfg_locus_t *locus, const char *arg)
switch (*arg)
{
case 'T':
debug_level |= MU_DEBUG_TRACE;
debug_level |= MU_DEBUG_LEVEL_UPTO (MU_DEBUG_TRACE7);
break;
case 'P':
debug_level |= MU_DEBUG_PROT;
debug_level |= MU_DEBUG_LEVEL_MASK (MU_DEBUG_PROT);
break;
case 'g':
......@@ -280,7 +280,9 @@ static struct mu_cfg_param sieve_cfg_param[] = {
static const char *sieve_argp_capa[] =
{
"common",
"debug",
"mailbox",
"locking",
"license",
"logging",
"mailer",
......@@ -454,9 +456,10 @@ main (int argc, char *argv[])
mu_strerror (rc));
goto cleanup;
}
mu_sieve_set_debug_object (mach, debug);
}
mu_sieve_set_debug_level (mach, debug, sieve_debug);
mu_sieve_set_debug_level (mach, sieve_debug);
/* Create, give a ticket to, and open the mailbox. */
if ((rc = mu_mailbox_create_default (&mbox, mbox_url)) != 0)
......