Parse and execute user-defined hooks. More...
#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "hook.h"
#include "attach/lib.h"
#include "compmbox/lib.h"
#include "expando/lib.h"
#include "index/lib.h"
#include "ncrypt/lib.h"
#include "parse/lib.h"
#include "pattern/lib.h"
#include "commands.h"
#include "globals.h"
#include "hdrline.h"
#include "muttlib.h"
#include "mx.h"
Go to the source code of this file.
Data Structures | |
struct | Hook |
A list of user hooks. More... | |
Functions | |
TAILQ_HEAD (HookList, Hook) | |
static void | hook_free (struct Hook **ptr) |
Free a Hook. | |
static struct Hook * | hook_new (void) |
Create a Hook. | |
enum CommandResult | mutt_parse_charset_iconv_hook (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse 'charset-hook' and 'iconv-hook' commands - Implements Command::parse() -. | |
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() -. | |
void | mutt_delete_hooks (HookFlags type) |
Delete matching hooks. | |
static void | idxfmt_hashelem_free (int type, void *obj, intptr_t data) |
Free our hash table data - Implements hash_hdata_free_t -. | |
static void | delete_idxfmt_hooks (void) |
Delete all the index-format-hooks. | |
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() -. | |
static HookFlags | mutt_get_hook_type (const char *name) |
Find a hook by name. | |
static enum CommandResult | mutt_parse_unhook (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'unhook' command - Implements Command::parse() -. | |
void | mutt_folder_hook (const char *path, const char *desc) |
Perform a folder hook. | |
char * | mutt_find_hook (HookFlags type, const char *pat) |
Find a matching hook. | |
void | mutt_message_hook (struct Mailbox *m, struct Email *e, HookFlags type) |
Perform a message hook. | |
static int | addr_hook (struct Buffer *path, HookFlags type, struct Mailbox *m, struct Email *e) |
Perform an address hook (get a path) | |
void | mutt_default_save (struct Buffer *path, struct Email *e) |
Find the default save path for an email. | |
void | mutt_select_fcc (struct Buffer *path, struct Email *e) |
Select the FCC path for an email. | |
static void | list_hook (struct ListHead *matches, const char *match, HookFlags type) |
Find hook strings matching. | |
void | mutt_crypt_hook (struct ListHead *list, struct Address *addr) |
Find crypto hooks for an Address. | |
void | mutt_account_hook (const char *url) |
Perform an account hook. | |
void | mutt_timeout_hook (void) |
Execute any timeout hooks. | |
void | mutt_startup_shutdown_hook (HookFlags type) |
Execute any startup/shutdown hooks. | |
const struct Expando * | mutt_idxfmt_hook (const char *name, struct Mailbox *m, struct Email *e) |
Get index-format-hook format string. | |
void | hooks_init (void) |
Setup feature commands. | |
Variables | |
const struct ExpandoDefinition | IndexFormatDef [] |
Expando definitions. | |
static struct HookList | Hooks = TAILQ_HEAD_INITIALIZER(Hooks) |
All simple hooks, e.g. MUTT_FOLDER_HOOK. | |
static struct HashTable * | IdxFmtHooks = NULL |
All Index Format hooks. | |
static HookFlags | CurrentHookType = MUTT_HOOK_NO_FLAGS |
The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK. | |
static const struct Command | HookCommands [] |
Hook Commands. | |
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 | |||
) |
|
static |
Free a Hook.
ptr | Hook to free |
Definition at line 92 of file hook.c.
|
static |
Create a Hook.
ptr | New Hook |
Definition at line 116 of file hook.c.
void mutt_delete_hooks | ( | HookFlags | type | ) |
|
static |
|
static |
Find a hook by name.
name | Name to find |
num | Hook ID, e.g. MUTT_FOLDER_HOOK |
MUTT_HOOK_NO_FLAGS | Error, no matching hook |
Definition at line 555 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 623 of file hook.c.
char * mutt_find_hook | ( | HookFlags | type, |
const char * | pat | ||
) |
Perform a message hook.
Definition at line 692 of file hook.c.
|
static |
Perform an address hook (get a path)
0 | Success |
-1 | Failure |
Definition at line 738 of file hook.c.
Find the default save path for an email.
Definition at line 770 of file hook.c.
Select the FCC path for an email.
Definition at line 808 of file hook.c.
|
static |
Find hook strings matching.
[out] | matches | List of hook strings |
[in] | match | String to match |
[in] | type | Hook type, see HookFlags |
Definition at line 850 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 870 of file hook.c.
void mutt_account_hook | ( | const char * | url | ) |
Perform an account hook.
url | Account URL to match |
Definition at line 879 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 924 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 956 of file hook.c.
Get index-format-hook format string.
ptr | Expando |
NULL | No matching hook |
Definition at line 983 of file hook.c.
void hooks_init | ( | void | ) |
Setup feature commands.
Definition at line 1043 of file hook.c.
|
extern |
Expando definitions.
Config:
Definition at line 295 of file mutt_config.c.
|
static |
|
static |
|
static |
The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.
|
static |
Hook Commands.