Compressed mbox local mailbox type. More...
#include "config.h"
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "expando/lib.h"
#include "expando.h"
#include "globals.h"
#include "hook.h"
#include "mx.h"
#include "protos.h"
Go to the source code of this file.
Functions | |
void | mutt_comp_init (void) |
Setup feature commands. | |
static bool | lock_realpath (struct Mailbox *m, bool excl) |
Try to lock the Mailbox.realpath. | |
static void | unlock_realpath (struct Mailbox *m) |
Unlock the mailbox->realpath. | |
static int | setup_paths (struct Mailbox *m) |
Set the mailbox paths. | |
static void | store_size (const struct Mailbox *m) |
Save the size of the compressed file. | |
static struct Expando * | validate_compress_expando (const char *s) |
Validate the Compress hooks. | |
static struct CompressInfo * | set_compress_info (struct Mailbox *m) |
Find the compress hooks for a mailbox. | |
static void | compress_info_free (struct Mailbox *m) |
Frees the compress info members and structure. | |
static bool | execute_command (struct Mailbox *m, const struct Expando *exp, const char *progress) |
Run a system command. | |
bool | mutt_comp_can_append (struct Mailbox *m) |
Can we append to this path? | |
bool | mutt_comp_can_read (const char *path) |
Can we read from this file? | |
int | mutt_comp_valid_command (const char *cmd) |
Is this command string allowed? | |
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() -. | |
static bool | comp_ac_add (struct Account *a, struct Mailbox *m) |
Add a Mailbox to an Account - Implements MxOps::ac_add() -. | |
static enum MxOpenReturns | comp_mbox_open (struct Mailbox *m) |
Open a Mailbox - Implements MxOps::mbox_open() -. | |
static bool | comp_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags) |
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -. | |
static enum MxStatus | comp_mbox_check (struct Mailbox *m) |
Check for new mail - Implements MxOps::mbox_check() -. | |
static enum MxStatus | comp_mbox_sync (struct Mailbox *m) |
Save changes to the Mailbox - Implements MxOps::mbox_sync() -. | |
static enum MxStatus | comp_mbox_close (struct Mailbox *m) |
Close a Mailbox - Implements MxOps::mbox_close() -. | |
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() -. | |
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() -. | |
static int | comp_msg_commit (struct Mailbox *m, struct Message *msg) |
Save changes to an email - Implements MxOps::msg_commit() -. | |
static int | comp_msg_close (struct Mailbox *m, struct Message *msg) |
Close an email - Implements MxOps::msg_close() -. | |
static int | comp_msg_padding_size (struct Mailbox *m) |
Bytes of padding between messages - Implements MxOps::msg_padding_size() -. | |
static int | comp_msg_save_hcache (struct Mailbox *m, struct Email *e) |
Save message to the header cache - Implements MxOps::msg_save_hcache() -. | |
static int | comp_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf) |
Prompt and validate new messages tags - Implements MxOps::tags_edit() -. | |
static int | comp_tags_commit (struct Mailbox *m, struct Email *e, const char *buf) |
Save the tags to a message - Implements MxOps::tags_commit() -. | |
static enum MailboxType | comp_path_probe (const char *path, const struct stat *st) |
Is this a compressed Mailbox? - Implements MxOps::path_probe() -. | |
static int | comp_path_canon (struct Buffer *path) |
Canonicalise a Mailbox path - Implements MxOps::path_canon() -. | |
Variables | |
static const struct Command | CompCommands [] |
Compression Commands. | |
const struct ExpandoDefinition | CompressFormatDef [] |
Expando definitions. | |
const struct MxOps | MxCompOps |
Compressed Mailbox - Implements MxOps -. | |
Compressed mbox local mailbox type.
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.
void mutt_comp_init | ( | void | ) |
Setup feature commands.
Definition at line 90 of file compress.c.
|
static |
Try to lock the Mailbox.realpath.
m | Mailbox to lock |
excl | Lock exclusively? |
true | Success (locked or readonly) |
false | Error (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 106 of file compress.c.
|
static |
Unlock the mailbox->realpath.
m | Mailbox to unlock |
Unlock a mailbox previously locked by lock_mailbox().
Definition at line 147 of file compress.c.
|
static |
Set the mailbox paths.
m | Mailbox to modify |
0 | Success |
-1 | Error |
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 173 of file compress.c.
|
static |
Save the size of the compressed file.
m | Mailbox |
Save the compressed file size in the compress_info struct.
Definition at line 201 of file compress.c.
|
static |
Validate the Compress hooks.
s | Command string |
ptr | Expando |
Definition at line 216 of file compress.c.
|
static |
Find the compress hooks for a mailbox.
m | Mailbox to examine |
ptr | CompressInfo Hook info for the mailbox's path |
NULL | Error |
When a mailbox is opened, we check if there are any matching hooks.
Definition at line 238 of file compress.c.
|
static |
Frees the compress info members and structure.
m | Mailbox to free compress_info for |
Definition at line 268 of file compress.c.
|
static |
Run a system command.
true | Success |
false | Failure |
Run the supplied command, taking care of all the NeoMutt requirements, such as locking files and blocking signals.
Definition at line 294 of file compress.c.
bool mutt_comp_can_append | ( | struct Mailbox * | m | ) |
Can we append to this path?
m | Mailbox |
true | Yes, we can append to the file |
false | No, 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 337 of file compress.c.
bool mutt_comp_can_read | ( | const char * | path | ) |
Can we read from this file?
path | Pathname of file to be tested |
true | Yes, we can read the file |
false | No, 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 366 of file compress.c.
int mutt_comp_valid_command | ( | const char * | cmd | ) |
Is this command string allowed?
cmd | Command string |
1 | Valid 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 386 of file compress.c.
|
static |
Compression Commands.
Definition at line 63 of file compress.c.
const struct ExpandoDefinition CompressFormatDef[] |
Expando definitions.
Config:
Definition at line 79 of file compress.c.