diff options
-rw-r--r-- | include/mailutils/smtp.h | 5 | ||||
-rw-r--r-- | libmailutils/url/dup.c | 4 | ||||
-rw-r--r-- | libproto/mailer/Makefile.am | 1 | ||||
-rw-r--r-- | libproto/mailer/smtp_capa_itr.c | 45 | ||||
-rw-r--r-- | libproto/mailer/smtp_io.c | 19 |
5 files changed, 72 insertions, 2 deletions
diff --git a/include/mailutils/smtp.h b/include/mailutils/smtp.h index 4ae6a33d8..6d8cdd967 100644 --- a/include/mailutils/smtp.h +++ b/include/mailutils/smtp.h @@ -45,6 +45,10 @@ int mu_smtp_open (mu_smtp_t); int mu_smtp_response (mu_smtp_t smtp); int mu_smtp_write (mu_smtp_t smtp, const char *fmt, ...) MU_PRINTFLIKE(2,3); +int mu_smtp_replcode (mu_smtp_t smtp, char *buf); +int mu_smtp_sget_reply (mu_smtp_t smtp, const char **pbuf); + + #define MU_SMTP_TRACE_CLR 0 #define MU_SMTP_TRACE_SET 1 #define MU_SMTP_TRACE_QRY 2 @@ -61,6 +65,7 @@ int mu_smtp_set_secret (mu_smtp_t smtp, mu_secret_t secret); int mu_smtp_get_secret (mu_smtp_t smtp, mu_secret_t *secret); int mu_smtp_capa_test (mu_smtp_t smtp, const char *capa, const char **pret); +int mu_smtp_capa_iterator (mu_smtp_t smtp, mu_iterator_t *itr); int mu_smtp_starttls (mu_smtp_t smtp); int mu_smtp_mail_basic (mu_smtp_t smtp, const char *email, diff --git a/libmailutils/url/dup.c b/libmailutils/url/dup.c index 141463eca..5b78d5245 100644 --- a/libmailutils/url/dup.c +++ b/libmailutils/url/dup.c @@ -34,11 +34,13 @@ int mu_url_dup (mu_url_t old_url, mu_url_t *new_url) { int rc; + const char *s; mu_url_t url = calloc (1, sizeof (*url)); if (!url) return ENOMEM; - url->name = strdup (old_url->name); + mu_url_sget_name (old_url, &s); + url->name = strdup (s); if (!url->name) { free (url); diff --git a/libproto/mailer/Makefile.am b/libproto/mailer/Makefile.am index 5fae96749..143680419 100644 --- a/libproto/mailer/Makefile.am +++ b/libproto/mailer/Makefile.am @@ -32,6 +32,7 @@ libmu_mailer_la_SOURCES = \ smtp.c\ smtp_auth.c\ smtp_capa.c\ + smtp_capa_itr.c\ smtp_carrier.c\ smtp_create.c\ smtp_data.c\ diff --git a/libproto/mailer/smtp_capa_itr.c b/libproto/mailer/smtp_capa_itr.c new file mode 100644 index 000000000..25152fa86 --- /dev/null +++ b/libproto/mailer/smtp_capa_itr.c @@ -0,0 +1,45 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2010-2012 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 <errno.h> +#include <stdlib.h> +#include <mailutils/errno.h> +#include <mailutils/list.h> +#include <mailutils/iterator.h> +#include <mailutils/smtp.h> +#include <mailutils/sys/smtp.h> + +int +mu_smtp_capa_iterator (mu_smtp_t smtp, mu_iterator_t *itr) +{ + if (!smtp || !itr) + return EINVAL; + if (MU_SMTP_FISSET (smtp, _MU_SMTP_ERR)) + return MU_ERR_FAILURE; + if (!smtp->capa) + { + int rc = mu_smtp_ehlo (smtp); + if (rc) + return rc; + } + if (!MU_SMTP_FISSET (smtp, _MU_SMTP_ESMTP)) + return MU_ERR_FAILURE; + return mu_list_get_iterator (smtp->capa, itr); +} diff --git a/libproto/mailer/smtp_io.c b/libproto/mailer/smtp_io.c index da46f7759..8df32affb 100644 --- a/libproto/mailer/smtp_io.c +++ b/libproto/mailer/smtp_io.c @@ -89,7 +89,8 @@ mu_smtp_response (mu_smtp_t smtp) smtp->flbuf = p; smtp->flsize = n; } - memcpy (smtp->flbuf, smtp->rdbuf + 4, n - 3); + memcpy (smtp->flbuf, smtp->rdbuf + 4, n - 1); + smtp->flbuf[n - 1] = 0; smtp->replptr = smtp->flbuf; rc = _mu_smtp_init_mlist (smtp); @@ -125,6 +126,22 @@ mu_smtp_response (mu_smtp_t smtp) return 0; } +int +mu_smtp_replcode (mu_smtp_t smtp, char *buf) +{ + if (!smtp || !buf) + return EINVAL; + strcpy (buf, smtp->replcode); + return 0; +} +int +mu_smtp_sget_reply (mu_smtp_t smtp, const char **pbuf) +{ + if (!smtp || !pbuf) + return EINVAL; + *pbuf = smtp->replptr; + return 0; +} |