* configure.ac (MU_APP_LIBRARIES): Load libmuaux after libmuargp
and libcfg. (fgetpwent): Use AC_CHECK_FUNCS * auth/virtual.c: Use mu_fgetpwent if fgetpwent is not available. * lib/Makefile.am: Add back utmp.c * lib/utmp.c: Restore after unintended remove. * m4/utmp.m4: Fix quoting. * libcfg/gsasl.c, libcfg/ldap.c, libcfg/pam.c, libcfg/radius.c, libcfg/sieve.c, libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c: Include stdlib.h * libproto/imap/folder.c, libproto/mbox/mbox.c, libproto/mbox/mbox0.h, libproto/pop/mbox.c, mailbox/attachment.c, mailbox/mailbox.c, mailbox/parsedate.y: Do not use alloca. * mailbox/Makefile.am (libmailutils_la_SOURCES): Add fgetpwent.c and intprops.h. * mailbox/fgetpwent.c (fgetpwent): Rename to mu_fgetpwent. * mailbox/gocs.c: Revert recent change. It broke the testsuite in sieve. * mailbox/syslog.c (log_facility): Initialize to LOG_FACILITY.
Showing
25 changed files
with
177 additions
and
73 deletions
1 | 2007-11-26 Sergey Poznyakoff <gray@gnu.org.ua> | 1 | 2007-11-26 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 2 | ||
3 | * configure.ac (MU_APP_LIBRARIES): Load libmuaux after libmuargp | ||
4 | and libcfg. | ||
5 | (fgetpwent): Use AC_CHECK_FUNCS | ||
6 | * auth/virtual.c: Use mu_fgetpwent if fgetpwent is not available. | ||
7 | |||
8 | * lib/Makefile.am: Add back utmp.c | ||
9 | * lib/utmp.c: Restore after unintended remove. | ||
10 | * m4/utmp.m4: Fix quoting. | ||
11 | |||
12 | * libcfg/gsasl.c, libcfg/ldap.c, libcfg/pam.c, libcfg/radius.c, | ||
13 | libcfg/sieve.c, libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c: | ||
14 | Include stdlib.h | ||
15 | |||
16 | * libproto/imap/folder.c, libproto/mbox/mbox.c, | ||
17 | libproto/mbox/mbox0.h, libproto/pop/mbox.c, mailbox/attachment.c, | ||
18 | mailbox/mailbox.c, mailbox/parsedate.y: Do not use alloca. | ||
19 | |||
20 | * mailbox/Makefile.am (libmailutils_la_SOURCES): Add fgetpwent.c | ||
21 | and intprops.h. | ||
22 | * mailbox/fgetpwent.c (fgetpwent): Rename to mu_fgetpwent. | ||
23 | * mailbox/gocs.c: Revert recent change. It broke the testsuite in | ||
24 | sieve. | ||
25 | * mailbox/syslog.c (log_facility): Initialize to LOG_FACILITY. | ||
26 | |||
3 | * configure.ac, NEWS: Add LDAP support. | 27 | * configure.ac, NEWS: Add LDAP support. |
4 | * auth/Makefile.am (libmuauth_la_SOURCES): Add ldap.c. | 28 | * auth/Makefile.am (libmuauth_la_SOURCES): Add ldap.c. |
5 | * auth/ldap.c: New file. | 29 | * auth/ldap.c: New file. | ... | ... |
... | @@ -70,6 +70,12 @@ mu_virtual_module_init (void *data) | ... | @@ -70,6 +70,12 @@ mu_virtual_module_init (void *data) |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | #if !HAVE_FGETPWENT | ||
74 | /* FIXME: A temporary solution. Need proper declaration in .h */ | ||
75 | extern struct passwd *mu_fgetpwent (FILE *fp); | ||
76 | #define fgetpwent mu_fgetpwent | ||
77 | #endif | ||
78 | |||
73 | static struct passwd * | 79 | static struct passwd * |
74 | getpwnam_virtual (const char *u) | 80 | getpwnam_virtual (const char *u) |
75 | { | 81 | { | ... | ... |
... | @@ -50,7 +50,7 @@ dnl Other variables | ... | @@ -50,7 +50,7 @@ dnl Other variables |
50 | AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)') | 50 | AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)') |
51 | 51 | ||
52 | AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)') | 52 | AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)') |
53 | AC_SUBST(MU_APP_LIBRARIES,'../lib/libmuaux.la ../libargp/libmuargp.a ../libcfg/libmucfg.la') | 53 | AC_SUBST(MU_APP_LIBRARIES,'../libargp/libmuargp.a ../libcfg/libmucfg.la ../lib/libmuaux.la') |
54 | 54 | ||
55 | AC_SUBST(MU_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_srcdir}/mailbox -I${top_srcdir}/libargp -I${top_srcdir}/libcfg') | 55 | AC_SUBST(MU_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_srcdir}/mailbox -I${top_srcdir}/libargp -I${top_srcdir}/libcfg') |
56 | 56 | ||
... | @@ -438,7 +438,7 @@ AH_BOTTOM([ | ... | @@ -438,7 +438,7 @@ AH_BOTTOM([ |
438 | #endif | 438 | #endif |
439 | ]) | 439 | ]) |
440 | 440 | ||
441 | AC_CHECK_FUNC(fgetpwent) | 441 | AC_CHECK_FUNCS(fgetpwent) |
442 | 442 | ||
443 | ## Check for presence of utmp.h and utmp-related functions | 443 | ## Check for presence of utmp.h and utmp-related functions |
444 | MU_CHECK_UTMP | 444 | MU_CHECK_UTMP | ... | ... |
lib/utmp.c
0 → 100644
1 | /* utmp.c -- Replacements for {set,get,end}utmp functions | ||
2 | |||
3 | Copyright (C) 2002 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 2 of the | ||
8 | License, or (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public | ||
16 | Licensealong with this program; if not, write to the Free | ||
17 | SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
18 | MA 02110-1301 USA. */ | ||
19 | |||
20 | #include <sys/types.h> | ||
21 | #include <sys/time.h> | ||
22 | #include <utmp.h> | ||
23 | #include <fcntl.h> | ||
24 | #include <unistd.h> | ||
25 | #include <string.h> | ||
26 | #include <stdio.h> | ||
27 | |||
28 | static char *utmp_name = _PATH_UTMP; | ||
29 | static int fd = -1; | ||
30 | static struct utmp ut; | ||
31 | |||
32 | void | ||
33 | endutent () | ||
34 | { | ||
35 | if (fd > 0) | ||
36 | close (fd); | ||
37 | fd = -1; | ||
38 | } | ||
39 | |||
40 | void | ||
41 | setutent () | ||
42 | { | ||
43 | endutent (); | ||
44 | if ((fd = open (utmp_name, O_RDWR)) < 0 | ||
45 | && ((fd = open (utmp_name, O_RDONLY)) < 0)) | ||
46 | perror ("setutent: Can't open utmp file"); | ||
47 | } | ||
48 | |||
49 | struct utmp * | ||
50 | getutent () | ||
51 | { | ||
52 | if (fd < 0) | ||
53 | setutent (); | ||
54 | |||
55 | if (fd < 0 || read (fd, &ut, sizeof ut) != sizeof ut) | ||
56 | return NULL; | ||
57 | |||
58 | return &ut; | ||
59 | } |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include <mailutils/gsasl.h> | 23 | #include <mailutils/gsasl.h> |
23 | 24 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include "mailutils/mutil.h" | 23 | #include "mailutils/mutil.h" |
23 | #include "mailutils/ldap.h" | 24 | #include "mailutils/ldap.h" | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | 23 | ||
23 | static char *pam_settings; | 24 | static char *pam_settings; | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include <mailutils/radius.h> | 23 | #include <mailutils/radius.h> |
23 | 24 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include <mailutils/libsieve.h> | 23 | #include <mailutils/libsieve.h> |
23 | 24 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include <mailutils/sql.h> | 23 | #include <mailutils/sql.h> |
23 | #include <mailutils/mutil.h> | 24 | #include <mailutils/mutil.h> | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | #include <mailutils/tls.h> | 23 | #include <mailutils/tls.h> |
23 | 24 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifdef HAVE_CONFIG_H | 18 | #ifdef HAVE_CONFIG_H |
19 | # include <config.h> | 19 | # include <config.h> |
20 | #endif | 20 | #endif |
21 | #include <stdlib.h> | ||
21 | #include "mailutils/libcfg.h" | 22 | #include "mailutils/libcfg.h" |
22 | 23 | ||
23 | static char *virtdomain_settings; | 24 | static char *virtdomain_settings; | ... | ... |
... | @@ -31,10 +31,6 @@ | ... | @@ -31,10 +31,6 @@ |
31 | #include <assert.h> | 31 | #include <assert.h> |
32 | #include <fnmatch.h> | 32 | #include <fnmatch.h> |
33 | 33 | ||
34 | #ifdef HAVE_ALLOCA_H | ||
35 | # include <alloca.h> | ||
36 | #endif | ||
37 | |||
38 | #ifdef HAVE_STRINGS_H | 34 | #ifdef HAVE_STRINGS_H |
39 | # include <strings.h> | 35 | # include <strings.h> |
40 | #endif | 36 | #endif |
... | @@ -1388,7 +1384,9 @@ imap_list (f_imap_t f_imap) | ... | @@ -1388,7 +1384,9 @@ imap_list (f_imap_t f_imap) |
1388 | int argc; | 1384 | int argc; |
1389 | char **argv; | 1385 | char **argv; |
1390 | 1386 | ||
1391 | buffer = alloca (len); | 1387 | buffer = malloc (len); |
1388 | if (!buffer) | ||
1389 | return ENOMEM; | ||
1392 | memcpy (buffer, f_imap->buffer, len); | 1390 | memcpy (buffer, f_imap->buffer, len); |
1393 | buffer[len] = '\0'; | 1391 | buffer[len] = '\0'; |
1394 | 1392 | ||
... | @@ -1475,7 +1473,7 @@ imap_list (f_imap_t f_imap) | ... | @@ -1475,7 +1473,7 @@ imap_list (f_imap_t f_imap) |
1475 | } | 1473 | } |
1476 | } | 1474 | } |
1477 | mu_argcv_free (argc, argv); | 1475 | mu_argcv_free (argc, argv); |
1478 | 1476 | free (buffer); | |
1479 | return status; | 1477 | return status; |
1480 | } | 1478 | } |
1481 | 1479 | ||
... | @@ -1769,16 +1767,22 @@ imap_body (f_imap_t f_imap, char **ptr) | ... | @@ -1769,16 +1767,22 @@ imap_body (f_imap_t f_imap, char **ptr) |
1769 | if (**ptr == '[') | 1767 | if (**ptr == '[') |
1770 | { | 1768 | { |
1771 | char *sep = strchr (*ptr, ']'); | 1769 | char *sep = strchr (*ptr, ']'); |
1772 | (*ptr)++; /* Move pass the '[' */ | 1770 | (*ptr)++; /* Move past the '[' */ |
1773 | if (sep) | 1771 | if (sep) |
1774 | { | 1772 | { |
1775 | size_t len = sep - *ptr; | 1773 | size_t len = sep - *ptr; |
1776 | char *section = alloca (len + 1); | 1774 | char *section = malloc (len + 1); |
1777 | char *p = section; | 1775 | char *p; |
1776 | |||
1777 | if (!section) | ||
1778 | return ENOMEM; | ||
1779 | |||
1778 | strncpy (section, *ptr, len); | 1780 | strncpy (section, *ptr, len); |
1779 | section[len] = '\0'; | 1781 | section[len] = '\0'; |
1780 | /* strupper. */ | 1782 | /* strupper. */ |
1781 | for (; *p; p++) if (isupper((unsigned)*p)) *p = toupper ((unsigned)*p); | 1783 | for (p = section; *p; p++) |
1784 | *p = toupper ((unsigned)*p); | ||
1785 | |||
1782 | /* Set the string type to update the correct line count. */ | 1786 | /* Set the string type to update the correct line count. */ |
1783 | /*if (!strstr (section, "FIELD"))*/ | 1787 | /*if (!strstr (section, "FIELD"))*/ |
1784 | { | 1788 | { |
... | @@ -1795,7 +1799,8 @@ imap_body (f_imap_t f_imap, char **ptr) | ... | @@ -1795,7 +1799,8 @@ imap_body (f_imap_t f_imap, char **ptr) |
1795 | f_imap->string.type = IMAP_MESSAGE; | 1799 | f_imap->string.type = IMAP_MESSAGE; |
1796 | } | 1800 | } |
1797 | } | 1801 | } |
1798 | sep++; /* Move pass the ']' */ | 1802 | free (section); |
1803 | sep++; /* Move past the ']' */ | ||
1799 | *ptr = sep; | 1804 | *ptr = sep; |
1800 | } | 1805 | } |
1801 | } | 1806 | } | ... | ... |
... | @@ -485,7 +485,9 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted) | ... | @@ -485,7 +485,9 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted) |
485 | /* Create temporary mu_mailbox_t. */ | 485 | /* Create temporary mu_mailbox_t. */ |
486 | { | 486 | { |
487 | mbox_data_t tmp_mud; | 487 | mbox_data_t tmp_mud; |
488 | char *m = alloca (5 + strlen (tmpmboxname) + 1); | 488 | char *m = malloc (5 + strlen (tmpmboxname) + 1); |
489 | if (!m) | ||
490 | return ENOMEM; | ||
489 | /* Try via the mbox: protocol. */ | 491 | /* Try via the mbox: protocol. */ |
490 | sprintf (m, "mbox:%s", tmpmboxname); | 492 | sprintf (m, "mbox:%s", tmpmboxname); |
491 | status = mu_mailbox_create (&tmpmailbox, m); | 493 | status = mu_mailbox_create (&tmpmailbox, m); |
... | @@ -499,11 +501,12 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted) | ... | @@ -499,11 +501,12 @@ mbox_expunge0 (mu_mailbox_t mailbox, int remove_deleted) |
499 | /* Ok give up. */ | 501 | /* Ok give up. */ |
500 | close (tempfile); | 502 | close (tempfile); |
501 | remove (tmpmboxname); | 503 | remove (tmpmboxname); |
504 | free (m); | ||
502 | free (tmpmboxname); | 505 | free (tmpmboxname); |
503 | return status; | 506 | return status; |
504 | } | 507 | } |
505 | } | 508 | } |
506 | 509 | free (m); | |
507 | /* Must be flag CREATE if not the mu_mailbox_open will try to mmap() | 510 | /* Must be flag CREATE if not the mu_mailbox_open will try to mmap() |
508 | the file. */ | 511 | the file. */ |
509 | status = mu_mailbox_open (tmpmailbox, MU_STREAM_CREAT | MU_STREAM_RDWR); | 512 | status = mu_mailbox_open (tmpmailbox, MU_STREAM_CREAT | MU_STREAM_RDWR); | ... | ... |
... | @@ -34,10 +34,6 @@ | ... | @@ -34,10 +34,6 @@ |
34 | #include <stdarg.h> | 34 | #include <stdarg.h> |
35 | #include <ctype.h> | 35 | #include <ctype.h> |
36 | 36 | ||
37 | #ifdef HAVE_ALLOCA_H | ||
38 | # include <alloca.h> | ||
39 | #endif | ||
40 | |||
41 | #ifdef HAVE_STRINGS_H | 37 | #ifdef HAVE_STRINGS_H |
42 | # include <strings.h> | 38 | # include <strings.h> |
43 | #endif | 39 | #endif | ... | ... |
... | @@ -2,7 +2,7 @@ dnl MU_CHECK_UTMP -- Check for the presence of utmp.h, setutent, getutent | ... | @@ -2,7 +2,7 @@ dnl MU_CHECK_UTMP -- Check for the presence of utmp.h, setutent, getutent |
2 | dnl and endutent calls. | 2 | dnl and endutent calls. |
3 | AC_DEFUN([MU_CHECK_UTMP], | 3 | AC_DEFUN([MU_CHECK_UTMP], |
4 | [ | 4 | [ |
5 | AC_CHECK_HEADERS(utmp.h) | 5 | AC_CHECK_HEADERS([utmp.h]) |
6 | # The three functions setutent,getutent and endutent depend on each other, | 6 | # The three functions setutent,getutent and endutent depend on each other, |
7 | # so it seems reasonable to provide replacements for all three if getutent | 7 | # so it seems reasonable to provide replacements for all three if getutent |
8 | # is not present. | 8 | # is not present. |
... | @@ -10,5 +10,5 @@ AC_DEFUN([MU_CHECK_UTMP], | ... | @@ -10,5 +10,5 @@ AC_DEFUN([MU_CHECK_UTMP], |
10 | AC_DEFINE(HAVE_GETUTENT_CALLS,, | 10 | AC_DEFINE(HAVE_GETUTENT_CALLS,, |
11 | [Define if your system has the three ???utent functions]), | 11 | [Define if your system has the three ???utent functions]), |
12 | [if test "$ac_cv_header_utmp_h" = "yes"; then | 12 | [if test "$ac_cv_header_utmp_h" = "yes"; then |
13 | AC_LIBOBJ(utmp) | 13 | AC_LIBOBJ([utmp]) |
14 | fi])]) | 14 | fi])]) | ... | ... |
... | @@ -52,6 +52,7 @@ libmailutils_la_SOURCES = \ | ... | @@ -52,6 +52,7 @@ libmailutils_la_SOURCES = \ |
52 | cfg_lexer.c\ | 52 | cfg_lexer.c\ |
53 | cfg_parser.c\ | 53 | cfg_parser.c\ |
54 | envelope.c\ | 54 | envelope.c\ |
55 | fgetpwent.c\ | ||
55 | file_stream.c\ | 56 | file_stream.c\ |
56 | filter.c\ | 57 | filter.c\ |
57 | filter_iconv.c\ | 58 | filter_iconv.c\ |
... | @@ -100,7 +101,7 @@ libmailutils_la_SOURCES = \ | ... | @@ -100,7 +101,7 @@ libmailutils_la_SOURCES = \ |
100 | url.c\ | 101 | url.c\ |
101 | version.c\ | 102 | version.c\ |
102 | wicket.c\ | 103 | wicket.c\ |
103 | imaxtostr.c offtostr.c umaxtostr.c | 104 | imaxtostr.c offtostr.c umaxtostr.c intprops.h |
104 | 105 | ||
105 | BUILT_SOURCES = parsedate.c muerrno.c cfg_parser.c cfg_parser.h | 106 | BUILT_SOURCES = parsedate.c muerrno.c cfg_parser.c cfg_parser.h |
106 | MOSTLYCLEANFILES= | 107 | MOSTLYCLEANFILES= | ... | ... |
... | @@ -28,10 +28,6 @@ | ... | @@ -28,10 +28,6 @@ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #ifdef HAVE_ALLOCA_H | ||
32 | # include <alloca.h> | ||
33 | #endif | ||
34 | |||
35 | #ifdef HAVE_LIBGEN_H | 31 | #ifdef HAVE_LIBGEN_H |
36 | # include <libgen.h> | 32 | # include <libgen.h> |
37 | #endif | 33 | #endif |
... | @@ -74,7 +70,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, | ... | @@ -74,7 +70,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, |
74 | mu_header_t hdr; | 70 | mu_header_t hdr; |
75 | mu_body_t body; | 71 | mu_body_t body; |
76 | mu_stream_t fstream = NULL, tstream = NULL; | 72 | mu_stream_t fstream = NULL, tstream = NULL; |
77 | char *header, *name = NULL, *fname = NULL; | 73 | char *header = NULL, *name = NULL, *fname = NULL; |
78 | int ret; | 74 | int ret; |
79 | 75 | ||
80 | if (newmsg == NULL) | 76 | if (newmsg == NULL) |
... | @@ -96,7 +92,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, | ... | @@ -96,7 +92,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, |
96 | else | 92 | else |
97 | name = fname; | 93 | name = fname; |
98 | if ((header = | 94 | if ((header = |
99 | alloca (strlen (MSG_HDR) + strlen (content_type) + | 95 | malloc (strlen (MSG_HDR) + strlen (content_type) + |
100 | strlen (name) * 2 + strlen (encoding) + 1)) == NULL) | 96 | strlen (name) * 2 + strlen (encoding) + 1)) == NULL) |
101 | ret = ENOMEM; | 97 | ret = ENOMEM; |
102 | else | 98 | else |
... | @@ -124,6 +120,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, | ... | @@ -124,6 +120,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding, |
124 | } | 120 | } |
125 | } | 121 | } |
126 | } | 122 | } |
123 | free (header); | ||
127 | } | 124 | } |
128 | } | 125 | } |
129 | } | 126 | } |
... | @@ -326,7 +323,6 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, | ... | @@ -326,7 +323,6 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, |
326 | size_t size; | 323 | size_t size; |
327 | size_t nbytes; | 324 | size_t nbytes; |
328 | mu_header_t hdr; | 325 | mu_header_t hdr; |
329 | char *content_encoding; | ||
330 | const char *fname = NULL; | 326 | const char *fname = NULL; |
331 | char *partname = NULL; | 327 | char *partname = NULL; |
332 | 328 | ||
... | @@ -353,20 +349,26 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, | ... | @@ -353,20 +349,26 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, |
353 | { | 349 | { |
354 | if ((ret = mu_stream_open (info->fstream)) == 0) | 350 | if ((ret = mu_stream_open (info->fstream)) == 0) |
355 | { | 351 | { |
352 | char *content_encoding; | ||
353 | char *content_encoding_mem = NULL; | ||
354 | |||
356 | mu_header_get_value (hdr, "Content-Transfer-Encoding", NULL, 0, | 355 | mu_header_get_value (hdr, "Content-Transfer-Encoding", NULL, 0, |
357 | &size); | 356 | &size); |
358 | if (size) | 357 | if (size) |
359 | { | 358 | { |
360 | if ((content_encoding = alloca (size + 1)) == NULL) | 359 | content_encoding_mem = malloc (size + 1); |
360 | if (content_encoding_mem == NULL) | ||
361 | ret = ENOMEM; | 361 | ret = ENOMEM; |
362 | content_encoding = content_encoding_mem; | ||
362 | mu_header_get_value (hdr, "Content-Transfer-Encoding", | 363 | mu_header_get_value (hdr, "Content-Transfer-Encoding", |
363 | content_encoding, size + 1, 0); | 364 | content_encoding, size + 1, 0); |
364 | } | 365 | } |
365 | else | 366 | else |
366 | content_encoding = (char *) "7bit"; | 367 | content_encoding = "7bit"; |
367 | ret = | 368 | ret = |
368 | mu_filter_create (&info->stream, istream, content_encoding, | 369 | mu_filter_create (&info->stream, istream, content_encoding, |
369 | MU_FILTER_DECODE, MU_STREAM_READ); | 370 | MU_FILTER_DECODE, MU_STREAM_READ); |
371 | free (content_encoding_mem); | ||
370 | } | 372 | } |
371 | } | 373 | } |
372 | } | 374 | } |
... | @@ -402,8 +404,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, | ... | @@ -402,8 +404,8 @@ mu_message_save_attachment (mu_message_t msg, const char *filename, |
402 | } | 404 | } |
403 | 405 | ||
404 | /* Free fname if we allocated it. */ | 406 | /* Free fname if we allocated it. */ |
405 | if(partname) | 407 | if (partname) |
406 | free(partname); | 408 | free (partname); |
407 | 409 | ||
408 | return ret; | 410 | return ret; |
409 | } | 411 | } |
... | @@ -473,7 +475,6 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data) | ... | @@ -473,7 +475,6 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data) |
473 | { | 475 | { |
474 | size_t size, nbytes; | 476 | size_t size, nbytes; |
475 | int ret = 0; | 477 | int ret = 0; |
476 | char *content_type; | ||
477 | mu_header_t hdr; | 478 | mu_header_t hdr; |
478 | mu_stream_t istream, ostream; | 479 | mu_stream_t istream, ostream; |
479 | struct _msg_info *info = NULL; | 480 | struct _msg_info *info = NULL; |
... | @@ -489,12 +490,14 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data) | ... | @@ -489,12 +490,14 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data) |
489 | mu_header_get_value (hdr, "Content-Type", NULL, 0, &size); | 490 | mu_header_get_value (hdr, "Content-Type", NULL, 0, &size); |
490 | if (size) | 491 | if (size) |
491 | { | 492 | { |
492 | if ((content_type = alloca (size + 1)) == NULL) | 493 | char *content_type; |
494 | if ((content_type = malloc (size + 1)) == NULL) | ||
493 | return ENOMEM; | 495 | return ENOMEM; |
494 | mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0); | 496 | mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0); |
495 | if (strncasecmp | 497 | ret = strncasecmp (content_type, "message/rfc822", |
496 | (content_type, "message/rfc822", | 498 | strlen ("message/rfc822")); |
497 | strlen ("message/rfc822")) != 0) | 499 | free (content_type); |
500 | if (ret != 0) | ||
498 | return EINVAL; | 501 | return EINVAL; |
499 | } | 502 | } |
500 | else | 503 | else | ... | ... |
... | @@ -40,7 +40,6 @@ static char *buffer; | ... | @@ -40,7 +40,6 @@ static char *buffer; |
40 | static size_t buflen; | 40 | static size_t buflen; |
41 | static struct passwd pw; | 41 | static struct passwd pw; |
42 | 42 | ||
43 | |||
44 | static char * | 43 | static char * |
45 | parse_line (char *s, char **p) | 44 | parse_line (char *s, char **p) |
46 | { | 45 | { |
... | @@ -81,7 +80,7 @@ getentry (char *s) | ... | @@ -81,7 +80,7 @@ getentry (char *s) |
81 | } | 80 | } |
82 | 81 | ||
83 | struct passwd * | 82 | struct passwd * |
84 | fgetpwent (FILE *fp) | 83 | mu_fgetpwent (FILE *fp) |
85 | { | 84 | { |
86 | size_t pos = 0; | 85 | size_t pos = 0; |
87 | int done = 0; | 86 | int done = 0; | ... | ... |
... | @@ -212,10 +212,7 @@ mu_gocs_logging_init (void *data) | ... | @@ -212,10 +212,7 @@ mu_gocs_logging_init (void *data) |
212 | mu_debug_default_printer = mu_debug_syslog_printer; | 212 | mu_debug_default_printer = mu_debug_syslog_printer; |
213 | } | 213 | } |
214 | else | 214 | else |
215 | { | 215 | mu_debug_default_printer = mu_debug_stderr_printer; |
216 | log_facility = LOG_FACILITY; | ||
217 | mu_debug_default_printer = mu_debug_stderr_printer; | ||
218 | } | ||
219 | 216 | ||
220 | /* FIXME: Tag */ | 217 | /* FIXME: Tag */ |
221 | return 0; | 218 | return 0; | ... | ... |
... | @@ -23,7 +23,6 @@ | ... | @@ -23,7 +23,6 @@ |
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <alloca.h> | ||
27 | #include <string.h> | 26 | #include <string.h> |
28 | 27 | ||
29 | #include <mailutils/debug.h> | 28 | #include <mailutils/debug.h> |
... | @@ -85,28 +84,11 @@ mu_mailbox_get_default_proto () | ... | @@ -85,28 +84,11 @@ mu_mailbox_get_default_proto () |
85 | return default_proto ? default_proto : "/"; | 84 | return default_proto ? default_proto : "/"; |
86 | } | 85 | } |
87 | 86 | ||
88 | /* The Mailbox Factory. | 87 | static int |
89 | Create an iterator for registrar and see if any url scheme match, | 88 | _create_mailbox (mu_mailbox_t *pmbox, const char *name) |
90 | Then we call the mailbox's mu_url_create() to parse the URL. Last | ||
91 | initialize the concrete mailbox and folder. */ | ||
92 | int | ||
93 | mu_mailbox_create (mu_mailbox_t *pmbox, const char *name) | ||
94 | { | 89 | { |
95 | mu_record_t record = NULL; | 90 | mu_record_t record = NULL; |
96 | |||
97 | if (pmbox == NULL) | ||
98 | return MU_ERR_OUT_PTR_NULL; | ||
99 | 91 | ||
100 | if (!mu_is_proto (name) && default_proto) | ||
101 | { | ||
102 | char *tmp_name = alloca (strlen (default_proto) + strlen (name) + 1); | ||
103 | if (!tmp_name) | ||
104 | return ENOMEM; | ||
105 | strcpy (tmp_name, default_proto); | ||
106 | strcat (tmp_name, name); | ||
107 | name = tmp_name; | ||
108 | } | ||
109 | |||
110 | if (mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL) == 0) | 92 | if (mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_FILE, &record, NULL) == 0) |
111 | { | 93 | { |
112 | int (*m_init) (mu_mailbox_t) = NULL; | 94 | int (*m_init) (mu_mailbox_t) = NULL; |
... | @@ -159,10 +141,34 @@ mu_mailbox_create (mu_mailbox_t *pmbox, const char *name) | ... | @@ -159,10 +141,34 @@ mu_mailbox_create (mu_mailbox_t *pmbox, const char *name) |
159 | return status; | 141 | return status; |
160 | } | 142 | } |
161 | } | 143 | } |
162 | |||
163 | return MU_ERR_NO_HANDLER; | 144 | return MU_ERR_NO_HANDLER; |
164 | } | 145 | } |
165 | 146 | ||
147 | /* The Mailbox Factory. | ||
148 | Create an iterator for registrar and see if any url scheme match, | ||
149 | Then we call the mailbox's mu_url_create() to parse the URL. Last | ||
150 | initialize the concrete mailbox and folder. */ | ||
151 | int | ||
152 | mu_mailbox_create (mu_mailbox_t *pmbox, const char *name) | ||
153 | { | ||
154 | int rc; | ||
155 | |||
156 | if (pmbox == NULL) | ||
157 | return MU_ERR_OUT_PTR_NULL; | ||
158 | |||
159 | if (!mu_is_proto (name) && default_proto) | ||
160 | { | ||
161 | char *tmp_name = malloc (strlen (default_proto) + strlen (name) + 1); | ||
162 | strcpy (tmp_name, default_proto); | ||
163 | strcat (tmp_name, name); | ||
164 | rc = _create_mailbox (pmbox, name); | ||
165 | free (name); | ||
166 | } | ||
167 | else | ||
168 | rc = _create_mailbox (pmbox, name); | ||
169 | return rc; | ||
170 | } | ||
171 | |||
166 | void | 172 | void |
167 | mu_mailbox_destroy (mu_mailbox_t *pmbox) | 173 | mu_mailbox_destroy (mu_mailbox_t *pmbox) |
168 | { | 174 | { | ... | ... |
-
Please register or sign in to post a comment