Commit c184124d c184124d67f9864bdf1fc8f1e48bb5bed72d0886 by Sergey Poznyakoff

(util_cache_command,util_run_cached_commands): New functions.

1 parent baa0bce1
......@@ -311,6 +311,8 @@ extern int util_merge_addresses __P((char **addr_str, const char *value));
extern int util_header_expand __P((header_t *hdr));
extern int util_get_message __P((mailbox_t mbox, size_t msgno,
message_t *msg));
void util_cache_command __P((list_t *list, const char *fmt, ...));
void util_run_cached_commands __P((list_t *list));
extern int ml_got_interrupt __P ((void));
extern void ml_clear_interrupt __P ((void));
......
......@@ -1252,3 +1252,34 @@ util_noapp ()
{
util_error (_("No applicable messages"));
}
void
util_cache_command (list_t *list, const char *fmt, ...)
{
char *cmd;
va_list ap;
va_start (ap, fmt);
vasprintf (&cmd, fmt, ap);
va_end (ap);
if (!*list)
list_create (list);
list_append (*list, cmd);
}
static int
_run_and_free (void *item, void *data)
{
util_do_command ((char *) item);
free (item);
return 0;
}
void
util_run_cached_commands (list_t *list)
{
list_do (*list, _run_and_free, NULL);
list_destroy (list);
}
......