Commit 79cbad0d 79cbad0dff9d90f4b79fc09f2c5793ed28531608 by Sergey Poznyakoff

Various minor fixes.

* include/mailutils/diag.h (mu_full_program_name): New extern.
* libmailutils/diag/diag.c (mu_full_program_name): New global.
(mu_set_program_name): Set mu_full_program_name.
(mu_diag_at_locus): Fix format specifier.
* libmailutils/diag/bt.c: Use mu_full_program_name instead of
program_invocation_name.
* libmailutils/diag/wd.c (mu_wd): Likewise.

* comsat/comsat.c: Fix format specifiers.
* lib/mailcap.c: Likewise.
* libmu_sieve/util.c: Cast formatted arguments to match format specs.
* mh/mh_getopt.c: Likewise.

* libmailutils/cidr/fromstr.c: Add missing includes.
* libproto/mailer/smtp.c: Likewise.
* libproto/pop/mbox.c: Likewise.
* testsuite/smtpsend.c: Likewise.
* mu/getarg.c: Likewise.
* mu/imap.c: Likewise.
* mu/pop.c (com_connect): Protect TLS code with #ifdef.
* mu/Makefile.am (EXTRA_DIST): Add mu-setup.awk.

* mail/summary.c (mail_summary): Fix data types of the counters.
1 parent 73be707d
......@@ -379,9 +379,10 @@ comsat_connection (int fd, struct sockaddr *sa, int salen,
{
char *p = mu_sockaddr_to_astr (sa, salen);
mu_diag_output (MU_DIAG_INFO,
ngettext ("received %d byte from %s",
"received %d bytes from %s", rdlen),
rdlen, p);
ngettext ("received %lu byte from %s",
"received %lu bytes from %s",
(unsigned long) rdlen),
(unsigned long) rdlen, p);
mu_diag_output (MU_DIAG_INFO, "string: %s", buffer);
free (p);
}
......
......@@ -30,6 +30,7 @@ extern "C" {
#endif
extern const char *mu_program_name;
extern const char *mu_full_program_name;
#define MU_DIAG_EMERG MU_LOG_EMERG
#define MU_DIAG_ALERT MU_LOG_ALERT
......
......@@ -387,7 +387,7 @@ dump_mailcap_entry (mu_mailcap_entry_t entry)
mu_strerror (status));
break;
}
printf ("fields[%d]: %s\n", i, buffer);
printf ("fields[%u]: %s\n", (unsigned) i, buffer);
}
printf ("\n");
}
......
......@@ -18,9 +18,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <mailutils/cidr.h>
#include <mailutils/errno.h>
#include <mailutils/sockaddr.h>
......
......@@ -23,8 +23,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <argp.h>
#include <mailutils/diag.h>
#include <mailutils/util.h>
/* Dump a stack trace and terminate current program.
......@@ -40,16 +41,13 @@ mu_gdb_bt ()
pid_t pid;
static char buf[1024];
static char fname[1024];
char *p;
int fd;
char *argv[8];
p = strrchr (program_invocation_name, '/');
if (p)
p++;
else
p = program_invocation_name;
sprintf (fname, "/tmp/mailutils.%s.%lu", p, (unsigned long) master_pid);
if (!mu_program_name)
abort ();
sprintf (fname, "/tmp/mailutils.%s.%lu",
mu_program_name, (unsigned long) master_pid);
pid = fork ();
if (pid == (pid_t)-1)
......@@ -72,7 +70,7 @@ mu_gdb_bt ()
close (fd);
argv[0] = "/usr/bin/gdb";
argv[1] = program_invocation_name;
argv[1] = (char*) mu_full_program_name;
sprintf (buf, "%lu", (unsigned long) master_pid);
argv[2] = buf;
argv[3] = "-ex";
......
......@@ -31,12 +31,14 @@
#include <mailutils/stream.h>
const char *mu_program_name;
const char *mu_full_program_name;
void
mu_set_program_name (const char *name)
{
const char *progname;
mu_full_program_name = name;
if (!name)
progname = name;
else
......@@ -86,7 +88,8 @@ mu_diag_at_locus (int level, struct mu_locus const *loc, const char *fmt, ...)
va_start (ap, fmt);
mu_stream_printf (mu_strerr, "\033f<%d>%s\033l<%u>\033c<%u>",
strlen (loc->mu_file), loc->mu_file, loc->mu_line,
(unsigned) strlen (loc->mu_file), loc->mu_file,
loc->mu_line,
loc->mu_col);
mu_diag_voutput (level, fmt, ap);
va_end (ap);
......
......@@ -20,7 +20,6 @@
#endif
#include <unistd.h>
#include <argp.h>
#include <mailutils/diag.h>
/* A debugging hook.
......@@ -46,7 +45,7 @@ mu_wd (unsigned to)
(unsigned long) pid);
mu_diag_output (MU_DIAG_CRIT,
"to attach: gdb -ex 'set variable mu_wd::_count_down=0' %s %lu",
program_invocation_name, (unsigned long) pid);
mu_full_program_name, (unsigned long) pid);
if (to)
{
_count_down = to;
......
......@@ -213,7 +213,8 @@ mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...)
if (mach->locus.mu_file)
mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
MU_LOGMODE_LOCUS,
strlen (mach->locus.mu_file), mach->locus.mu_file,
(unsigned) strlen (mach->locus.mu_file),
mach->locus.mu_file,
mach->locus.mu_line);
if (mach->identifier)
mu_stream_printf (mach->errstream, "%s: ", mach->identifier);
......@@ -238,7 +239,8 @@ mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...)
if (mach->locus.mu_file)
mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
MU_LOGMODE_LOCUS,
strlen (mach->locus.mu_file), mach->locus.mu_file,
(unsigned) strlen (mach->locus.mu_file),
mach->locus.mu_file,
mach->locus.mu_line);
mu_stream_vprintf (mach->errstream, fmt, ap);
mu_stream_write (mach->errstream, "\n", 1, NULL);
......@@ -258,7 +260,8 @@ mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
if (mach->locus.mu_file)
mu_stream_printf (mach->errstream, "\033O<%d>\033f<%u>%s\033l<%u>",
MU_LOGMODE_LOCUS,
strlen (mach->locus.mu_file), mach->locus.mu_file,
(unsigned) strlen (mach->locus.mu_file),
mach->locus.mu_file,
mach->locus.mu_line);
mach->logger (mach->data, mach->errstream, mach->msgno, mach->msg,
action, fmt, ap);
......
......@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <mailutils/nls.h>
#include <mailutils/address.h>
......
......@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <mailutils/pop3.h>
#include <mailutils/attribute.h>
......
......@@ -28,8 +28,8 @@ mail_summary (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
mu_attribute_t attr;
size_t msgno;
size_t count = 0;
int mseen = 0, mnew = 0, mdelete = 0;
int first_new = 0, first_unread = 0;
unsigned long mseen = 0, mnew = 0, mdelete = 0;
size_t first_new = 0, first_unread = 0;
mu_mailbox_messages_count (mbox, &count);
for (msgno = 1; msgno <= count; msgno++)
......@@ -62,16 +62,14 @@ mail_summary (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
mu_mailbox_get_url (mbox, &url);
mu_printf ("\"%s\": ", util_url_to_string (url));
}
mu_printf (
ngettext ("%d message", "%d messages", count), count);
mu_printf (ngettext ("%lu message", "%lu messages",
(unsigned long) count), (unsigned long) count);
if (mnew > 0)
mu_printf (ngettext (" %d new", " %d new", mnew), mnew);
mu_printf (ngettext (" %lu new", " %lu new", mnew), mnew);
if (mseen > 0)
mu_printf (ngettext (" %d unread", " %d unread", mseen),
mseen);
mu_printf (ngettext (" %lu unread", " %lu unread", mseen), mseen);
if (mdelete > 0)
mu_printf (
ngettext (" %d deleted", " %d deleted", mdelete),
mu_printf (ngettext (" %lu deleted", " %lu deleted", mdelete),
mdelete);
mu_printf ("\n");
......
......@@ -135,7 +135,7 @@ mh_help (struct mh_option *mh_opt, const char *doc)
printf ("[no]");
if (len > p->match_len)
printf ("(%*.*s)%s",
p->match_len, p->match_len, p->opt,
(int) p->match_len, (int) p->match_len, p->opt,
p->opt + p->match_len);
else
printf ("%s", p->opt);
......
......@@ -80,7 +80,7 @@ AM_CPPFLAGS = \
-DI18NLIBS="\"$(LIBINTL)\""
BUILT_SOURCES=mu-setup.c mu-setup.h
EXTRA_DIST=mu-setup.c mu-setup.h template.c
EXTRA_DIST=mu-setup.awk mu-setup.c mu-setup.h template.c
mu-setup.h: Makefile.am $(MODULES) $(IDLE_MODULES)
$(AM_V_GEN)$(AWK) -f $(top_srcdir)/mu/mu-setup.awk -v mode=h \
......
......@@ -21,6 +21,7 @@
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <mailutils/mailutils.h>
#include "mu.h"
......
......@@ -22,6 +22,7 @@
#include <termios.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <mailutils/mailutils.h>
#include <mailutils/imap.h>
#include "mu.h"
......
......@@ -501,13 +501,12 @@ com_connect (int argc, char **argv)
{
if (strcmp (argv[i], "-tls") == 0)
{
if (WITH_TLS)
#ifdef WITH_TLS
tls = 1;
else
{
#else
mu_error ("TLS not supported");
return 0;
}
#endif
}
else
break;
......
......@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <mailutils/cctype.h>
#include <mailutils/mailutils.h>
#include <mailutils/smtp.h>
......