Commit 34128509 34128509db514024afd85a714cb9cad1f71d2d82 by Sergey Poznyakoff

Minor changes in SMTP and URL code.

* include/mailutils/smtp.h (mu_smtp_replcode)
(mu_smtp_sget_reply)
(mu_smtp_capa_iterator): New protos.
* libmailutils/url/dup.c (mu_url_dup): Bugfix. Obtain the
name using mu_url_sget_name, which will create it if necessary.
* libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Add
smtp_capa_itr.c
* libproto/mailer/smtp_capa_itr.c: New file.
* libproto/mailer/smtp_io.c (mu_smtp_response): Fix filling of
smtp->flbuf.
(mu_smtp_replcode,mu_smtp_sget_reply): New functions.
1 parent 0b1e16be
......@@ -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,
......
......@@ -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);
......
......@@ -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\
......
/* 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);
}
......@@ -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;
}
......