Parse and execute user-defined hooks. More...
#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "email/lib.h"
#include "alias/lib.h"
#include "mutt.h"
#include "hook.h"
#include "ncrypt/lib.h"
#include "pattern/lib.h"
#include "context.h"
#include "format_flags.h"
#include "hdrline.h"
#include "init.h"
#include "mutt_attach.h"
#include "mutt_commands.h"
#include "mutt_globals.h"
#include "muttlib.h"
#include "mx.h"
#include "compmbox/lib.h"
Go to the source code of this file.
Data Structures | |
struct | Hook |
A list of user hooks. More... | |
Functions | |
TAILQ_HEAD (HookList, Hook) | |
enum CommandResult | mutt_parse_hook (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'hook' family of commands - Implements Command::parse() More... | |
static void | delete_hook (struct Hook *h) |
Delete a Hook. More... | |
void | mutt_delete_hooks (HookFlags type) |
Delete matching hooks. More... | |
static void | delete_idxfmt_hooklist (int type, void *obj, intptr_t data) |
Delete a index-format-hook from the Hash Table - Implements hash_hdata_free_t. More... | |
static void | delete_idxfmt_hooks (void) |
Delete all the index-format-hooks. More... | |
enum CommandResult | mutt_parse_idxfmt_hook (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'index-format-hook' command - Implements Command::parse() More... | |
enum CommandResult | mutt_parse_unhook (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'unhook' command - Implements Command::parse() More... | |
void | mutt_folder_hook (const char *path, const char *desc) |
Perform a folder hook. More... | |
char * | mutt_find_hook (HookFlags type, const char *pat) |
Find a matching hook. More... | |
void | mutt_message_hook (struct Mailbox *m, struct Email *e, HookFlags type) |
Perform a message hook. More... | |
static int | addr_hook (char *path, size_t pathlen, HookFlags type, struct Context *ctx, struct Email *e) |
Perform an address hook (get a path) More... | |
void | mutt_default_save (char *path, size_t pathlen, struct Email *e) |
Find the default save path for an email. More... | |
void | mutt_select_fcc (struct Buffer *path, struct Email *e) |
Select the FCC path for an email. More... | |
static void | list_hook (struct ListHead *matches, const char *match, HookFlags hook) |
Find hook strings matching. More... | |
void | mutt_crypt_hook (struct ListHead *list, struct Address *addr) |
Find crypto hooks for an Address. More... | |
void | mutt_account_hook (const char *url) |
Perform an account hook. More... | |
void | mutt_timeout_hook (void) |
Execute any timeout hooks. More... | |
void | mutt_startup_shutdown_hook (HookFlags type) |
Execute any startup/shutdown hooks. More... | |
const char * | mutt_idxfmt_hook (const char *name, struct Mailbox *m, struct Email *e) |
Get index-format-hook format string. More... | |
Variables | |
char * | C_DefaultHook |
Config: Pattern to use for hooks that only have a simple regex. More... | |
bool | C_ForceName |
Config: Save outgoing mail in a folder of their name. More... | |
bool | C_SaveName |
Config: Save outgoing message to mailbox of recipient's name if it exists. More... | |
static struct HookList | Hooks = TAILQ_HEAD_INITIALIZER(Hooks) |
static struct HashTable * | IdxFmtHooks = NULL |
static HookFlags | current_hook_type = MUTT_HOOK_NO_FLAGS |
Parse and execute user-defined hooks.
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 hook.c.
TAILQ_HEAD | ( | HookList | , |
Hook | |||
) |
enum CommandResult mutt_parse_hook | ( | struct Buffer * | buf, |
struct Buffer * | s, | ||
intptr_t | data, | ||
struct Buffer * | err | ||
) |
Parse the 'hook' family of commands - Implements Command::parse()
This is used by 'account-hook', 'append-hook' and many more.
Definition at line 85 of file hook.c.
|
static |
Delete a Hook.
h | Hook to delete |
Definition at line 288 of file hook.c.
void mutt_delete_hooks | ( | HookFlags | type | ) |
|
static |
Delete a index-format-hook from the Hash Table - Implements hash_hdata_free_t.
Definition at line 325 of file hook.c.
|
static |
enum CommandResult mutt_parse_idxfmt_hook | ( | struct Buffer * | buf, |
struct Buffer * | s, | ||
intptr_t | data, | ||
struct Buffer * | err | ||
) |
Parse the 'index-format-hook' command - Implements Command::parse()
Definition at line 351 of file hook.c.
enum CommandResult mutt_parse_unhook | ( | struct Buffer * | buf, |
struct Buffer * | s, | ||
intptr_t | data, | ||
struct Buffer * | err | ||
) |
Parse the 'unhook' command - Implements Command::parse()
Definition at line 453 of file hook.c.
void mutt_folder_hook | ( | const char * | path, |
const char * | desc | ||
) |
Perform a folder hook.
path | Path to potentially match |
desc | Description to potentially match |
Definition at line 504 of file hook.c.
char* mutt_find_hook | ( | HookFlags | type, |
const char * | pat | ||
) |
Find a matching hook.
ptr | Command string |
Definition at line 552 of file hook.c.
Perform a message hook.
Definition at line 573 of file hook.c.
|
static |
Perform an address hook (get a path)
path | Buffer for path |
pathlen | Length of buffer |
type | Hook type, see HookFlags |
ctx | Mailbox Context |
e |
0 | Success |
-1 | Failure |
Definition at line 620 of file hook.c.
void mutt_default_save | ( | char * | path, |
size_t | pathlen, | ||
struct Email * | e | ||
) |
Find the default save path for an email.
Definition at line 654 of file hook.c.
Select the FCC path for an email.
Definition at line 692 of file hook.c.
|
static |
Find hook strings matching.
[out] | matches | List of hook strings |
[in] | match | String to match |
[in] | hook | Hook type, see HookFlags |
Definition at line 726 of file hook.c.
void mutt_crypt_hook | ( | struct ListHead * | list, |
struct Address * | addr | ||
) |
Find crypto hooks for an Address.
[out] | list | List of keys |
[in] | addr | Address to match |
The crypt-hook associates keys with addresses.
Definition at line 746 of file hook.c.
void mutt_account_hook | ( | const char * | url | ) |
Perform an account hook.
url | Account URL to match |
Definition at line 755 of file hook.c.
void mutt_timeout_hook | ( | void | ) |
Execute any timeout hooks.
The user can configure hooks to be run on timeout. This function finds all the matching hooks and executes them.
Definition at line 800 of file hook.c.
void mutt_startup_shutdown_hook | ( | HookFlags | type | ) |
Execute any startup/shutdown hooks.
type | Hook type: MUTT_STARTUP_HOOK or MUTT_SHUTDOWN_HOOK |
The user can configure hooks to be run on startup/shutdown. This function finds all the matching hooks and executes them.
Definition at line 836 of file hook.c.
Get index-format-hook format string.
ptr | printf(3)-like format string |
NULL | No matching hook |
Definition at line 866 of file hook.c.
char* C_DefaultHook |
bool C_ForceName |
bool C_SaveName |
|
static |
|
static |