Commit 76df98da 76df98da17f576b71e6cbc83bbf527b685be1178 by Sergey Poznyakoff

Introduce stdstream module; move deprecated functions to libmu_compat.

* include/mailutils/log.h: New file.
* include/mailutils/stdstream.h: New file.
* include/mailutils/Makefile.am (pkginclude_HEADERS): Add stdstream.h
and log.h.
* include/mailutils/argcv.h: Include mailutils/types.h
* include/mailutils/mailutils.h: Include stdstream.h
Remove vartab.h
* include/mailutils/types.hin (MU_DEPRECATED): New define.
* include/mailutils/vartab.h: Mark this header and all prototypes
it defines as deprecated.

* libmailutils/stdstream/Makefile.am: New file.
* libmailutils/stdstream/basestr.c: New file.
* libmailutils/stdstream/strerr.c: New file.
* libmu_compat/Makefile.am: New file.
* libmu_compat/tests/.gitignore: New file.
* libmu_compat/tests/Makefile.am: New file.
* libmu_compat/tests/atlocal.in: New file.
* libmu_compat/tests/testsuite.at: New file.
* libmailutils/base/Makefile.am (noinst_LTLIBRARIES): Remove
argcv.c and vartab.c.
* libmailutils/Makefile.am (SUBDIRS): Add stdstream.
(libmailutils_la_LIBADD): Add stdstream/libstdstream.la.
* libmailutils/tests/Makefile.am (noinst_PROGRAMS): Remove argcv
(TESTSUITE_AT): Remove argcv.at
* libmailutils/tests/testsuite.at: Do not include argcv.at.

* libmailutils/base/argcv.c: Move to libmu_compat/argcv.c
* libmailutils/tests/argcv.at: Move to libmu_compat/tests/argcv.at
* libmailutils/tests/argcv.c: Move to libmu_compat/tests/argcv.c
* libmailutils/base/vartab.c: Move to libmu_compat/vartab.c

* Makefile.am (SUBDIRS): Add libmu_compat.
* configure.ac: Add libmu_compat/tests, libmu_compat/tests/Makefile,
libmu_compat/tests/atlocal, libmu_compat/Makefile and
libmailutils/stdstream/Makefile to config file list.

* mu/ldflags.c (lib_descr): Add mu_compat.
* mu/logger.c (logger_parse_opt): -t does not imply --syslog.
(mutool_logger): Use inline-comment filter to insert "tag: "
prefix.
Flush and destroy both streams before returning.

* po/POTFILES.in: Add libmailutils/stream/logstream.c,
libmailutils/stdstream/baseio.c, libmailutils/stdstream/strerr.c
and mu/logger.c.
1 parent 30bf4d54
......@@ -94,6 +94,7 @@ SUBDIRS = . \
sql\
libmu_auth\
libproto\
libmu_compat\
testsuite\
lib\
libmu_argp\
......
......@@ -1205,6 +1205,7 @@ AC_ARG_WITH([mh-bindir],
# Initialize the (autotest) test suite.
AC_CONFIG_TESTDIR(libmailutils/tests)
AC_CONFIG_TESTDIR(testsuite)
AC_CONFIG_TESTDIR(libmu_compat/tests)
AC_CONFIG_TESTDIR(frm/tests)
AC_CONFIG_TESTDIR(maidag/tests)
AC_CONFIG_TESTDIR(messages/tests)
......@@ -1214,6 +1215,8 @@ AC_CONFIG_TESTDIR(mh/tests)
AC_CONFIG_FILES([libmailutils/tests/Makefile
libmailutils/tests/atlocal
libmu_compat/tests/Makefile
libmu_compat/tests/atlocal
testsuite/Makefile
testsuite/atlocal
frm/tests/Makefile
......@@ -1368,6 +1371,7 @@ AC_CONFIG_FILES([
libproto/pop/Makefile
libproto/nntp/Makefile
libproto/imap/Makefile
libmu_compat/Makefile
maidag/Makefile
mail/Makefile
mail/testsuite/Makefile
......@@ -1384,6 +1388,7 @@ AC_CONFIG_FILES([
libmailutils/server/Makefile
libmailutils/string/Makefile
libmailutils/stream/Makefile
libmailutils/stdstream/Makefile
libmailutils/url/Makefile
libmailutils/Makefile
messages/Makefile
......
......@@ -61,6 +61,7 @@ pkginclude_HEADERS = \
libcfg.h\
list.h\
locker.h\
log.h\
mailbox.h\
mailcap.h\
mailer.h\
......@@ -90,6 +91,7 @@ pkginclude_HEADERS = \
server.h\
sieve.h\
smtp.h\
stdstream.h\
stream.h\
syslog.h\
sql.h\
......
......@@ -24,6 +24,8 @@
#include <unistd.h>
#include <string.h>
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
......@@ -37,19 +39,21 @@ enum mu_argcv_escape
mu_argcv_escape_c
/* mu_argcv_escape_sh */
};
int mu_argcv_join (int argc, char **argv, char *delim,
enum mu_argcv_escape esc,
char **pstring);
int mu_argcv_string (int argc, char **argv, char **string);
void mu_argcv_remove (int *pargc, char ***pargv,
int (*sel) (const char *, void *), void *);
int mu_argcv_string (int argc, char **argv, char **string);
/* Deprecated interfaces */
#define MU_ARGCV_RETURN_DELIMS 0x01
#ifndef MU_ARCGV_DEPRECATED
# define MU_ARCGV_DEPRECATED __attribute__((deprecated))
# define MU_ARCGV_DEPRECATED MU_DEPRECATED
#endif
int mu_argcv_get (const char *command, const char *delim,
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 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 A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_LOG_H
#define _MAILUTILS_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <mailutils/types.h>
#define MU_LOG_DEBUG 0
#define MU_LOG_INFO 1
#define MU_LOG_NOTICE 2
#define MU_LOG_WARNING 3
#define MU_LOG_ERROR 4
#define MU_LOG_CRIT 5
#define MU_LOG_ALERT 6
#define MU_LOG_EMERG 7
#define MU_LOGMODE_SEVERITY 0x0001
#define MU_LOGMODE_LOCUS 0x0002
int mu_log_stream_create (mu_stream_t *, mu_stream_t);
int mu_syslog_stream_create (mu_stream_t *, int);
extern char *_mu_severity_str[];
extern int _mu_severity_num;
#ifdef __cplusplus
}
#endif
#endif
......@@ -59,12 +59,12 @@
#include <mailutils/url.h>
#include <mailutils/gocs.h>
#include <mailutils/version.h>
#include <mailutils/vartab.h>
#include <mailutils/io.h>
#include <mailutils/secret.h>
#include <mailutils/cctype.h>
#include <mailutils/cstr.h>
#include <mailutils/wordsplit.h>
#include <mailutils/log.h>
#include <mailutils/stdstream.h>
/* EOF */
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009 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 A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _MAILUTILS_STDSTREAM_H
#define _MAILUTILS_STDSTREAM_H
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
extern mu_stream_t mu_strin;
extern mu_stream_t mu_strout;
extern mu_stream_t mu_strerr;
extern const char *mu_program_name;
#define MU_STRERR_STDERR 0
#define MU_STRERR_SYSLOG 1
/* #define MU_STRERR_FILE 2 */
void mu_stdstream_setup (void);
int mu_stdstream_strerr_create (mu_stream_t *str, int type, int facility,
int priority, const char *tag,
const char *fname);
#ifdef __cplusplus
}
#endif
#endif
......@@ -33,6 +33,10 @@
# define MU_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg)))
#endif
#ifndef MU_DEPRECATED
# define MU_DEPRECATED __attribute__ ((deprecated))
#endif
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -20,17 +20,27 @@
#include <mailutils/types.h>
#ifdef MU_SUPPRESS_DEPRECATION
# undef MU_DEPRECATED
# define MU_DEPRECATED
#else
# warning "Mailutils support for vartab functions has been deprecated."
# warning "Revise your code to use <mailutils/wordsplit.h>."
#endif
typedef int (*mu_var_expansion_fp) (const char *name, void *data, char **p);
typedef void (*mu_var_free_fp) (void *data, char *value);
int mu_vartab_create (mu_vartab_t *pvar);
int mu_vartab_destroy (mu_vartab_t *pvar);
int mu_vartab_create (mu_vartab_t *pvar) MU_DEPRECATED;
int mu_vartab_destroy (mu_vartab_t *pvar) MU_DEPRECATED;
int mu_vartab_define (mu_vartab_t var, const char *name, const char *value,
int isstatic);
int isstatic) MU_DEPRECATED;
int mu_vartab_define_exp (mu_vartab_t var, const char *name,
mu_var_expansion_fp fun, mu_var_free_fp free,
void *data);
int mu_vartab_count (mu_vartab_t vt, size_t *pcount);
int mu_vartab_getvar (mu_vartab_t vt, const char *name, const char **pvalue);
int mu_vartab_expand (mu_vartab_t vt, const char *str, char **pres);
void *data) MU_DEPRECATED;
int mu_vartab_count (mu_vartab_t vt, size_t *pcount) MU_DEPRECATED;
int mu_vartab_getvar (mu_vartab_t vt, const char *name, const char **pvalue)
MU_DEPRECATED;
int mu_vartab_expand (mu_vartab_t vt, const char *str, char **pres)
MU_DEPRECATED;
#endif
......
......@@ -17,7 +17,7 @@
# <http://www.gnu.org/licenses/>.
SUBDIRS = auth base address cfg diag filter mailbox mailer mime\
server string stream property url . tests
server string stream stdstream property url . tests
lib_LTLIBRARIES = libmailutils.la
......@@ -38,6 +38,7 @@ libmailutils_la_LIBADD = \
server/libserver.la\
string/libstring.la\
stream/libstream.la\
stdstream/libstdstream.la\
url/liburl.la
libmailutils_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
......
......@@ -20,7 +20,6 @@ noinst_LTLIBRARIES = libbase.la
libbase_la_SOURCES = \
alloc.c\
amd.c\
argcv.c\
argcvfree.c\
argcvjoin.c\
argcvrem.c\
......@@ -65,7 +64,6 @@ libbase_la_SOURCES = \
ticket.c\
tilde.c\
usremail.c\
vartab.c\
version.c\
wicket.c
......
# GNU Mailutils -- a suite of utilities for electronic mail
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
noinst_LTLIBRARIES = libstdstream.la
libstdstream_la_SOURCES = \
basestr.c\
strerr.c
INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2010 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <mailutils/types.h>
#include <mailutils/errno.h>
#include <mailutils/log.h>
#include <mailutils/stream.h>
#include <mailutils/stdstream.h>
mu_stream_t mu_strin;
mu_stream_t mu_strout;
mu_stream_t mu_strerr;
void
mu_stdstream_setup ()
{
int rc;
int fd;
/* Ensure that first 3 descriptors are open in proper mode */
fd = open ("/dev/null", O_WRONLY);
switch (fd)
{
case 2:
/* keep it open */;
break;
case 1:
/* keep it open and try 0 */
fd = open ("/dev/null", O_RDONLY);
if (fd != 0)
close (fd);
break;
default:
close (fd);
break;
}
/* Create the corresponding streams */
rc = mu_stdio_stream_create (&mu_strin, MU_STDIN_FD, 0);
if (rc)
{
fprintf (stderr, "mu_stdio_stream_create(%d): %s\n",
MU_STDIN_FD, mu_strerror (rc));
abort ();
}
rc = mu_stdio_stream_create (&mu_strout, MU_STDOUT_FD, 0);
if (rc)
{
fprintf (stderr, "mu_stdio_stream_create(%d): %s\n",
MU_STDOUT_FD, mu_strerror (rc));
abort ();
}
if (mu_stdstream_strerr_create (&mu_strerr, MU_STRERR_STDERR, 0, 0,
NULL, NULL))
abort ();
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2010 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <mailutils/types.h>
#include <mailutils/nls.h>
#include <mailutils/io.h>
#include <mailutils/errno.h>
#include <mailutils/log.h>
#include <mailutils/stream.h>
#include <mailutils/stdstream.h>
#include <mailutils/filter.h>
int
mu_stdstream_strerr_create (mu_stream_t *plogger, int type, int facility,
int priority, const char *tag,
const char *fname MU_ARG_UNUSED)
{
int rc;
mu_stream_t transport;
if (!tag)
tag = mu_program_name;
switch (type)
{
case MU_STRERR_STDERR:
{
mu_stream_t str;
char *fltargs[3] = { "INLINE-COMMENT", };
rc = mu_stdio_stream_create (&str, MU_STDERR_FD, 0);
if (rc)
{
fprintf (stderr, _("%s: cannot open error stream: %s\n"),
tag, mu_strerror (rc));
return MU_ERR_FAILURE;
}
mu_asprintf (&fltargs[1], "%s: ", tag);
fltargs[2] = NULL;
rc = mu_filter_create_args (&transport, str,
"INLINE-COMMENT", 2, (const char**)fltargs,
MU_FILTER_ENCODE, MU_STREAM_WRITE);
mu_stream_unref (str);
free (fltargs[1]);
if (rc)
{
fprintf (stderr,
_("%s: cannot open output filter stream: %s"),
tag, mu_strerror (rc));
return MU_ERR_FAILURE;
}
}
break;
case MU_STRERR_SYSLOG:
openlog (tag, LOG_PID, facility);
rc = mu_syslog_stream_create (&transport, priority);
if (rc)
{
fprintf (stderr, _("%s: cannot create syslog stream: %s\n"),
tag, mu_strerror (rc));
return MU_ERR_FAILURE;
}
break;
default:
fprintf (stderr, _("%s: cannot create error stream: %s\n"),
tag, mu_strerror (EINVAL));
return EINVAL;
}
rc = mu_log_stream_create (plogger, transport);
mu_stream_unref (transport);
if (rc)
{
fprintf (stderr, _("%s: cannot open logger stream: %s\n"),
tag , mu_strerror (rc));
return MU_ERR_FAILURE;
}
return 0;
}
......@@ -41,7 +41,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
INCLUDES = @MU_LIB_COMMON_INCLUDES@
noinst_PROGRAMS = \
addr\
argcv\
decode2047\
encode2047\
fltst\
......@@ -63,7 +62,6 @@ EXTRA_DIST += Encode Decode Wicketfile
TESTSUITE_AT = \
address.at\
argcv.at\
base64d.at\
base64e.at\
decode2047.at\
......
......@@ -55,7 +55,6 @@ AT_INIT
m4_include([list.at])
m4_include([address.at])
m4_include([argcv.at])
m4_include([wordsplit.at])
m4_include([url.at])
m4_include([mailcap.at])
......
# This file is part of GNU Mailutils
# Copyright (C) 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 A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
SUBDIRS = . tests
lib_LTLIBRARIES = libmu_compat.la
libmu_compat_la_SOURCES = \
argcv.c\
vartab.c
INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
atconfig
atlocal
package.m4
testsuite
testsuite.dir
testsuite.log
argcv
# This file is part of GNU Mailutils.
# Copyright (C) 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 A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
## ------------ ##
## package.m4. ##
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
$(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
#
## -------------------------- ##
## Non-installable programs
## -------------------------- ##
INCLUDES = @MU_LIB_COMMON_INCLUDES@
noinst_PROGRAMS = argcv
LDADD = ../libmu_compat.la ${MU_LIB_MAILUTILS}
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
argcv.at\
testsuite.at
TESTSUITE = $(srcdir)/testsuite
M4=m4
AUTOTEST = $(AUTOM4TE) --language=autotest
$(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
$(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
$(AM_V_at)mv $@.tmp $@
atconfig: $(top_builddir)/config.status
cd $(top_builddir) && ./config.status tests/$@
clean-local:
@test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
check-local: atconfig atlocal $(TESTSUITE)
@$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
......@@ -22,10 +22,14 @@ m4_pushdef([TESTARGS],[
m4_pushdef([MU_TEST_GROUP],[Argcv])
m4_pushdef([MU_TEST_KEYWORDS],[argcv])
m4_pushdef([MU_TEST_COMMAND],[argcv])
MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5])
m4_popdef([MU_TEST_COMMAND])
m4_popdef([MU_TEST_KEYWORDS])
m4_popdef([MU_TEST_GROUP])
AT_SETUP([Argcv: m4_if([$1],[],mu_firstline([$3]),[$1])])
AT_KEYWORDS([argcv $2])
AT_CHECK([
AT_DATA([input],[$3
])
argcv < input],[0],[$4],[$5],[$6],[$7])
AT_CLEANUP
])
dnl ------------------------------------------------------------
......
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Mailutils test suite.
# Copyright (C) 2004, 2010 Free Software Foundation, Inc.
PATH=@abs_builddir@:@abs_top_builddir@/libmailutils/tests:$top_srcdir:$srcdir:$PATH
# This file is part of GNU Mailutils. -*- Autotest -*-
# Copyright (C) 2007, 2008, 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 A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
m4_include([testsuite.inc])
AT_INIT
m4_include([argcv.at])
......@@ -24,6 +24,7 @@
#include <mailutils/stream.h>
#include <mailutils/errno.h>
#include <mailutils/iterator.h>
#define MU_SUPPRESS_DEPRECATION
#include <mailutils/vartab.h>
struct _mu_vartab
......
......@@ -57,6 +57,7 @@ struct lib_descr {
{ "nntp", "mu_nntp", 0 },
{ "mailer", "mu_mailer", 0 },
{ "sieve", "mu_sieve", NOTALL },
{ "compat", "mu_compat" },
{ NULL }
};
......
......@@ -84,7 +84,6 @@ logger_parse_opt (int key, char *arg, struct argp_state *state)
case 't':
syslog_tag = arg;
use_syslog = 1;
break;
case 'p':
......@@ -157,10 +156,10 @@ mutool_logger (int argc, char **argv)
exit (1);
}
if (use_syslog)
{
if (!syslog_tag)
syslog_tag = "mu-logger";
if (use_syslog)
{
openlog (syslog_tag, LOG_PID, syslog_facility);
rc = mu_syslog_stream_create (&transport, syslog_priority);
......@@ -173,12 +172,27 @@ mutool_logger (int argc, char **argv)
}
else
{
rc = mu_stdio_stream_create (&transport, MU_STDERR_FD, 0);
mu_stream_t str;
char *fltargs[3] = { "INLINE-COMMENT", };
rc = mu_stdio_stream_create (&str, MU_STDERR_FD, 0);
if (rc)
{
mu_error (_("cannot open error stream: %s"), mu_strerror (rc));
return 1;
}
mu_asprintf (&fltargs[1], "%s: ", syslog_tag);
fltargs[2] = NULL;
rc = mu_filter_create_args (&transport, str,
"INLINE-COMMENT", 2, (const char *)fltargs,
MU_FILTER_ENCODE, MU_STREAM_WRITE);
mu_stream_unref (str);
free (fltargs[1]);
if (rc)
{
mu_error (_("cannot open filter stream: %s"), mu_strerror (rc));
return 1;
}
}
rc = mu_log_stream_create (&logger, transport);
......@@ -227,7 +241,10 @@ mutool_logger (int argc, char **argv)
}
}
return !!mu_stream_copy (logger, transport, 0, NULL);
rc = mu_stream_copy (logger, transport, 0, NULL);
mu_stream_unref (transport);
mu_stream_unref (logger);
return !!rc;
}
/*
......
......@@ -133,6 +133,7 @@ libmailutils/server/acl.c
libmailutils/stream/file_stream.c
libmailutils/stream/prog_stream.c
libmailutils/stream/logstream.c
libmailutils/filter/filter_iconv.c
......@@ -156,6 +157,9 @@ libmailutils/base/tempfile.c
libmailutils/string/trueans.c
libmailutils/stdstream/baseio.c
libmailutils/stdstream/strerr.c
messages/messages.c
mh/anno.c
......@@ -226,6 +230,7 @@ mu/shell.c
mu/cflags.c
mu/ldflags.c
mu/wicket.c
mu/logger.c
# EOF
......