summaryrefslogtreecommitdiff
path: root/mu/libexec/imap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mu/libexec/imap.c')
-rw-r--r--mu/libexec/imap.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/mu/libexec/imap.c b/mu/libexec/imap.c
index 17fe817b3..2843ec157 100644
--- a/mu/libexec/imap.c
+++ b/mu/libexec/imap.c
@@ -1,5 +1,5 @@
/* GNU Mailutils -- a suite of utilities for electronic mail
- Copyright (C) 2010-2020 Free Software Foundation, Inc.
+ Copyright (C) 2010-2024 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
@@ -28,6 +28,7 @@
#include <mailutils/imapio.h>
#include <mailutils/imaputil.h>
#include <mailutils/msgset.h>
+#include <mailutils/sys/envelope.h>
#include "mu.h"
char imap_docstring[] = N_("IMAP4 client shell");
@@ -521,12 +522,15 @@ com_connect (int argc, char **argv)
if (tls)
{
mu_stream_t tlsstream;
-
- status = mu_tls_client_stream_create (&tlsstream, tcp, tcp, 0);
+
+ status = mu_tlsfd_stream_convert (&tlsstream, tcp, NULL,
+ MU_TLS_CLIENT);
mu_stream_unref (tcp);
if (status)
{
- mu_error (_("cannot create TLS stream: %s"),
+ if (status == MU_ERR_TRANSPORT_SET)
+ mu_stream_destroy (&tlsstream);
+ mu_error ("cannot create TLS stream: %s",
mu_strerror (status));
return 0;
}
@@ -534,7 +538,8 @@ com_connect (int argc, char **argv)
}
#endif
mu_imap_set_carrier (imap, tcp);
-
+ mu_stream_unref (tcp);
+
if (QRY_VERBOSE ())
{
imap_set_verbose ();
@@ -994,32 +999,42 @@ com_unsubscribe (int argc, char **argv)
static int
com_append (int argc, char **argv)
{
- struct tm tmbuf, *tm = NULL;
- struct mu_timezone tzbuf, *tz = NULL;
int flags = 0;
mu_stream_t stream;
int rc, i;
+ mu_envelope_t env = NULL;
+ mu_attribute_t atr = NULL;
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "-time") == 0)
{
char *p;
-
+ char datebuf[MU_DATETIME_FROM_LENGTH+1];
+ struct tm tm;
+
if (++i == argc)
{
mu_error (_("-time requires argument"));
return 0;
}
+
rc = mu_scan_datetime (argv[i], MU_DATETIME_INTERNALDATE,
- &tmbuf, &tzbuf, &p);
+ &tm, NULL, &p);
if (rc || *p)
{
mu_error (_("cannot parse time"));
return 0;
}
- tm = &tmbuf;
- tz = &tzbuf;
+
+ mu_strftime (datebuf, sizeof (datebuf), MU_DATETIME_FROM, &tm);
+ rc = mu_envelope_create (&env, NULL);
+ if (rc)
+ {
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_envelope_create", NULL, rc);
+ return 0;
+ }
+ env->date = mu_strdup (datebuf);
}
else if (strcmp (argv[i], "-flag") == 0)
{
@@ -1033,6 +1048,13 @@ com_append (int argc, char **argv)
mu_error (_("unrecognized flag: %s"), argv[i]);
return 0;
}
+ rc = mu_attribute_create (&atr, NULL);
+ if (rc)
+ {
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_attribute_create", NULL, rc);
+ return 0;
+ }
+ mu_attribute_set_flags (atr, flags);
}
else if (strcmp (argv[i], "--") == 0)
{
@@ -1062,8 +1084,10 @@ com_append (int argc, char **argv)
return 0;
}
- rc = mu_imap_append_stream (imap, argv[i], flags, tm, tz, stream);
+ rc = mu_imap_append_stream (imap, argv[i], env, atr, stream);
mu_stream_unref (stream);
+ mu_envelope_destroy (&env, NULL);
+ mu_attribute_destroy (&atr, NULL);
if (rc)
report_failure ("append", rc);
return 0;
@@ -1298,6 +1322,8 @@ struct mutool_command imap_comtab[] = {
int
main (int argc, char **argv)
{
+ mu_set_program_name (argv[0]);
+
mu_action_getopt (&argc, &argv, NULL, imap_docstring, NULL);
if (argc)

Return to:

Send suggestions and report system problems to the System administrator.