#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
+#include "lib/debug.h"
#include <string.h>
#include <ctype.h>
i = 0;
for (u = *expn; u; u = u->next) {
if (safe_strcmp (a->mailbox, u->data) == 0) { /* alias already found */
- dprint (1,
- (debugfile,
- "mutt_expand_aliases_r(): loop in alias found for '%s'\n",
- a->mailbox));
+ debug_print(1, ("loop in alias found for '%s'\n", a->mailbox));
i = 1;
break;
}
{
/* NULL address is assumed to be the user. */
if (!addr) {
- dprint (5, (debugfile, "mail_addr_is_user: yes, NULL address\n"));
+ debug_print(5, ("yes, NULL address\n"));
return 1;
}
if (!addr->mailbox) {
- dprint (5, (debugfile, "mail_addr_is_user: no, no mailbox\n"));
+ debug_print(5, ("no, no mailbox\n"));
return 0;
}
if (ascii_strcasecmp (addr->mailbox, Username) == 0) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox,
- Username));
+ debug_print(5, ("yes, %s = %s\n", addr->mailbox, Username));
return 1;
}
if (string_is_address (addr->mailbox, Username, Hostname)) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
- addr->mailbox, Username, Hostname));
+ debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, Hostname));
return 1;
}
if (string_is_address (addr->mailbox, Username, mutt_fqdn (0))) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
- addr->mailbox, Username, mutt_fqdn (0)));
+ debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (0)));
return 1;
}
if (string_is_address (addr->mailbox, Username, mutt_fqdn (1))) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s = %s @ %s \n",
- addr->mailbox, Username, mutt_fqdn (1)));
+ debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (1)));
return 1;
}
if (From && !ascii_strcasecmp (From->mailbox, addr->mailbox)) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s = %s\n", addr->mailbox,
- From->mailbox));
+ debug_print(5, ("yes, %s = %s\n", addr->mailbox, From->mailbox));
return 1;
}
if (rx_list_match (Alternates, addr->mailbox)) {
- dprint (5,
- (debugfile, "mail_addr_is_user: yes, %s matched by alternates.\n",
- addr->mailbox));
+ debug_print(5, ("yes, %s matched by alternates.\n", addr->mailbox));
if (rx_list_match (UnAlternates, addr->mailbox))
- dprint (5,
- (debugfile,
- "mail_addr_is_user: but, %s matched by unalternates.\n",
- addr->mailbox));
+ debug_print(5, ("but, %s matched by unalternates.\n", addr->mailbox));
else
return 1;
}
- dprint (5, (debugfile, "mail_addr_is_user: no, all failed.\n"));
+ debug_print(5, ("no, all failed.\n"));
return 0;
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
strfcpy (command, entry->composecommand, sizeof (command));
if (rfc1524_expand_filename (entry->nametemplate,
a->filename, newfile, sizeof (newfile))) {
- dprint (1, (debugfile, "oldfile: %s\t newfile: %s\n",
- a->filename, newfile));
+ debug_print (1, ("oldfile: %s\t newfile: %s\n", a->filename, newfile));
if (safe_symlink (a->filename, newfile) == -1) {
if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
!= M_YES)
strfcpy (command, entry->editcommand, sizeof (command));
if (rfc1524_expand_filename (entry->nametemplate,
a->filename, newfile, sizeof (newfile))) {
- dprint (1, (debugfile, "oldfile: %s\t newfile: %s\n",
- a->filename, newfile));
+ debug_print (1, ("oldfile: %s\t newfile: %s\n", a->filename, newfile));
if (safe_symlink (a->filename, newfile) == -1) {
if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES)
!= M_YES)
n == TYPEMULTIPART ? "multipart" :
n == TYPETEXT ? "text" :
n == TYPEVIDEO ? "video" : "other", tmp.subtype);
- dprint (1, (debugfile, "mutt_check_lookup_list: \"%s\" -> %s\n",
- b->filename, type));
+ debug_print (1, ("\"%s\" -> %s\n", b->filename, type));
}
if (tmp.subtype)
FREE (&tmp.subtype);
rfc1524_entry *entry;
int piped = FALSE;
- dprint (2, (debugfile, "Using mailcap...\n"));
+ debug_print (2, ("Using mailcap...\n"));
entry = rfc1524_new_entry ();
rfc1524_mailcap_lookup (a, type, entry, M_PRINT);
mutt_mktemp (newfile);
if (mutt_decode_save_attachment (fp, a, newfile, M_PRINTING, 0) == 0) {
- dprint (2,
- (debugfile, "successfully decoded %s type attachment to %s\n",
+ debug_print (2, ("successfully decoded %s type attachment to %s\n",
type, newfile));
if ((ifp = fopen (newfile, "r")) == NULL) {
goto bail0;
}
- dprint (2, (debugfile, "successfully opened %s read-only\n", newfile));
+ debug_print (2, ("successfully opened %s read-only\n", newfile));
mutt_endwin (NULL);
if ((thepid =
goto bail0;
}
- dprint (2, (debugfile, "Filter created.\n"));
+ debug_print (2, ("Filter created.\n"));
mutt_copy_stream (ifp, fpout);
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
init_pair (i, fg, bg);
- dprint (1, (debugfile, "mutt_alloc_color(): Color pairs used so far: %d\n",
- UserColors));
+ debug_print (1, ("Color pairs used so far: %d\n", UserColors));
return (COLOR_PAIR (p->index));
}
return;
UserColors--;
- dprint (1,
- (debugfile, "mutt_free_color(): Color pairs used so far: %d\n",
- UserColors));
+ debug_print (1, ("Color pairs used so far: %d\n", UserColors));
if (p == ColorList) {
ColorList = ColorList->next;
if (!safe_strcmp (buf->data, tmp->pattern)) {
if (!do_cache)
do_cache = 1;
- dprint (1,
- (debugfile, "Freeing pattern \"%s\" from ColorIndexList\n",
- tmp->pattern));
+ debug_print (1, ("Freeing pattern \"%s\" from ColorIndexList\n", tmp->pattern));
if (last)
last->next = tmp->next;
else
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <errno.h>
#include <unistd.h>
int ext = 0, done = 0, r = 0;
snprintf (oldfile, sizeof (oldfile), "%s.bak", filename);
- dprint (1, (debugfile, "Renaming %s to %s\n", filename, oldfile));
+ debug_print (1, ("Renaming %s to %s\n", filename, oldfile));
/* if file not exist, create it */
if ((ifp = safe_fopen (filename, "a")))
return (-1);
}
- dprint (1, (debugfile, "Opening %s\n", oldfile));
+ debug_print (1, ("Opening %s\n", oldfile));
if (!(ifp = safe_fopen (oldfile, "r"))) {
mutt_perror (_("Unable to open backup file for reading"));
return (-1);
}
- dprint (1, (debugfile, "Opening %s\n", filename));
+ debug_print (1, ("Opening %s\n", filename));
if (!(ofp = safe_fopen (filename, "w"))) {
fclose (ifp);
mutt_perror (_("Unable to open new file for writing"));
#endif
#include "lib/str.h"
+#include "lib/debug.h"
#include <dirent.h>
#include <string.h>
char imap_path[LONG_STRING];
#endif
- dprint (2, (debugfile, "mutt_complete: completing %s\n", s));
+ debug_print (2, ("completing %s\n", s));
#ifdef USE_NNTP
if (option (OPTNEWS)) {
}
if (dirp == NULL) {
- dprint (1,
- (debugfile, "mutt_complete(): %s: %s (errno %d).\n", exp_dirpart,
- strerror (errno), errno));
+ debug_print (1, ("%s: %s (errno %d).\n", exp_dirpart, strerror (errno), errno));
return (-1);
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <errno.h>
#include <string.h>
cmd = get_compression_cmd (ci->open, ctx);
if (cmd == NULL)
return (-1);
- dprint (2, (debugfile, "DecompressCmd: '%s'\n", cmd));
+ debug_print (2, ("DecompressCmd: '%s'\n", cmd));
if ((fp = fopen (ctx->realpath, "r")) == NULL) {
mutt_perror (ctx->realpath);
/* close a compressed mailbox */
void mutt_fast_close_compressed (CONTEXT * ctx)
{
- dprint (2, (debugfile, "mutt_fast_close_compressed called on '%s'\n",
- ctx->path));
+ debug_print (2, ("called on '%s'\n", ctx->path));
if (ctx->compressinfo) {
if (ctx->fp)
return (-1);
}
- dprint (2, (debugfile, "CompressCommand: '%s'\n", cmd));
+ debug_print (2, ("CompressCommand: '%s'\n", cmd));
endwin ();
fflush (stdout);
char *cmd;
COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo;
- dprint (2, (debugfile, "mutt_slow_close_compressed called on '%s'\n",
- ctx->path));
+ debug_print (2, ("called on '%s'\n", ctx->path));
if (!(ctx->append && ((append = get_append_command (ctx->realpath, ctx))
|| (append = ci->close)))) { /* if we can not or should not append,
return (-1);
}
- dprint (2, (debugfile, "CompressCmd: '%s'\n", cmd));
+ debug_print (2, ("CompressCmd: '%s'\n", cmd));
endwin ();
fflush (stdout);
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging support]),
[ if test x$enableval = xyes ; then
AC_DEFINE(DEBUG,1,[ Define to enable debugging info. ])
+ want_debug=yes
fi
])
+AM_CONDITIONAL(WANT_DEBUG, test x$want_debug = xyes)
AC_ARG_ENABLE(flock, AC_HELP_STRING([--enable-flock], [Use flock() to lock files]),
[if test $enableval = yes; then
#include "lib/mem.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
*/
if (flags & CH_REORDER) {
for (t = HeaderOrderList; t; t = t->next) {
- dprint (1, (debugfile, "Reorder list: %s\n", t->data));
+ debug_print (1, ("Reorder list: %s\n", t->data));
hdr_count++;
}
}
- dprint (1, (debugfile, "WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not"));
+ debug_print (1, ("WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not"));
headers = safe_calloc (hdr_count, sizeof (char *));
if (flags & CH_REORDER) {
for (t = HeaderOrderList, x = 0; (t); t = t->next, x++) {
if (!ascii_strncasecmp (buf, t->data, safe_strlen (t->data))) {
- dprint (2, (debugfile, "Reorder: %s matches %s\n", t->data, buf));
+ debug_print (2, ("Reorder: %s matches %s\n", t->data, buf));
break;
}
}
} /* If beginning of header */
if (!ignore) {
- dprint (2,
- (debugfile, "Reorder: x = %d; hdr_count = %d\n", x, hdr_count));
+ debug_print (2, ("Reorder: x = %d; hdr_count = %d\n", x, hdr_count));
if (!this_one)
this_one = safe_strdup (buf);
else {
_mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags,
chflags)) == 0 && (ferror (fpout)
|| feof (fpout))) {
- dprint (1, (debugfile, "_mutt_copy_message failed to detect EOF!\n"));
+ debug_print (1, ("_mutt_copy_message failed to detect EOF!\n"));
r = -1;
}
mx_close_message (&msg);
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/wait.h>
#include <string.h>
gpgme_release (ctx);
state_attach_puts (_("[-- End signature information --]\n\n"), s);
- dprint (1, (debugfile, "verify_one: returning %d.\n", badsig));
+ debug_print (1, ("returning %d.\n", badsig));
return badsig ? 1 : anywarn ? 2 : 0;
}
char body_charset[STRING]; /* Only used for clearsigned messages. */
- dprint (2, (debugfile, "Entering pgp_application_pgp handler\n"));
+ debug_print (2, ("Entering pgp_application_pgp handler\n"));
/* For clearsigned messages we won't be able to get a character set
but we know that this may only be text thus we assume Latin-1
" of PGP message! --]\n\n"), s);
return;
}
- dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n"));
+ debug_print (2, ("Leaving pgp_application_pgp handler\n"));
}
/*
BODY *orig_body = a;
int is_signed;
- dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
+ debug_print (2, ("Entering pgp_encrypted handler\n"));
a = a->parts;
if (!a || a->type != TYPEAPPLICATION || !a->subtype
|| ascii_strcasecmp ("pgp-encrypted", a->subtype)
fclose (fpout);
mutt_unlink (tempfile);
- dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
+ debug_print (2, ("Leaving pgp_encrypted handler\n"));
}
/* Support for application/smime */
int is_signed;
- dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
+ debug_print (2, ("Entering smime_encrypted handler\n"));
a->warnsig = 0;
mutt_mktemp (tempfile);
fclose (fpout);
mutt_unlink (tempfile);
- dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
+ debug_print (2, ("Leaving smime_encrypted handler\n"));
}
if (!keys)
return NULL;
- dprint (5, (debugfile, "crypt_getkeybyaddr: looking for %s <%s>.",
- a->personal, a->mailbox));
+ debug_print (5, ("looking for %s <%s>.\n", a->personal, a->mailbox));
for (k = keys; k; k = k->next) {
- dprint (5, (debugfile, " looking at key: %s `%.15s'\n",
- crypt_keyid (k), k->uid));
+ debug_print (5, (" looking at key: %s `%.15s'\n", crypt_keyid (k), k->uid));
if (abilities && !(k->flags & abilities)) {
- dprint (5, (debugfile, " insufficient abilities: Has %x, want %x\n",
- k->flags, abilities));
+ debug_print (5, (" insufficient abilities: Has %x, want %x\n", k->flags, abilities));
continue;
}
continue;
match = 0;
- dprint (5, (debugfile, "crypt_getkeybystr: matching \"%s\" against "
- "key %s, \"%s\": ", p, crypt_keyid (k), k->uid));
+ debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
if (!*p || !safe_strcasecmp (p, crypt_keyid (k))
|| (!safe_strncasecmp (p, "0x", 2)
|| str_isstr (k->uid, p)) {
crypt_key_t *tmp;
- dprint (5, (debugfile, "match.\n"));
+ debug_print (5, ("match.\n"));
*matches_endp = tmp = crypt_copy_key (k);
matches_endp = &tmp->next;
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <termios.h>
#include <sys/types.h>
vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
va_end (ap);
- dprint (1, (debugfile, "%s\n", Errorbuf));
+ debug_print (1, ("%s\n", Errorbuf));
mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
0, COLS - 2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
snprintf (Errorbuf, sizeof (Errorbuf), "%s", TmpErrorbuf); /* overkill */
{
char *p = strerror (errno);
- dprint (1, (debugfile, "%s: %s (errno = %d)\n", s,
- p ? p : "unknown error", errno));
+ debug_print (1, ("%s: %s (errno = %d)\n", s, p ? p : "unknown error", errno));
mutt_error ("%s: %s (errno = %d) from %s:%i", s, p ? p : _("unknown error"), errno, filename, line);
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
op = km_dokey (MENU_MAIN);
- dprint (4,
- (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
+ debug_print (4, ("Got op %d\n", op));
#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
if (SigWinch) {
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <string.h>
if (!*s)
return 0;
- dprint (3, (debugfile, "\nis_from(): parsing: %s", s));
+ debug_print (3, ("parsing: %s\n", s));
if (!is_day_name (s)) {
const char *p;
len = pathlen - 1;
memcpy (path, s, len);
path[len] = 0;
- dprint (3, (debugfile, "is_from(): got return path: %s\n", path));
+ debug_print (3, ("got return path: %s\n", path));
}
s = p + 1;
return 0;
if (!is_day_name (s)) {
- dprint (1, (debugfile, "is_from(): expected weekday, got: %s\n", s));
+ debug_print (1, ("expected weekday, got: %s\n", s));
return 0;
}
}
return 0;
tm.tm_year = yr > 1900 ? yr - 1900 : (yr < 70 ? yr + 100 : yr);
- dprint (3,
- (debugfile,
- "is_from(): month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
+ debug_print (3, ("month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n",
tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
tm.tm_year));
WHERE char *SmimeImportCertCommand;
WHERE char *SmimeGetCertEmailCommand;
-
-
-#ifdef DEBUG
-WHERE FILE *debugfile INITVAL (0);
-WHERE int debuglevel INITVAL (0);
-#endif
-
#ifdef MAIN_C
const char *Weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
const char *Months[] =
#include "lib/mem.h"
#include "lib/str.h"
+#include "lib/debug.h"
/****************
* Read the GNUPG keys. For now we read the complete keyring by
if (!*buf)
return NULL;
- dprint (2, (debugfile, "parse_pub_line: buf = `%s'\n", buf));
+ debug_print (2, ("buf = `%s'\n", buf));
for (p = buf; p; p = pend) {
if ((pend = strchr (p, ':')))
switch (field) {
case 1: /* record type */
{
- dprint (2, (debugfile, "record type: %s\n", p));
+ debug_print (2, ("record type: %s\n", p));
if (!safe_strcmp (p, "pub"));
else if (!safe_strcmp (p, "sub"))
}
case 2: /* trust info */
{
- dprint (2, (debugfile, "trust info: %s\n", p));
+ debug_print (2, ("trust info: %s\n", p));
switch (*p) { /* look only at the first letter */
case 'e':
case 3: /* key length */
{
- dprint (2, (debugfile, "key len: %s\n", p));
+ debug_print (2, ("key len: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
k->keylen = atoi (p); /* fixme: add validation checks */
case 4: /* pubkey algo */
{
- dprint (2, (debugfile, "pubkey algorithm: %s\n", p));
+ debug_print (2, ("pubkey algorithm: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB))) {
k->numalg = atoi (p);
}
case 5: /* 16 hex digits with the long keyid. */
{
- dprint (2, (debugfile, "key id: %s\n", p));
+ debug_print (2, ("key id: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
str_replace (&k->keyid, p);
char tstr[11];
struct tm time;
- dprint (2, (debugfile, "time stamp: %s\n", p));
+ debug_print (2, ("time stamp: %s\n", p));
if (!p)
break;
if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))
break;
- dprint (2, (debugfile, "user ID: %s\n", p));
+ debug_print (2, ("user ID: %s\n", p));
uid = safe_calloc (sizeof (pgp_uid_t), 1);
fix_uid (p);
case 11: /* signature class */
break;
case 12: /* key capabilities */
- dprint (2, (debugfile, "capabilities info: %s\n", p));
+ debug_print (2, ("capabilities info: %s\n", p));
while (*p) {
switch (*p++) {
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#define BUFI_SIZE 1000
#define BUFO_SIZE 2000
buf[i++] = ch;
}
if (i != 4) {
- dprint (2, (debugfile, "%s:%d [mutt_decode_base64()]: "
- "didn't get a multiple of 4 chars.\n", __FILE__, __LINE__));
+ debug_print (2, ("didn't get a multiple of 4 chars.\n"));
break;
}
#include "mutt_idna.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <sys/stat.h>
#include <string.h>
mutt_edit_file (editor, path);
stat (path, &st);
if (mtime == st.st_mtime) {
- dprint (1,
- (debugfile, "ci_edit_headers(): temp file was not modified.\n"));
+ debug_print (1, ("temp file was not modified.\n"));
/* the file has not changed! */
mutt_unlink (path);
return;
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include "mutt.h"
#include "imap_private.h"
if (!method[0])
continue;
- dprint (2,
- (debugfile, "imap_authenticate: Trying method %s\n", method));
+ debug_print (2, ("Trying method %s\n", method));
authenticator = imap_authenticators;
while (authenticator->authenticate) {
}
else {
/* Fall back to default: any authenticator */
- dprint (2,
- (debugfile, "imap_authenticate: Using any available method.\n"));
+ debug_print (2, ("Using any available method.\n"));
authenticator = imap_authenticators;
while (authenticator->authenticate) {
#include "auth.h"
#include "lib/intl.h"
+#include "lib/debug.h"
/* 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)
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_RESPOND) {
- dprint (1, (debugfile, "Invalid response from server.\n"));
+ debug_print (1, ("Invalid response from server.\n"));
goto bail;
}
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_OK) {
- dprint (1, (debugfile, "Error receiving server response.\n"));
+ debug_print (1, ("Error receiving server response.\n"));
goto bail;
}
#define MD5_DIGEST_LEN 16
#include "lib/intl.h"
+#include "lib/debug.h"
/* forward declarations */
static void hmac_md5 (const char *password, char *challenge,
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_RESPOND) {
- dprint (1, (debugfile, "Invalid response from server: %s\n", ibuf));
+ debug_print (1, ("Invalid response from server: %s\n", ibuf));
goto bail;
}
if ((len = mutt_from_base64 (obuf, idata->cmd.buf + 2)) == -1) {
- dprint (1, (debugfile, "Error decoding base64 response.\n"));
+ debug_print (1, ("Error decoding base64 response.\n"));
goto bail;
}
obuf[len] = '\0';
- dprint (2, (debugfile, "CRAM challenge: %s\n", obuf));
+ debug_print (2, ("CRAM challenge: %s\n", obuf));
/* The client makes note of the data and then responds with a string
* consisting of the user name, a space, and a 'digest'. The latter is
hmac_response[9], hmac_response[10], hmac_response[11],
hmac_response[12], hmac_response[13], hmac_response[14],
hmac_response[15]);
- dprint (2, (debugfile, "CRAM response: %s\n", obuf));
+ debug_print (2, ("CRAM response: %s\n", obuf));
/* XXX - ibuf must be long enough to store the base64 encoding of obuf,
* plus the additional debris
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_OK) {
- dprint (1, (debugfile, "Error receiving server response.\n"));
+ debug_print (1, ("Error receiving server response.\n"));
goto bail;
}
#include "auth.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <netinet/in.h>
maj_stat = gss_import_name (&min_stat, &request_buf, gss_nt_service_name,
&target_name);
if (maj_stat != GSS_S_COMPLETE) {
- dprint (2, (debugfile, "Couldn't get service name for [%s]\n", buf1));
+ debug_print (2, ("Couldn't get service name for [%s]\n", buf1));
return IMAP_AUTH_UNAVAIL;
}
#ifdef DEBUG
else if (debuglevel >= 2) {
maj_stat = gss_display_name (&min_stat, target_name, &request_buf,
&mech_name);
- dprint (2, (debugfile, "Using service name [%s]\n",
+ debug_print (2, ("Using service name [%s]\n",
(char *) request_buf.value));
maj_stat = gss_release_buffer (&min_stat, &request_buf);
}
&send_token, (unsigned int *) &cflags,
NULL);
if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
- dprint (1, (debugfile, "Error acquiring credentials - no TGT?\n"));
+ debug_print (1, ("Error acquiring credentials - no TGT?\n"));
gss_release_name (&min_stat, &target_name);
return IMAP_AUTH_UNAVAIL;
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_RESPOND) {
- dprint (2, (debugfile, "Invalid response from server: %s\n", buf1));
+ debug_print (2, ("Invalid response from server: %s\n", buf1));
gss_release_name (&min_stat, &target_name);
goto bail;
}
/* now start the security context initialisation loop... */
- dprint (2, (debugfile, "Sending credentials\n"));
+ debug_print (2, ("Sending credentials\n"));
mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
sizeof (buf1) - 2);
gss_release_buffer (&min_stat, &send_token);
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_RESPOND) {
- dprint (1, (debugfile, "Error receiving server response.\n"));
+ debug_print (1, ("Error receiving server response.\n"));
gss_release_name (&min_stat, &target_name);
goto bail;
}
NULL, &send_token,
(unsigned int *) &cflags, NULL);
if (maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED) {
- dprint (1, (debugfile, "Error exchanging credentials\n"));
+ debug_print (1, ("Error exchanging credentials\n"));
gss_release_name (&min_stat, &target_name);
goto err_abort_cmd;
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_RESPOND) {
- dprint (1, (debugfile, "Error receiving server response.\n"));
+ debug_print (1, ("Error receiving server response.\n"));
goto bail;
}
request_buf.length = mutt_from_base64 (buf2, idata->cmd.buf + 2);
maj_stat = gss_unwrap (&min_stat, context, &request_buf, &send_token,
&cflags, &quality);
if (maj_stat != GSS_S_COMPLETE) {
- dprint (2, (debugfile, "Couldn't unwrap security level data\n"));
+ debug_print (2, ("Couldn't unwrap security level data\n"));
gss_release_buffer (&min_stat, &send_token);
goto err_abort_cmd;
}
- dprint (2, (debugfile, "Credential exchange complete\n"));
+ debug_print (2, ("Credential exchange complete\n"));
/* first octet is security levels supported. We want NONE */
server_conf_flags = ((char *) send_token.value)[0];
if (!(((char *) send_token.value)[0] & GSS_AUTH_P_NONE)) {
- dprint (2, (debugfile, "Server requires integrity or privacy\n"));
+ debug_print (2, ("Server requires integrity or privacy\n"));
gss_release_buffer (&min_stat, &send_token);
goto err_abort_cmd;
}
((char *) send_token.value)[0] = 0;
buf_size = ntohl (*((long *) send_token.value));
gss_release_buffer (&min_stat, &send_token);
- dprint (2, (debugfile, "Unwrapped security level flags: %c%c%c\n",
+ debug_print (2, ("Unwrapped security level flags: %c%c%c\n",
server_conf_flags & GSS_AUTH_P_NONE ? 'N' : '-',
server_conf_flags & GSS_AUTH_P_INTEGRITY ? 'I' : '-',
server_conf_flags & GSS_AUTH_P_PRIVACY ? 'P' : '-'));
- dprint (2, (debugfile, "Maximum GSS token size is %ld\n", buf_size));
+ debug_print (2, ("Maximum GSS token size is %ld\n", buf_size));
/* agree to terms (hack!) */
buf_size = htonl (buf_size); /* not relevant without integrity/privacy */
maj_stat = gss_wrap (&min_stat, context, 0, GSS_C_QOP_DEFAULT, &request_buf,
&cflags, &send_token);
if (maj_stat != GSS_S_COMPLETE) {
- dprint (2, (debugfile, "Error creating login request\n"));
+ debug_print (2, ("Error creating login request\n"));
goto err_abort_cmd;
}
mutt_to_base64 ((unsigned char *) buf1, send_token.value, send_token.length,
sizeof (buf1) - 2);
- dprint (2, (debugfile, "Requesting authorisation as %s\n",
- idata->conn->account.user));
+ debug_print (2, ("Requesting authorisation as %s\n", idata->conn->account.user));
safe_strcat (buf1, sizeof (buf1), "\r\n");
mutt_socket_write (idata->conn, buf1);
rc = imap_cmd_step (idata);
while (rc == IMAP_CMD_CONTINUE);
if (rc == IMAP_CMD_RESPOND) {
- dprint (1, (debugfile, "Unexpected server continuation request.\n"));
+ debug_print (1, ("Unexpected server continuation request.\n"));
goto err_abort_cmd;
}
if (imap_code (idata->cmd.buf)) {
/* flush the security context */
- dprint (2, (debugfile, "Releasing GSS credentials\n"));
+ debug_print (2, ("Releasing GSS credentials\n"));
maj_stat = gss_delete_sec_context (&min_stat, &context, &send_token);
if (maj_stat != GSS_S_COMPLETE)
- dprint (1, (debugfile, "Error releasing credentials\n"));
+ debug_print (1, ("Error releasing credentials\n"));
/* send_token may contain a notification to the server to flush
* credentials. RFC 1731 doesn't specify what to do, and since this
#endif
#include "lib/intl.h"
+#include "lib/debug.h"
#include "mutt.h"
#include "imap_private.h"
/* don't print the password unless we're at the ungodly debugging level
* of 5 or higher */
- if (debuglevel < IMAP_LOG_PASS)
- dprint (2, (debugfile, "Sending LOGIN command for %s...\n",
+ if (DebugLevel < IMAP_LOG_PASS)
+ debug_print (2, ("Sending LOGIN command for %s...\n",
idata->conn->account.user));
#endif
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#ifdef USE_SASL2
#include <sasl/sasl.h>
unsigned char client_start;
if (mutt_sasl_client_new (idata->conn, &saslconn) < 0) {
- dprint (1, (debugfile,
- "imap_auth_sasl: Error allocating SASL connection.\n"));
+ debug_print (1, ("Error allocating SASL connection.\n"));
return IMAP_AUTH_FAILURE;
}
if (rc != SASL_OK && rc != SASL_CONTINUE) {
if (method)
- dprint (2, (debugfile, "imap_auth_sasl: %s unavailable\n", method));
+ debug_print (2, ("%s unavailable\n", method));
else
- dprint (1,
- (debugfile,
- "imap_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
+ debug_print (1, ("Failure starting authentication exchange. No shared mechanisms?\n"));
/* SASL doesn't support LOGIN, so fall back */
return IMAP_AUTH_UNAVAIL;
while (irc == IMAP_CMD_CONTINUE);
if (method && irc == IMAP_CMD_NO) {
- dprint (2, (debugfile, "imap_auth_sasl: %s failed\n", method));
+ debug_print (2, ("%s failed\n", method));
sasl_dispose (&saslconn);
return IMAP_AUTH_UNAVAIL;
}
if (sasl_decode64 (idata->cmd.buf + 2, safe_strlen (idata->cmd.buf + 2), buf,
#endif
&len) != SASL_OK) {
- dprint (1,
- (debugfile,
- "imap_auth_sasl: error base64-decoding server response.\n"));
+ debug_print (1, ("error base64-decoding server response.\n"));
goto bail;
}
}
/* send out response, or line break if none needed */
if (olen) {
if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) {
- dprint (1,
- (debugfile,
- "imap_auth_sasl: error base64-encoding client response.\n"));
+ debug_print (1, ("error base64-encoding client response.\n"));
goto bail;
}
/* If SASL has errored out, send an abort string to the server */
if (rc < 0) {
mutt_socket_write (idata->conn, "*\r\n");
- dprint (1,
- (debugfile, "imap_auth_sasl: sasl_client_step error %d\n", rc));
+ debug_print (1, ("sasl_client_step error %d\n", rc));
}
olen = 0;
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include "mutt.h"
#include "imap_private.h"
strncpy (mbox, buf, sizeof (mbox) - 1);
n = safe_strlen (mbox);
- dprint (3, (debugfile, "imap_browse: mbox: %s\n", mbox));
+ debug_print (3, ("mbox: %s\n", mbox));
/* if our target exists and has inferiors, enter it if we
* aren't already going to */
mbox[n] = '\0';
if (showparents) {
- dprint (3, (debugfile, "imap_init_browse: adding parent %s\n", mbox));
+ debug_print (3, ("adding parent %s\n", mbox));
imap_add_folder (idata->delim, mbox, 1, 0, state, 1);
}
/* Listing the home namespace, so INBOX should be included. Home
* namespace is not "", so we have to list it explicitly. We ask the
* server to see if it has descendants. */
- dprint (3, (debugfile, "imap_browse: adding INBOX\n"));
+ debug_print (3, ("adding INBOX\n"));
if (browse_add_list_result (idata, "LIST \"\" \"INBOX\"", state, 0))
goto fail;
}
nsup = state->entrylen;
- dprint (3, (debugfile, "imap_browse: Quoting mailbox scan: %s -> ", mbox));
+ debug_print (3, ("Quoting mailbox scan: %s:\n", mbox));
snprintf (buf, sizeof (buf), "%s%%", mbox);
imap_quote_string (buf2, sizeof (buf2), buf);
- dprint (3, (debugfile, "%s\n", buf2));
+ debug_print (3, ("%s\n", buf2));
snprintf (buf, sizeof (buf), "%s \"\" %s", list_cmd, buf2);
if (browse_add_list_result (idata, buf, state, 0))
goto fail;
if (nsi[i].listable && !nsi[i].home_namespace) {
imap_add_folder (nsi[i].delim, nsi[i].prefix, nsi[i].noselect,
nsi[i].noinferiors, state, 0);
- dprint (3, (debugfile, "imap_browse: adding namespace: %s\n",
- nsi[i].prefix));
+ debug_print (3, ("adding namespace: %s\n", nsi[i].prefix));
}
}
short n;
if (imap_parse_path (folder, &mx) < 0) {
- dprint (1, (debugfile, "imap_mailbox_create: Bad starting path %s\n",
- folder));
+ debug_print (1, ("Bad starting path %s\n", folder));
return -1;
}
if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) {
- dprint (1,
- (debugfile,
- "imap_mailbox_create: Couldn't find open connection to %s",
- mx.account.host));
+ debug_print (1, ("Couldn't find open connection to %s\n", mx.account.host));
goto fail;
}
char newname[SHORT_STRING];
if (imap_parse_path (mailbox, &mx) < 0) {
- dprint (1, (debugfile, "imap_mailbox_rename: Bad source mailbox %s\n",
- mailbox));
+ debug_print (1, ("Bad source mailbox %s\n", mailbox));
return -1;
}
if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) {
- dprint (1,
- (debugfile,
- "imap_mailbox_rename: Couldn't find open connection to %s",
- mx.account.host));
+ debug_print (1, ("Couldn't find open connection to %s\n", mx.account.host));
goto fail;
}
IMAP_MBOX mx;
if (imap_parse_path (state->folder, &mx)) {
- dprint (2, (debugfile,
- "browse_add_list_result: current folder %s makes no sense\n",
- state->folder));
+ debug_print (2, ("current folder %s makes no sense\n", state->folder));
return -1;
}
}
/* skip "" namespaces, they are already listed at the root */
if ((ns[0] != '\0') && (nsbused < nsblen) && (*nns < nsilen)) {
- dprint (3,
- (debugfile, "browse_get_namespace: adding %s\n", ns));
+ debug_print (3, ("adding %s\n", ns));
nsi->type = type;
/* Cyrus doesn't append the delimiter to the namespace,
* but UW-IMAP does. We'll strip it here and add it back
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
if (len == cmd->blen) {
safe_realloc (&cmd->buf, cmd->blen + IMAP_CMD_BUFSIZE);
cmd->blen = cmd->blen + IMAP_CMD_BUFSIZE;
- dprint (3, (debugfile, "imap_cmd_step: grew buffer to %u bytes\n",
- cmd->blen));
+ debug_print (3, ("grew buffer to %u bytes\n", cmd->blen));
}
c = mutt_socket_readln (cmd->buf + len, cmd->blen - len, idata->conn);
if (c <= 0) {
- dprint (1,
- (debugfile, "imap_cmd_step: Error reading server response.\n"));
+ debug_print (1, ("Error reading server response.\n"));
/* cmd_handle_fatal (idata); */
return IMAP_CMD_BAD;
}
if ((cmd->blen > IMAP_CMD_BUFSIZE) && (len <= IMAP_CMD_BUFSIZE)) {
safe_realloc (&cmd->buf, IMAP_CMD_BUFSIZE);
cmd->blen = IMAP_CMD_BUFSIZE;
- dprint (3,
- (debugfile, "imap_cmd_step: shrank buffer to %u bytes\n",
- cmd->blen));
+ debug_print (3, ("shrank buffer to %u bytes\n", cmd->blen));
}
idata->lastread = time (NULL);
if (flags & IMAP_CMD_FAIL_OK)
return -2;
- dprint (1,
- (debugfile, "imap_exec: command failed: %s\n", idata->cmd.buf));
+ debug_print (1, ("command failed: %s\n", idata->cmd.buf));
return -1;
}
(idata->reopen & IMAP_NEWMAIL_PENDING)
&& count > idata->ctx->msgcount) {
/* read new mail messages */
- dprint (2, (debugfile, "imap_cmd_finish: Fetching new mail\n"));
+ debug_print (2, ("Fetching new mail\n"));
/* check_status: curs_main uses imap_check_mailbox to detect
* whether the index needs updating */
idata->check_status = IMAP_NEWMAIL_PENDING;
imap_read_headers (idata, idata->ctx->msgcount, count - 1);
}
else if (idata->reopen & IMAP_EXPUNGE_PENDING) {
- dprint (2, (debugfile, "imap_cmd_finish: Expunging mailbox\n"));
+ debug_print (2, ("Expunging mailbox\n"));
imap_expunge_mailbox (idata);
/* Detect whether we've gotten unexpected EXPUNGE messages */
if (idata->reopen & IMAP_EXPUNGE_PENDING &&
* connection, so update that one.
*/
if (ascii_strncasecmp ("EXISTS", s, 6) == 0) {
- dprint (2, (debugfile, "Handling EXISTS\n"));
+ debug_print (2, ("Handling EXISTS\n"));
/* new mail arrived */
count = atoi (pn);
/* at least the InterChange server sends EXISTS messages freely,
* even when there is no new mail */
else if (count == idata->ctx->msgcount)
- dprint (3, (debugfile,
- "cmd_handle_untagged: superfluous EXISTS message.\n"));
+ debug_print (3, ("superfluous EXISTS message.\n"));
else {
if (!(idata->reopen & IMAP_EXPUNGE_PENDING)) {
- dprint (2, (debugfile,
- "cmd_handle_untagged: New mail in %s - %d messages total.\n",
- idata->mailbox, count));
+ debug_print (2, ("New mail in %s - %d messages total.\n", idata->mailbox, count));
idata->reopen |= IMAP_NEWMAIL_PENDING;
}
idata->newMailCount = count;
else if (ascii_strncasecmp ("MYRIGHTS", s, 8) == 0)
cmd_parse_myrights (idata, s);
else if (ascii_strncasecmp ("BYE", s, 3) == 0) {
- dprint (2, (debugfile, "Handling BYE\n"));
+ debug_print (2, ("Handling BYE\n"));
/* check if we're logging out */
if (idata->status == IMAP_BYE)
}
else if (option (OPTIMAPSERVERNOISE)
&& (ascii_strncasecmp ("NO", s, 2) == 0)) {
- dprint (2, (debugfile, "Handling untagged NO\n"));
+ debug_print (2, ("Handling untagged NO\n"));
/* Display the warning message from the server */
mutt_error ("%s", s + 3);
{
int x;
- dprint (2, (debugfile, "Handling CAPABILITY\n"));
+ debug_print (2, ("Handling CAPABILITY\n"));
s = imap_next_word (s);
FREE (&idata->capstr);
int expno, cur;
HEADER *h;
- dprint (2, (debugfile, "Handling EXPUNGE\n"));
+ debug_print (2, ("Handling EXPUNGE\n"));
expno = atoi (s);
int msgno, cur;
HEADER *h = NULL;
- dprint (2, (debugfile, "Handling FETCH\n"));
+ debug_print (2, ("Handling FETCH\n"));
msgno = atoi (s);
h = idata->ctx->hdrs[cur];
if (h->active && h->index + 1 == msgno) {
- dprint (2,
- (debugfile, "Message UID %d updated\n",
- HEADER_DATA (h)->uid));
+ debug_print (2, ("Message UID %d updated\n", HEADER_DATA (h)->uid));
break;
}
}
if (!h) {
- dprint (1, (debugfile, "FETCH response ignored for this message\n"));
+ debug_print (1, ("FETCH response ignored for this message\n"));
return;
}
s = imap_next_word (s);
if (*s != '(') {
- dprint (1, (debugfile, "Malformed FETCH response"));
+ debug_print (1, ("Malformed FETCH response\n"));
return;
}
s++;
if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
- dprint (2, (debugfile, "Only handle FLAGS updates\n"));
+ debug_print (2, ("Only handle FLAGS updates\n"));
return;
}
/* cmd_parse_myrights: set rights bits according to MYRIGHTS response */
static void cmd_parse_myrights (IMAP_DATA * idata, char *s)
{
- dprint (2, (debugfile, "Handling MYRIGHTS\n"));
+ debug_print (2, ("Handling MYRIGHTS\n"));
s = imap_next_word (s);
s = imap_next_word (s);
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <unistd.h>
#include <ctype.h>
else if (mutt_bit_isset (idata->capabilities, STATUS))
snprintf (buf, sizeof (buf), "STATUS %s (UID-VALIDITY)", mbox);
else {
- dprint (2, (debugfile, "imap_access: STATUS not supported?\n"));
+ debug_print (2, ("STATUS not supported?\n"));
return -1;
}
if (imap_exec (idata, buf, IMAP_CMD_FAIL_OK) < 0) {
- dprint (1, (debugfile, "imap_access: Can't check STATUS of %s\n", mbox));
+ debug_print (1, ("Can't check STATUS of %s\n", mbox));
return -1;
}
int r = 0;
- dprint (2, (debugfile, "imap_read_literal: reading %ld bytes\n", bytes));
+ debug_print (2, ("reading %ld bytes\n", bytes));
for (pos = 0; pos < bytes; pos++) {
if (mutt_socket_readchar (idata->conn, &c) != 1) {
- dprint (1,
- (debugfile,
- "imap_read_literal: error during read, %ld bytes read\n",
- pos));
+ debug_print (1, ("error during read, %ld bytes read\n", pos));
idata->status = IMAP_FATAL;
return -1;
#endif
fputc (c, fp);
#ifdef DEBUG
- if (debuglevel >= IMAP_LOG_LTRL)
- fputc (c, debugfile);
+ if (DebugLevel >= IMAP_LOG_LTRL)
+ fputc (c, DebugFile);
#endif
}
h = idata->ctx->hdrs[i];
if (h->index == -1) {
- dprint (2,
- (debugfile, "Expunging message UID %d.\n",
- HEADER_DATA (h)->uid));
+ debug_print (2, ("Expunging message UID %d.\n", HEADER_DATA (h)->uid));
h->active = 0;
while (rc == IMAP_CMD_CONTINUE);
if (rc != IMAP_CMD_OK) {
- dprint (1, (debugfile, "imap_get_delim: failed.\n"));
+ debug_print (1, ("failed.\n"));
return -1;
}
- dprint (2, (debugfile, "Delimiter: %c\n", idata->delim));
+ debug_print (2, ("Delimiter: %c\n", idata->delim));
return -1;
}
if (!imap_authenticate (idata)) {
idata->state = IMAP_AUTHENTICATED;
if (idata->conn->ssf)
- dprint (2, (debugfile, "Communication encrypted at %d bits\n",
- idata->conn->ssf));
+ debug_print (2, ("Communication encrypted at %d bits\n", idata->conn->ssf));
}
else
mutt_account_unsetpass (&idata->conn->account);
/* sanity-check string */
if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
- dprint (1, (debugfile, "imap_get_flags: not a FLAGS response: %s\n", s));
+ debug_print (1, ("not a FLAGS response: %s\n", s));
return NULL;
}
s += 5;
SKIPWS (s);
if (*s != '(') {
- dprint (1, (debugfile, "imap_get_flags: bogus FLAGS response: %s\n", s));
+ debug_print (1, ("bogus FLAGS response: %s\n", s));
return NULL;
}
/* note bad flags response */
if (*s != ')') {
- dprint (1, (debugfile,
- "imap_get_flags: Unterminated FLAGS response: %s\n", s));
+ debug_print (1, ("Unterminated FLAGS response: %s\n", s));
mutt_free_list (hflags);
return NULL;
if (ascii_strncasecmp ("FLAGS", pc, 5) == 0) {
/* don't override PERMANENTFLAGS */
if (!idata->flags) {
- dprint (2, (debugfile, "Getting mailbox FLAGS\n"));
+ debug_print (2, ("Getting mailbox FLAGS\n"));
if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL)
goto fail;
}
}
/* PERMANENTFLAGS are massaged to look like FLAGS, then override FLAGS */
else if (ascii_strncasecmp ("OK [PERMANENTFLAGS", pc, 18) == 0) {
- dprint (2, (debugfile, "Getting mailbox PERMANENTFLAGS\n"));
+ debug_print (2, ("Getting mailbox PERMANENTFLAGS\n"));
/* safe to call on NULL */
mutt_free_list (&(idata->flags));
/* skip "OK [PERMANENT" so syntax is the same as FLAGS */
#ifdef USE_HCACHE
/* save UIDVALIDITY for the header cache */
else if (ascii_strncasecmp ("OK [UIDVALIDITY", pc, 14) == 0) {
- dprint (2, (debugfile, "Getting mailbox UIDVALIDITY\n"));
+ debug_print (2, ("Getting mailbox UIDVALIDITY\n"));
pc += 3;
pc = imap_next_word (pc);
if (!ascii_strncasecmp
(imap_get_qualifier (idata->cmd.buf), "[READ-ONLY]", 11)
&& !mutt_bit_isset (idata->capabilities, ACL)) {
- dprint (2, (debugfile, "Mailbox is read-only.\n"));
+ debug_print (2, ("Mailbox is read-only.\n"));
ctx->readonly = 1;
}
#ifdef DEBUG
/* dump the mailbox flags we've found */
- if (debuglevel > 2) {
+ if (DebugLevel > 2) {
if (!idata->flags)
- dprint (3, (debugfile, "No folder flags found\n"));
+ debug_print (3, ("No folder flags found\n"));
else {
LIST *t = idata->flags;
- dprint (3, (debugfile, "Mailbox flags: "));
+ debug_print (3, ("Mailbox flags:\n"));
t = t->next;
while (t) {
- dprint (3, (debugfile, "[%s] ", t->data));
+ debug_print (3, ("[%s]\n", t->data));
t = t->next;
}
- dprint (3, (debugfile, "\n"));
}
}
#endif
goto fail;
}
- dprint (2,
- (debugfile, "imap_open_mailbox: msgcount is %d\n", ctx->msgcount));
+ debug_print (2, ("msgcount is %d\n", ctx->msgcount));
FREE (&mx.mbox);
return 0;
/*
int imap_close_connection (CONTEXT *ctx)
{
- dprint (1, (debugfile, "imap_close_connection(): closing connection\n"));
+ debug_print (1, (debugfile, "imap_close_connection(): closing connection\n"));
if (CTX_DATA->status != IMAP_BYE)
{
mutt_message _("Closing connection to IMAP server...");
idata = (IMAP_DATA *) ctx->data;
if (idata->state != IMAP_SELECTED) {
- dprint (2, (debugfile, "imap_sync_mailbox: no mailbox selected\n"));
+ debug_print (2, ("no mailbox selected\n"));
return -1;
}
* This works better if we're expunging, of course. */
if (ctx->hdrs[n]->refs_changed || ctx->hdrs[n]->irt_changed ||
ctx->hdrs[n]->attach_del) {
- dprint (3,
- (debugfile,
- "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
+ debug_print (3, ("Attachments to be deleted, falling back to _mutt_save_message\n"));
if (!appendctx)
appendctx = mx_open_mailbox (ctx->path, M_APPEND | M_QUIET, NULL);
if (!appendctx) {
- dprint (1,
- (debugfile,
- "imap_sync_mailbox: Error opening mailbox in append mode\n"));
+ debug_print (1, ("Error opening mailbox in append mode\n"));
}
else
_mutt_save_message (ctx->hdrs[n], appendctx, 1, 0, 0);
if (isdigit ((unsigned char) *s)) {
if (*s != '0') {
msgcount = atoi (s);
- dprint (2,
- (debugfile, "%d new messages in %s\n", msgcount, path));
+ debug_print (2, ("%d new messages in %s\n", msgcount, path));
}
}
}
else
- dprint (1,
- (debugfile,
- "imap_mailbox_check: STATUS response doesn't match requested mailbox.\n"));
+ debug_print (1, ("STATUS response doesn't match requested mailbox.\n"));
}
}
while (rc == IMAP_CMD_CONTINUE);
/* verify passed in path is an IMAP path */
if (imap_parse_path (path, &mx)) {
- dprint (2, (debugfile, "imap_complete: bad path %s\n", path));
+ debug_print (2, ("bad path %s\n", path));
return -1;
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#if HAVE_STDINT_H
#include <stdint.h>
mutt_hcache_restore ((unsigned char *) uid_validity, 0);
ctx->hdrs[msgno]->index = h.sid - 1;
if (h.sid != ctx->msgcount + 1)
- dprint (1,
- (debugfile,
- "imap_read_headers: msgcount and sequence ID are inconsistent!"));
+ debug_print (1, ("msgcount and sequence ID are inconsistent!\n"));
/* messages which have not been expunged are ACTIVE (borrowed from mh
* folders) */
ctx->hdrs[msgno]->active = 1;
ctx->hdrs[msgno]->index = h.sid - 1;
if (h.sid != ctx->msgcount + 1)
- dprint (1,
- (debugfile,
- "imap_read_headers: msgcount and sequence ID are inconsistent!"));
+ debug_print (1, ("msgcount and sequence ID are inconsistent!\n"));
/* messages which have not been expunged are ACTIVE (borrowed from mh
* folders) */
ctx->hdrs[msgno]->active = 1;
if (rc != IMAP_CMD_RESPOND) {
char *pc;
- dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
- idata->cmd.buf));
+ debug_print (1, ("command failed: %s\n", idata->cmd.buf));
pc = idata->cmd.buf + SEQLEN;
SKIPWS (pc);
if (!imap_code (idata->cmd.buf)) {
char *pc;
- dprint (1, (debugfile, "imap_append_message(): command failed: %s\n",
- idata->cmd.buf));
+ debug_print (1, ("command failed: %s\n", idata->cmd.buf));
pc = idata->cmd.buf + SEQLEN;
SKIPWS (pc);
pc = imap_next_word (pc);
idata = (IMAP_DATA *) ctx->data;
if (imap_parse_path (dest, &mx)) {
- dprint (1, (debugfile, "imap_copy_messages: bad destination %s\n", dest));
+ debug_print (1, ("bad destination %s\n", dest));
return -1;
}
/* check that the save-to folder is in the same account */
if (!mutt_account_match (&(CTX_DATA->conn->account), &(mx.account))) {
- dprint (3, (debugfile, "imap_copy_messages: %s not same server as %s\n",
- dest, ctx->path));
+ debug_print (3, ("%s not same server as %s\n", dest, ctx->path));
return 1;
}
if (h && h->attach_del) {
- dprint (3,
- (debugfile,
- "imap_copy_messages: Message contains attachments to be deleted\n"));
+ debug_print (3, ("Message contains attachments to be deleted\n"));
return 1;
}
* remainder. */
for (n = 0; n < ctx->msgcount; n++) {
if (ctx->hdrs[n]->tagged && ctx->hdrs[n]->attach_del) {
- dprint (3,
- (debugfile,
- "imap_copy_messages: Message contains attachments to be deleted\n"));
+ debug_print (3, ("Message contains attachments to be deleted\n"));
return 1;
}
rc = imap_sync_message (idata, ctx->hdrs[n], &sync_cmd, &err_continue);
if (rc < 0)
{
- dprint (1, (debugfile, "imap_copy_messages: could not sync\n"));
+ debug_print (1, ("could not sync\n"));
goto fail;
}
}
rc = imap_make_msg_set (idata, &cmd, M_TAG, 0);
if (!rc) {
- dprint (1, (debugfile, "imap_copy_messages: No messages tagged\n"));
+ debug_print (1, ("No messages tagged\n"));
goto fail;
}
mutt_message (_("Copying %d messages to %s..."), rc, mbox);
rc = imap_sync_message (idata, h, &sync_cmd, &err_continue);
if (rc < 0)
{
- dprint (1, (debugfile, "imap_copy_messages: could not sync\n"));
+ debug_print (1, ("could not sync\n"));
goto fail;
}
}
imap_error ("imap_copy_messages", idata->cmd.buf);
goto fail;
}
- dprint (2,
- (debugfile, "imap_copy_messages: server suggests TRYCREATE\n"));
+ debug_print (2, ("server suggests TRYCREATE\n"));
snprintf (mmbox, sizeof (mmbox), _("Create %s?"), mbox);
if (option (OPTCONFIRMCREATE) && mutt_yesorno (mmbox, 1) < 1) {
mutt_clear_error ();
memset (&newh, 0, sizeof (newh));
newh.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA));
- dprint (2, (debugfile, "imap_fetch_message: parsing FLAGS\n"));
+ debug_print (2, ("parsing FLAGS\n"));
if ((s = msg_parse_flags (&newh, s)) == NULL) {
FREE (&newh.data);
return NULL;
s += 12;
SKIPWS (s);
if (*s != '\"') {
- dprint (1,
- (debugfile,
- "msg_parse_fetch(): bogus INTERNALDATE entry: %s\n", s));
+ debug_print (1, ("bogus INTERNALDATE entry: %s\n", s));
return -1;
}
s++;
/* sanity-check string */
if (ascii_strncasecmp ("FLAGS", s, 5) != 0) {
- dprint (1, (debugfile, "msg_parse_flags: not a FLAGS response: %s\n", s));
+ debug_print (1, ("not a FLAGS response: %s\n", s));
return NULL;
}
s += 5;
SKIPWS (s);
if (*s != '(') {
- dprint (1, (debugfile, "msg_parse_flags: bogus FLAGS response: %s\n", s));
+ debug_print (1, ("bogus FLAGS response: %s\n", s));
return NULL;
}
s++;
s++;
}
else {
- dprint (1, (debugfile,
- "msg_parse_flags: Unterminated FLAGS response: %s\n", s));
+ debug_print (1, ("Unterminated FLAGS response: %s\n", s));
return NULL;
}
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <stdlib.h>
#include <ctype.h>
ImapPort = ntohs (service->s_port);
else
ImapPort = IMAP_PORT;
- dprint (3, (debugfile, "Using default IMAP port %d\n", ImapPort));
+ debug_print (3, ("Using default IMAP port %d\n", ImapPort));
}
if (!ImapsPort) {
service = getservbyname ("imaps", "tcp");
ImapsPort = ntohs (service->s_port);
else
ImapsPort = IMAP_SSL_PORT;
- dprint (3, (debugfile, "Using default IMAPS port %d\n", ImapsPort));
+ debug_print (3, ("Using default IMAPS port %d\n", ImapsPort));
}
/* Defaults */
}
if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1) {
- dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path));
+ debug_print (1, ("NULL host in %s\n", path));
FREE (&mx->mbox);
return -1;
}
if (!ascii_strncmp (tmp, "ssl", 3))
mx->account.flags |= M_ACCT_SSL;
else {
- dprint (1,
- (debugfile,
- "imap_parse_path: Unknown connection type in %s\n", path));
+ debug_print (1, ("Unknown connection type in %s\n", path));
FREE (&mx->mbox);
return -1;
}
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/wait.h>
+/* for synonym warning reports: synonym found during parsing */
+typedef struct {
+ char* f; /* file */
+ int l; /* line */
+ int n; /* new name (index) */
+ int o; /* old name (index) */
+} syn_t;
+
+/* for synonym warning reports: list of synonyms found */
list2_t* Synonyms;
+/* for synonym warning reports: current rc file */
+char* CurRCFile = NULL;
+/* for synonym warning reports: current rc line */
+int CurRCLine = 0;
+
+/* for synonym warning reports: adds synonym to end of list */
+static void syn_add (int n, int o) {
+ syn_t* tmp = safe_malloc (sizeof (syn_t));
+ tmp->f = safe_strdup (CurRCFile);
+ tmp->l = CurRCLine;
+ tmp->n = n;
+ tmp->o = o;
+ list_push_back (&Synonyms, tmp);
+}
+
+/* for synonym warning reports: free single item (for list_del()) */
+static void syn_del (void** p) {
+ FREE(&(*(syn_t**) p)->f);
+ FREE(p);
+}
void toggle_quadoption (int opt)
{
for (i = 0; MuttVars[i].option; i++)
if (safe_strcmp (s, MuttVars[i].option) == 0) {
if (MuttVars[i].type == DT_SYN)
- list_push_back (&Synonyms, &MuttVars[i]);
+ syn_add (mutt_option_index ((char *) MuttVars[i].data), i);
return (MuttVars[i].type ==
DT_SYN ? mutt_option_index ((char *) MuttVars[i].data) : i);
}
}
} while (pc && *pc != '`');
if (!pc) {
- dprint (1, (debugfile, "mutt_get_token: mismatched backtics\n"));
+ debug_print (1, ("mismatched backtics\n"));
return (-1);
}
cmd = str_substrdup (tok->dptr, pc);
if ((pid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
- dprint (1,
- (debugfile, "mutt_get_token: unable to fork command: %s",
- cmd));
+ debug_print (1, ("unable to fork command: %s\n", cmd));
FREE (&cmd);
return (-1);
}
mutt_extract_token (buf, s, 0);
- dprint (2, (debugfile, "parse_alias: First token is '%s'.\n", buf->data));
+ debug_print (2, ("first token is '%s'.\n", buf->data));
/* check to see if an alias with this name already exists */
for (; tmp; tmp = tmp->next) {
mutt_extract_token (buf, s,
M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON);
- dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n", buf->data));
+ debug_print (2, ("second token is '%s'.\n", buf->data));
tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data);
if (last)
last->next = tmp;
return -1;
}
#ifdef DEBUG
- if (debuglevel >= 2) {
+ if (DebugLevel >= 2) {
ADDRESS *a;
for (a = tmp->addr; a; a = a->next) {
if (!a->group)
- dprint (2, (debugfile, "parse_alias: %s\n", a->mailbox));
+ debug_print (2, ("%s\n", a->mailbox));
else
- dprint (2, (debugfile, "parse_alias: Group %s\n", a->mailbox));
+ debug_print (2, ("group %s\n", a->mailbox));
}
}
#endif
size_t buflen;
pid_t pid;
- dprint (2, (debugfile, "Reading configuration file '%s'.\n", rcfile));
+ debug_print (2, ("reading configuration file '%s'.\n", rcfile));
+ str_replace (&CurRCFile, rcfile);
+ CurRCLine = 0;
if ((f = mutt_open_read (rcfile, &pid)) == NULL) {
snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno));
memset (&token, 0, sizeof (token));
while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL) {
+ CurRCLine++;
conv = ConfigCharset && (*ConfigCharset) && Charset;
if (conv) {
currentline = safe_strdup (linebuf);
return (-1);
}
-#ifdef DEBUG
-static void start_debug (void)
-{
- time_t t;
- int i;
- char buf[_POSIX_PATH_MAX];
- char buf2[_POSIX_PATH_MAX];
-
- /* rotate the old debug logs */
- for (i = 3; i >= 0; i--) {
- snprintf (buf, sizeof (buf), "%s/.muttdebug%d", NONULL (Homedir), i);
- snprintf (buf2, sizeof (buf2), "%s/.muttdebug%d", NONULL (Homedir),
- i + 1);
- rename (buf, buf2);
- }
- if ((debugfile = safe_fopen (buf, "w")) != NULL) {
- t = time (0);
- setbuf (debugfile, NULL); /* don't buffer the debugging output! */
- fprintf (debugfile,
- "Mutt-ng %s started at %s.\nDebugging at level %d.\n\n",
- MUTT_VERSION, asctime (localtime (&t)), debuglevel);
- }
-}
-#endif
-
static int mutt_execute_commands (LIST * p)
{
BUFFER err, token;
Shell = safe_strdup ((p = getenv ("SHELL")) ? p : "/bin/sh");
}
-#ifdef DEBUG
- /* Start up debugging mode if requested */
- if (debuglevel > 0)
- start_debug ();
-#endif
+ debug_start(Homedir);
/* And about the host... */
uname (&utsname);
int i = 0;
fprintf (stderr, _("Warning: the following synonym variables were found:\n"));
for (i = 0; i < Synonyms->length; i++)
- fprintf (stderr, "$%s ($%s should be used)\n",
- ((struct option_t*) Synonyms->data[i])->option,
- (char*) ((struct option_t*) Synonyms->data[i])->data);
+ fprintf (stderr, "$%s ($%s should be used) (%s:%d)\n",
+ MuttVars[((syn_t*) Synonyms->data[i])->o].option,
+ MuttVars[((syn_t*) Synonyms->data[i])->n].option,
+ NONULL(((syn_t*) Synonyms->data[i])->f),
+ ((syn_t*) Synonyms->data[i])->l);
fprintf (stderr, _("Warning: Synonym variables are scheduled for removal.\n"));
- list_del (&Synonyms, NULL);
+ list_del (&Synonyms, syn_del);
need_pause = 1;
}
+ /* this is not needed during runtime */
+ FREE(&CurRCFile);
if (need_pause && !option (OPTNOCURSES)) {
if (mutt_any_key_to_continue (NULL) == -1)
#include "lib/mem.h"
#include "lib/str.h"
+#include "lib/debug.h"
extern short Umask;
if ((chunk = fread (buf, 1, chunk, in)) < 1)
break;
if (fwrite (buf, 1, chunk, out) != chunk) {
- /* dprint (1, (debugfile, "mutt_copy_bytes(): fwrite() returned short byte count\n")); */
+ debug_print (1, ("fwrite() returned short byte count\n"));
return (-1);
}
size -= chunk;
/* make sure the file is not symlink */
if (lstat (path, &osb) < 0 || fstat (fd, &nsb) < 0 ||
compare_stat (&osb, &nsb) == -1) {
-/* dprint (1, (debugfile, "safe_open(): %s is a symlink!\n", path)); */
+ debug_print (1, ("%s is a symlink!\n", path));
close (fd);
return (-1);
}
INCLUDES = -I$(top_srcdir) -I../intl
noinst_LIBRARIES = libsane.a
-noinst_HEADERS = mem.h str.h exit.h intl.h list.h rx.h
+noinst_HEADERS = mem.h str.h exit.h intl.h list.h rx.h debug.h
libsane_a_SOURCES = mem.c exit.c str.c list.c rx.h \
- mem.h exit.h str.h list.h rx.c intl.h
+ mem.h exit.h str.h list.h rx.c debug.h intl.h
+
+if WANT_DEBUG
+libsane_a_SOURCES += debug.c
+endif
--- /dev/null
+/*
+ * written for mutt-ng by:
+ * Rocco Rutte <pdmef@cs.tu-berlin.de>
+ *
+ * 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 <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+
+#include "debug.h"
+
+#include "mutt.h"
+#include "globals.h"
+#include "str.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 < 0 || !basedir || !*basedir)
+ return;
+ /* rotate the old debug logs */
+ for (i = 3; i >= 0; i--) {
+ snprintf (buf, sizeof (buf), "%s/.muttngdebug%d", NONULL (basedir), i);
+ snprintf (buf2, sizeof (buf2), "%s/.muttngdebug%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,
+ "Mutt-ng %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 < 0)
+ 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 */
--- /dev/null
+/*
+ * written for mutt-ng by:
+ * Rocco Rutte <pdmef@cs.tu-berlin.de>
+ *
+ * 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 <stdio.h>
+
+#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 */
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
break;
case 'd':
+ debug_setlevel(atoi(optarg));
#ifdef DEBUG
- debuglevel = atoi (optarg);
- printf (_("Debugging at level %d.\n"), debuglevel);
+ printf (_("Debugging at level %d.\n"), atoi(optarg));
#else
printf _("DEBUG was not defined during compilation. Ignored.\n");
#endif
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/stat.h>
#include <dirent.h>
if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL) {
/* TODO: memory leak??? */
- dprint (1, (debugfile, "mmdf_parse_mailbox: unexpected EOF\n"));
+ debug_print (1, ("unexpected EOF\n"));
break;
}
if (!is_from (buf, return_path, sizeof (return_path), &t)) {
if (fseek (ctx->fp, loc, SEEK_SET) != 0) {
- dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
mutt_error _("Mailbox is corrupt!");
return (-1);
fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
safe_strcmp (MMDF_SEP, buf) != 0) {
if (fseek (ctx->fp, loc, SEEK_SET) != 0)
- dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
hdr->content->length = -1;
}
}
ctx->msgcount++;
}
else {
- dprint (1, (debugfile, "mmdf_parse_mailbox: corrupt mailbox!\n"));
+ debug_print (1, ("corrupt mailbox!\n"));
mutt_error _("Mailbox is corrupt!");
return (-1);
if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
fgets (buf, sizeof (buf), ctx->fp) == NULL ||
safe_strncmp ("From ", buf, 5) != 0) {
- dprint (1,
- (debugfile,
- "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n",
- curhdr->index, curhdr->content->length));
- dprint (1, (debugfile, "\tLINE: %s", buf));
+ debug_print (1, ("bad content-length in message %d (cl=%ld)\n",
+ curhdr->index, curhdr->content->length));
+ debug_print (1, ("LINE: %s\n", buf));
if (fseek (ctx->fp, loc, SEEK_SET) != 0) { /* nope, return the previous position */
- dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
}
curhdr->content->length = -1;
}
/* count the number of lines in this message */
if (fseek (ctx->fp, loc, SEEK_SET) != 0)
- dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
while (cl-- > 0) {
if (fgetc (ctx->fp) == '\n')
curhdr->lines++;
/* return to the offset of the next message separator */
if (fseek (ctx->fp, tmploc, SEEK_SET) != 0)
- dprint (1, (debugfile, "mbox_parse_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
}
}
* folder.
*/
if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
- dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL) {
if ((ctx->magic == M_MBOX && safe_strncmp ("From ", buffer, 5) == 0)
|| (ctx->magic == M_MMDF && safe_strcmp (MMDF_SEP, buffer) == 0)) {
if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
- dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
if (ctx->magic == M_MBOX)
mbox_parse_mailbox (ctx);
else
modified = 1;
}
else {
- dprint (1, (debugfile, "mbox_check_mailbox: fgets returned NULL.\n"));
+ debug_print (1, ("fgets returned NULL.\n"));
modified = 1;
}
}
mutt_error
_("sync: mbox modified, but no modified messages! (report this bug)");
mutt_sleep (5); /* the mutt_error /will/ get cleared! */
- dprint (1, (debugfile, "_mbox_sync_mailbox(): no modified messages.\n"));
+ debug_print (1, ("no modified messages.\n"));
unlink (tempfile);
goto bail;
}
if (fclose (fp) != 0) {
fp = NULL;
- dprint (1,
- (debugfile, "_mbox_sync_mailbox: fclose() returned non-zero.\n"));
+ debug_print (1, ("fclose() returned non-zero.\n"));
unlink (tempfile);
mutt_perror (tempfile);
mutt_sleep (5);
if ((fp = fopen (tempfile, "r")) == NULL) {
mutt_unblock_signals ();
mx_fastclose_mailbox (ctx);
- dprint (1,
- (debugfile,
- "_mbox_sync_mailbox: unable to reopen temp copy of mailbox!\n"));
+ debug_print (1, ("unable to reopen temp copy of mailbox!\n"));
mutt_perror (tempfile);
mutt_sleep (5);
return (-1);
fgets (buf, sizeof (buf), ctx->fp) == NULL ||
(ctx->magic == M_MBOX && safe_strncmp ("From ", buf, 5) != 0) ||
(ctx->magic == M_MMDF && safe_strcmp (MMDF_SEP, buf) != 0)) {
- dprint (1,
- (debugfile,
- "_mbox_sync_mailbox: message not in expected position."));
- dprint (1, (debugfile, "\tLINE: %s\n", buf));
+ debug_print (1, ("message not in expected position.\n"));
+ debug_print (1, ("LINE: %s\n", buf));
i = -1;
}
else {
if (fseek (ctx->fp, offset, SEEK_SET) != 0) { /* return to proper offset */
i = -1;
- dprint (1, (debugfile, "_mbox_sync_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
}
else {
/* copy the temp mailbox back into place starting at the first
case M_MBOX:
case M_MMDF:
if (fseek (ctx->fp, 0, SEEK_SET) != 0) {
- dprint (1, (debugfile, "mbox_reopen_mailbox: fseek() failed\n"));
+ debug_print (1, ("fseek() failed\n"));
rc = -1;
}
else {
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/stat.h>
#include <sys/types.h>
/* FOO - really ignore the return value? */
- dprint (2,
- (debugfile, "%s:%d: parsing %s\n", __FILE__, __LINE__,
- de->d_name));
+ debug_print (2, ("parsing %s\n", de->d_name));
maildir_parse_entry (ctx, last, subdir, de->d_name, count, is_old,
de->d_ino);
}
while (md) {
- dprint (2, (debugfile, "%s:%d maildir_add_to_context(): Considering %s\n",
- __FILE__, __LINE__, NONULL (md->canon_fname)));
+ debug_print (2, ("considering %s\n", NONULL (md->canon_fname)));
if (md->h) {
- dprint (2,
- (debugfile,
- "%s:%d Adding header structure. Flags: %s%s%s%s%s\n", __FILE__,
- __LINE__, md->h->flagged ? "f" : "", md->h->deleted ? "D" : "",
- md->h->replied ? "r" : "", md->h->old ? "O" : "",
- md->h->read ? "R" : ""));
+ debug_print (2, ("flags: %s%s%s%s%s\n", md->h->flagged ? "f" : "",
+ md->h->deleted ? "D" : "", md->h->replied ? "r" : "",
+ md->h->old ? "O" : "", md->h->read ? "R" : ""));
if (ctx->msgcount == ctx->hdrmax)
mx_alloc_memory (ctx);
dest->path, subdir, (long) time (NULL),
(unsigned int) getpid (), Counter++, NONULL (Hostname), suffix);
- dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
- path));
+ debug_print (2, ("trying %s.\n", path));
umask (Umask);
if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1) {
}
}
else {
- dprint (2, (debugfile, "maildir_open_new_message (): Success.\n"));
+ debug_print (2, ("success.\n"));
msg->path = safe_strdup (path);
break;
}
NONULL (Hostname), suffix);
snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
- dprint (2, (debugfile, "maildir_commit_message (): renaming %s to %s.\n",
- msg->path, full));
+ debug_print (2, ("renaming %s to %s.\n", msg->path, full));
if (safe_rename (msg->path, full) == 0) {
if (hdr)
char *p;
if ((p = strrchr (h->path, '/')) == NULL) {
- dprint (1,
- (debugfile,
- "maildir_sync_message: %s: unable to find subdir!\n",
- h->path));
+ debug_print (1, ("%s: unable to find subdir!\n", h->path));
return (-1);
}
p++;
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
/* The low-level interface we use. */
if (!irrev && idna_to_ascii_8z (tmp, &t2, 1) != IDNA_SUCCESS)
irrev = 1;
if (!irrev && ascii_strcasecmp (t2, in)) {
- dprint (1,
- (debugfile,
- "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
- in, t2));
+ debug_print (1, ("not reversible. in = '%s', t2 = '%s'.\n", in, t2));
irrev = 1;
}
#include "mutt_socket.h"
#include "lib/mem.h"
+#include "lib/debug.h"
#ifdef USE_SASL2
#include <errno.h>
{
int err;
- dprint (1, (debugfile, "getnameinfo: "));
switch (ret) {
case EAI_AGAIN:
- dprint (1,
- (debugfile,
- "The name could not be resolved at this time. Future attempts may succeed.\n"));
+ debug_print (1, ("The name could not be resolved at this time. Future attempts may succeed.\n"));
err = SASL_TRYAGAIN;
break;
case EAI_BADFLAGS:
- dprint (1, (debugfile, "The flags had an invalid value.\n"));
+ debug_print (1, ("The flags had an invalid value.\n"));
err = SASL_BADPARAM;
break;
case EAI_FAIL:
- dprint (1, (debugfile, "A non-recoverable error occurred.\n"));
+ debug_print (1, ("A non-recoverable error occurred.\n"));
err = SASL_FAIL;
break;
case EAI_FAMILY:
- dprint (1,
- (debugfile,
- "The address family was not recognized or the address length was invalid for the specified family.\n"));
+ debug_print (1, ("The address family was not recognized or the address length was invalid for the specified family.\n"));
err = SASL_BADPROT;
break;
case EAI_MEMORY:
- dprint (1, (debugfile, "There was a memory allocation failure.\n"));
+ debug_print (1, ("There was a memory allocation failure.\n"));
err = SASL_NOMEM;
break;
case EAI_NONAME:
- dprint (1,
- (debugfile,
- "The name does not resolve for the supplied parameters. NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n"));
+ debug_print (1, ("The name does not resolve for the supplied parameters. NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n"));
err = SASL_FAIL; /* no real equivalent */
break;
case EAI_SYSTEM:
- dprint (1,
- (debugfile,
- "A system error occurred. The error code can be found in errno(%d,%s)).\n",
- errno, strerror (errno)));
+ debug_print (1, ("A system error occurred. The error code can be found in errno(%d,%s)).\n",
+ errno, strerror (errno)));
err = SASL_FAIL; /* no real equivalent */
break;
default:
- dprint (1, (debugfile, "Unknown error %d\n", ret));
+ debug_print (1, ("Unknown error %d\n", ret));
err = SASL_FAIL; /* no real equivalent */
break;
}
rc = sasl_client_init (callbacks);
if (rc != SASL_OK) {
- dprint (1,
- (debugfile, "mutt_sasl_start: libsasl initialisation failed.\n"));
+ debug_print (1, ("libsasl initialisation failed.\n"));
return SASL_FAIL;
}
service = "pop";
break;
default:
- dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
+ debug_print (1, ("account type unset\n"));
return -1;
}
#ifdef USE_SASL2
size = sizeof (local);
if (getsockname (conn->fd, (struct sockaddr *) &local, &size)) {
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: getsockname for local failed\n"));
+ debug_print (1, ("getsockname for local failed\n"));
return -1;
}
else
if (iptostring
((struct sockaddr *) &local, size, iplocalport,
IP_PORT_BUFLEN) != SASL_OK) {
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: iptostring for local failed\n"));
+ debug_print (1, ("iptostring for local failed\n"));
return -1;
}
size = sizeof (remote);
if (getpeername (conn->fd, (struct sockaddr *) &remote, &size)) {
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: getsockname for remote failed\n"));
+ debug_print (1, ("getsockname for remote failed\n"));
return -1;
}
else
if (iptostring
((struct sockaddr *) &remote, size, ipremoteport,
IP_PORT_BUFLEN) != SASL_OK) {
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: iptostring for remote failed\n"));
+ debug_print (1, ("iptostring for remote failed\n"));
return -1;
}
- dprint (1,
- (debugfile, "local ip: %s, remote ip:%s\n", iplocalport,
- ipremoteport));
+ debug_print (1, ("local ip: %s, remote ip:%s\n", iplocalport, ipremoteport));
rc =
sasl_client_new (service, conn->account.host, iplocalport, ipremoteport,
#endif
if (rc != SASL_OK) {
- dprint (1, (debugfile,
- "mutt_sasl_client_new: Error allocating SASL connection\n"));
+ debug_print (1, ("Error allocating SASL connection\n"));
return -1;
}
#ifdef SASL_IP_LOCAL
if (sasl_setprop (*saslconn, SASL_IP_LOCAL, &local) != SASL_OK) {
- dprint (1, (debugfile,
- "mutt_sasl_client_new: Error setting local IP address\n"));
+ debug_print (1, ("Error setting local IP address\n"));
return -1;
}
#endif
#ifdef SASL_IP_REMOTE
if (sasl_setprop (*saslconn, SASL_IP_REMOTE, &remote) != SASL_OK) {
- dprint (1, (debugfile,
- "mutt_sasl_client_new: Error setting remote IP address\n"));
+ debug_print (1, ("Error setting remote IP address\n"));
return -1;
}
#endif
secprops.maxbufsize = M_SASL_MAXBUF;
secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
if (sasl_setprop (*saslconn, SASL_SEC_PROPS, &secprops) != SASL_OK) {
- dprint (1, (debugfile,
- "mutt_sasl_client_new: Error setting security properties\n"));
+ debug_print (1, ("Error setting security properties\n"));
return -1;
}
#if (defined(USE_SSL) || defined(USE_GNUTLS) && !defined(USE_NSS))
if (conn->account.flags & M_ACCT_SSL) {
#ifdef USE_SASL2 /* I'm not sure this actually has an effect, at least with SASLv2 */
- dprint (2, (debugfile, "External SSF: %d\n", conn->ssf));
+ debug_print (2, ("External SSF: %d\n", conn->ssf));
if (sasl_setprop (*saslconn, SASL_SSF_EXTERNAL, &(conn->ssf)) != SASL_OK)
#else
memset (&extprops, 0, sizeof (extprops));
extprops.ssf = conn->ssf;
- dprint (2, (debugfile, "External SSF: %d\n", extprops.ssf));
+ debug_print (2, ("External SSF: %d\n", extprops.ssf));
if (sasl_setprop (*saslconn, SASL_SSF_EXTERNAL, &extprops) != SASL_OK)
#endif
{
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: Error setting external properties\n"));
+ debug_print (1, ("Error setting external properties\n"));
return -1;
}
#ifdef USE_SASL2
- dprint (2,
- (debugfile, "External authentication name: %s\n",
- conn->account.user));
+ debug_print (2, ("External authentication name: %s\n", conn->account.user));
if (sasl_setprop (*saslconn, SASL_AUTH_EXTERNAL, conn->account.user) !=
SASL_OK) {
- dprint (1,
- (debugfile,
- "mutt_sasl_client_new: Error setting external properties\n"));
+ debug_print (1, ("Error setting external properties\n"));
return -1;
}
#endif
char resp[SHORT_STRING];
while (interaction->id != SASL_CB_LIST_END) {
- dprint (2,
- (debugfile,
- "mutt_sasl_interact: filling in SASL interaction %ld.\n",
- interaction->id));
+ debug_print (2, ("filling in SASL interaction %ld.\n", interaction->id));
snprintf (prompt, sizeof (prompt), "%s: ", interaction->prompt);
resp[0] = '\0';
#else
sasl_getprop (saslconn, SASL_SSF, (void **) &sasldata->ssf);
#endif
- dprint (3, (debugfile, "SASL protection strength: %u\n", *sasldata->ssf));
+ debug_print (3, ("SASL protection strength: %u\n", *sasldata->ssf));
/* Add SASL SSF to transport SSF */
conn->ssf += *sasldata->ssf;
#ifdef USE_SASL2
#else
sasl_getprop (saslconn, SASL_MAXOUTBUF, (void **) &sasldata->pbufsize);
#endif
- dprint (3,
- (debugfile, "SASL protection buffer size: %u\n",
- *sasldata->pbufsize));
+ debug_print (3, ("SASL protection buffer size: %u\n", *sasldata->pbufsize));
/* clear input buffer */
sasldata->buf = NULL;
/* mutt_sasl_cb_log: callback to log SASL messages */
static int mutt_sasl_cb_log (void *context, int priority, const char *message)
{
- dprint (priority, (debugfile, "SASL: %s\n", message));
+ debug_print (priority, ("SASL: %s\n", message));
return SASL_OK;
}
if (!account)
return SASL_BADPARAM;
- dprint (2, (debugfile, "mutt_sasl_cb_authname: getting %s for %s:%u\n",
+ debug_print (2, ("getting %s for %s:%u\n",
id == SASL_CB_AUTHNAME ? "authname" : "user",
account->host, account->port));
if (!account || !psecret)
return SASL_BADPARAM;
- dprint (2, (debugfile,
- "mutt_sasl_cb_pass: getting password for %s@%s:%u\n",
+ debug_print (2, ("getting password for %s@%s:%u\n",
account->user, account->host, account->port));
if (mutt_account_getpass (account))
rc = sasl_decode (sasldata->saslconn, buf, rc, &sasldata->buf,
&sasldata->blen);
if (rc != SASL_OK) {
- dprint (1, (debugfile, "SASL decode failed: %s\n",
+ debug_print (1, ("SASL decode failed: %s\n",
sasl_errstring (rc, NULL, NULL)));
goto out;
}
rc = sasl_encode (sasldata->saslconn, buf, olen, &pbuf, &plen);
if (rc != SASL_OK) {
- dprint (1, (debugfile, "SASL encoding failed: %s\n",
+ debug_print (1, ("SASL encoding failed: %s\n",
sasl_errstring (rc, NULL, NULL)));
goto fail;
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <unistd.h>
#include <netinet/in.h>
int rc = -1;
if (conn->fd < 0)
- dprint (1,
- (debugfile,
- "mutt_socket_close: Attempt to close closed connection.\n"));
+ debug_print (1, ("Attempt to close closed connection.\n"));
else
rc = conn->conn_close (conn);
int rc;
if (conn->fd < 0) {
- dprint (1,
- (debugfile,
- "mutt_socket_read: attempt to read from closed connection\n"));
+ debug_print (1, ("attempt to read from closed connection\n"));
return -1;
}
int rc;
int len;
- dprint (dbg, (debugfile, "> %s", buf));
+ debug_print (dbg, ("> %s", buf));
if (conn->fd < 0) {
- dprint (1,
- (debugfile,
- "mutt_socket_write: attempt to write to closed connection\n"));
+ debug_print (1, ("attempt to write to closed connection\n"));
return -1;
}
len = safe_strlen (buf);
if ((rc = conn->conn_write (conn, buf, len)) < 0) {
- dprint (1, (debugfile,
- "mutt_socket_write: error writing, closing socket\n"));
+ debug_print (1, ("error writing, closing socket\n"));
mutt_socket_close (conn);
return -1;
}
if (rc < len) {
- dprint (1, (debugfile,
- "mutt_socket_write: ERROR: wrote %d of %d bytes!\n", rc,
- len));
+ debug_print (1, ("ERROR: wrote %d of %d bytes!\n", rc, len));
}
return rc;
conn->available =
conn->conn_read (conn, conn->inbuf, sizeof (conn->inbuf));
else {
- dprint (1,
- (debugfile,
- "mutt_socket_readchar: attempt to read from closed connection.\n"));
+ debug_print (1, ("attempt to read from closed connection.\n"));
return -1;
}
conn->bufpos = 0;
else
buf[i] = '\0';
- dprint (dbg, (debugfile, "< %s\n", buf));
+ debug_print (dbg, ("< %s\n", buf));
/* number of bytes read, not safe_strlen */
return i + 1;
int save_errno;
if (safe_strlen (Preconnect)) {
- dprint (2, (debugfile, "Executing preconnect: %s\n", Preconnect));
+ debug_print (2, ("Executing preconnect: %s\n", Preconnect));
rc = mutt_system (Preconnect);
- dprint (2, (debugfile, "Preconnect result: %d\n", rc));
+ debug_print (2, ("Preconnect result: %d\n", rc));
if (rc) {
save_errno = errno;
mutt_perror (_("Preconnect command failed."));
sa_size = sizeof (struct sockaddr_in6);
#endif
else {
- dprint (1, (debugfile, "Unknown address family!\n"));
+ debug_print (1, ("Unknown address family!\n"));
return -1;
}
if (connect (fd, sa, sa_size) < 0) {
save_errno = errno;
- dprint (2, (debugfile, "Connection failed. errno: %d...\n", errno));
+ debug_print (2, ("Connection failed. errno: %d...\n", errno));
SigInt = 0; /* reset in case we caught SIGINTR while in connect() */
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#if OPENSSL_VERSION_NUMBER >= 0x00904000L
#define READ_X509_KEY(fp, key) PEM_read_X509(fp, key, NULL, NULL)
ssldata = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata));
/* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS. */
if (!(ssldata->ctx = SSL_CTX_new (TLSv1_client_method ()))) {
- dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL_CTX\n"));
+ debug_print (1, ("Error allocating SSL_CTX\n"));
goto bail_ssldata;
}
ssl_get_client_cert (ssldata, conn);
if (!(ssldata->ssl = SSL_new (ssldata->ctx))) {
- dprint (1, (debugfile, "mutt_ssl_starttls: Error allocating SSL\n"));
+ debug_print (1, ("Error allocating SSL\n"));
goto bail_ctx;
}
if (SSL_set_fd (ssldata->ssl, conn->fd) != 1) {
- dprint (1, (debugfile, "mutt_ssl_starttls: Error setting fd\n"));
+ debug_print (1, ("Error setting fd\n"));
goto bail_ssl;
}
if (X509_STORE_set_default_paths (ctx))
pass++;
else
- dprint (2, (debugfile, "X509_STORE_set_default_paths failed\n"));
+ debug_print (2, ("X509_STORE_set_default_paths failed\n"));
}
if (X509_STORE_load_locations (ctx, SslCertFile, NULL))
pass++;
else
- dprint (2, (debugfile, "X509_STORE_load_locations_failed\n"));
+ debug_print (2, ("X509_STORE_load_locations_failed\n"));
if (pass == 0) {
/* nothing to do */
err = X509_STORE_CTX_get_error (&xsc);
snprintf (buf, sizeof (buf), "%s (%d)",
X509_verify_cert_error_string (err), err);
- dprint (2, (debugfile, "X509_verify_cert: %s\n", buf));
+ debug_print (2, ("X509_verify_cert: %s\n", buf));
}
#endif
X509_STORE_CTX_cleanup (&xsc);
/* expiration check */
if (X509_cmp_current_time (X509_get_notBefore (peercert)) >= 0) {
- dprint (2, (debugfile, "Server certificate is not yet valid\n"));
+ debug_print (2, ("Server certificate is not yet valid\n"));
mutt_error (_("Server certificate is not yet valid"));
mutt_sleep (2);
return 0;
}
if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0) {
- dprint (2, (debugfile, "Server certificate has expired"));
+ debug_print (2, ("Server certificate has expired\n"));
mutt_error (_("Server certificate has expired"));
mutt_sleep (2);
return 0;
char *name = NULL, *c;
if (check_certificate_by_signer (data->cert)) {
- dprint (1, (debugfile, "ssl_check_certificate: signer check passed\n"));
+ debug_print (1, ("signer check passed\n"));
return 1;
}
/* automatic check from user's database */
if (SslCertFile && check_certificate_by_digest (data->cert)) {
- dprint (1, (debugfile, "ssl_check_certificate: digest check passed\n"));
+ debug_print (1, ("digest check passed\n"));
return 1;
}
static void ssl_get_client_cert (sslsockdata * ssldata, CONNECTION * conn)
{
if (SslClientCert) {
- dprint (2, (debugfile, "Using client certificate %s\n", SslClientCert));
+ debug_print (2, ("Using client certificate %s\n", SslClientCert));
SSL_CTX_set_default_passwd_cb_userdata (ssldata->ctx, &conn->account);
SSL_CTX_set_default_passwd_cb (ssldata->ctx, ssl_passwd_cb);
SSL_CTX_use_certificate_file (ssldata->ctx, SslClientCert,
if (mutt_account_getuser (account))
return 0;
- dprint (2, (debugfile, "ssl_passwd_cb: getting password for %s@%s:%u\n",
+ debug_print (2, ("getting password for %s@%s:%u\n",
account->user, account->host, account->port));
if (mutt_account_getpass (account))
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <ctype.h>
if (b->parameter)
mutt_free_parameter (&b->parameter);
if (b->unlink && b->filename) {
- dprint (1, (debugfile, "mutt_free_body: Unlinking %s.\n", b->filename));
+ debug_print (1, ("unlinking %s.\n", b->filename));
unlink (b->filename);
}
else if (b->filename)
- dprint (1,
- (debugfile, "mutt_free_body: Not unlinking %s.\n",
- b->filename));
+ debug_print (1, ("not unlinking %s.\n", b->filename));
FREE (&b->filename);
FREE (&b->content);
{
snprintf (s, _POSIX_PATH_MAX, "%s/muttng-%s-%d-%d-%d", NONULL (Tempdir),
NONULL (Hostname), (int) getuid (), (int) getpid (), Counter++);
- dprint (1,
- (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
+ debug_print (1, ("%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
unlink (s);
}
if (regexec
(l->rx->rx, s, (size_t) l->nmatch, (regmatch_t *) pmatch,
(int) 0) == 0) {
- dprint (5,
- (debugfile, "mutt_match_spam_list: %s matches %s\n", s,
- l->rx->pattern));
- dprint (5,
- (debugfile, "mutt_match_spam_list: %d subs\n",
- l->rx->rx->re_nsub));
+ debug_print (5, ("%s matches %s\n%d subst", s, l->rx->pattern, l->rx->rx->re_nsub));
/* Copy template into text, with substitutions. */
for (p = l->template; *p;) {
}
}
text[tlen] = '\0';
- dprint (5, (debugfile, "mutt_match_spam_list: \"%s\"\n", text));
+ debug_print (5, ("\"%s\"\n", text));
return 1;
}
}
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
+#include "lib/debug.h"
#include <dirent.h>
#include <fcntl.h>
while (fcntl (fd, F_SETLK, &lck) == -1) {
struct stat sb;
- dprint (1, (debugfile, "mx_lock_file(): fcntl errno %d.\n", errno));
+ debug_print (1, ("fcntl errno %d.\n", errno));
if (errno != EAGAIN && errno != EACCES) {
mutt_perror ("fcntl");
return (-1);
ADDRESS *p = NULL;
if (!MX_IDX(dest->magic-1)) {
- dprint (1, (debugfile, "mx_open_new_message(): function "
- "unimplemented for mailbox type %d.\n", dest->magic));
+ debug_print (1, ("function unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
}
}
- dprint (1, (debugfile, "mx_check_mailbox: null or invalid context.\n"));
+ debug_print (1, ("null or invalid context.\n"));
return (-1);
}
if (msg->fp == NULL) {
mutt_perror (path);
- dprint (1, (debugfile, "mx_open_message: fopen: %s: %s (errno %d).\n",
- path, strerror (errno), errno));
+ debug_print (1, ("fopen: %s: %s (errno %d).\n", path, strerror (errno), errno));
FREE (&msg);
}
}
#endif /* USE_NNTP */
default:
- dprint (1,
- (debugfile,
- "mx_open_message(): function not implemented for mailbox type %d.\n",
- ctx->magic));
+ debug_print (1, ("function not implemented for mailbox type %d.\n", ctx->magic));
FREE (&msg);
break;
}
int r = 0;
if (!(msg->write && ctx->append)) {
- dprint (1,
- (debugfile,
- "mx_commit_message(): msg->write = %d, ctx->append = %d\n",
- msg->write, ctx->append));
+ debug_print (1, ("msg->write = %d, ctx->append = %d\n", msg->write, ctx->append));
return -1;
}
(*msg)->fp = NULL;
if ((*msg)->path) {
- dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",
- (*msg)->path));
+ debug_print (1, ("unlinking %s\n", (*msg)->path));
unlink ((*msg)->path);
FREE (&(*msg)->path);
}
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <unistd.h>
#include <string.h>
data->lastMessage = data->entries[x - 1].last;
data->num = x;
mutt_newsgroup_stat (data);
- dprint (2, (debugfile, "parse_line: Newsgroup %s\n", data->group));
+ debug_print (2, ("Newsgroup %s\n", data->group));
return 0;
}
if (!data) {
#ifdef DEBUG
if (group)
- dprint (3, (debugfile, "newsgroup %s not found\n", group));
+ debug_print (3, ("newsgroup %s not found\n", group));
#endif
return;
}
if (!data || !data->rc)
continue;
nntp_create_newsrc_line (data, &buf, &line, &llen);
- dprint (2, (debugfile, "Added to newsrc: %s", line));
+ debug_print (2, ("Added to newsrc: %s\n", line));
line += safe_strlen (line);
}
/* newrc being fully rewritten */
if (!data || data->subscribed || !data->cache)
continue;
nntp_delete_cache (data);
- dprint (2, (debugfile, "Removed from .index: %s\n", data->group));
+ debug_print (2, ("Removed from .index: %s\n", data->group));
}
return;
}
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <unistd.h>
#include <string.h>
static unsigned int _checked = 0;
-#ifdef DEBUG
-static void nntp_error (const char *where, const char *msg)
-{
- dprint (1,
- (debugfile, "nntp_error(): unexpected response in %s: %s\n", where,
- msg));
+static void nntp_error (const char *where, const char *msg) {
+ debug_print (1, ("unexpected response in %s: %s\n", where, msg));
}
-#endif /* DEBUG */
static int nntp_auth (NNTP_SERVER * serv)
{
#ifdef DEBUG
/* don't print the password unless we're at the ungodly debugging level */
- if (debuglevel < M_SOCK_LOG_FULL)
- dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
+ if (DebugLevel < M_SOCK_LOG_FULL)
+ debug_print (M_SOCK_LOG_CMD, ("> AUTHINFO PASS *\n"));
#endif
snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
mutt_socket_write_d (conn, buf, M_SOCK_LOG_FULL);
ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
if (ret) {
-#ifdef DEBUG
if (ret != -1)
- dprint (1, (debugfile, "nntp_read_header: %s\n", buf));
-#endif
+ debug_print (1, ("%s\n", buf));
fclose (f);
unlink (tempfile);
return (ret == -1 ? -1 : 1);
d++;
while (*d && (*d == '\t' || *d == ' '))
d++;
- dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
+ debug_print (2, ("group: %s, desc: %s\n", line, d));
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
safe_strcmp (d, data->desc)) {
FREE (&data->desc);
if (ret == 1) {
mutt_error (_("Article %d not found on server"),
ctx->hdrs[msgno]->article_num);
- dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
+ debug_print (1, ("%s\n", buf));
}
if (ret) {
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
+#include "lib/debug.h"
#include <sys/stat.h>
#include <ctype.h>
}
else if (*p == '\033' && *(p + 1) == ']'
&& check_attachment_marker ((char *) p) == 0) {
- dprint (2, (debugfile, "fill_buffer: Seen attachment marker.\n"));
+ debug_print (2, ("seen attachment marker.\n"));
while (*p++ != '\a') /* skip pseudo-ANSI sequence */
;
}
k = mbrtowc (&wc, (char *) buf + ch, cnt - ch, &mbstate);
if (k == -2 || k == -1) {
- dprint (1, (debugfile, "%s:%d: mbrtowc returned %d; errno = %d.\n",
- __FILE__, __LINE__, k, errno));
+ debug_print (1, ("mbrtowc returned %d; errno = %d.\n", k, errno));
if (col + 4 > wrap_cols)
break;
col += 4;
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/rx.h"
+#include "lib/debug.h"
#include <string.h>
#include <ctype.h>
const char *p;
size_t i;
- dprint (2, (debugfile, "parse_parameters: `%s'\n", s));
+ debug_print (2, ("`%s'\n", s));
while (*s) {
if ((p = strpbrk (s, "=;")) == NULL) {
- dprint (1,
- (debugfile, "parse_parameters: malformed parameter: %s\n", s));
+ debug_print (1, ("malformed parameter: %s\n", s));
goto bail;
}
new->value = safe_strdup (buffer);
- dprint (2, (debugfile, "parse_parameter: `%s' = `%s'\n",
- new->attribute ? new->attribute : "",
+ debug_print (2, ("`%s' = `%s'\n", new->attribute ? new->attribute : "",
new->value ? new->value : ""));
/* Add this parameter to the list */
head = cur = new;
}
else {
- dprint (1,
- (debugfile, "parse_parameters(): parameter with no value: %s\n",
- s));
+ debug_print (1, ("parameter with no value: %s\n", s));
s = p;
}
c++;
SKIPWS (c);
if (!*c) {
- dprint (1,
- (debugfile,
- "mutt_read_mime_header(): skipping empty header field: %s\n",
- line));
+ debug_print (1, ("skipping empty header field: %s\n", line));
continue;
}
}
else {
- dprint (1,
- (debugfile, "read_mime_header: bogus MIME header: %s\n", line));
+ debug_print (1, ("bogus MIME header: %s\n", line));
break;
}
else if (sscanf (t, "%d:%d", &hour, &min) == 2)
sec = 0;
else {
- dprint (1,
- (debugfile, "parse_date: could not process time format: %s\n",
- t));
+ debug_print (1, ("could not process time format: %s\n", t));
return (-1);
}
tm.tm_hour = hour;
}
if (count < 4) { /* don't check for missing timezone */
- dprint (1,
- (debugfile,
- "parse_date(): error parsing date format, using received time\n"));
+ debug_print (1, ("error parsing date format, using received time\n"));
return (-1);
}
}
if (e->spam && e->spam->data)
- dprint (5, (debugfile, "p822: spam = %s\n", e->spam->data));
+ debug_print (5, ("spam = %s\n", e->spam->data));
}
}
/* check for missing or invalid date */
if (hdr->date_sent <= 0) {
- dprint (1,
- (debugfile,
- "read_rfc822_header(): no date found, using received time from msg separator\n"));
+ debug_print (1, ("no date found, using received time from msg separator\n"));
hdr->date_sent = hdr->received;
}
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/wait.h>
#include <string.h>
while ((line = mutt_read_line (line, &linelen, fpin, &lineno)) != NULL) {
if (regexec (PgpGoodSign.rx, line, 0, NULL, 0) == 0) {
- dprint (2, (debugfile, "pgp_copy_checksig: \"%s\" matches regexp.\n",
- line));
+ debug_print (2, ("\"%s\" matches regexp.\n", line));
rv = 0;
}
else
- dprint (2,
- (debugfile,
- "pgp_copy_checksig: \"%s\" doesn't match regexp.\n", line));
+ debug_print (2, ("\"%s\" doesn't match regexp.\n", line));
if (strncmp (line, "[GNUPG:] ", 9) == 0)
continue;
FREE (&line);
}
else {
- dprint (2, (debugfile, "pgp_copy_checksig: No pattern.\n"));
+ debug_print (2, ("No pattern.\n"));
mutt_copy_stream (fpin, fpout);
rv = 1;
}
if ((rv = mutt_wait_filter (thepid)))
badsig = -1;
- dprint (1,
- (debugfile, "pgp_verify_one: mutt_wait_filter returned %d.\n",
- rv));
+ debug_print (1, ("mutt_wait_filter returned %d.\n", rv));
}
safe_fclose (&pgperr);
mutt_unlink (sigfile);
mutt_unlink (pgperrfile);
- dprint (1, (debugfile, "pgp_verify_one: returning %d.\n", badsig));
+ debug_print (1, ("returning %d.\n", badsig));
return badsig;
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
/*
* The actual command line formatter.
{
mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_pgp_command,
(unsigned long) cctx, 0);
- dprint (2, (debugfile, "mutt_pgp_command: %s\n", d));
+ debug_print (2, ("%s\n", d));
}
/*
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <ctype.h>
if (!keys)
return NULL;
- dprint (5, (debugfile, "pgp_getkeybyaddr: looking for %s <%s>.",
- a->personal, a->mailbox));
-
+ debug_print (5, ("looking for %s <%s>\n", a->personal, a->mailbox));
for (k = keys; k; k = kn) {
kn = k->next;
- dprint (5, (debugfile, " looking at key: %s\n", pgp_keyid (k)));
+ debug_print (5, (" looking at key: %s\n", pgp_keyid (k)));
if (abilities && !(k->flags & abilities)) {
- dprint (5, (debugfile, " insufficient abilities: Has %x, want %x\n",
+ debug_print (5, (" insufficient abilities: Has %x, want %x\n",
k->flags, abilities));
continue;
}
match = 0;
for (a = k->address; a; a = a->next) {
- dprint (5,
- (debugfile,
- "pgp_getkeybystr: matching \"%s\" against key %s, \"%s\": ", p,
- pgp_keyid (k), a->addr));
+ debug_print (5, ("matching \"%s\" against key %s, \"%s\":\n", p, pgp_keyid (k), a->addr));
if (!*p || safe_strcasecmp (p, pgp_keyid (k)) == 0
|| (!safe_strncasecmp (p, "0x", 2)
&& !safe_strcasecmp (p + 2, pgp_keyid (k)))
|| (option (OPTPGPLONGIDS) && !safe_strncasecmp (p, "0x", 2)
&& !safe_strcasecmp (p + 2, k->keyid + 8))
|| str_isstr (a->addr, p)) {
- dprint (5, (debugfile, "match.\n"));
+ debug_print (5, ("match.\n"));
match = 1;
break;
}
#include <string.h>
#include <ctype.h>
+#include "lib/debug.h"
+
static struct {
short id;
const char *name;
break;
}
if (r == NULL) {
- dprint (1,
- (debugfile, "pgp_dearmor: Can't find begin of ASCII armor.\n"));
+ debug_print (1, ("Can't find begin of ASCII armor.\n"));
return;
}
break;
}
if (r == NULL) {
- dprint (1, (debugfile, "pgp_dearmor: Armor header doesn't end.\n"));
+ debug_print (1, ("Armor header doesn't end.\n"));
return;
}
break;
}
if (r == NULL) {
- dprint (1, (debugfile, "pgp_dearmor: Can't find end of ASCII armor.\n"));
+ debug_print (1, ("Can't find end of ASCII armor.\n"));
return;
}
if ((end = ftell (in) - safe_strlen (line)) < start) {
- dprint (1, (debugfile, "pgp_dearmor: end < start???\n"));
+ debug_print (1, ("end < start???\n"));
return;
}
if (fseek (in, start, SEEK_SET) == -1) {
- dprint (1, (debugfile, "pgp_dearmor: Can't seekto start.\n"));
+ debug_print (1, ("Can't seekto start.\n"));
return;
}
{
/* is signature? */
if ((p[0] & 0x3f) != PT_SIG) {
- dprint (1, (debugfile, "pgp_mic_from_packet: tag = %d, want %d.\n",
- p[0] & 0x3f, PT_SIG));
+ debug_print (1, ("tag = %d, want %d.\n", p[0] & 0x3f, PT_SIG));
return -1;
}
/* version 4 signature */
return (short) p[4];
else {
- dprint (1, (debugfile, "pgp_mic_from_packet: Bad signature packet.\n"));
+ debug_print (1, ("Bad signature packet.\n"));
return -1;
}
}
rv = pgp_mic_from_packet (p, l);
}
else {
- dprint (1, (debugfile, "pgp_find_hash: No packet.\n"));
+ debug_print (1, ("No packet.\n"));
}
bye:
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <string.h>
#include <unistd.h>
if (ret == PQ_OK) {
pop_data->cmd_top = CMD_AVAILABLE;
- dprint (1, (debugfile, "pop_read_header: set TOP capability\n"));
+ debug_print (1, ("set TOP capability\n"));
}
if (ret == PQ_ERR) {
pop_data->cmd_top = CMD_NOT_AVAILABLE;
- dprint (1, (debugfile, "pop_read_header: unset TOP capability\n"));
+ debug_print (1, ("unset TOP capability\n"));
snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
_("Command TOP is not supported by server."));
}
break;
if (i == ctx->msgcount) {
- dprint (1,
- (debugfile, "pop_fetch_headers: new header %d %s\n", index,
- line));
+ debug_print (1, ("new header %d %s\n", index, line));
if (i >= ctx->hdrmax)
mx_alloc_memory (ctx);
if (ret == PQ_OK) {
pop_data->cmd_uidl = CMD_AVAILABLE;
- dprint (1, (debugfile, "pop_fetch_headers: set UIDL capability\n"));
+ debug_print (1, ("set UIDL capability\n"));
}
if (ret == PQ_ERR && pop_data->cmd_uidl == CMD_UNKNOWN) {
pop_data->cmd_uidl = CMD_NOT_AVAILABLE;
- dprint (1, (debugfile, "pop_fetch_headers: unset UIDL capability\n"));
+ debug_print (1, ("unset UIDL capability\n"));
snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
_("Command UIDL is not supported by server."));
}
if (!pop_data->clear_cache)
return;
- dprint (1, (debugfile, "pop_clear_cache: delete cached messages\n"));
+ debug_print (1, ("delete cached messages\n"));
for (i = 0; i < POP_CACHE_LEN; i++) {
if (pop_data->cache[i].path) {
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <string.h>
#include <unistd.h>
unsigned char client_start;
if (mutt_sasl_client_new (pop_data->conn, &saslconn) < 0) {
- dprint (1,
- (debugfile,
- "pop_auth_sasl: Error allocating SASL connection.\n"));
+ debug_print (1, ("Error allocating SASL connection.\n"));
return POP_A_FAILURE;
}
}
if (rc != SASL_OK && rc != SASL_CONTINUE) {
- dprint (1,
- (debugfile,
- "pop_auth_sasl: Failure starting authentication exchange. No shared mechanisms?\n"));
+ debug_print (1, ("Failure starting authentication exchange. No shared mechanisms?\n"));
/* SASL doesn't support suggested mechanisms, so fall back */
return POP_A_UNAVAIL;
&& sasl_decode64 (inbuf, strlen (inbuf), buf, &len) != SASL_OK)
#endif
{
- dprint (1,
- (debugfile,
- "pop_auth_sasl: error base64-decoding server response.\n"));
+ debug_print (1, ("error base64-decoding server response.\n"));
goto bail;
}
/* send out response, or line break if none needed */
if (pc) {
if (sasl_encode64 (pc, olen, buf, sizeof (buf), &olen) != SASL_OK) {
- dprint (1,
- (debugfile,
- "pop_auth_sasl: error base64-encoding client response.\n"));
+ debug_print (1, ("error base64-encoding client response.\n"));
goto bail;
}
if (ret == PQ_OK) {
pop_data->cmd_user = CMD_AVAILABLE;
- dprint (1, (debugfile, "pop_auth_user: set USER capability\n"));
+ debug_print (1, ("set USER capability\n"));
}
if (ret == PQ_ERR) {
pop_data->cmd_user = CMD_NOT_AVAILABLE;
- dprint (1, (debugfile, "pop_auth_user: unset USER capability\n"));
+ debug_print (1, ("unset USER capability\n"));
snprintf (pop_data->err_msg, sizeof (pop_data->err_msg),
_("Command USER is not supported by server."));
}
snprintf (buf, sizeof (buf), "PASS %s\r\n", pop_data->conn->account.pass);
ret = pop_query_d (pop_data, buf, sizeof (buf),
#ifdef DEBUG
- /* don't print the password unless we're at the ungodly debugging level */
- debuglevel < M_SOCK_LOG_FULL ? "PASS *\r\n" :
+ /* don't print the password unless we're at the ungodly debugging level */
+ DebugLevel < M_SOCK_LOG_FULL ? "PASS *\r\n" :
#endif
- NULL);
+ NULL);
}
switch (ret) {
comma = strchr (method, ':');
if (comma)
*comma++ = '\0';
- dprint (2, (debugfile, "pop_authenticate: Trying method %s\n", method));
+ debug_print (2, ("Trying method %s\n", method));
authenticator = pop_authenticators;
while (authenticator->authenticate) {
}
else {
/* Fall back to default: any authenticator */
- dprint (2,
- (debugfile, "pop_authenticate: Using any available method.\n"));
+ debug_print (2, ("Using any available method.\n"));
authenticator = pop_authenticators;
while (authenticator->authenticate) {
#include "lib/mem.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <string.h>
#include <unistd.h>
/* print msg instaed of real command */
if (msg) {
dbg = M_SOCK_LOG_FULL;
- dprint (M_SOCK_LOG_CMD, (debugfile, "> %s", msg));
+ debug_print (M_SOCK_LOG_CMD, ("> %s", msg));
}
#endif
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <unistd.h>
newpc = imap_mailbox_check (Postponed, 0);
if (newpc >= 0) {
PostCount = newpc;
- dprint (2,
- (debugfile,
- "mutt_num_postponed: %d postponed IMAP messages found.\n",
- PostCount));
+ debug_print (2, ("%d postponed IMAP messages found.\n", PostCount));
}
else
- dprint (2,
- (debugfile,
- "mutt_num_postponed: using old IMAP postponed count.\n"));
+ debug_print (2, ("using old IMAP postponed count.\n"));
}
return PostCount;
}
#endif
#include "mbyte.h"
-#ifdef DEBUG
-#define dprint(N,X) do { if(debuglevel>=N) fprintf X; } while (0)
-#else
-#define dprint(N,X)
-#endif
-
#define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
#define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
mutt_expand_file_fmt (cmd, sizeof (cmd), QueryCmd, s);
if ((thepid = mutt_create_filter (cmd, NULL, &fp, NULL)) < 0) {
- dprint (1, (debugfile, "unable to fork command: %s", cmd));
+ debug_print (1, ("unable to fork command: %s\n", cmd));
return 0;
}
if (!quiet)
FREE (&buf);
fclose (fp);
if (mutt_wait_filter (thepid)) {
- dprint (1, (debugfile, "Error: %s\n", msg));
+ debug_print (1, ("Error: %s\n", msg));
if (!quiet)
mutt_error ("%s", msg);
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
/* ignore comments */
if (*buf == '#')
continue;
- dprint (2, (debugfile, "mailcap entry: %s\n", buf));
+ debug_print (2, ("mailcap entry: %s\n", buf));
/* check type */
ch = get_field (buf);
while (ch) {
field = ch;
ch = get_field (ch);
- dprint (2, (debugfile, "field: %s\n", field));
+ debug_print (2, ("field: %s\n", field));
if (!ascii_strcasecmp (field, "needsterminal")) {
if (entry)
path[x] = '\0';
mutt_expand_path (path, sizeof (path));
- dprint (2, (debugfile, "Checking mailcap file: %s\n", path));
+ debug_print (2, ("Checking mailcap file: %s\n", path));
found = rfc1524_mailcap_parse (a, path, type, entry, opt);
}
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <ctype.h>
#include <stdlib.h>
}
if (!tempfp) {
- dprint (1,
- (debugfile,
- "newsend_message: can't create tempfile %s (errno=%d)\n",
- msg->content->filename, errno));
+ debug_print (1, ("can't create tempfile %s (errno=%d)\n",
+ msg->content->filename, errno));
mutt_perror (msg->content->filename);
goto cleanup;
}
#include "lib/mem.h"
#include "lib/str.h"
#include "lib/intl.h"
+#include "lib/debug.h"
#include <string.h>
#include <stdlib.h>
if (a->type == TYPEMULTIPART) {
/* First, find the boundary to use */
if (!(p = mutt_get_parameter ("boundary", a->parameter))) {
- dprint (1,
- (debugfile,
- "mutt_write_mime_body(): no boundary parameter found!\n"));
+ debug_print (1, ("no boundary parameter found!\n"));
mutt_error _("No boundary parameter found! [report this error]");
return (-1);
}
if ((fpin = fopen (a->filename, "r")) == NULL) {
- dprint (1,
- (debugfile, "write_mime_body: %s no longer exists!\n",
- a->filename));
+ debug_print (1, ("%s no longer exists!\n", a->filename));
mutt_error (_("%s no longer exists!"), a->filename);
return -1;
}
}
if ((fp = fopen (fname, "r")) == NULL) {
- dprint (1, (debugfile, "mutt_get_content_info: %s: %s (errno %d).\n",
- fname, strerror (errno), errno));
+ debug_print (1, ("%s: %s (errno %d).\n", fname, strerror (errno), errno));
return (NULL);
}
strfcpy (buf, PKGDATADIR "/mime.types", sizeof (buf));
break;
default:
- dprint (1,
- (debugfile,
- "mutt_lookup_mime_type: Internal error, count = %d.\n",
- count));
+ debug_print (1, ("Internal error, count = %d.\n", count));
goto bye; /* shouldn't happen */
}
}
if (dup) {
- dprint (2, (debugfile, "mutt_remove_duplicates: Removing %s\n",
- addr->mailbox));
+ debug_print (2, ("Removing %s\n", addr->mailbox));
*last = addr->next;
set_noconv_flags (hdr->content, 1);
if (mx_open_mailbox (path, M_APPEND | M_QUIET, &f) == NULL) {
- dprint (1,
- (debugfile,
- "mutt_write_fcc(): unable to open mailbox %s in append-mode, aborting.\n",
- path));
+ debug_print (1, ("unable to open mailbox %s in append-mode, aborting.\n", path));
return (-1);
}
fflush (tempfp);
if (ferror (tempfp)) {
- dprint (1,
- (debugfile, "mutt_write_fcc(): %s: write failed.\n", tempfile));
+ debug_print (1, ("%s: write failed.\n", tempfile));
fclose (tempfp);
unlink (tempfile);
mx_commit_message (msg, &f); /* XXX - really? */
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/wait.h>
#include <string.h>
{
mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_smime_command,
(unsigned long) cctx, 0);
- dprint (2, (debugfile, "mutt_smime_command: %s\n", d));
+ debug_print (2, ("%s\n", d));
}
-
-
-
static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout,
FILE ** smimeerr, int smimeinfd, int smimeoutfd,
int smimeerrfd, const char *fname,
#include <ctype.h>
#include <sys/types.h>
#include "lib/str.h"
+#include "lib/debug.h"
/* Define this as a fall through, HAVE_STDARG_H is probably already set */
spadlen = -spadlen; /* Left Justifty */
#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ debug_print (1, ("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
zpadlen, spadlen, min, max, place));
#endif
}
#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
+ debug_print (1, ("fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
#endif
/* Convert integer part */