NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference

Compressed mbox local mailbox type. More...

#include <stdbool.h>
#include <stdio.h>
#include "mx.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CompressInfo
 Private data for compress. More...
 

Functions

void mutt_comp_init (void)
 Setup feature commands. 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...
 

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 lib.h.

Function Documentation

◆ mutt_comp_init()

void mutt_comp_init ( void  )

Setup feature commands.

Definition at line 66 of file compress.c.

67 {
69 }
#define COMMANDS_REGISTER(cmds)
Definition: mutt_commands.h:77
static const struct Command comp_commands[]
Definition: compress.c:55
+ Here is the caller graph for this function:

◆ mutt_comp_can_append()

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 356 of file compress.c.

357 {
358  if (!m)
359  return false;
360 
361  /* If this succeeds, we know there's an open-hook */
362  struct CompressInfo *ci = set_compress_info(m);
363  if (!ci)
364  return false;
365 
366  /* We have an open-hook, so to append we need an append-hook,
367  * or a close-hook. */
368  if (ci->cmd_append || ci->cmd_close)
369  return true;
370 
371  mutt_error(_("Can't append without an append-hook or close-hook : %s"), mailbox_path(m));
372  return false;
373 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:203
const char * cmd_append
append-hook command
Definition: lib.h:50
#define _(a)
Definition: message.h:28
const char * cmd_close
close-hook command
Definition: lib.h:51
static struct CompressInfo * set_compress_info(struct Mailbox *m)
Find the compress hooks for a mailbox.
Definition: compress.c:193
Private data for compress.
Definition: lib.h:48
#define mutt_error(...)
Definition: logging.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_comp_can_read()

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 can't 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 385 of file compress.c.

386 {
387  if (!path)
388  return false;
389 
390  if (mutt_find_hook(MUTT_OPEN_HOOK, path))
391  return true;
392 
393  return false;
394 }
char * mutt_find_hook(HookFlags type, const char *pat)
Find a matching hook.
Definition: hook.c:552
#define MUTT_OPEN_HOOK
open-hook: to read a compressed mailbox
Definition: hook.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_comp_valid_command()

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 405 of file compress.c.

406 {
407  if (!cmd)
408  return 0;
409 
410  return strstr(cmd, "%f") && strstr(cmd, "%t");
411 }
+ Here is the caller graph for this function:

Variable Documentation

◆ MxCompOps

struct MxOps MxCompOps

Compressed Mailbox - Implements MxOps.

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

Definition at line 932 of file compress.c.