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)); ...@@ -311,6 +311,8 @@ extern int util_merge_addresses __P((char **addr_str, const char *value));
311 extern int util_header_expand __P((header_t *hdr)); 311 extern int util_header_expand __P((header_t *hdr));
312 extern int util_get_message __P((mailbox_t mbox, size_t msgno, 312 extern int util_get_message __P((mailbox_t mbox, size_t msgno,
313 message_t *msg)); 313 message_t *msg));
314 void util_cache_command __P((list_t *list, const char *fmt, ...));
315 void util_run_cached_commands __P((list_t *list));
314 316
315 extern int ml_got_interrupt __P ((void)); 317 extern int ml_got_interrupt __P ((void));
316 extern void ml_clear_interrupt __P ((void)); 318 extern void ml_clear_interrupt __P ((void));
......
...@@ -1252,3 +1252,34 @@ util_noapp () ...@@ -1252,3 +1252,34 @@ util_noapp ()
1252 { 1252 {
1253 util_error (_("No applicable messages")); 1253 util_error (_("No applicable messages"));
1254 } 1254 }
1255
1256 void
1257 util_cache_command (list_t *list, const char *fmt, ...)
1258 {
1259 char *cmd;
1260 va_list ap;
1261
1262 va_start (ap, fmt);
1263 vasprintf (&cmd, fmt, ap);
1264 va_end (ap);
1265
1266 if (!*list)
1267 list_create (list);
1268
1269 list_append (*list, cmd);
1270 }
1271
1272 static int
1273 _run_and_free (void *item, void *data)
1274 {
1275 util_do_command ((char *) item);
1276 free (item);
1277 return 0;
1278 }
1279
1280 void
1281 util_run_cached_commands (list_t *list)
1282 {
1283 list_do (*list, _run_and_free, NULL);
1284 list_destroy (list);
1285 }
......