NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
compress.c
Go to the documentation of this file.
1
25
38
39#include "config.h"
40#include <errno.h>
41#include <stdbool.h>
42#include <stdio.h>
43#include <string.h>
44#include <sys/stat.h>
45#include <unistd.h>
46#include "mutt/lib.h"
47#include "config/lib.h"
48#include "core/lib.h"
49#include "gui/lib.h"
50#include "mutt.h"
51#include "lib.h"
52#include "expando/lib.h"
53#include "hooks/lib.h"
54#include "expando.h"
55#include "mx.h"
56
57struct Email;
58
62const struct Command CompCommands[] = {
63 // clang-format off
64 { "append-hook", CMD_APPEND_HOOK, parse_compress_hook,
65 N_("Define command to append to a compressed mailbox"),
66 N_("append-hook <regex> <shell-command>"),
67 "optionalfeatures.html#append-hook" },
68 { "close-hook", CMD_CLOSE_HOOK, parse_compress_hook,
69 N_("Define command to close a compressed mailbox"),
70 N_("close-hook <regex> <shell-command>"),
71 "optionalfeatures.html#close-hook" },
72 { "open-hook", CMD_OPEN_HOOK, parse_compress_hook,
73 N_("Define command to open a compressed mailbox"),
74 N_("open-hook <regex> <shell-command>"),
75 "optionalfeatures.html#open-hook" },
76
77 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
78 // clang-format on
79};
80
90 // clang-format off
91 { "f", "from", ED_COMPRESS, ED_CMP_FROM, NULL },
92 { "t", "to", ED_COMPRESS, ED_CMP_TO, NULL },
93 { NULL, NULL, 0, -1, NULL }
94 // clang-format on
95};
96
108static bool lock_realpath(struct Mailbox *m, bool excl)
109{
110 if (!m || !m->compress_info)
111 return false;
112
113 struct CompressInfo *ci = m->compress_info;
114
115 if (ci->locked)
116 return true;
117
118 if (excl)
119 ci->fp_lock = mutt_file_fopen(m->realpath, "a");
120 else
121 ci->fp_lock = mutt_file_fopen(m->realpath, "r");
122 if (!ci->fp_lock)
123 {
124 mutt_perror("%s", m->realpath);
125 return false;
126 }
127
128 int r = mutt_file_lock(fileno(ci->fp_lock), excl, true);
129 if (r == 0)
130 {
131 ci->locked = true;
132 }
133 else if (excl)
134 {
136 m->readonly = true;
137 return true;
138 }
139 else
140 {
142 }
143
144 return r == 0;
145}
146
153static void unlock_realpath(struct Mailbox *m)
154{
155 if (!m || !m->compress_info)
156 return;
157
158 struct CompressInfo *ci = m->compress_info;
159
160 if (!ci->locked)
161 return;
162
163 mutt_file_unlock(fileno(ci->fp_lock));
164
165 ci->locked = false;
167}
168
179static int setup_paths(struct Mailbox *m)
180{
181 if (!m)
182 return -1;
183
184 /* Setup the right paths */
186
187 /* We will uncompress to TMPDIR */
188 struct Buffer *buf = buf_pool_get();
189 buf_mktemp(buf);
190 buf_copy(&m->pathbuf, buf);
191 buf_pool_release(&buf);
192
193 return mutt_file_touch(mailbox_path(m)) ? 0 : -1;
194}
195
202static void store_size(const struct Mailbox *m)
203{
204 if (!m || !m->compress_info)
205 return;
206
207 struct CompressInfo *ci = m->compress_info;
208
210}
211
220static struct CompressInfo *set_compress_info(struct Mailbox *m)
221{
222 if (!m)
223 return NULL;
224
225 if (m->compress_info)
226 return m->compress_info;
227
228 /* Open is compulsory */
229 struct Hook *open_hook = mutt_find_hook(CMD_OPEN_HOOK, mailbox_path(m));
230 if (!open_hook)
231 return NULL;
232
233 struct Hook *close_hook = mutt_find_hook(CMD_CLOSE_HOOK, mailbox_path(m));
234 struct Hook *append_hook = mutt_find_hook(CMD_APPEND_HOOK, mailbox_path(m));
235
236 struct CompressInfo *ci = MUTT_MEM_CALLOC(1, struct CompressInfo);
237 m->compress_info = ci;
238
239 ci->cmd_open = open_hook->expando;
240 ci->cmd_close = close_hook ? close_hook->expando : NULL;
241 ci->cmd_append = append_hook ? append_hook->expando : NULL;
242
243 return ci;
244}
245
250static void compress_info_free(struct Mailbox *m)
251{
252 if (!m || !m->compress_info)
253 return;
254
256
257 FREE(&m->compress_info);
258}
259
271static bool execute_command(struct Mailbox *m, const struct Expando *exp, const char *progress)
272{
273 if (!m || !exp || !progress)
274 return false;
275
276 if (m->verbose)
277 mutt_message(progress, m->realpath);
278
279 bool rc = true;
280 struct Buffer *sys_cmd = buf_pool_get();
281 buf_alloc(sys_cmd, STR_COMMAND);
282
284 mutt_endwin();
285 fflush(stdout);
286
288
289 if (mutt_system(buf_string(sys_cmd)) != 0)
290 {
291 rc = false;
293 mutt_error(_("Error running \"%s\""), buf_string(sys_cmd));
294 }
295
297
298 buf_pool_release(&sys_cmd);
299 return rc;
300}
301
314{
315 if (!m)
316 return false;
317
318 /* If this succeeds, we know there's an open-hook */
319 struct CompressInfo *ci = set_compress_info(m);
320 if (!ci)
321 return false;
322
323 /* We have an open-hook, so to append we need an append-hook,
324 * or a close-hook. */
325 if (ci->cmd_append || ci->cmd_close)
326 return true;
327
328 mutt_error(_("Can't append without an append-hook or close-hook : %s"), mailbox_path(m));
329 return false;
330}
331
342bool mutt_comp_can_read(const char *path)
343{
344 if (!path)
345 return false;
346
347 if (mutt_find_hook(CMD_OPEN_HOOK, path))
348 return true;
349
350 return false;
351}
352
356static bool comp_ac_owns_path(struct Account *a, const char *path)
357{
358 return false;
359}
360
364static bool comp_ac_add(struct Account *a, struct Mailbox *m)
365{
366 return true;
367}
368
378{
379 struct CompressInfo *ci = set_compress_info(m);
380 if (!ci)
381 return MX_OPEN_ERROR;
382
383 /* If there's no close-hook, or the file isn't writable */
384 if (!ci->cmd_close || (access(mailbox_path(m), W_OK) != 0))
385 m->readonly = true;
386
387 if (setup_paths(m) != 0)
388 goto cmo_fail;
389 store_size(m);
390
391 if (!lock_realpath(m, false))
392 {
393 mutt_error(_("Unable to lock mailbox"));
394 goto cmo_fail;
395 }
396
397 if (!execute_command(m, ci->cmd_open, _("Decompressing %s")))
398 goto cmo_fail;
399
401
403 if (m->type == MUTT_UNKNOWN)
404 {
405 mutt_error(_("Can't identify the contents of the compressed file"));
406 goto cmo_fail;
407 }
408
409 ci->child_ops = mx_get_ops(m->type);
410 if (!ci->child_ops)
411 {
412 mutt_error(_("Can't find mailbox ops for mailbox type %d"), m->type);
413 goto cmo_fail;
414 }
415
416 m->account->type = m->type;
417 return ci->child_ops->mbox_open(m);
418
419cmo_fail:
420 /* remove the partial uncompressed file */
421 (void) remove(mailbox_path(m));
423 return MX_OPEN_ERROR;
424}
425
432static bool comp_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags)
433{
434 /* If this succeeds, we know there's an open-hook */
435 struct CompressInfo *ci = set_compress_info(m);
436 if (!ci)
437 return false;
438
439 /* To append we need an append-hook or a close-hook */
440 if (!ci->cmd_append && !ci->cmd_close)
441 {
442 mutt_error(_("Can't append without an append-hook or close-hook : %s"),
443 mailbox_path(m));
444 goto cmoa_fail1;
445 }
446
447 if (setup_paths(m) != 0)
448 goto cmoa_fail2;
449
450 /* Lock the realpath for the duration of the append.
451 * It will be unlocked in the close */
452 if (!lock_realpath(m, true))
453 {
454 mutt_error(_("Unable to lock mailbox"));
455 goto cmoa_fail2;
456 }
457
458 /* Open the existing mailbox, unless we are appending */
459 if (!ci->cmd_append && (mutt_file_get_size(m->realpath) > 0))
460 {
461 if (!execute_command(m, ci->cmd_open, _("Decompressing %s")))
462 {
463 mutt_error(_("Compress command failed: %s"), ci->cmd_open->string);
464 goto cmoa_fail2;
465 }
467 }
468 else
469 {
470 m->type = cs_subset_enum(NeoMutt->sub, "mbox_type");
471 }
472
473 /* We can only deal with mbox and mmdf mailboxes */
474 if ((m->type != MUTT_MBOX) && (m->type != MUTT_MMDF))
475 {
476 mutt_error(_("Unsupported mailbox type for appending"));
477 goto cmoa_fail2;
478 }
479
480 ci->child_ops = mx_get_ops(m->type);
481 if (!ci->child_ops)
482 {
483 mutt_error(_("Can't find mailbox ops for mailbox type %d"), m->type);
484 goto cmoa_fail2;
485 }
486
487 if (!ci->child_ops->mbox_open_append(m, flags))
488 goto cmoa_fail2;
489
490 return true;
491
492cmoa_fail2:
493 /* remove the partial uncompressed file */
494 (void) remove(mailbox_path(m));
495cmoa_fail1:
496 /* Free the compress_info to prevent close from trying to recompress */
498
499 return false;
500}
501
512static enum MxStatus comp_mbox_check(struct Mailbox *m)
513{
514 if (!m->compress_info)
515 return MX_STATUS_ERROR;
516
517 struct CompressInfo *ci = m->compress_info;
518
519 const struct MxOps *ops = ci->child_ops;
520 if (!ops)
521 return MX_STATUS_ERROR;
522
523 long size = mutt_file_get_size(m->realpath);
524 if (size == ci->size)
525 return MX_STATUS_OK;
526
527 if (!lock_realpath(m, false))
528 {
529 mutt_error(_("Unable to lock mailbox"));
530 return MX_STATUS_ERROR;
531 }
532
533 bool rc = execute_command(m, ci->cmd_open, _("Decompressing %s"));
534 store_size(m);
536 if (!rc)
537 return MX_STATUS_ERROR;
538
539 return ops->mbox_check(m);
540}
541
548static enum MxStatus comp_mbox_sync(struct Mailbox *m)
549{
550 if (!m->compress_info)
551 return MX_STATUS_ERROR;
552
553 struct CompressInfo *ci = m->compress_info;
554
555 if (!ci->cmd_close)
556 {
557 mutt_error(_("Can't sync a compressed file without a close-hook"));
558 return MX_STATUS_ERROR;
559 }
560
561 const struct MxOps *ops = ci->child_ops;
562 if (!ops)
563 return MX_STATUS_ERROR;
564
565 if (!lock_realpath(m, true))
566 {
567 mutt_error(_("Unable to lock mailbox"));
568 return MX_STATUS_ERROR;
569 }
570
571 enum MxStatus check = comp_mbox_check(m);
572 if (check != MX_STATUS_OK)
573 goto sync_cleanup;
574
575 check = ops->mbox_sync(m);
576 if (check != MX_STATUS_OK)
577 goto sync_cleanup;
578
579 if (!execute_command(m, ci->cmd_close, _("Compressing %s")))
580 {
581 check = MX_STATUS_ERROR;
582 goto sync_cleanup;
583 }
584
585 check = MX_STATUS_OK;
586
587sync_cleanup:
588 store_size(m);
590 return check;
591}
592
599static enum MxStatus comp_mbox_close(struct Mailbox *m)
600{
601 if (!m->compress_info)
602 return MX_STATUS_ERROR;
603
604 struct CompressInfo *ci = m->compress_info;
605
606 const struct MxOps *ops = ci->child_ops;
607 if (!ops)
608 {
610 return MX_STATUS_ERROR;
611 }
612
613 ops->mbox_close(m);
614
615 /* sync has already been called, so we only need to delete some files */
616 if (m->append)
617 {
618 const struct Expando *append = NULL;
619 const char *msg = NULL;
620
621 /* The file exists and we can append */
622 if ((access(m->realpath, F_OK) == 0) && ci->cmd_append)
623 {
624 append = ci->cmd_append;
625 msg = _("Compressed-appending to %s...");
626 }
627 else
628 {
629 append = ci->cmd_close;
630 msg = _("Compressing %s");
631 }
632
633 if (!execute_command(m, append, msg))
634 {
636 mutt_error(_("Error. Preserving temporary file: %s"), mailbox_path(m));
637 }
638 else
639 {
640 if (remove(mailbox_path(m)) < 0)
641 {
642 mutt_debug(LL_DEBUG1, "remove failed: %s: %s (errno %d)\n",
643 mailbox_path(m), strerror(errno), errno);
644 }
645 }
646
648 }
649 else
650 {
651 /* If the file was removed, remove the compressed folder too */
652 if (access(mailbox_path(m), F_OK) != 0)
653 {
654 const bool c_save_empty = cs_subset_bool(NeoMutt->sub, "save_empty");
655 if (!c_save_empty)
656 {
657 if (remove(m->realpath) < 0)
658 {
659 mutt_debug(LL_DEBUG1, "remove failed: %s: %s (errno %d)\n",
660 m->realpath, strerror(errno), errno);
661 }
662 }
663 }
664 else
665 {
666 if (remove(mailbox_path(m)) < 0)
667 {
668 mutt_debug(LL_DEBUG1, "remove failed: %s: %s (errno %d)\n",
669 mailbox_path(m), strerror(errno), errno);
670 }
671 }
672 }
673
675
676 return MX_STATUS_OK;
677}
678
682static bool comp_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
683{
684 if (!m->compress_info)
685 return false;
686
687 struct CompressInfo *ci = m->compress_info;
688
689 const struct MxOps *ops = ci->child_ops;
690 if (!ops)
691 return false;
692
693 /* Delegate */
694 return ops->msg_open(m, msg, e);
695}
696
700static bool comp_msg_open_new(struct Mailbox *m, struct Message *msg, const struct Email *e)
701{
702 if (!m->compress_info)
703 return false;
704
705 struct CompressInfo *ci = m->compress_info;
706
707 const struct MxOps *ops = ci->child_ops;
708 if (!ops)
709 return false;
710
711 /* Delegate */
712 return ops->msg_open_new(m, msg, e);
713}
714
718static int comp_msg_commit(struct Mailbox *m, struct Message *msg)
719{
720 if (!m->compress_info)
721 return -1;
722
723 struct CompressInfo *ci = m->compress_info;
724
725 const struct MxOps *ops = ci->child_ops;
726 if (!ops)
727 return -1;
728
729 /* Delegate */
730 return ops->msg_commit(m, msg);
731}
732
736static int comp_msg_close(struct Mailbox *m, struct Message *msg)
737{
738 if (!m->compress_info)
739 return -1;
740
741 struct CompressInfo *ci = m->compress_info;
742
743 const struct MxOps *ops = ci->child_ops;
744 if (!ops)
745 return -1;
746
747 /* Delegate */
748 return ops->msg_close(m, msg);
749}
750
754static int comp_msg_padding_size(struct Mailbox *m)
755{
756 if (!m->compress_info)
757 return 0;
758
759 struct CompressInfo *ci = m->compress_info;
760
761 const struct MxOps *ops = ci->child_ops;
762 if (!ops || !ops->msg_padding_size)
763 return 0;
764
765 return ops->msg_padding_size(m);
766}
767
771static int comp_msg_save_hcache(struct Mailbox *m, struct Email *e)
772{
773 if (!m->compress_info)
774 return 0;
775
776 struct CompressInfo *ci = m->compress_info;
777
778 const struct MxOps *ops = ci->child_ops;
779 if (!ops || !ops->msg_save_hcache)
780 return 0;
781
782 return ops->msg_save_hcache(m, e);
783}
784
788static int comp_tags_edit(struct Mailbox *m, const char *tags, struct Buffer *buf)
789{
790 if (!m->compress_info)
791 return 0;
792
793 struct CompressInfo *ci = m->compress_info;
794
795 const struct MxOps *ops = ci->child_ops;
796 if (!ops || !ops->tags_edit)
797 return 0;
798
799 return ops->tags_edit(m, tags, buf);
800}
801
805static int comp_tags_commit(struct Mailbox *m, struct Email *e, const char *buf)
806{
807 if (!m->compress_info)
808 return 0;
809
810 struct CompressInfo *ci = m->compress_info;
811
812 const struct MxOps *ops = ci->child_ops;
813 if (!ops || !ops->tags_commit)
814 return 0;
815
816 return ops->tags_commit(m, e, buf);
817}
818
822static enum MailboxType comp_path_probe(const char *path, const struct stat *st)
823{
824 if (!st || !S_ISREG(st->st_mode))
825 return MUTT_UNKNOWN;
826
827 if (mutt_comp_can_read(path))
828 return MUTT_COMPRESSED;
829
830 return MUTT_UNKNOWN;
831}
832
836static int comp_path_canon(struct Buffer *path)
837{
838 mutt_path_canon(path, NeoMutt->home_dir, false);
839 return 0;
840}
841
848const struct MxOps MxCompOps = {
849 // clang-format off
850 .type = MUTT_COMPRESSED,
851 .name = "compressed",
852 .is_local = true,
853 .ac_owns_path = comp_ac_owns_path,
854 .ac_add = comp_ac_add,
855 .mbox_open = comp_mbox_open,
856 .mbox_open_append = comp_mbox_open_append,
857 .mbox_check = comp_mbox_check,
858 .mbox_check_stats = NULL,
859 .mbox_sync = comp_mbox_sync,
860 .mbox_close = comp_mbox_close,
861 .msg_open = comp_msg_open,
862 .msg_open_new = comp_msg_open_new,
863 .msg_commit = comp_msg_commit,
864 .msg_close = comp_msg_close,
865 .msg_padding_size = comp_msg_padding_size,
866 .msg_save_hcache = comp_msg_save_hcache,
867 .tags_edit = comp_tags_edit,
868 .tags_commit = comp_tags_commit,
869 .path_probe = comp_path_probe,
870 .path_canon = comp_path_canon,
871 .path_is_empty = NULL,
872 // clang-format on
873};
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition buffer.c:607
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:342
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_CLOSE_HOOK
:close-hook
Definition command.h:73
@ CMD_NONE
No Command.
Definition command.h:62
@ CMD_OPEN_HOOK
:open-hook
Definition command.h:103
@ CMD_APPEND_HOOK
:append-hook
Definition command.h:67
static struct CompressInfo * set_compress_info(struct Mailbox *m)
Find the compress hooks for a mailbox.
Definition compress.c:220
static void compress_info_free(struct Mailbox *m)
Frees the compress info members and structure.
Definition compress.c:250
static int setup_paths(struct Mailbox *m)
Set the mailbox paths.
Definition compress.c:179
const struct ExpandoDefinition CompressFormatDef[]
Expando definitions.
Definition compress.c:89
static void store_size(const struct Mailbox *m)
Save the size of the compressed file.
Definition compress.c:202
static bool lock_realpath(struct Mailbox *m, bool excl)
Try to lock the Mailbox.realpath.
Definition compress.c:108
bool mutt_comp_can_append(struct Mailbox *m)
Can we append to this path?
Definition compress.c:313
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition compress.c:153
const struct Command CompCommands[]
Compression Commands.
Definition compress.c:62
static bool execute_command(struct Mailbox *m, const struct Expando *exp, const char *progress)
Run a system command.
Definition compress.c:271
bool mutt_comp_can_read(const char *path)
Can we read from this file?
Definition compress.c:342
const struct ExpandoRenderCallback CompressRenderCallbacks[]
Callbacks for Compression Hook Expandos.
Definition expando.c:64
Compress Expando definitions.
Compressed mbox local mailbox type.
@ ED_CMP_FROM
'from' path
Definition lib.h:51
@ ED_CMP_TO
'to' path
Definition lib.h:52
unsigned char cs_subset_enum(const struct ConfigSubset *sub, const char *name)
Get a enumeration config item by name.
Definition helpers.c:71
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
MailboxType
Supported mailbox formats.
Definition mailbox.h:40
@ MUTT_MMDF
'mmdf' Mailbox type
Definition mailbox.h:45
@ MUTT_MBOX
'mbox' Mailbox type
Definition mailbox.h:44
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition mailbox.h:52
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition curs_lib.c:174
void mutt_endwin(void)
Shutdown curses.
Definition curs_lib.c:152
@ ED_COMPRESS
Compress ED_CMP_ ExpandoDataCompress.
Definition domain.h:40
int expando_render(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando + data into a string.
Definition expando.c:161
Parse Expando string.
bool mutt_file_touch(const char *path)
Make sure a file exists.
Definition file.c:974
int mutt_file_lock(int fd, bool excl, bool timeout)
(Try to) Lock a file using fcntl()
Definition file.c:1088
int mutt_file_unlock(int fd)
Unlock a file previously locked by mutt_file_lock().
Definition file.c:1136
long mutt_file_get_size(const char *path)
Get the size of a file.
Definition file.c:1415
#define mutt_file_fclose(FP)
Definition file.h:144
#define mutt_file_fopen(PATH, MODE)
Definition file.h:143
enum CommandResult parse_compress_hook(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse compress hook commands - Implements Command::parse() -.
Definition parse.c:914
#define mutt_error(...)
Definition logging2.h:94
#define mutt_message(...)
Definition logging2.h:93
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
#define mutt_perror(...)
Definition logging2.h:95
static bool comp_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add() -.
Definition compress.c:364
static bool comp_ac_owns_path(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -.
Definition compress.c:356
const struct MxOps MxCompOps
Compressed Mailbox - Implements MxOps -.
Definition compress.c:848
static enum MxStatus comp_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
Definition compress.c:512
static enum MxStatus comp_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
Definition compress.c:599
static bool comp_mbox_open_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -.
Definition compress.c:432
static enum MxOpenReturns comp_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
Definition compress.c:377
static enum MxStatus comp_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
Definition compress.c:548
static int comp_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
Definition compress.c:736
static int comp_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit() -.
Definition compress.c:718
static bool comp_msg_open_new(struct Mailbox *m, struct Message *msg, const struct Email *e)
Open a new message in a Mailbox - Implements MxOps::msg_open_new() -.
Definition compress.c:700
static bool comp_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
Open an email message in a Mailbox - Implements MxOps::msg_open() -.
Definition compress.c:682
static int comp_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Implements MxOps::msg_padding_size() -.
Definition compress.c:754
static int comp_msg_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Implements MxOps::msg_save_hcache() -.
Definition compress.c:771
static int comp_path_canon(struct Buffer *path)
Canonicalise a Mailbox path - Implements MxOps::path_canon() -.
Definition compress.c:836
static enum MailboxType comp_path_probe(const char *path, const struct stat *st)
Is this a compressed Mailbox?
Definition compress.c:822
static int comp_tags_commit(struct Mailbox *m, struct Email *e, const char *buf)
Save the tags to a message - Implements MxOps::tags_commit() -.
Definition compress.c:805
static int comp_tags_edit(struct Mailbox *m, const char *tags, struct Buffer *buf)
Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
Definition compress.c:788
Convenience wrapper for the gui headers.
struct Hook * mutt_find_hook(enum CommandId id, const char *pat)
Find a matching hook.
Definition exec.c:115
Hook Commands.
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
Convenience wrapper for the library headers.
#define N_(a)
Definition message.h:32
#define _(a)
Definition message.h:28
bool mutt_path_canon(struct Buffer *path, const char *homedir, bool is_dir)
Create the canonical version of a path.
Definition path.c:248
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
Many unsorted constants and some structs.
int mutt_system(const char *cmd)
Run an external command.
Definition system.c:51
const struct MxOps * mx_get_ops(enum MailboxType type)
Get mailbox operations.
Definition mx.c:124
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition mx.c:1326
API for mailboxes.
uint8_t OpenMailboxFlags
Definition mxapi.h:51
MxOpenReturns
Return values for mbox_open().
Definition mxapi.h:83
@ MX_OPEN_ERROR
Open failed with an error.
Definition mxapi.h:85
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close().
Definition mxapi.h:70
@ MX_STATUS_ERROR
An error occurred.
Definition mxapi.h:71
@ MX_STATUS_OK
No changes.
Definition mxapi.h:72
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
@ MUTT_FORMAT_NONE
No flags are set.
Definition render.h:37
void mutt_sig_block(void)
Block signals during critical operations.
Definition signal.c:227
void mutt_sig_unblock(void)
Restore previously blocked signals.
Definition signal.c:245
#define STR_COMMAND
Enough space for a long command line.
Definition string2.h:42
A group of associated Mailboxes.
Definition account.h:36
enum MailboxType type
Type of Mailboxes this Account contains.
Definition account.h:37
String manipulation buffer.
Definition buffer.h:36
size_t dsize
Length of data.
Definition buffer.h:39
Private data for compress.
Definition lib.h:62
const struct Expando * cmd_open
open-hook command
Definition lib.h:65
FILE * fp_lock
fp used for locking
Definition lib.h:69
const struct Expando * cmd_close
close-hook command
Definition lib.h:64
const struct MxOps * child_ops
callbacks of de-compressed file
Definition lib.h:67
bool locked
if realpath is locked
Definition lib.h:68
long size
size of the compressed file
Definition lib.h:66
const struct Expando * cmd_append
append-hook command
Definition lib.h:63
The envelope/body of an email.
Definition email.h:39
Definition of a format string.
Definition definition.h:49
Parsed Expando trees.
Definition expando.h:41
const char * string
Pointer to the parsed string.
Definition expando.h:42
A list of user hooks.
Definition hook.h:33
struct Expando * expando
Used for format hooks.
Definition hook.h:39
A mailbox.
Definition mailbox.h:81
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:83
bool append
Mailbox is opened in append mode.
Definition mailbox.h:111
enum MailboxType type
Mailbox type.
Definition mailbox.h:104
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:82
struct Account * account
Account that owns this Mailbox.
Definition mailbox.h:129
void * compress_info
Compressed mbox module private data.
Definition mailbox.h:123
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:118
bool verbose
Display status messages?
Definition mailbox.h:119
A local copy of an email.
Definition message.h:34
Definition mxapi.h:98
bool(* msg_open)(struct Mailbox *m, struct Message *msg, struct Email *e)
Definition mxapi.h:223
int(* tags_commit)(struct Mailbox *m, struct Email *e, const char *buf)
Definition mxapi.h:330
int(* msg_save_hcache)(struct Mailbox *m, struct Email *e)
Definition mxapi.h:296
int(* msg_padding_size)(struct Mailbox *m)
Definition mxapi.h:281
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition mxapi.h:313
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Definition mxapi.h:254
enum MxOpenReturns(* mbox_open)(struct Mailbox *m)
Definition mxapi.h:143
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Definition mxapi.h:269
bool(* msg_open_new)(struct Mailbox *m, struct Message *msg, const struct Email *e)
Definition mxapi.h:239
enum MxStatus(* mbox_close)(struct Mailbox *m)
Definition mxapi.h:206
enum MxStatus(* mbox_sync)(struct Mailbox *m)
Definition mxapi.h:194
bool(* mbox_open_append)(struct Mailbox *m, OpenMailboxFlags flags)
Definition mxapi.h:157
enum MxStatus(* mbox_check)(struct Mailbox *m)
Definition mxapi.h:169
Container for Accounts, Notifications.
Definition neomutt.h:41
char * home_dir
User's home directory.
Definition neomutt.h:55
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
#define buf_mktemp(buf)
Definition tmp.h:33