Commit c42bddb0 c42bddb0b814375bf68db9ee17fb77b888befaaa by Sergey Poznyakoff

Minor changes.

* am/debug.m4 (MU_DEBUG_MODE): Rewrite. Use -Wdeclaration-after-statement
if supported.
* comsat/oldcfg.c: Remove.
* comsat/Makefile.am (comsatd_SOURCES): Remove oldcfg.c.
* comsat/comsat.c: Remove the obsolete --config and --convert-config options.
* comsat/comsat.h (convert_config): Remove.
1 parent 3c21c658
......@@ -16,19 +16,26 @@ dnl
AC_DEFUN([MU_DEBUG_MODE],
[AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [enable debugging mode]),
[if test x"$enableval" = xyes; then
if test x"$GCC" = xyes; then
AC_MSG_CHECKING([whether gcc accepts -ggdb])
save_CFLAGS=$CFLAGS
CFLAGS="-ggdb -Wall"
AC_TRY_COMPILE([],void f(){},
AC_MSG_RESULT(yes),
[if test x"$ac_cv_prog_cc_g" = xyes; then
CFLAGS="-g -Wall"
else
CFLAGS=
fi
AC_MSG_RESULT(no)])
CFLAGS="`echo $save_CFLAGS | sed 's/-O[[0-9]]//g'` $CFLAGS"
fi
fi])])
[mu_debug_mode=$enableval],
[mu_debug_mode=maybe])
save_CC=$CC
CC="$CC -Wall"
AC_TRY_COMPILE([],[void main(){}],
[CFLAGS="$CFLAGS -Wall"])
CC="$CC -Wdeclaration-after-statement"
AC_TRY_COMPILE([],[void main(){}],
[CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
if test "$mu_debug_mode" != no; then
CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//g'`
AC_MSG_CHECKING([whether cc accepts -ggdb])
CC="$CC -ggdb"
AC_TRY_COMPILE([],[void main(){}],
[AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -ggdb"],
[AC_MSG_RESULT(no)
CFLAGS="$CFLAGS -g"])
fi
CC=$save_CC])
......
......@@ -22,7 +22,7 @@ INCLUDES = @MU_APP_COMMON_INCLUDES@
sbin_PROGRAMS = comsatd
comsatd_SOURCES = action.c comsat.c comsat.h oldcfg.c
comsatd_SOURCES = action.c comsat.c comsat.h
AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
comsatd_LDADD = \
......
......@@ -63,9 +63,6 @@ static char args_doc[] = N_("\n--test MBOX-URL MSG-QID");
static struct argp_option options[] =
{
{ "config", 'c', N_("FILE"), OPTION_HIDDEN, "", 0 },
{ "convert-config", 'C', N_("FILE"), 0,
N_("convert the configuration FILE to new format"), 0 },
{ "test", 't', NULL, 0, N_("run in test mode"), 0 },
{ "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0},
{ "inetd", 'i', 0, 0, N_("run in inetd mode"), 0 },
......@@ -151,33 +148,6 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state)
switch (key)
{
case 'c':
{
char *cfg;
int fd;
FILE *fp;
mu_diag_output (MU_DIAG_WARNING,
_("The old configuration file format and the --config command\n"
"line option are deprecated and will be removed in the future\n"
"release. Please use --convert-config option to convert your\n"
"settings to the new format."));
/* FIXME: Refer to the docs */
fd = mu_tempfile (NULL, &cfg);
fp = fdopen (fd, "w");
convert_config (arg, fp);
fclose (fp);
mu_get_config (cfg, mu_program_name, comsat_cfg_param, 0, NULL);
unlink (cfg);
free (cfg);
}
break;
case 'C':
convert_config (arg, stdout);
exit (0);
case 'd':
mu_argp_node_list_new (lst, "mode", "daemon");
if (arg)
......
......@@ -79,5 +79,4 @@ extern char hostname[];
extern struct daemon_param daemon_param;
void run_user_action (FILE *tty, const char *cr, mu_message_t msg);
void convert_config (const char *config_file, FILE *outfile);
......
/* This file is part of GNU Mailutils.
Copyright (C) 1998, 2001, 2002, 2005, 2007, 2009, 2010 Free Software
Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Mailutils is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils; see the file COPYING. If not, write
to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301 USA. */
#include "comsat.h"
static int
print_and_free_acl (void *item, void *data)
{
FILE *outfile = data;
char **argv = item;
fprintf (outfile, " %s from %s;\n", argv[1], argv[2]);
mu_argv_free (argv);
return 0;
}
void
convert_config (const char *config_file, FILE *outfile)
{
FILE *fp;
int line;
char buf[128];
char *ptr;
mu_list_t aclist = NULL;
if (!config_file)
return;
fp = fopen (config_file, "r");
if (!fp)
{
mu_error (_("cannot open config file %s: %s"), config_file,
mu_strerror (errno));
return;
}
fprintf (outfile,
"# Configuration file for GNU comsatd, converted from %s\n",
config_file);
fprintf (outfile,
"# Copy it to the comsatd configuration file\n");
fprintf (outfile,
"# or to %s/mailutils.rc, in section `program %s'\n\n",
SYSCONFDIR, mu_program_name);
line = 0;
while ((ptr = fgets (buf, sizeof buf, fp)))
{
int len;
int argc;
char **argv;
line++;
len = strlen (ptr);
if (len > 0 && ptr[len-1] == '\n')
ptr[--len] = 0;
while (*ptr && mu_isblank (*ptr))
ptr++;
if (!*ptr || *ptr == '#')
{
fprintf (outfile, "%s\n", ptr);
continue;
}
mu_argcv_get (ptr, "", NULL, &argc, &argv);
if (argc < 2)
{
mu_error (_("%s:%d: too few fields"), config_file, line);
mu_argcv_free (argc, argv);
continue;
}
if (strcmp (argv[0], "acl") == 0)
{
if (!aclist)
mu_list_create (&aclist);
mu_list_append (aclist, argv);
}
else
{
mu_argcv_free (argc, argv);
fprintf (outfile, "%s;\n", ptr);
}
}
fclose (fp);
if (aclist)
{
fprintf (outfile, "acl {\n");
mu_list_do (aclist, print_and_free_acl, outfile);
fprintf (outfile, "};\n");
mu_list_destroy (&aclist);
}
}