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 = . \ ...@@ -94,6 +94,7 @@ SUBDIRS = . \
94 sql\ 94 sql\
95 libmu_auth\ 95 libmu_auth\
96 libproto\ 96 libproto\
97 libmu_compat\
97 testsuite\ 98 testsuite\
98 lib\ 99 lib\
99 libmu_argp\ 100 libmu_argp\
......
...@@ -1205,6 +1205,7 @@ AC_ARG_WITH([mh-bindir], ...@@ -1205,6 +1205,7 @@ AC_ARG_WITH([mh-bindir],
1205 # Initialize the (autotest) test suite. 1205 # Initialize the (autotest) test suite.
1206 AC_CONFIG_TESTDIR(libmailutils/tests) 1206 AC_CONFIG_TESTDIR(libmailutils/tests)
1207 AC_CONFIG_TESTDIR(testsuite) 1207 AC_CONFIG_TESTDIR(testsuite)
1208 AC_CONFIG_TESTDIR(libmu_compat/tests)
1208 AC_CONFIG_TESTDIR(frm/tests) 1209 AC_CONFIG_TESTDIR(frm/tests)
1209 AC_CONFIG_TESTDIR(maidag/tests) 1210 AC_CONFIG_TESTDIR(maidag/tests)
1210 AC_CONFIG_TESTDIR(messages/tests) 1211 AC_CONFIG_TESTDIR(messages/tests)
...@@ -1214,6 +1215,8 @@ AC_CONFIG_TESTDIR(mh/tests) ...@@ -1214,6 +1215,8 @@ AC_CONFIG_TESTDIR(mh/tests)
1214 1215
1215 AC_CONFIG_FILES([libmailutils/tests/Makefile 1216 AC_CONFIG_FILES([libmailutils/tests/Makefile
1216 libmailutils/tests/atlocal 1217 libmailutils/tests/atlocal
1218 libmu_compat/tests/Makefile
1219 libmu_compat/tests/atlocal
1217 testsuite/Makefile 1220 testsuite/Makefile
1218 testsuite/atlocal 1221 testsuite/atlocal
1219 frm/tests/Makefile 1222 frm/tests/Makefile
...@@ -1368,6 +1371,7 @@ AC_CONFIG_FILES([ ...@@ -1368,6 +1371,7 @@ AC_CONFIG_FILES([
1368 libproto/pop/Makefile 1371 libproto/pop/Makefile
1369 libproto/nntp/Makefile 1372 libproto/nntp/Makefile
1370 libproto/imap/Makefile 1373 libproto/imap/Makefile
1374 libmu_compat/Makefile
1371 maidag/Makefile 1375 maidag/Makefile
1372 mail/Makefile 1376 mail/Makefile
1373 mail/testsuite/Makefile 1377 mail/testsuite/Makefile
...@@ -1384,6 +1388,7 @@ AC_CONFIG_FILES([ ...@@ -1384,6 +1388,7 @@ AC_CONFIG_FILES([
1384 libmailutils/server/Makefile 1388 libmailutils/server/Makefile
1385 libmailutils/string/Makefile 1389 libmailutils/string/Makefile
1386 libmailutils/stream/Makefile 1390 libmailutils/stream/Makefile
1391 libmailutils/stdstream/Makefile
1387 libmailutils/url/Makefile 1392 libmailutils/url/Makefile
1388 libmailutils/Makefile 1393 libmailutils/Makefile
1389 messages/Makefile 1394 messages/Makefile
......
...@@ -61,6 +61,7 @@ pkginclude_HEADERS = \ ...@@ -61,6 +61,7 @@ pkginclude_HEADERS = \
61 libcfg.h\ 61 libcfg.h\
62 list.h\ 62 list.h\
63 locker.h\ 63 locker.h\
64 log.h\
64 mailbox.h\ 65 mailbox.h\
65 mailcap.h\ 66 mailcap.h\
66 mailer.h\ 67 mailer.h\
...@@ -90,6 +91,7 @@ pkginclude_HEADERS = \ ...@@ -90,6 +91,7 @@ pkginclude_HEADERS = \
90 server.h\ 91 server.h\
91 sieve.h\ 92 sieve.h\
92 smtp.h\ 93 smtp.h\
94 stdstream.h\
93 stream.h\ 95 stream.h\
94 syslog.h\ 96 syslog.h\
95 sql.h\ 97 sql.h\
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
24 #include <unistd.h> 24 #include <unistd.h>
25 #include <string.h> 25 #include <string.h>
26 26
27 #include <mailutils/types.h>
28
27 #ifdef __cplusplus 29 #ifdef __cplusplus
28 extern "C" { 30 extern "C" {
29 #endif 31 #endif
...@@ -37,20 +39,22 @@ enum mu_argcv_escape ...@@ -37,20 +39,22 @@ enum mu_argcv_escape
37 mu_argcv_escape_c 39 mu_argcv_escape_c
38 /* mu_argcv_escape_sh */ 40 /* mu_argcv_escape_sh */
39 }; 41 };
42
40 int mu_argcv_join (int argc, char **argv, char *delim, 43 int mu_argcv_join (int argc, char **argv, char *delim,
41 enum mu_argcv_escape esc, 44 enum mu_argcv_escape esc,
42 char **pstring); 45 char **pstring);
43 int mu_argcv_string (int argc, char **argv, char **string);
44
45 void mu_argcv_remove (int *pargc, char ***pargv, 46 void mu_argcv_remove (int *pargc, char ***pargv,
46 int (*sel) (const char *, void *), void *); 47 int (*sel) (const char *, void *), void *);
47 48 int mu_argcv_string (int argc, char **argv, char **string);
49
50
48 /* Deprecated interfaces */ 51 /* Deprecated interfaces */
52
49 #define MU_ARGCV_RETURN_DELIMS 0x01 53 #define MU_ARGCV_RETURN_DELIMS 0x01
50 54
51 #ifndef MU_ARCGV_DEPRECATED 55 #ifndef MU_ARCGV_DEPRECATED
52 # define MU_ARCGV_DEPRECATED __attribute__((deprecated)) 56 # define MU_ARCGV_DEPRECATED MU_DEPRECATED
53 #endif 57 #endif
54 58
55 int mu_argcv_get (const char *command, const char *delim, 59 int mu_argcv_get (const char *command, const char *delim,
56 const char *cmnt, 60 const char *cmnt,
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2010 Free Software Foundation, Inc.
3
4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 GNU Mailutils is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef _MAILUTILS_LOG_H
18 #define _MAILUTILS_LOG_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <mailutils/types.h>
25
26 #define MU_LOG_DEBUG 0
27 #define MU_LOG_INFO 1
28 #define MU_LOG_NOTICE 2
29 #define MU_LOG_WARNING 3
30 #define MU_LOG_ERROR 4
31 #define MU_LOG_CRIT 5
32 #define MU_LOG_ALERT 6
33 #define MU_LOG_EMERG 7
34
35 #define MU_LOGMODE_SEVERITY 0x0001
36 #define MU_LOGMODE_LOCUS 0x0002
37
38 int mu_log_stream_create (mu_stream_t *, mu_stream_t);
39 int mu_syslog_stream_create (mu_stream_t *, int);
40
41 extern char *_mu_severity_str[];
42 extern int _mu_severity_num;
43
44 #ifdef __cplusplus
45 }
46 #endif
47
48 #endif
49
...@@ -59,12 +59,12 @@ ...@@ -59,12 +59,12 @@
59 #include <mailutils/url.h> 59 #include <mailutils/url.h>
60 #include <mailutils/gocs.h> 60 #include <mailutils/gocs.h>
61 #include <mailutils/version.h> 61 #include <mailutils/version.h>
62 #include <mailutils/vartab.h>
63 #include <mailutils/io.h> 62 #include <mailutils/io.h>
64 #include <mailutils/secret.h> 63 #include <mailutils/secret.h>
65 #include <mailutils/cctype.h> 64 #include <mailutils/cctype.h>
66 #include <mailutils/cstr.h> 65 #include <mailutils/cstr.h>
67 #include <mailutils/wordsplit.h> 66 #include <mailutils/wordsplit.h>
68 #include <mailutils/log.h> 67 #include <mailutils/log.h>
68 #include <mailutils/stdstream.h>
69 69
70 /* EOF */ 70 /* EOF */
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2009 Free Software Foundation, Inc.
3
4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 GNU Mailutils is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef _MAILUTILS_STDSTREAM_H
18 #define _MAILUTILS_STDSTREAM_H
19
20 #include <mailutils/types.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 extern mu_stream_t mu_strin;
27 extern mu_stream_t mu_strout;
28 extern mu_stream_t mu_strerr;
29
30 extern const char *mu_program_name;
31
32 #define MU_STRERR_STDERR 0
33 #define MU_STRERR_SYSLOG 1
34 /* #define MU_STRERR_FILE 2 */
35
36 void mu_stdstream_setup (void);
37 int mu_stdstream_strerr_create (mu_stream_t *str, int type, int facility,
38 int priority, const char *tag,
39 const char *fname);
40
41 #ifdef __cplusplus
42 }
43 #endif
44
45 #endif
46
...@@ -106,7 +106,7 @@ enum mu_buffer_type ...@@ -106,7 +106,7 @@ enum mu_buffer_type
106 */ 106 */
107 #define MU_IOCTL_LOGSTREAM_GET_MODE 22 107 #define MU_IOCTL_LOGSTREAM_GET_MODE 22
108 #define MU_IOCTL_LOGSTREAM_SET_MODE 23 108 #define MU_IOCTL_LOGSTREAM_SET_MODE 23
109 109
110 #define MU_TRANSPORT_INPUT 0 110 #define MU_TRANSPORT_INPUT 0
111 #define MU_TRANSPORT_OUTPUT 1 111 #define MU_TRANSPORT_OUTPUT 1
112 #define MU_TRANSPORT_VALID_TYPE(n) \ 112 #define MU_TRANSPORT_VALID_TYPE(n) \
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
33 # define MU_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg))) 33 # define MU_PRINTFLIKE(fmt,narg) __attribute__ ((__format__ (__printf__, fmt, narg)))
34 #endif 34 #endif
35 35
36 #ifndef MU_DEPRECATED
37 # define MU_DEPRECATED __attribute__ ((deprecated))
38 #endif
39
36 #ifdef __cplusplus 40 #ifdef __cplusplus
37 extern "C" { 41 extern "C" {
38 #endif 42 #endif
......
...@@ -20,17 +20,27 @@ ...@@ -20,17 +20,27 @@
20 20
21 #include <mailutils/types.h> 21 #include <mailutils/types.h>
22 22
23 #ifdef MU_SUPPRESS_DEPRECATION
24 # undef MU_DEPRECATED
25 # define MU_DEPRECATED
26 #else
27 # warning "Mailutils support for vartab functions has been deprecated."
28 # warning "Revise your code to use <mailutils/wordsplit.h>."
29 #endif
30
23 typedef int (*mu_var_expansion_fp) (const char *name, void *data, char **p); 31 typedef int (*mu_var_expansion_fp) (const char *name, void *data, char **p);
24 typedef void (*mu_var_free_fp) (void *data, char *value); 32 typedef void (*mu_var_free_fp) (void *data, char *value);
25 33
26 int mu_vartab_create (mu_vartab_t *pvar); 34 int mu_vartab_create (mu_vartab_t *pvar) MU_DEPRECATED;
27 int mu_vartab_destroy (mu_vartab_t *pvar); 35 int mu_vartab_destroy (mu_vartab_t *pvar) MU_DEPRECATED;
28 int mu_vartab_define (mu_vartab_t var, const char *name, const char *value, 36 int mu_vartab_define (mu_vartab_t var, const char *name, const char *value,
29 int isstatic); 37 int isstatic) MU_DEPRECATED;
30 int mu_vartab_define_exp (mu_vartab_t var, const char *name, 38 int mu_vartab_define_exp (mu_vartab_t var, const char *name,
31 mu_var_expansion_fp fun, mu_var_free_fp free, 39 mu_var_expansion_fp fun, mu_var_free_fp free,
32 void *data); 40 void *data) MU_DEPRECATED;
33 int mu_vartab_count (mu_vartab_t vt, size_t *pcount); 41 int mu_vartab_count (mu_vartab_t vt, size_t *pcount) MU_DEPRECATED;
34 int mu_vartab_getvar (mu_vartab_t vt, const char *name, const char **pvalue); 42 int mu_vartab_getvar (mu_vartab_t vt, const char *name, const char **pvalue)
35 int mu_vartab_expand (mu_vartab_t vt, const char *str, char **pres); 43 MU_DEPRECATED;
44 int mu_vartab_expand (mu_vartab_t vt, const char *str, char **pres)
45 MU_DEPRECATED;
36 #endif 46 #endif
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
17 # <http://www.gnu.org/licenses/>. 17 # <http://www.gnu.org/licenses/>.
18 18
19 SUBDIRS = auth base address cfg diag filter mailbox mailer mime\ 19 SUBDIRS = auth base address cfg diag filter mailbox mailer mime\
20 server string stream property url . tests 20 server string stream stdstream property url . tests
21 21
22 lib_LTLIBRARIES = libmailutils.la 22 lib_LTLIBRARIES = libmailutils.la
23 23
...@@ -38,6 +38,7 @@ libmailutils_la_LIBADD = \ ...@@ -38,6 +38,7 @@ libmailutils_la_LIBADD = \
38 server/libserver.la\ 38 server/libserver.la\
39 string/libstring.la\ 39 string/libstring.la\
40 stream/libstream.la\ 40 stream/libstream.la\
41 stdstream/libstdstream.la\
41 url/liburl.la 42 url/liburl.la
42 43
43 libmailutils_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ 44 libmailutils_la_LDFLAGS = -version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
......
...@@ -20,7 +20,6 @@ noinst_LTLIBRARIES = libbase.la ...@@ -20,7 +20,6 @@ noinst_LTLIBRARIES = libbase.la
20 libbase_la_SOURCES = \ 20 libbase_la_SOURCES = \
21 alloc.c\ 21 alloc.c\
22 amd.c\ 22 amd.c\
23 argcv.c\
24 argcvfree.c\ 23 argcvfree.c\
25 argcvjoin.c\ 24 argcvjoin.c\
26 argcvrem.c\ 25 argcvrem.c\
...@@ -65,7 +64,6 @@ libbase_la_SOURCES = \ ...@@ -65,7 +64,6 @@ libbase_la_SOURCES = \
65 ticket.c\ 64 ticket.c\
66 tilde.c\ 65 tilde.c\
67 usremail.c\ 66 usremail.c\
68 vartab.c\
69 version.c\ 67 version.c\
70 wicket.c 68 wicket.c
71 69
......
1 # GNU Mailutils -- a suite of utilities for electronic mail
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 3 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General
15 # Public License along with this library. If not, see
16 # <http://www.gnu.org/licenses/>.
17
18 noinst_LTLIBRARIES = libstdstream.la
19
20 libstdstream_la_SOURCES = \
21 basestr.c\
22 strerr.c
23
24 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2010 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20
21 #include <unistd.h>
22 #include <fcntl.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <mailutils/types.h>
26 #include <mailutils/errno.h>
27 #include <mailutils/log.h>
28 #include <mailutils/stream.h>
29 #include <mailutils/stdstream.h>
30
31 mu_stream_t mu_strin;
32 mu_stream_t mu_strout;
33 mu_stream_t mu_strerr;
34
35 void
36 mu_stdstream_setup ()
37 {
38 int rc;
39 int fd;
40
41 /* Ensure that first 3 descriptors are open in proper mode */
42 fd = open ("/dev/null", O_WRONLY);
43 switch (fd)
44 {
45 case 2:
46 /* keep it open */;
47 break;
48
49 case 1:
50 /* keep it open and try 0 */
51 fd = open ("/dev/null", O_RDONLY);
52 if (fd != 0)
53 close (fd);
54 break;
55
56 default:
57 close (fd);
58 break;
59 }
60
61 /* Create the corresponding streams */
62 rc = mu_stdio_stream_create (&mu_strin, MU_STDIN_FD, 0);
63 if (rc)
64 {
65 fprintf (stderr, "mu_stdio_stream_create(%d): %s\n",
66 MU_STDIN_FD, mu_strerror (rc));
67 abort ();
68 }
69 rc = mu_stdio_stream_create (&mu_strout, MU_STDOUT_FD, 0);
70 if (rc)
71 {
72 fprintf (stderr, "mu_stdio_stream_create(%d): %s\n",
73 MU_STDOUT_FD, mu_strerror (rc));
74 abort ();
75 }
76
77 if (mu_stdstream_strerr_create (&mu_strerr, MU_STRERR_STDERR, 0, 0,
78 NULL, NULL))
79 abort ();
80 }
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2010 Free Software Foundation, Inc.
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <syslog.h>
24 #include <mailutils/types.h>
25 #include <mailutils/nls.h>
26 #include <mailutils/io.h>
27 #include <mailutils/errno.h>
28 #include <mailutils/log.h>
29 #include <mailutils/stream.h>
30 #include <mailutils/stdstream.h>
31 #include <mailutils/filter.h>
32
33 int
34 mu_stdstream_strerr_create (mu_stream_t *plogger, int type, int facility,
35 int priority, const char *tag,
36 const char *fname MU_ARG_UNUSED)
37 {
38 int rc;
39 mu_stream_t transport;
40
41 if (!tag)
42 tag = mu_program_name;
43 switch (type)
44 {
45 case MU_STRERR_STDERR:
46 {
47 mu_stream_t str;
48 char *fltargs[3] = { "INLINE-COMMENT", };
49
50 rc = mu_stdio_stream_create (&str, MU_STDERR_FD, 0);
51 if (rc)
52 {
53 fprintf (stderr, _("%s: cannot open error stream: %s\n"),
54 tag, mu_strerror (rc));
55 return MU_ERR_FAILURE;
56 }
57 mu_asprintf (&fltargs[1], "%s: ", tag);
58 fltargs[2] = NULL;
59 rc = mu_filter_create_args (&transport, str,
60 "INLINE-COMMENT", 2, (const char**)fltargs,
61 MU_FILTER_ENCODE, MU_STREAM_WRITE);
62 mu_stream_unref (str);
63 free (fltargs[1]);
64 if (rc)
65 {
66 fprintf (stderr,
67 _("%s: cannot open output filter stream: %s"),
68 tag, mu_strerror (rc));
69 return MU_ERR_FAILURE;
70 }
71 }
72 break;
73
74 case MU_STRERR_SYSLOG:
75 openlog (tag, LOG_PID, facility);
76 rc = mu_syslog_stream_create (&transport, priority);
77 if (rc)
78 {
79 fprintf (stderr, _("%s: cannot create syslog stream: %s\n"),
80 tag, mu_strerror (rc));
81 return MU_ERR_FAILURE;
82 }
83 break;
84
85 default:
86 fprintf (stderr, _("%s: cannot create error stream: %s\n"),
87 tag, mu_strerror (EINVAL));
88 return EINVAL;
89 }
90
91 rc = mu_log_stream_create (plogger, transport);
92 mu_stream_unref (transport);
93 if (rc)
94 {
95 fprintf (stderr, _("%s: cannot open logger stream: %s\n"),
96 tag , mu_strerror (rc));
97 return MU_ERR_FAILURE;
98 }
99 return 0;
100 }
101
...@@ -158,7 +158,7 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size, ...@@ -158,7 +158,7 @@ _log_write (struct _mu_stream *str, const char *buf, size_t size,
158 158
159 if (severity >= _mu_severity_num) 159 if (severity >= _mu_severity_num)
160 severity = MU_LOG_EMERG; 160 severity = MU_LOG_EMERG;
161 161
162 if (logmode & MU_LOGMODE_LOCUS) 162 if (logmode & MU_LOGMODE_LOCUS)
163 { 163 {
164 if (fname) 164 if (fname)
......
...@@ -57,7 +57,7 @@ _syslog_ctl (struct _mu_stream *str, int op, void *arg) ...@@ -57,7 +57,7 @@ _syslog_ctl (struct _mu_stream *str, int op, void *arg)
57 return EINVAL; 57 return EINVAL;
58 sp->prio = *(int*)arg; 58 sp->prio = *(int*)arg;
59 break; 59 break;
60 60
61 default: 61 default:
62 return ENOSYS; 62 return ENOSYS;
63 } 63 }
......
...@@ -41,7 +41,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac ...@@ -41,7 +41,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
41 INCLUDES = @MU_LIB_COMMON_INCLUDES@ 41 INCLUDES = @MU_LIB_COMMON_INCLUDES@
42 noinst_PROGRAMS = \ 42 noinst_PROGRAMS = \
43 addr\ 43 addr\
44 argcv\
45 decode2047\ 44 decode2047\
46 encode2047\ 45 encode2047\
47 fltst\ 46 fltst\
...@@ -63,7 +62,6 @@ EXTRA_DIST += Encode Decode Wicketfile ...@@ -63,7 +62,6 @@ EXTRA_DIST += Encode Decode Wicketfile
63 62
64 TESTSUITE_AT = \ 63 TESTSUITE_AT = \
65 address.at\ 64 address.at\
66 argcv.at\
67 base64d.at\ 65 base64d.at\
68 base64e.at\ 66 base64e.at\
69 decode2047.at\ 67 decode2047.at\
......
...@@ -55,7 +55,6 @@ AT_INIT ...@@ -55,7 +55,6 @@ AT_INIT
55 55
56 m4_include([list.at]) 56 m4_include([list.at])
57 m4_include([address.at]) 57 m4_include([address.at])
58 m4_include([argcv.at])
59 m4_include([wordsplit.at]) 58 m4_include([wordsplit.at])
60 m4_include([url.at]) 59 m4_include([url.at])
61 m4_include([mailcap.at]) 60 m4_include([mailcap.at])
......
1 # This file is part of GNU Mailutils
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 SUBDIRS = . tests
18 lib_LTLIBRARIES = libmu_compat.la
19
20 libmu_compat_la_SOURCES = \
21 argcv.c\
22 vartab.c
23
24 INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
25
1 atconfig
2 atlocal
3 package.m4
4 testsuite
5 testsuite.dir
6 testsuite.log
7 argcv
1 # This file is part of GNU Mailutils.
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
18 DISTCLEANFILES = atconfig $(check_SCRIPTS)
19 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
20
21 ## ------------ ##
22 ## package.m4. ##
23 ## ------------ ##
24
25 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
26 $(AM_V_GEN){ \
27 echo '# Signature of the current package.'; \
28 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
29 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
30 echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
31 echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
32 echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
33 } >$(srcdir)/package.m4
34
35 #
36
37 ## -------------------------- ##
38 ## Non-installable programs
39 ## -------------------------- ##
40
41 INCLUDES = @MU_LIB_COMMON_INCLUDES@
42 noinst_PROGRAMS = argcv
43
44 LDADD = ../libmu_compat.la ${MU_LIB_MAILUTILS}
45
46 ## ------------ ##
47 ## Test suite. ##
48 ## ------------ ##
49
50 TESTSUITE_AT = \
51 argcv.at\
52 testsuite.at
53
54 TESTSUITE = $(srcdir)/testsuite
55 M4=m4
56
57 AUTOTEST = $(AUTOM4TE) --language=autotest
58 $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
59 $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
60 $(AM_V_at)mv $@.tmp $@
61
62 atconfig: $(top_builddir)/config.status
63 cd $(top_builddir) && ./config.status tests/$@
64
65 clean-local:
66 @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
67
68 check-local: atconfig atlocal $(TESTSUITE)
69 @$(SHELL) $(TESTSUITE)
70
71 # Run the test suite on the *installed* tree.
72 #installcheck-local:
73 # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
74
75
...@@ -22,10 +22,14 @@ m4_pushdef([TESTARGS],[ ...@@ -22,10 +22,14 @@ m4_pushdef([TESTARGS],[
22 m4_pushdef([MU_TEST_GROUP],[Argcv]) 22 m4_pushdef([MU_TEST_GROUP],[Argcv])
23 m4_pushdef([MU_TEST_KEYWORDS],[argcv]) 23 m4_pushdef([MU_TEST_KEYWORDS],[argcv])
24 m4_pushdef([MU_TEST_COMMAND],[argcv]) 24 m4_pushdef([MU_TEST_COMMAND],[argcv])
25 MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5]) 25
26 m4_popdef([MU_TEST_COMMAND]) 26 AT_SETUP([Argcv: m4_if([$1],[],mu_firstline([$3]),[$1])])
27 m4_popdef([MU_TEST_KEYWORDS]) 27 AT_KEYWORDS([argcv $2])
28 m4_popdef([MU_TEST_GROUP]) 28 AT_CHECK([
29 AT_DATA([input],[$3
30 ])
31 argcv < input],[0],[$4],[$5],[$6],[$7])
32 AT_CLEANUP
29 ]) 33 ])
30 34
31 dnl ------------------------------------------------------------ 35 dnl ------------------------------------------------------------
......
1 # @configure_input@ -*- shell-script -*-
2 # Configurable variable values for Mailutils test suite.
3 # Copyright (C) 2004, 2010 Free Software Foundation, Inc.
4
5 PATH=@abs_builddir@:@abs_top_builddir@/libmailutils/tests:$top_srcdir:$srcdir:$PATH
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 m4_include([testsuite.inc])
18 AT_INIT
19 m4_include([argcv.at])
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 #include <mailutils/stream.h> 24 #include <mailutils/stream.h>
25 #include <mailutils/errno.h> 25 #include <mailutils/errno.h>
26 #include <mailutils/iterator.h> 26 #include <mailutils/iterator.h>
27 #define MU_SUPPRESS_DEPRECATION
27 #include <mailutils/vartab.h> 28 #include <mailutils/vartab.h>
28 29
29 struct _mu_vartab 30 struct _mu_vartab
......
...@@ -57,6 +57,7 @@ struct lib_descr { ...@@ -57,6 +57,7 @@ struct lib_descr {
57 { "nntp", "mu_nntp", 0 }, 57 { "nntp", "mu_nntp", 0 },
58 { "mailer", "mu_mailer", 0 }, 58 { "mailer", "mu_mailer", 0 },
59 { "sieve", "mu_sieve", NOTALL }, 59 { "sieve", "mu_sieve", NOTALL },
60 { "compat", "mu_compat" },
60 { NULL } 61 { NULL }
61 }; 62 };
62 63
......
...@@ -84,7 +84,6 @@ logger_parse_opt (int key, char *arg, struct argp_state *state) ...@@ -84,7 +84,6 @@ logger_parse_opt (int key, char *arg, struct argp_state *state)
84 84
85 case 't': 85 case 't':
86 syslog_tag = arg; 86 syslog_tag = arg;
87 use_syslog = 1;
88 break; 87 break;
89 88
90 case 'p': 89 case 'p':
...@@ -157,10 +156,10 @@ mutool_logger (int argc, char **argv) ...@@ -157,10 +156,10 @@ mutool_logger (int argc, char **argv)
157 exit (1); 156 exit (1);
158 } 157 }
159 158
159 if (!syslog_tag)
160 syslog_tag = "mu-logger";
160 if (use_syslog) 161 if (use_syslog)
161 { 162 {
162 if (!syslog_tag)
163 syslog_tag = "mu-logger";
164 openlog (syslog_tag, LOG_PID, syslog_facility); 163 openlog (syslog_tag, LOG_PID, syslog_facility);
165 164
166 rc = mu_syslog_stream_create (&transport, syslog_priority); 165 rc = mu_syslog_stream_create (&transport, syslog_priority);
...@@ -173,12 +172,27 @@ mutool_logger (int argc, char **argv) ...@@ -173,12 +172,27 @@ mutool_logger (int argc, char **argv)
173 } 172 }
174 else 173 else
175 { 174 {
176 rc = mu_stdio_stream_create (&transport, MU_STDERR_FD, 0); 175 mu_stream_t str;
176 char *fltargs[3] = { "INLINE-COMMENT", };
177
178 rc = mu_stdio_stream_create (&str, MU_STDERR_FD, 0);
177 if (rc) 179 if (rc)
178 { 180 {
179 mu_error (_("cannot open error stream: %s"), mu_strerror (rc)); 181 mu_error (_("cannot open error stream: %s"), mu_strerror (rc));
180 return 1; 182 return 1;
181 } 183 }
184 mu_asprintf (&fltargs[1], "%s: ", syslog_tag);
185 fltargs[2] = NULL;
186 rc = mu_filter_create_args (&transport, str,
187 "INLINE-COMMENT", 2, (const char *)fltargs,
188 MU_FILTER_ENCODE, MU_STREAM_WRITE);
189 mu_stream_unref (str);
190 free (fltargs[1]);
191 if (rc)
192 {
193 mu_error (_("cannot open filter stream: %s"), mu_strerror (rc));
194 return 1;
195 }
182 } 196 }
183 197
184 rc = mu_log_stream_create (&logger, transport); 198 rc = mu_log_stream_create (&logger, transport);
...@@ -227,7 +241,10 @@ mutool_logger (int argc, char **argv) ...@@ -227,7 +241,10 @@ mutool_logger (int argc, char **argv)
227 } 241 }
228 } 242 }
229 243
230 return !!mu_stream_copy (logger, transport, 0, NULL); 244 rc = mu_stream_copy (logger, transport, 0, NULL);
245 mu_stream_unref (transport);
246 mu_stream_unref (logger);
247 return !!rc;
231 } 248 }
232 249
233 /* 250 /*
......
...@@ -133,6 +133,7 @@ libmailutils/server/acl.c ...@@ -133,6 +133,7 @@ libmailutils/server/acl.c
133 133
134 libmailutils/stream/file_stream.c 134 libmailutils/stream/file_stream.c
135 libmailutils/stream/prog_stream.c 135 libmailutils/stream/prog_stream.c
136 libmailutils/stream/logstream.c
136 137
137 libmailutils/filter/filter_iconv.c 138 libmailutils/filter/filter_iconv.c
138 139
...@@ -156,6 +157,9 @@ libmailutils/base/tempfile.c ...@@ -156,6 +157,9 @@ libmailutils/base/tempfile.c
156 157
157 libmailutils/string/trueans.c 158 libmailutils/string/trueans.c
158 159
160 libmailutils/stdstream/baseio.c
161 libmailutils/stdstream/strerr.c
162
159 messages/messages.c 163 messages/messages.c
160 164
161 mh/anno.c 165 mh/anno.c
...@@ -226,6 +230,7 @@ mu/shell.c ...@@ -226,6 +230,7 @@ mu/shell.c
226 mu/cflags.c 230 mu/cflags.c
227 mu/ldflags.c 231 mu/ldflags.c
228 mu/wicket.c 232 mu/wicket.c
233 mu/logger.c
229 234
230 # EOF 235 # EOF
231 236
......