Commit aa0debf5 aa0debf5d7f45684db96fe2a5be171ad870975ab by Sergey Poznyakoff

imap client: implement STORE, DELETE, RENAME, CHECK, EXPUNGE, COPY, CLOSE and UNSELECT.

* include/mailutils/imap.h (imap_command): New struct.
(mu_imap_gencom): New function.
(mu_imap_store,mu_imap_delete)
(mu_imap_rename,mu_imap_mailbox_close,mu_imap_close)
(mu_imap_check): New functions.
(_mu_close_handler): New function.
* include/mailutils/sys/imap.h (mu_imap_client_state): Add new states.
* libproto/imap/gencom.c: New file.
* libproto/imap/close.c: New file.
* libproto/imap/delete.c: New file.
* libproto/imap/rename.c: New file.
* libproto/imap/store.c: New file.
* libproto/imap/unselect.c: New file.
* libproto/imap/check.c: New file.
* libproto/imap/expunge.c: New file.
* libproto/imap/copy.c: New file.
* libproto/imap/Makefile.am (libmu_imap_la_SOURCES): Add new files.

* mu/imap.c: Implement new commands.
* mu/shell.c (execute_line): Treat backslash as escape only before
another backslash or double-quote.
1 parent b12c4638
......@@ -38,13 +38,25 @@ enum mu_imap_session_state
MU_IMAP_SESSION_INIT, /* Initial state (disconnected) */
MU_IMAP_SESSION_NONAUTH, /* Non-Authenticated State */
MU_IMAP_SESSION_AUTH, /* Authenticated State */
MU_IMAP_SESSION_SELECTED, /* Selected State */
MU_IMAP_SESSION_LOGOUT, /* Logout State */
MU_IMAP_SESSION_SELECTED /* Selected State */
};
int mu_imap_create (mu_imap_t *pimap);
void mu_imap_destroy (mu_imap_t *pimap);
struct imap_command
{
int session_state;
char *capa;
int rx_state;
int uid;
int argc;
char const **argv;
void (*handler) (mu_imap_t);
};
int mu_imap_gencom (mu_imap_t imap, struct imap_command *cmd);
int mu_imap_connect (mu_imap_t imap);
int mu_imap_disconnect (mu_imap_t imap);
......@@ -58,8 +70,23 @@ int mu_imap_logout (mu_imap_t imap);
int mu_imap_id (mu_imap_t imap, char **idenv, mu_assoc_t *passoc);
int mu_imap_noop (mu_imap_t imap);
int mu_imap_check (mu_imap_t imap);
int mu_imap_fetch (mu_imap_t imap, int uid, const char *msgset,
const char *items);
int mu_imap_store (mu_imap_t imap, int uid, const char *msgset,
const char *items);
int mu_imap_delete (mu_imap_t imap, const char *mailbox);
int mu_imap_rename (mu_imap_t imap, const char *mailbox,
const char *new_mailbox);
int mu_imap_copy (mu_imap_t imap, int uid, const char *msgset,
const char *mailbox);
int mu_imap_close (mu_imap_t imap);
int mu_imap_unselect (mu_imap_t imap);
int mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items);
int mu_imap_expunge (mu_imap_t imap);
int mu_imap_set_carrier (mu_imap_t imap, mu_stream_t carrier);
int mu_imap_get_carrier (mu_imap_t imap, mu_stream_t *pcarrier);
......
......@@ -57,6 +57,14 @@ enum mu_imap_client_state
MU_IMAP_CLIENT_STATUS_RX,
MU_IMAP_CLIENT_NOOP_RX,
MU_IMAP_CLIENT_FETCH_RX,
MU_IMAP_CLIENT_STORE_RX,
MU_IMAP_CLIENT_DELETE_RX,
MU_IMAP_CLIENT_RENAME_RX,
MU_IMAP_CLIENT_CLOSE_RX,
MU_IMAP_CLIENT_UNSELECT_RX,
MU_IMAP_CLIENT_CHECK_RX,
MU_IMAP_CLIENT_COPY_RX,
MU_IMAP_CLIENT_EXPUNGE_RX,
MU_IMAP_CLIENT_CLOSING
};
......@@ -194,6 +202,8 @@ int _mu_imap_collect_flags (struct imap_list_element *arg, int *res);
struct imap_list_element *_mu_imap_list_at (mu_list_t list, int idx);
int _mu_imap_parse_fetch_response (mu_list_t resp, mu_list_t *result_list);
void _mu_close_handler (mu_imap_t imap);
# ifdef __cplusplus
}
......
......@@ -16,6 +16,7 @@ imapio
listop
mailcap
prop
scantime
strftime
url-comp
url-parse
......
......@@ -29,25 +29,34 @@ libmu_imap_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@
libmu_imap_la_SOURCES = \
fake-folder.c\
fetch.c\
gencom.c\
callback.c\
capability.c\
capatst.c\
carrier.c\
check.c\
close.c\
connect.c\
copy.c\
create.c\
delete.c\
destroy.c\
disconnect.c\
err.c\
expunge.c\
id.c\
login.c\
logout.c\
noop.c\
rename.c\
resplist.c\
response.c\
resproc.c\
select.c\
state.c\
status.c\
store.c\
tag.c\
trace.c
trace.c\
unselect.c
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_check (mu_imap_t imap)
{
static char const *command = "CHECK";
static struct imap_command com = {
MU_IMAP_SESSION_SELECTED,
NULL,
MU_IMAP_CLIENT_CHECK_RX,
0,
1,
&command,
NULL
};
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
void
_mu_close_handler (mu_imap_t imap)
{
if (imap->resp_code == MU_IMAP_OK)
imap->session_state = MU_IMAP_SESSION_AUTH;
}
int
mu_imap_close (mu_imap_t imap)
{
static char const *command = "CLOSE";
static struct imap_command com = {
MU_IMAP_SESSION_SELECTED,
NULL,
MU_IMAP_CLIENT_CLOSE_RX,
0,
1,
&command,
_mu_close_handler
};
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_copy (mu_imap_t imap, int uid, const char *msgset, const char *mailbox)
{
char const *argv[3];
static struct imap_command com;
argv[0] = "COPY";
argv[1] = msgset;
argv[2] = mailbox;
com.session_state = MU_IMAP_SESSION_SELECTED;
com.capa = NULL;
com.rx_state = MU_IMAP_CLIENT_COPY_RX;
com.uid = 0;
com.argc = 3;
com.argv = argv;
com.handler = NULL;
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_delete (mu_imap_t imap, const char *mailbox)
{
char const *argv[2];
static struct imap_command com;
argv[0] = "DELETE";
argv[1] = mailbox;
com.session_state = MU_IMAP_SESSION_AUTH;
com.capa = NULL;
com.rx_state = MU_IMAP_CLIENT_DELETE_RX;
com.uid = 0;
com.argc = 2;
com.argv = argv;
com.handler = NULL;
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_expunge (mu_imap_t imap)
{
static char const *command = "EXPUNGE";
static struct imap_command com = {
MU_IMAP_SESSION_SELECTED,
NULL,
MU_IMAP_CLIENT_EXPUNGE_RX,
0,
1,
&command,
NULL
};
return mu_imap_gencom (imap, &com);
}
......@@ -29,53 +29,24 @@
#include <mailutils/sys/imap.h>
int
mu_imap_fetch (mu_imap_t imap, const char *msgset, const char *items)
mu_imap_fetch (mu_imap_t imap, int uid, const char *msgset, const char *items)
{
int status;
if (imap == NULL)
return EINVAL;
if (!imap->io)
return MU_ERR_NO_TRANSPORT;
char const *argv[3];
static struct imap_command com;
if (imap->session_state != MU_IMAP_SESSION_SELECTED)
return MU_ERR_SEQ;
argv[0] = "FETCH";
argv[1] = msgset;
argv[2] = items;
switch (imap->client_state)
{
case MU_IMAP_CLIENT_READY:
status = _mu_imap_tag_next (imap);
MU_IMAP_CHECK_EAGAIN (imap, status);
status = mu_imapio_printf (imap->io, "%s FETCH %s %s\r\n",
imap->tag_str, msgset, items);
MU_IMAP_CHECK_ERROR (imap, status);
MU_IMAP_FCLR (imap, MU_IMAP_RESP);
imap->client_state = MU_IMAP_CLIENT_FETCH_RX;
case MU_IMAP_CLIENT_FETCH_RX:
status = _mu_imap_response (imap, NULL, NULL);
MU_IMAP_CHECK_EAGAIN (imap, status);
switch (imap->resp_code)
{
case MU_IMAP_OK:
status = 0;
break;
case MU_IMAP_NO:
status = MU_ERR_FAILURE;
break;
case MU_IMAP_BAD:
status = MU_ERR_BADREPLY;
break;
}
imap->client_state = MU_IMAP_CLIENT_READY;
break;
default:
status = EINPROGRESS;
}
return status;
com.session_state = MU_IMAP_SESSION_SELECTED;
com.capa = NULL;
com.rx_state = MU_IMAP_CLIENT_FETCH_RX;
com.uid = uid;
com.argc = 3;
com.argv = argv;
com.handler = NULL;
return mu_imap_gencom (imap, &com);
}
static void
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_gencom (mu_imap_t imap, struct imap_command *cmd)
{
int status;
int i;
if (imap == NULL || !cmd || cmd->argc < 1)
return EINVAL;
if (!imap->io)
return MU_ERR_NO_TRANSPORT;
if (imap->session_state < cmd->session_state)
return MU_ERR_SEQ;
if (cmd->capa)
{
status = mu_imap_capability_test (imap, cmd->capa, NULL);
switch (status)
{
case 0:
break;
case MU_ERR_NOENT:
return ENOSYS;
default:
return status;
}
}
if (imap->client_state == MU_IMAP_CLIENT_READY)
{
status = _mu_imap_tag_next (imap);
MU_IMAP_CHECK_EAGAIN (imap, status);
status = mu_imapio_printf (imap->io, "%s", imap->tag_str);
if (status == 0 && cmd->uid)
status = mu_imapio_printf (imap->io, " UID");
MU_IMAP_CHECK_ERROR (imap, status);
for (i = 0; i < cmd->argc; i++)
{
status = mu_imapio_printf (imap->io, " %s", cmd->argv[i]);
MU_IMAP_CHECK_ERROR (imap, status);
}
status = mu_imapio_send (imap->io, "\r\n", 2);
MU_IMAP_CHECK_ERROR (imap, status);
MU_IMAP_FCLR (imap, MU_IMAP_RESP);
imap->client_state = cmd->rx_state;
}
if (imap->client_state == cmd->rx_state)
{
status = _mu_imap_response (imap, NULL, NULL);
MU_IMAP_CHECK_EAGAIN (imap, status);
if (cmd->handler)
cmd->handler (imap);
switch (imap->resp_code)
{
case MU_IMAP_OK:
status = 0;
break;
case MU_IMAP_NO:
status = MU_ERR_FAILURE;
break;
case MU_IMAP_BAD:
status = MU_ERR_BADREPLY;
break;
}
imap->client_state = MU_IMAP_CLIENT_READY;
}
else
status = EINPROGRESS;
return status;
}
......@@ -51,7 +51,7 @@ mu_imap_logout (mu_imap_t imap)
status = _mu_imap_response (imap, NULL, NULL);
MU_IMAP_CHECK_EAGAIN (imap, status);
imap->client_state = MU_IMAP_CLIENT_READY;
imap->session_state = MU_IMAP_SESSION_LOGOUT;
imap->session_state = MU_IMAP_SESSION_INIT;
break;
default:
......
......@@ -19,56 +19,22 @@
# include <config.h>
#endif
#include <stdlib.h>
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_noop (mu_imap_t imap)
{
int status;
if (imap == NULL)
return EINVAL;
if (!imap->io)
return MU_ERR_NO_TRANSPORT;
if (imap->session_state == MU_IMAP_SESSION_INIT)
return MU_ERR_SEQ;
switch (imap->client_state)
{
case MU_IMAP_CLIENT_READY:
status = _mu_imap_tag_next (imap);
MU_IMAP_CHECK_EAGAIN (imap, status);
status = mu_imapio_printf (imap->io, "%s NOOP\r\n", imap->tag_str);
MU_IMAP_CHECK_ERROR (imap, status);
MU_IMAP_FCLR (imap, MU_IMAP_RESP);
imap->client_state = MU_IMAP_CLIENT_NOOP_RX;
case MU_IMAP_CLIENT_NOOP_RX:
status = _mu_imap_response (imap, NULL, NULL);
MU_IMAP_CHECK_EAGAIN (imap, status);
switch (imap->resp_code)
{
case MU_IMAP_OK:
status = 0;
break;
case MU_IMAP_NO:
status = MU_ERR_FAILURE;
break;
case MU_IMAP_BAD:
status = MU_ERR_BADREPLY;
break;
}
imap->client_state = MU_IMAP_CLIENT_READY;
break;
default:
status = EINPROGRESS;
}
return status;
static char const *command = "NOOP";
static struct imap_command com = {
MU_IMAP_SESSION_INIT,
NULL,
MU_IMAP_CLIENT_NOOP_RX,
0,
1,
&command,
NULL
};
return mu_imap_gencom (imap, &com);
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_rename (mu_imap_t imap, const char *mailbox, const char *new_mailbox)
{
char const *argv[3];
static struct imap_command com;
argv[0] = "RENAME";
argv[1] = mailbox;
argv[2] = new_mailbox;
com.session_state = MU_IMAP_SESSION_AUTH;
com.capa = NULL;
com.rx_state = MU_IMAP_CLIENT_DELETE_RX;
com.uid = 0;
com.argc = 3;
com.argv = argv;
com.handler = NULL;
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_store (mu_imap_t imap, int uid, const char *msgset, const char *items)
{
char const *argv[3];
static struct imap_command com;
argv[0] = "STORE";
argv[1] = msgset;
argv[2] = items;
com.session_state = MU_IMAP_SESSION_SELECTED;
com.capa = NULL;
com.rx_state = MU_IMAP_CLIENT_STORE_RX;
com.uid = uid;
com.argc = 3;
com.argv = argv;
com.handler = NULL;
return mu_imap_gencom (imap, &com);
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2011 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 of the License, 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 this library. If not, see
<http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/imap.h>
#include <mailutils/sys/imap.h>
int
mu_imap_unselect (mu_imap_t imap)
{
static char const *command = "UNSELECT";
static struct imap_command com = {
MU_IMAP_SESSION_SELECTED,
NULL,
MU_IMAP_CLIENT_UNSELECT_RX,
0,
1,
&command,
_mu_close_handler
};
return mu_imap_gencom (imap, &com);
}
......@@ -69,11 +69,7 @@ current_imap_state ()
if (imap == NULL)
state = MU_IMAP_SESSION_INIT;
else
{
mu_imap_state (imap, &state);
if (state == MU_IMAP_SESSION_LOGOUT)
state = MU_IMAP_SESSION_INIT;
}
mu_imap_state (imap, &state);
return state;
}
......@@ -731,6 +727,15 @@ com_noop (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
}
static int
com_check (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
{
int status = mu_imap_check (imap);
if (status)
report_failure ("check", status);
return 0;
}
static int
com_fetch (int argc, char **argv)
{
int status;
......@@ -739,7 +744,7 @@ com_fetch (int argc, char **argv)
mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
imap_fetch_callback,
out);
status = mu_imap_fetch (imap, argv[1], argv[2]);
status = mu_imap_fetch (imap, 0, argv[1], argv[2]);
mu_stream_destroy (&out);
mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
imap_fetch_callback,
......@@ -749,22 +754,76 @@ com_fetch (int argc, char **argv)
return 0;
}
static int
com_store (int argc, char **argv)
{
int status = mu_imap_store (imap, 0, argv[1], argv[2]);
if (status)
report_failure ("store", status);
return 0;
}
static int
com_close (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
{
int status = mu_imap_close (imap);
if (status)
report_failure ("close", status);
return 0;
}
static int
com_unselect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
{
int status = mu_imap_noop (imap);
if (status)
report_failure ("unselect", status);
return 0;
}
static int
com_delete (int argc, char **argv)
{
int status = mu_imap_delete (imap, argv[1]);
if (status)
report_failure ("delete", status);
return 0;
}
static int
com_rename (int argc, char **argv)
{
int status = mu_imap_rename (imap, argv[1], argv[2]);
if (status)
report_failure ("rename", status);
return 0;
}
static int
com_expunge (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
{
int status = mu_imap_expunge (imap);
if (status)
report_failure ("expunge", status);
return 0;
}
struct mutool_command imap_comtab[] = {
{ "capability", 1, -1, 0,
{ "capability", 1, -1, 0,
com_capability,
/* TRANSLATORS: -reread is a keyword; do not translate. */
N_("[-reread] [NAME...]"),
N_("list server capabilities") },
{ "verbose", 1, 4, 0,
{ "verbose", 1, 4, 0,
com_verbose,
"[on|off|mask|unmask] [secure [payload]]",
N_("control the protocol tracing") },
{ "connect", 1, 4, 0,
{ "connect", 1, 4, 0,
com_connect,
/* TRANSLATORS: --tls is a keyword. */
/* TRANSLATORS: -tls is a keyword. */
N_("[-tls] HOSTNAME [PORT]"),
N_("open connection") },
{ "disconnect", 1, 1, 0,
{ "disconnect", 1, 1, 0,
com_disconnect,
NULL,
N_("close connection") },
......@@ -784,6 +843,10 @@ struct mutool_command imap_comtab[] = {
com_noop,
NULL,
N_("no operation (keepalive)") },
{ "check", 1, 1, 0,
com_check,
NULL,
N_("request a server checkpoint") },
{ "select", 1, 2, 0,
com_select,
N_("[MBOX]"),
......@@ -800,6 +863,30 @@ struct mutool_command imap_comtab[] = {
com_fetch,
N_("MSGSET ITEMS"),
N_("fetch message data") },
{ "store", 3, 3, CMD_COALESCE_EXTRA_ARGS,
com_store,
N_("MSGSET ITEMS"),
N_("alter mailbox data") },
{ "close", 1, 1, 0,
com_close,
NULL,
N_("close the mailbox (with expunge)") },
{ "unselect", 1, 1, 0,
com_unselect,
NULL,
N_("close the mailbox (without expunge)") },
{ "delete", 2, 2, 0,
com_delete,
N_("MAILBOX"),
N_("delete the mailbox") },
{ "rename", 3, 3, 0,
com_rename,
N_("OLD-NAME NEW-NAME"),
N_("rename existing mailbox") },
{ "expunge", 1, 1, 0,
com_expunge,
NULL,
N_("permanently remove messages marked for deletion") },
{ "quit", 1, 1, 0,
com_logout,
NULL,
......
......@@ -23,13 +23,13 @@ typedef int (*mutool_action_t) (int argc, char **argv);
struct mutool_command
{
const char *name; /* User printable name of the function. */
int argmin; /* Min. acceptable number of arguments (> 1) */
int argmin; /* Min. acceptable number of arguments (>= 1) */
int argmax; /* Max. allowed number of arguments (-1 means not
limited */
int flags;
mutool_action_t func; /* Function to call to do the job. */
const char *argdoc; /* Documentation for the arguments */
const char *docstring;/* Documentation for this function. */
const char *docstring;/* Documentation for this function. */
};
extern char *mutool_shell_prompt;
......
......@@ -521,8 +521,9 @@ execute_line (char *line)
int status = 0;
ws.ws_comment = "#";
ws.ws_escape = "\\\"";
rc = mu_wordsplit (line, &ws,
MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT|
MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT|MU_WRDSF_ESCAPE|
MU_WRDSF_INCREMENTAL|MU_WRDSF_APPEND);
if (rc == MU_WRDSE_NOINPUT)
{
......