NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
compress.c File Reference

Compressed mbox local mailbox type. More...

#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "compress.h"
#include "account.h"
#include "context.h"
#include "curs_lib.h"
#include "format_flags.h"
#include "globals.h"
#include "hook.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
+ Include dependency graph for compress.c:

Go to the source code of this file.

Functions

static bool lock_realpath (struct Mailbox *m, bool excl)
 Try to lock the ctx->realpath. More...
 
static void unlock_realpath (struct Mailbox *m)
 Unlock the mailbox->realpath. More...
 
static int setup_paths (struct Mailbox *m)
 Set the mailbox paths. More...
 
static void store_size (const struct Mailbox *m)
 Save the size of the compressed file. More...
 
static const char * find_hook (int type, const char *path)
 Find a hook to match a path. More...
 
static struct CompressInfoset_compress_info (struct Mailbox *m)
 Find the compress hooks for a mailbox. More...
 
static void free_compress_info (struct Mailbox *m)
 Frees the compress info members and structure. More...
 
static char * escape_path (char *src)
 Escapes single quotes in a path for a command string. More...
 
static const char * compress_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, enum FormatFlag flags)
 Expand the filenames in a command string - Implements format_t. More...
 
static void expand_command_str (const struct Mailbox *m, const char *cmd, char *buf, int buflen)
 Expand placeholders in command string. More...
 
static int execute_command (struct Mailbox *m, const char *command, const char *progress)
 Run a system command. More...
 
bool mutt_comp_can_append (struct Mailbox *m)
 Can we append to this path? More...
 
bool mutt_comp_can_read (const char *path)
 Can we read from this file? More...
 
int mutt_comp_valid_command (const char *cmd)
 Is this command string allowed? More...
 
struct Accountcomp_ac_find (struct Account *a, const char *path)
 Find a Account that matches a Mailbox path. More...
 
int comp_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to a Account. More...
 
static int comp_mbox_open (struct Mailbox *m, struct Context *ctx)
 Implements MxOps::mbox_open() More...
 
static int comp_mbox_open_append (struct Mailbox *m, int flags)
 Implements MxOps::mbox_open_append() More...
 
static int comp_mbox_check (struct Context *ctx, int *index_hint)
 Implements MxOps::mbox_check() More...
 
static int comp_mbox_sync (struct Context *ctx, int *index_hint)
 Implements MxOps::mbox_sync() More...
 
static int comp_mbox_close (struct Context *ctx)
 Implements MxOps::mbox_close() More...
 
static int comp_msg_open (struct Mailbox *m, struct Message *msg, int msgno)
 Implements MxOps::msg_open() More...
 
static int comp_msg_open_new (struct Mailbox *m, struct Message *msg, struct Email *e)
 Implements MxOps::msg_open_new() More...
 
static int comp_msg_commit (struct Mailbox *m, struct Message *msg)
 Implements MxOps::msg_commit() More...
 
static int comp_msg_close (struct Mailbox *m, struct Message *msg)
 Implements MxOps::msg_close() More...
 
static int comp_msg_padding_size (struct Mailbox *m)
 Bytes of padding between messages - Implements MxOps::msg_padding_size() More...
 
static int comp_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen)
 Implements MxOps::tags_edit() More...
 
static int comp_tags_commit (struct Mailbox *m, struct Email *e, char *buf)
 Implements MxOps::tags_commit() More...
 
enum MailboxType comp_path_probe (const char *path, const struct stat *st)
 Is this a compressed mailbox? - Implements MxOps::path_probe() More...
 
int comp_path_canon (char *buf, size_t buflen)
 Canonicalise a mailbox path - Implements MxOps::path_canon() More...
 
int comp_path_pretty (char *buf, size_t buflen, const char *folder)
 Implements MxOps::path_pretty() More...
 
int comp_path_parent (char *buf, size_t buflen)
 Implements MxOps::path_parent() More...
 

Variables

struct MxOps MxCompOps
 Compressed mailbox - Implements MxOps. More...
 

Detailed Description

Compressed mbox local mailbox type.

Authors
  • Alain Penders
  • Richard Russon

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file compress.c.

Function Documentation

static bool lock_realpath ( struct Mailbox m,
bool  excl 
)
static

Try to lock the ctx->realpath.

Parameters
mMailbox to lock
exclLock exclusively?
Return values
trueSuccess (locked or readonly)
falseError (can't lock the file)

Try to (exclusively) lock the mailbox. If we succeed, then we mark the mailbox as locked. If we fail, but we didn't want exclusive rights, then the mailbox will be marked readonly.

Definition at line 70 of file compress.c.

71 {
72  if (!m || !m->compress_info)
73  return false;
74 
75  struct CompressInfo *ci = m->compress_info;
76 
77  if (ci->locked)
78  return true;
79 
80  if (excl)
81  ci->lockfp = fopen(m->realpath, "a");
82  else
83  ci->lockfp = fopen(m->realpath, "r");
84  if (!ci->lockfp)
85  {
87  return false;
88  }
89 
90  int r = mutt_file_lock(fileno(ci->lockfp), excl, true);
91  if (r == 0)
92  ci->locked = true;
93  else if (excl)
94  {
96  m->readonly = true;
97  return true;
98  }
99 
100  return r == 0;
101 }
#define mutt_perror(...)
Definition: logging.h:89
bool locked
if realpath is locked
Definition: compress.h:44
bool readonly
don&#39;t allow changes to the mailbox
Definition: mailbox.h:113
int mutt_file_lock(int fd, bool excl, bool timeout)
Private data for compress.
Definition: compress.h:37
FILE * lockfp
fp used for locking
Definition: compress.h:45
int mutt_file_fclose(FILE **f)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void unlock_realpath ( struct Mailbox m)
static

Unlock the mailbox->realpath.

Parameters
mMailbox to unlock

Unlock a mailbox previously locked by lock_mailbox().

Definition at line 109 of file compress.c.

110 {
111  if (!m || !m->compress_info)
112  return;
113 
114  struct CompressInfo *ci = m->compress_info;
115 
116  if (!ci->locked)
117  return;
118 
119  mutt_file_unlock(fileno(ci->lockfp));
120 
121  ci->locked = false;
122  mutt_file_fclose(&ci->lockfp);
123 }
bool locked
if realpath is locked
Definition: compress.h:44
int mutt_file_unlock(int fd)
Private data for compress.
Definition: compress.h:37
FILE * lockfp
fp used for locking
Definition: compress.h:45
int mutt_file_fclose(FILE **f)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int setup_paths ( struct Mailbox m)
static

Set the mailbox paths.

Parameters
mMailbox to modify
Return values
0Success
-1Error

Save the compressed filename in mailbox->realpath. Create a temporary filename and put its name in mailbox->path. The temporary file is created to prevent symlink attacks.

Definition at line 135 of file compress.c.

136 {
137  if (!m)
138  return -1;
139 
140  char tmp[PATH_MAX];
141 
142  /* Setup the right paths */
143  mutt_str_strfcpy(m->realpath, m->path, sizeof(m->realpath));
144 
145  /* We will uncompress to /tmp */
146  mutt_mktemp(tmp, sizeof(tmp));
147  mutt_str_strfcpy(m->path, tmp, sizeof(m->path));
148 
149  FILE *fp = mutt_file_fopen(m->path, "w");
150  if (!fp)
151  return -1;
152 
153  mutt_file_fclose(&fp);
154  return 0;
155 }
#define mutt_mktemp(a, b)
Definition: muttlib.h:71
#define PATH_MAX
Definition: mutt.h:46
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
char path[PATH_MAX]
Definition: mailbox.h:78
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:548
int mutt_file_fclose(FILE **f)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void store_size ( const struct Mailbox m)
static

Save the size of the compressed file.

Parameters
mMailbox

Save the compressed file size in the compress_info struct.

Definition at line 163 of file compress.c.

164 {
165  if (!m || !m->compress_info)
166  return;
167 
168  struct CompressInfo *ci = m->compress_info;
169 
170  ci->size = mutt_file_get_size(m->realpath);
171 }
long mutt_file_get_size(const char *path)
Get the size of a file.
Definition: file.c:1393
long size
size of the compressed file
Definition: compress.h:42
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* find_hook ( int  type,
const char *  path 
)
static

Find a hook to match a path.

Parameters
typeType of hook, e.g. MUTT_CLOSE_HOOK
pathFilename to test
Return values
ptrMatching hook command
NULLNo matches

Each hook has a type and a pattern. Find a command that matches the type and path supplied. e.g.

User config: open-hook '.gz$' "gzip -cd '%f' > '%t'"

Call: find_hook (MUTT_OPEN_HOOK, "myfile.gz");

Definition at line 189 of file compress.c.

190 {
191  if (!path)
192  return NULL;
193 
194  const char *c = mutt_find_hook(type, path);
195  if (!c || !*c)
196  return NULL;
197 
198  return c;
199 }
char * mutt_find_hook(int type, const char *pat)
Find a matching hook.
Definition: hook.c:417

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static struct CompressInfo* set_compress_info ( struct Mailbox m)
static

Find the compress hooks for a mailbox.

Parameters
mMailbox to examine
Return values
ptrCompressInfo Hook info for the mailbox's path
NULLError

When a mailbox is opened, we check if there are any matching hooks.

Definition at line 209 of file compress.c.

210 {
211  if (!m)
212  return NULL;
213 
214  if (m->compress_info)
215  return m->compress_info;
216 
217  /* Open is compulsory */
218  const char *o = find_hook(MUTT_OPEN_HOOK, m->path);
219  if (!o)
220  return NULL;
221 
222  const char *c = find_hook(MUTT_CLOSE_HOOK, m->path);
223  const char *a = find_hook(MUTT_APPEND_HOOK, m->path);
224 
225  struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo));
226  m->compress_info = ci;
227 
228  ci->open = mutt_str_strdup(o);
229  ci->close = mutt_str_strdup(c);
230  ci->append = mutt_str_strdup(a);
231 
232  return ci;
233 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
const char * close
close-hook command
Definition: compress.h:40
#define MUTT_APPEND_HOOK
Definition: hook.h:55
#define MUTT_CLOSE_HOOK
Definition: hook.h:56
static const char * find_hook(int type, const char *path)
Find a hook to match a path.
Definition: compress.c:189
#define MUTT_OPEN_HOOK
Definition: hook.h:54
Private data for compress.
Definition: compress.h:37
char path[PATH_MAX]
Definition: mailbox.h:78
const char * append
append-hook command
Definition: compress.h:39
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:384
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const char * open
open-hook command
Definition: compress.h:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void free_compress_info ( struct Mailbox m)
static

Frees the compress info members and structure.

Parameters
mMailbox to free compress_info for

Definition at line 239 of file compress.c.

240 {
241  if (!m || !m->compress_info)
242  return;
243 
244  struct CompressInfo *ci = m->compress_info;
245  FREE(&ci->open);
246  FREE(&ci->close);
247  FREE(&ci->append);
248 
249  unlock_realpath(m);
250 
251  FREE(&m->compress_info);
252 }
const char * close
close-hook command
Definition: compress.h:40
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition: compress.c:109
Private data for compress.
Definition: compress.h:37
const char * append
append-hook command
Definition: compress.h:39
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
#define FREE(x)
Definition: memory.h:46
const char * open
open-hook command
Definition: compress.h:41

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static char* escape_path ( char *  src)
static

Escapes single quotes in a path for a command string.

Parameters
srcthe path to escape
Return values
ptrThe escaped string

Definition at line 259 of file compress.c.

260 {
261  static char dest[HUGE_STRING];
262  char *destp = dest;
263  int destsize = 0;
264 
265  if (!src)
266  return NULL;
267 
268  while (*src && (destsize < sizeof(dest) - 1))
269  {
270  if (*src != '\'')
271  {
272  *destp++ = *src++;
273  destsize++;
274  }
275  else
276  {
277  /* convert ' into '\'' */
278  if (destsize + 4 < sizeof(dest))
279  {
280  *destp++ = *src++;
281  *destp++ = '\\';
282  *destp++ = '\'';
283  *destp++ = '\'';
284  destsize += 4;
285  }
286  else
287  break;
288  }
289  }
290  *destp = '\0';
291 
292  return dest;
293 }
#define HUGE_STRING
Definition: string2.h:37

+ Here is the caller graph for this function:

static const char* compress_format_str ( char *  buf,
size_t  buflen,
size_t  col,
int  cols,
char  op,
const char *  src,
const char *  prec,
const char *  if_str,
const char *  else_str,
unsigned long  data,
enum FormatFlag  flags 
)
static

Expand the filenames in a command string - Implements format_t.

Expando Description
%f Compressed file
%t Plaintext, temporary file

Definition at line 303 of file compress.c.

307 {
308  if (!buf || (data == 0))
309  return src;
310 
311  struct Mailbox *m = (struct Mailbox *) data;
312 
313  switch (op)
314  {
315  case 'f':
316  /* Compressed file */
317  snprintf(buf, buflen, "%s", NONULL(escape_path(m->realpath)));
318  break;
319  case 't':
320  /* Plaintext, temporary file */
321  snprintf(buf, buflen, "%s", NONULL(escape_path(m->path)));
322  break;
323  }
324  return src;
325 }
#define NONULL(x)
Definition: string2.h:39
static char * escape_path(char *src)
Escapes single quotes in a path for a command string.
Definition: compress.c:259
A mailbox.
Definition: mailbox.h:76
char path[PATH_MAX]
Definition: mailbox.h:78
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void expand_command_str ( const struct Mailbox m,
const char *  cmd,
char *  buf,
int  buflen 
)
static

Expand placeholders in command string.

Parameters
mMailbox for paths
cmdTemplate command to be expanded
bufBuffer to store the command
buflenSize of the buffer

This function takes a hook command and expands the filename placeholders within it. The function calls mutt_expando_format() to do the replacement which calls our callback function compress_format_str(). e.g.

Template command: gzip -cd 'f' > 't'

Result: gzip -dc '~/mail/abc.gz' > '/tmp/xyz'

Definition at line 344 of file compress.c.

345 {
346  if (!m || !cmd || !buf)
347  return;
348 
349  mutt_expando_format(buf, buflen, 0, buflen, cmd, compress_format_str,
350  (unsigned long) m, 0);
351 }
static const char * compress_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, unsigned long data, enum FormatFlag flags)
Expand the filenames in a command string - Implements format_t.
Definition: compress.c:303
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, enum FormatFlag flags)
Expand expandos (x) in a string.
Definition: muttlib.c:816

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int execute_command ( struct Mailbox m,
const char *  command,
const char *  progress 
)
static

Run a system command.

Parameters
mMailbox to work with
commandCommand string to execute
progressMessage to show the user
Return values
1Success
0Failure

Run the supplied command, taking care of all the NeoMutt requirements, such as locking files and blocking signals.

Definition at line 364 of file compress.c.

365 {
366  int rc = 1;
367  char sys_cmd[HUGE_STRING];
368 
369  if (!m || !command || !progress)
370  return 0;
371 
372  if (!m->quiet)
373  {
374  mutt_message(progress, m->realpath);
375  }
376 
377  mutt_sig_block();
378  endwin();
379  fflush(stdout);
380 
381  expand_command_str(m, command, sys_cmd, sizeof(sys_cmd));
382 
383  if (mutt_system(sys_cmd) != 0)
384  {
385  rc = 0;
387  mutt_error(_("Error running \"%s\""), sys_cmd);
388  }
389 
391 
392  return rc;
393 }
void mutt_sig_unblock(void)
Restore previously blocked signals.
Definition: signal.c:161
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
#define HUGE_STRING
Definition: string2.h:37
bool quiet
inhibit status messages?
Definition: mailbox.h:112
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:531
#define mutt_error(...)
Definition: logging.h:88
static void expand_command_str(const struct Mailbox *m, const char *cmd, char *buf, int buflen)
Expand placeholders in command string.
Definition: compress.c:344
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
void mutt_sig_block(void)
Block signals during critical operations.
Definition: signal.c:143
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_comp_can_append ( struct Mailbox m)

Can we append to this path?

Parameters
mMailbox
Return values
trueYes, we can append to the file
falseNo, appending isn't possible

To append to a file we can either use an 'append-hook' or a combination of 'open-hook' and 'close-hook'.

A match means it's our responsibility to append to the file.

Definition at line 406 of file compress.c.

407 {
408  if (!m)
409  return false;
410 
411  /* If this succeeds, we know there's an open-hook */
412  struct CompressInfo *ci = set_compress_info(m);
413  if (!ci)
414  return false;
415 
416  /* We have an open-hook, so to append we need an append-hook,
417  * or a close-hook. */
418  if (ci->append || ci->close)
419  return true;
420 
421  mutt_error(_("Cannot append without an append-hook or close-hook : %s"), m->path);
422  return false;
423 }
const char * close
close-hook command
Definition: compress.h:40
#define _(a)
Definition: message.h:28
Private data for compress.
Definition: compress.h:37
char path[PATH_MAX]
Definition: mailbox.h:78
const char * append
append-hook command
Definition: compress.h:39
#define mutt_error(...)
Definition: logging.h:88
static struct CompressInfo * set_compress_info(struct Mailbox *m)
Find the compress hooks for a mailbox.
Definition: compress.c:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_comp_can_read ( const char *  path)

Can we read from this file?

Parameters
pathPathname of file to be tested
Return values
trueYes, we can read the file
falseNo, we cannot read the file

Search for an 'open-hook' with a regex that matches the path.

A match means it's our responsibility to open the file.

Definition at line 435 of file compress.c.

436 {
437  if (!path)
438  return false;
439 
440  if (find_hook(MUTT_OPEN_HOOK, path))
441  return true;
442  else
443  return false;
444 }
static const char * find_hook(int type, const char *path)
Find a hook to match a path.
Definition: compress.c:189
#define MUTT_OPEN_HOOK
Definition: hook.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_comp_valid_command ( const char *  cmd)

Is this command string allowed?

Parameters
cmdCommand string
Return values
1Valid command
0"%f" and/or "%t" is missing

A valid command string must have both "%f" (from file) and "%t" (to file). We don't check if we can actually run the command.

Definition at line 455 of file compress.c.

456 {
457  if (!cmd)
458  return 0;
459 
460  return strstr(cmd, "%f") && strstr(cmd, "%t");
461 }

+ Here is the caller graph for this function:

struct Account* comp_ac_find ( struct Account a,
const char *  path 
)

Find a Account that matches a Mailbox path.

Definition at line 466 of file compress.c.

467 {
468  return NULL;
469 }
int comp_ac_add ( struct Account a,
struct Mailbox m 
)

Add a Mailbox to a Account.

Definition at line 474 of file compress.c.

475 {
476  if (!a || !m)
477  return -1;
478 
479  if (m->magic != MUTT_COMPRESSED)
480  return -1;
481 
482  m->account = a;
483 
484  struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
485  np->m = m;
486  STAILQ_INSERT_TAIL(&a->mailboxes, np, entries);
487  return 0;
488 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
struct MailboxList mailboxes
Definition: account.h:39
#define STAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:387
struct Mailbox * m
Definition: mailbox.h:139
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
struct Account * account
Definition: mailbox.h:125
Compressed file Mailbox type.
Definition: magic.h:45
List of Mailboxes.
Definition: mailbox.h:137

+ Here is the call graph for this function:

static int comp_mbox_open ( struct Mailbox m,
struct Context ctx 
)
static

Implements MxOps::mbox_open()

Set up a compressed mailbox to be read. Decompress the mailbox and set up the paths and hooks needed. Then determine the type of the mailbox so we can delegate the handling of messages.

Definition at line 498 of file compress.c.

499 {
500  if (!ctx || !ctx->mailbox || (ctx->mailbox->magic != MUTT_COMPRESSED))
501  return -1;
502 
503  struct CompressInfo *ci = set_compress_info(m);
504  if (!ci)
505  return -1;
506 
507  /* If there's no close-hook, or the file isn't writable */
508  if (!ci->close || (access(m->path, W_OK) != 0))
509  m->readonly = true;
510 
511  if (setup_paths(m) != 0)
512  goto cmo_fail;
513  store_size(m);
514 
515  if (!lock_realpath(m, false))
516  {
517  mutt_error(_("Unable to lock mailbox"));
518  goto cmo_fail;
519  }
520 
521  int rc = execute_command(m, ci->open, _("Decompressing %s"));
522  if (rc == 0)
523  goto cmo_fail;
524 
525  unlock_realpath(m);
526 
527  m->magic = mx_path_probe(m->path, NULL);
528  if (m->magic == MUTT_UNKNOWN)
529  {
530  mutt_error(_("Can't identify the contents of the compressed file"));
531  goto cmo_fail;
532  }
533 
534  ci->child_ops = mx_get_ops(m->magic);
535  if (!ci->child_ops)
536  {
537  mutt_error(_("Can't find mailbox ops for mailbox type %d"), m->magic);
538  goto cmo_fail;
539  }
540 
541  m->account->magic = m->magic;
542  return ci->child_ops->mbox_open(m, ctx);
543 
544 cmo_fail:
545  /* remove the partial uncompressed file */
546  remove(m->path);
548  return -1;
549 }
const char * close
close-hook command
Definition: compress.h:40
static void store_size(const struct Mailbox *m)
Save the size of the compressed file.
Definition: compress.c:163
int(* mbox_open)(struct Mailbox *m, struct Context *ctx)
Open a mailbox.
Definition: mx.h:132
#define _(a)
Definition: message.h:28
struct Mailbox * mailbox
Definition: context.h:50
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
bool readonly
don&#39;t allow changes to the mailbox
Definition: mailbox.h:113
enum MailboxType magic
Definition: account.h:38
static bool lock_realpath(struct Mailbox *m, bool excl)
Try to lock the ctx->realpath.
Definition: compress.c:70
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition: compress.c:109
Private data for compress.
Definition: compress.h:37
static void free_compress_info(struct Mailbox *m)
Frees the compress info members and structure.
Definition: compress.c:239
char path[PATH_MAX]
Definition: mailbox.h:78
struct Account * account
Definition: mailbox.h:125
Mailbox wasn&#39;t recognised.
Definition: magic.h:36
static int setup_paths(struct Mailbox *m)
Set the mailbox paths.
Definition: compress.c:135
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
#define mutt_error(...)
Definition: logging.h:88
Compressed file Mailbox type.
Definition: magic.h:45
const char * open
open-hook command
Definition: compress.h:41
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
Run a system command.
Definition: compress.c:364
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
static struct CompressInfo * set_compress_info(struct Mailbox *m)
Find the compress hooks for a mailbox.
Definition: compress.c:209

+ Here is the call graph for this function:

static int comp_mbox_open_append ( struct Mailbox m,
int  flags 
)
static

Implements MxOps::mbox_open_append()

flags may also contain MUTT_NEWFOLDER

To append to a compressed mailbox we need an append-hook (or both open- and close-hooks).

Definition at line 559 of file compress.c.

560 {
561  if (!m)
562  return -1;
563 
564  /* If this succeeds, we know there's an open-hook */
565  struct CompressInfo *ci = set_compress_info(m);
566  if (!ci)
567  return -1;
568 
569  /* To append we need an append-hook or a close-hook */
570  if (!ci->append && !ci->close)
571  {
572  mutt_error(_("Cannot append without an append-hook or close-hook : %s"), m->path);
573  goto cmoa_fail1;
574  }
575 
576  if (setup_paths(m) != 0)
577  goto cmoa_fail2;
578 
579  /* Lock the realpath for the duration of the append.
580  * It will be unlocked in the close */
581  if (!lock_realpath(m, true))
582  {
583  mutt_error(_("Unable to lock mailbox"));
584  goto cmoa_fail2;
585  }
586 
587  /* Open the existing mailbox, unless we are appending */
588  if (!ci->append && (mutt_file_get_size(m->realpath) > 0))
589  {
590  int rc = execute_command(m, ci->open, _("Decompressing %s"));
591  if (rc == 0)
592  {
593  mutt_error(_("Compress command failed: %s"), ci->open);
594  goto cmoa_fail2;
595  }
596  m->magic = mx_path_probe(m->path, NULL);
597  }
598  else
599  m->magic = MboxType;
600 
601  /* We can only deal with mbox and mmdf mailboxes */
602  if ((m->magic != MUTT_MBOX) && (m->magic != MUTT_MMDF))
603  {
604  mutt_error(_("Unsupported mailbox type for appending"));
605  goto cmoa_fail2;
606  }
607 
608  ci->child_ops = mx_get_ops(m->magic);
609  if (!ci->child_ops)
610  {
611  mutt_error(_("Can't find mailbox ops for mailbox type %d"), m->magic);
612  goto cmoa_fail2;
613  }
614 
615  if (ci->child_ops->mbox_open_append(m, flags) != 0)
616  goto cmoa_fail2;
617 
618  return 0;
619 
620 cmoa_fail2:
621  /* remove the partial uncompressed file */
622  remove(m->path);
623 cmoa_fail1:
624  /* Free the compress_info to prevent close from trying to recompress */
626 
627  return -1;
628 }
const char * close
close-hook command
Definition: compress.h:40
long mutt_file_get_size(const char *path)
Get the size of a file.
Definition: file.c:1393
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
#define _(a)
Definition: message.h:28
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
static bool lock_realpath(struct Mailbox *m, bool excl)
Try to lock the ctx->realpath.
Definition: compress.c:70
int(* mbox_open_append)(struct Mailbox *m, int flags)
Open a mailbox for appending.
Definition: mx.h:140
Private data for compress.
Definition: compress.h:37
static void free_compress_info(struct Mailbox *m)
Frees the compress info members and structure.
Definition: compress.c:239
char path[PATH_MAX]
Definition: mailbox.h:78
const char * append
append-hook command
Definition: compress.h:39
static int setup_paths(struct Mailbox *m)
Set the mailbox paths.
Definition: compress.c:135
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
#define mutt_error(...)
Definition: logging.h:88
const char * open
open-hook command
Definition: compress.h:41
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
Run a system command.
Definition: compress.c:364
short MboxType
Config: Default type for creating new mailboxes.
Definition: mx.c:92
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
static struct CompressInfo * set_compress_info(struct Mailbox *m)
Find the compress hooks for a mailbox.
Definition: compress.c:209

+ Here is the call graph for this function:

static int comp_mbox_check ( struct Context ctx,
int *  index_hint 
)
static

Implements MxOps::mbox_check()

Parameters
ctxMailbox
index_hintCurrently selected mailbox
Return values
0Mailbox OK
MUTT_REOPENEDThe mailbox was closed and reopened
-1Mailbox bad

If the compressed file changes in size but the mailbox hasn't been changed in NeoMutt, then we can close and reopen the mailbox.

If the mailbox has been changed in NeoMutt, warn the user.

The return codes are picked to match mx_mbox_check().

Definition at line 645 of file compress.c.

646 {
647  if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
648  return -1;
649 
650  struct Mailbox *m = ctx->mailbox;
651  struct CompressInfo *ci = m->compress_info;
652 
653  const struct MxOps *ops = ci->child_ops;
654  if (!ops)
655  return -1;
656 
657  int size = mutt_file_get_size(m->realpath);
658  if (size == ci->size)
659  return 0;
660 
661  if (!lock_realpath(m, false))
662  {
663  mutt_error(_("Unable to lock mailbox"));
664  return -1;
665  }
666 
667  int rc = execute_command(m, ci->open, _("Decompressing %s"));
668  store_size(m);
669  unlock_realpath(m);
670  if (rc == 0)
671  return -1;
672 
673  return ops->mbox_check(ctx, index_hint);
674 }
static void store_size(const struct Mailbox *m)
Save the size of the compressed file.
Definition: compress.c:163
long mutt_file_get_size(const char *path)
Get the size of a file.
Definition: file.c:1393
#define _(a)
Definition: message.h:28
long size
size of the compressed file
Definition: compress.h:42
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:76
static bool lock_realpath(struct Mailbox *m, bool excl)
Try to lock the ctx->realpath.
Definition: compress.c:70
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition: compress.c:109
int(* mbox_check)(struct Context *ctx, int *index_hint)
Check for new mail.
Definition: mx.h:148
Private data for compress.
Definition: compress.h:37
#define mutt_error(...)
Definition: logging.h:88
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const char * open
open-hook command
Definition: compress.h:41
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
Run a system command.
Definition: compress.c:364
The Mailbox API.
Definition: mx.h:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int comp_mbox_sync ( struct Context ctx,
int *  index_hint 
)
static

Implements MxOps::mbox_sync()

Changes in NeoMutt only affect the tmp file. Calling comp_mbox_sync() will commit them to the compressed file.

Definition at line 682 of file compress.c.

683 {
684  if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
685  return -1;
686 
687  struct Mailbox *m = ctx->mailbox;
688  struct CompressInfo *ci = m->compress_info;
689 
690  if (!ci->close)
691  {
692  mutt_error(_("Can't sync a compressed file without a close-hook"));
693  return -1;
694  }
695 
696  const struct MxOps *ops = ci->child_ops;
697  if (!ops)
698  return -1;
699 
700  if (!lock_realpath(m, true))
701  {
702  mutt_error(_("Unable to lock mailbox"));
703  return -1;
704  }
705 
706  int rc = comp_mbox_check(ctx, index_hint);
707  if (rc != 0)
708  goto sync_cleanup;
709 
710  rc = ops->mbox_sync(ctx, index_hint);
711  if (rc != 0)
712  goto sync_cleanup;
713 
714  rc = execute_command(m, ci->close, _("Compressing %s"));
715  if (rc == 0)
716  {
717  rc = -1;
718  goto sync_cleanup;
719  }
720 
721  rc = 0;
722 
723 sync_cleanup:
724  store_size(m);
725  unlock_realpath(m);
726  return rc;
727 }
int(* mbox_sync)(struct Context *ctx, int *index_hint)
Save changes to the mailbox.
Definition: mx.h:164
const char * close
close-hook command
Definition: compress.h:40
static void store_size(const struct Mailbox *m)
Save the size of the compressed file.
Definition: compress.c:163
#define _(a)
Definition: message.h:28
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:76
static bool lock_realpath(struct Mailbox *m, bool excl)
Try to lock the ctx->realpath.
Definition: compress.c:70
static int comp_mbox_check(struct Context *ctx, int *index_hint)
Implements MxOps::mbox_check()
Definition: compress.c:645
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition: compress.c:109
Private data for compress.
Definition: compress.h:37
#define mutt_error(...)
Definition: logging.h:88
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
Run a system command.
Definition: compress.c:364
The Mailbox API.
Definition: mx.h:103

+ Here is the call graph for this function:

static int comp_mbox_close ( struct Context ctx)
static

Implements MxOps::mbox_close()

If the mailbox has been changed then re-compress the tmp file. Then delete the tmp file.

Definition at line 735 of file compress.c.

736 {
737  if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
738  return -1;
739 
740  struct Mailbox *m = ctx->mailbox;
741  struct CompressInfo *ci = m->compress_info;
742 
743  const struct MxOps *ops = ci->child_ops;
744  if (!ops)
745  {
747  return -1;
748  }
749 
750  ops->mbox_close(ctx);
751 
752  /* sync has already been called, so we only need to delete some files */
753  if (!m->append)
754  {
755  /* If the file was removed, remove the compressed folder too */
756  if ((access(m->path, F_OK) != 0) && !SaveEmpty)
757  {
758  remove(m->realpath);
759  }
760  else
761  {
762  remove(m->path);
763  }
764  }
765  else
766  {
767  const char *append = NULL;
768  const char *msg = NULL;
769 
770  /* The file exists and we can append */
771  if ((access(m->realpath, F_OK) == 0) && ci->append)
772  {
773  append = ci->append;
774  msg = _("Compressed-appending to %s...");
775  }
776  else
777  {
778  append = ci->close;
779  msg = _("Compressing %s...");
780  }
781 
782  int rc = execute_command(m, append, msg);
783  if (rc == 0)
784  {
786  mutt_error(_("Error. Preserving temporary file: %s"), m->path);
787  }
788  else
789  remove(m->path);
790 
791  unlock_realpath(m);
792  }
793 
795 
796  return 0;
797 }
const char * close
close-hook command
Definition: compress.h:40
int(* mbox_close)(struct Context *ctx)
Close a mailbox.
Definition: mx.h:171
#define _(a)
Definition: message.h:28
WHERE bool SaveEmpty
Config: (mbox,mmdf) Preserve empty mailboxes.
Definition: globals.h:251
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:76
static void unlock_realpath(struct Mailbox *m)
Unlock the mailbox->realpath.
Definition: compress.c:109
bool append
mailbox is opened in append mode
Definition: mailbox.h:107
Private data for compress.
Definition: compress.h:37
static void free_compress_info(struct Mailbox *m)
Frees the compress info members and structure.
Definition: compress.c:239
char path[PATH_MAX]
Definition: mailbox.h:78
const char * append
append-hook command
Definition: compress.h:39
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:531
#define mutt_error(...)
Definition: logging.h:88
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
static int execute_command(struct Mailbox *m, const char *command, const char *progress)
Run a system command.
Definition: compress.c:364
The Mailbox API.
Definition: mx.h:103

+ Here is the call graph for this function:

static int comp_msg_open ( struct Mailbox m,
struct Message msg,
int  msgno 
)
static

Implements MxOps::msg_open()

Definition at line 802 of file compress.c.

803 {
804  if (!m || !m->compress_info)
805  return -1;
806 
807  struct CompressInfo *ci = m->compress_info;
808 
809  const struct MxOps *ops = ci->child_ops;
810  if (!ops)
811  return -1;
812 
813  /* Delegate */
814  return ops->msg_open(m, msg, msgno);
815 }
int(* msg_open)(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in mailbox.
Definition: mx.h:180
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_msg_open_new ( struct Mailbox m,
struct Message msg,
struct Email e 
)
static

Implements MxOps::msg_open_new()

Definition at line 820 of file compress.c.

821 {
822  if (!m || !m->compress_info)
823  return -1;
824 
825  struct CompressInfo *ci = m->compress_info;
826 
827  const struct MxOps *ops = ci->child_ops;
828  if (!ops)
829  return -1;
830 
831  /* Delegate */
832  return ops->msg_open_new(m, msg, e);
833 }
int(* msg_open_new)(struct Mailbox *m, struct Message *msg, struct Email *e)
Open a new message in a mailbox.
Definition: mx.h:189
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_msg_commit ( struct Mailbox m,
struct Message msg 
)
static

Implements MxOps::msg_commit()

Definition at line 838 of file compress.c.

839 {
840  if (!m || !m->compress_info)
841  return -1;
842 
843  struct CompressInfo *ci = m->compress_info;
844 
845  const struct MxOps *ops = ci->child_ops;
846  if (!ops)
847  return -1;
848 
849  /* Delegate */
850  return ops->msg_commit(m, msg);
851 }
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Save changes to an email.
Definition: mx.h:197
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_msg_close ( struct Mailbox m,
struct Message msg 
)
static

Implements MxOps::msg_close()

Definition at line 856 of file compress.c.

857 {
858  if (!m || !m->compress_info)
859  return -1;
860 
861  struct CompressInfo *ci = m->compress_info;
862 
863  const struct MxOps *ops = ci->child_ops;
864  if (!ops)
865  return -1;
866 
867  /* Delegate */
868  return ops->msg_close(m, msg);
869 }
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Close an email.
Definition: mx.h:205
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_msg_padding_size ( struct Mailbox m)
static

Bytes of padding between messages - Implements MxOps::msg_padding_size()

Definition at line 874 of file compress.c.

875 {
876  if (!m || !m->compress_info)
877  return 0;
878 
879  struct CompressInfo *ci = m->compress_info;
880 
881  const struct MxOps *ops = ci->child_ops;
882  if (!ops || !ops->msg_padding_size)
883  return 0;
884 
885  return ops->msg_padding_size(m);
886 }
int(* msg_padding_size)(struct Mailbox *m)
Bytes of padding between messages.
Definition: mx.h:211
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_tags_edit ( struct Mailbox m,
const char *  tags,
char *  buf,
size_t  buflen 
)
static

Implements MxOps::tags_edit()

Definition at line 891 of file compress.c.

892 {
893  if (!m || !m->compress_info)
894  return 0;
895 
896  struct CompressInfo *ci = m->compress_info;
897 
898  const struct MxOps *ops = ci->child_ops;
899  if (!ops || !ops->tags_edit)
900  return 0;
901 
902  return ops->tags_edit(m, tags, buf, buflen);
903 }
int(* tags_edit)(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Prompt and validate new messages tags.
Definition: mx.h:222
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
static int comp_tags_commit ( struct Mailbox m,
struct Email e,
char *  buf 
)
static

Implements MxOps::tags_commit()

Definition at line 908 of file compress.c.

909 {
910  if (!m || !m->compress_info)
911  return 0;
912 
913  struct CompressInfo *ci = m->compress_info;
914 
915  const struct MxOps *ops = ci->child_ops;
916  if (!ops || !ops->tags_commit)
917  return 0;
918 
919  return ops->tags_commit(m, e, buf);
920 }
Private data for compress.
Definition: compress.h:37
void * compress_info
compressed mbox module private data
Definition: mailbox.h:118
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: compress.h:43
The Mailbox API.
Definition: mx.h:103
int(* tags_commit)(struct Mailbox *m, struct Email *e, char *buf)
Save the tags to a message.
Definition: mx.h:231
enum MailboxType comp_path_probe ( const char *  path,
const struct stat *  st 
)

Is this a compressed mailbox? - Implements MxOps::path_probe()

Definition at line 925 of file compress.c.

926 {
927  if (!path)
928  return MUTT_UNKNOWN;
929 
930  if (!st || !S_ISREG(st->st_mode))
931  return MUTT_UNKNOWN;
932 
933  if (mutt_comp_can_read(path))
934  return MUTT_COMPRESSED;
935 
936  return MUTT_UNKNOWN;
937 }
bool mutt_comp_can_read(const char *path)
Can we read from this file?
Definition: compress.c:435
Mailbox wasn&#39;t recognised.
Definition: magic.h:36
Compressed file Mailbox type.
Definition: magic.h:45

+ Here is the call graph for this function:

int comp_path_canon ( char *  buf,
size_t  buflen 
)

Canonicalise a mailbox path - Implements MxOps::path_canon()

Definition at line 942 of file compress.c.

943 {
944  if (!buf)
945  return -1;
946 
947  mutt_path_canon(buf, buflen, HomeDir);
948  return 0;
949 }
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:47
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir)
Create the canonical version of a path.
Definition: path.c:219

+ Here is the call graph for this function:

int comp_path_pretty ( char *  buf,
size_t  buflen,
const char *  folder 
)

Implements MxOps::path_pretty()

Definition at line 954 of file compress.c.

955 {
956  if (!buf)
957  return -1;
958 
959  if (mutt_path_abbr_folder(buf, buflen, folder))
960  return 0;
961 
962  if (mutt_path_pretty(buf, buflen, HomeDir))
963  return 0;
964 
965  return -1;
966 }
bool mutt_path_pretty(char *buf, size_t buflen, const char *homedir)
Tidy a filesystem path.
Definition: path.c:181
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:47
bool mutt_path_abbr_folder(char *buf, size_t buflen, const char *folder)
Create a folder abbreviation.
Definition: path.c:505

+ Here is the call graph for this function:

int comp_path_parent ( char *  buf,
size_t  buflen 
)

Implements MxOps::path_parent()

Definition at line 971 of file compress.c.

972 {
973  if (!buf)
974  return -1;
975 
976  if (mutt_path_parent(buf, buflen))
977  return 0;
978 
979  if (buf[0] == '~')
980  mutt_path_canon(buf, buflen, HomeDir);
981 
982  if (mutt_path_parent(buf, buflen))
983  return 0;
984 
985  return -1;
986 }
bool mutt_path_parent(char *buf, size_t buflen)
Find the parent of a path.
Definition: path.c:472
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:47
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir)
Create the canonical version of a path.
Definition: path.c:219

+ Here is the call graph for this function:

Variable Documentation

struct MxOps MxCompOps
Initial value:
= {
.magic = MUTT_COMPRESSED,
.name = "compressed",
.ac_find = comp_ac_find,
.ac_add = comp_ac_add,
.mbox_open = comp_mbox_open,
.mbox_open_append = comp_mbox_open_append,
.mbox_check = comp_mbox_check,
.mbox_sync = comp_mbox_sync,
.mbox_close = comp_mbox_close,
.msg_open = comp_msg_open,
.msg_open_new = comp_msg_open_new,
.msg_commit = comp_msg_commit,
.msg_close = comp_msg_close,
.msg_padding_size = comp_msg_padding_size,
.tags_edit = comp_tags_edit,
.tags_commit = comp_tags_commit,
.path_probe = comp_path_probe,
.path_canon = comp_path_canon,
.path_pretty = comp_path_pretty,
.path_parent = comp_path_parent,
}
static int comp_mbox_close(struct Context *ctx)
Implements MxOps::mbox_close()
Definition: compress.c:735
static int comp_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
Implements MxOps::msg_open()
Definition: compress.c:802
static int comp_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
Implements MxOps::msg_open_new()
Definition: compress.c:820
static int comp_mbox_open_append(struct Mailbox *m, int flags)
Implements MxOps::mbox_open_append()
Definition: compress.c:559
static int comp_tags_commit(struct Mailbox *m, struct Email *e, char *buf)
Implements MxOps::tags_commit()
Definition: compress.c:908
static int comp_mbox_open(struct Mailbox *m, struct Context *ctx)
Implements MxOps::mbox_open()
Definition: compress.c:498
struct Account * comp_ac_find(struct Account *a, const char *path)
Find a Account that matches a Mailbox path.
Definition: compress.c:466
int comp_path_pretty(char *buf, size_t buflen, const char *folder)
Implements MxOps::path_pretty()
Definition: compress.c:954
int comp_path_canon(char *buf, size_t buflen)
Canonicalise a mailbox path - Implements MxOps::path_canon()
Definition: compress.c:942
static int comp_mbox_check(struct Context *ctx, int *index_hint)
Implements MxOps::mbox_check()
Definition: compress.c:645
static int comp_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Implements MxOps::msg_padding_size()
Definition: compress.c:874
static int comp_msg_close(struct Mailbox *m, struct Message *msg)
Implements MxOps::msg_close()
Definition: compress.c:856
enum MailboxType comp_path_probe(const char *path, const struct stat *st)
Is this a compressed mailbox? - Implements MxOps::path_probe()
Definition: compress.c:925
static int comp_mbox_sync(struct Context *ctx, int *index_hint)
Implements MxOps::mbox_sync()
Definition: compress.c:682
int comp_path_parent(char *buf, size_t buflen)
Implements MxOps::path_parent()
Definition: compress.c:971
int comp_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to a Account.
Definition: compress.c:474
Compressed file Mailbox type.
Definition: magic.h:45
static int comp_tags_edit(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Implements MxOps::tags_edit()
Definition: compress.c:891
static int comp_msg_commit(struct Mailbox *m, struct Message *msg)
Implements MxOps::msg_commit()
Definition: compress.c:838

Compressed mailbox - Implements MxOps.

Compress only uses open, close and check. The message functions are delegated to mbox.

Definition at line 995 of file compress.c.