NeoMutt  2023-11-03-85-g512e01
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
hook.h File Reference

Parse and execute user-defined hooks. More...

#include "config.h"
#include <stdint.h>
#include "core/lib.h"
+ Include dependency graph for hook.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MUTT_HOOK_NO_FLAGS   0
 No flags are set.
 
#define MUTT_FOLDER_HOOK   (1 << 0)
 folder-hook: when entering a mailbox
 
#define MUTT_MBOX_HOOK   (1 << 1)
 mbox-hook: move messages after reading them
 
#define MUTT_SEND_HOOK   (1 << 2)
 send-hook: when composing a new email
 
#define MUTT_FCC_HOOK   (1 << 3)
 fcc-hook: to save outgoing email
 
#define MUTT_SAVE_HOOK   (1 << 4)
 save-hook: set a default folder when saving an email
 
#define MUTT_CHARSET_HOOK   (1 << 5)
 charset-hook: create a charset alias for malformed emails
 
#define MUTT_ICONV_HOOK   (1 << 6)
 iconv-hook: create a system charset alias
 
#define MUTT_MESSAGE_HOOK   (1 << 7)
 message-hook: run before displaying a message
 
#define MUTT_CRYPT_HOOK   (1 << 8)
 crypt-hook: automatically select a PGP/SMIME key
 
#define MUTT_ACCOUNT_HOOK   (1 << 9)
 account-hook: when changing between accounts
 
#define MUTT_REPLY_HOOK   (1 << 10)
 reply-hook: when replying to an email
 
#define MUTT_SEND2_HOOK   (1 << 11)
 send2-hook: when changing fields in the compose menu
 
#define MUTT_OPEN_HOOK   (1 << 12)
 open-hook: to read a compressed mailbox
 
#define MUTT_APPEND_HOOK   (1 << 13)
 append-hook: append to a compressed mailbox
 
#define MUTT_CLOSE_HOOK   (1 << 14)
 close-hook: write to a compressed mailbox
 
#define MUTT_IDXFMTHOOK   (1 << 15)
 index-format-hook: customise the format of the index
 
#define MUTT_TIMEOUT_HOOK   (1 << 16)
 timeout-hook: run a command periodically
 
#define MUTT_STARTUP_HOOK   (1 << 17)
 startup-hook: run when starting NeoMutt
 
#define MUTT_SHUTDOWN_HOOK   (1 << 18)
 shutdown-hook: run when leaving NeoMutt
 
#define MUTT_GLOBAL_HOOK   (1 << 19)
 Hooks which don't take a regex.
 

Typedefs

typedef uint32_t HookFlags
 Flags for mutt_parse_hook(), e.g. MUTT_FOLDER_HOOK.
 

Functions

void hooks_init (void)
 Setup feature commands.
 
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_account_hook (const char *url)
 Perform an account hook.
 
void mutt_crypt_hook (struct ListHead *list, struct Address *addr)
 Find crypto hooks for an Address.
 
void mutt_default_save (struct Buffer *path, struct Email *e)
 Find the default save path for an email.
 
void mutt_delete_hooks (HookFlags type)
 Delete matching hooks.
 
char * mutt_find_hook (HookFlags type, const char *pat)
 Find a matching hook.
 
void mutt_folder_hook (const char *path, const char *desc)
 Perform a folder hook.
 
const char * mutt_idxfmt_hook (const char *name, struct Mailbox *m, struct Email *e)
 Get index-format-hook format string.
 
void mutt_message_hook (struct Mailbox *m, struct Email *e, HookFlags type)
 Perform a message 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() -.
 
void mutt_select_fcc (struct Buffer *path, struct Email *e)
 Select the FCC path for an email.
 
void mutt_startup_shutdown_hook (HookFlags type)
 Execute any startup/shutdown hooks.
 
void mutt_timeout_hook (void)
 Execute any timeout hooks.
 

Detailed Description

Parse and execute user-defined hooks.

Authors
  • 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 hook.h.

Macro Definition Documentation

◆ MUTT_HOOK_NO_FLAGS

#define MUTT_HOOK_NO_FLAGS   0

No flags are set.

Definition at line 36 of file hook.h.

◆ MUTT_FOLDER_HOOK

#define MUTT_FOLDER_HOOK   (1 << 0)

folder-hook: when entering a mailbox

Definition at line 37 of file hook.h.

◆ MUTT_MBOX_HOOK

#define MUTT_MBOX_HOOK   (1 << 1)

mbox-hook: move messages after reading them

Definition at line 38 of file hook.h.

◆ MUTT_SEND_HOOK

#define MUTT_SEND_HOOK   (1 << 2)

send-hook: when composing a new email

Definition at line 39 of file hook.h.

◆ MUTT_FCC_HOOK

#define MUTT_FCC_HOOK   (1 << 3)

fcc-hook: to save outgoing email

Definition at line 40 of file hook.h.

◆ MUTT_SAVE_HOOK

#define MUTT_SAVE_HOOK   (1 << 4)

save-hook: set a default folder when saving an email

Definition at line 41 of file hook.h.

◆ MUTT_CHARSET_HOOK

#define MUTT_CHARSET_HOOK   (1 << 5)

charset-hook: create a charset alias for malformed emails

Definition at line 42 of file hook.h.

◆ MUTT_ICONV_HOOK

#define MUTT_ICONV_HOOK   (1 << 6)

iconv-hook: create a system charset alias

Definition at line 43 of file hook.h.

◆ MUTT_MESSAGE_HOOK

#define MUTT_MESSAGE_HOOK   (1 << 7)

message-hook: run before displaying a message

Definition at line 44 of file hook.h.

◆ MUTT_CRYPT_HOOK

#define MUTT_CRYPT_HOOK   (1 << 8)

crypt-hook: automatically select a PGP/SMIME key

Definition at line 45 of file hook.h.

◆ MUTT_ACCOUNT_HOOK

#define MUTT_ACCOUNT_HOOK   (1 << 9)

account-hook: when changing between accounts

Definition at line 46 of file hook.h.

◆ MUTT_REPLY_HOOK

#define MUTT_REPLY_HOOK   (1 << 10)

reply-hook: when replying to an email

Definition at line 47 of file hook.h.

◆ MUTT_SEND2_HOOK

#define MUTT_SEND2_HOOK   (1 << 11)

send2-hook: when changing fields in the compose menu

Definition at line 48 of file hook.h.

◆ MUTT_OPEN_HOOK

#define MUTT_OPEN_HOOK   (1 << 12)

open-hook: to read a compressed mailbox

Definition at line 49 of file hook.h.

◆ MUTT_APPEND_HOOK

#define MUTT_APPEND_HOOK   (1 << 13)

append-hook: append to a compressed mailbox

Definition at line 50 of file hook.h.

◆ MUTT_CLOSE_HOOK

#define MUTT_CLOSE_HOOK   (1 << 14)

close-hook: write to a compressed mailbox

Definition at line 51 of file hook.h.

◆ MUTT_IDXFMTHOOK

#define MUTT_IDXFMTHOOK   (1 << 15)

index-format-hook: customise the format of the index

Definition at line 52 of file hook.h.

◆ MUTT_TIMEOUT_HOOK

#define MUTT_TIMEOUT_HOOK   (1 << 16)

timeout-hook: run a command periodically

Definition at line 53 of file hook.h.

◆ MUTT_STARTUP_HOOK

#define MUTT_STARTUP_HOOK   (1 << 17)

startup-hook: run when starting NeoMutt

Definition at line 54 of file hook.h.

◆ MUTT_SHUTDOWN_HOOK

#define MUTT_SHUTDOWN_HOOK   (1 << 18)

shutdown-hook: run when leaving NeoMutt

Definition at line 55 of file hook.h.

◆ MUTT_GLOBAL_HOOK

#define MUTT_GLOBAL_HOOK   (1 << 19)

Hooks which don't take a regex.

Definition at line 56 of file hook.h.

Typedef Documentation

◆ HookFlags

typedef uint32_t HookFlags

Flags for mutt_parse_hook(), e.g. MUTT_FOLDER_HOOK.

Definition at line 35 of file hook.h.

Function Documentation

◆ hooks_init()

void hooks_init ( void  )

Setup feature commands.

Definition at line 1020 of file hook.c.

1021{
1023}
void commands_register(const struct Command *cmds, const size_t num_cmds)
Add commands to Commands array.
Definition: command.c:53
static const struct Command HookCommands[]
Hook Commands.
Definition: hook.c:993
#define mutt_array_size(x)
Definition: memory.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_account_hook()

void mutt_account_hook ( const char *  url)

Perform an account hook.

Parameters
urlAccount URL to match

Definition at line 853 of file hook.c.

854{
855 /* parsing commands with URLs in an account hook can cause a recursive
856 * call. We just skip processing if this occurs. Typically such commands
857 * belong in a folder-hook -- perhaps we should warn the user. */
858 static bool inhook = false;
859 if (inhook)
860 return;
861
862 struct Hook *hook = NULL;
863 struct Buffer *err = buf_pool_get();
864
865 TAILQ_FOREACH(hook, &Hooks, entries)
866 {
867 if (!(hook->command && (hook->type & MUTT_ACCOUNT_HOOK)))
868 continue;
869
870 if (mutt_regex_match(&hook->regex, url))
871 {
872 inhook = true;
873 mutt_debug(LL_DEBUG1, "account-hook '%s' matches '%s'\n", hook->regex.pattern, url);
874 mutt_debug(LL_DEBUG5, " %s\n", hook->command);
875
876 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
877 {
878 mutt_error("%s", buf_string(err));
879 buf_pool_release(&err);
880
881 inhook = false;
882 goto done;
883 }
884
885 inhook = false;
886 }
887 }
888done:
889 buf_pool_release(&err);
890}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition: command.h:37
enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct Buffer *err)
Parse and run a muttrc line in a relative directory.
Definition: commands.c:158
#define mutt_error(...)
Definition: logging2.h:92
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static struct HookList Hooks
All simple hooks, e.g. MUTT_FOLDER_HOOK.
Definition: hook.c:71
#define MUTT_ACCOUNT_HOOK
account-hook: when changing between accounts
Definition: hook.h:46
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
Definition: regex.c:636
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
String manipulation buffer.
Definition: buffer.h:34
A list of user hooks.
Definition: hook.c:60
HookFlags type
Hook type.
Definition: hook.c:61
struct Regex regex
Regular expression.
Definition: hook.c:62
char * command
Filename, command or pattern to execute.
Definition: hook.c:63
char * source_file
Used for relative-directory source.
Definition: hook.c:64
char * pattern
printable version
Definition: regex3.h:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_crypt_hook()

void mutt_crypt_hook ( struct ListHead *  list,
struct Address addr 
)

Find crypto hooks for an Address.

Parameters
[out]listList of keys
[in]addrAddress to match

The crypt-hook associates keys with addresses.

Definition at line 844 of file hook.c.

845{
847}
static void list_hook(struct ListHead *matches, const char *match, HookFlags type)
Find hook strings matching.
Definition: hook.c:824
#define MUTT_CRYPT_HOOK
crypt-hook: automatically select a PGP/SMIME key
Definition: hook.h:45
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_default_save()

void mutt_default_save ( struct Buffer path,
struct Email e 
)

Find the default save path for an email.

Parameters
pathBuffer for the path
eEmail

Definition at line 744 of file hook.c.

745{
746 struct Mailbox *m_cur = get_current_mailbox();
747 if (addr_hook(path, MUTT_SAVE_HOOK, m_cur, e) == 0)
748 return;
749
750 struct Envelope *env = e->env;
751 const struct Address *from = TAILQ_FIRST(&env->from);
752 const struct Address *reply_to = TAILQ_FIRST(&env->reply_to);
753 const struct Address *to = TAILQ_FIRST(&env->to);
754 const struct Address *cc = TAILQ_FIRST(&env->cc);
755 const struct Address *addr = NULL;
756 bool from_me = mutt_addr_is_user(from);
757
758 if (!from_me && reply_to && reply_to->mailbox)
759 addr = reply_to;
760 else if (!from_me && from && from->mailbox)
761 addr = from;
762 else if (to && to->mailbox)
763 addr = to;
764 else if (cc && cc->mailbox)
765 addr = cc;
766 else
767 addr = NULL;
768 if (addr)
769 {
770 struct Buffer *tmp = buf_pool_get();
771 mutt_safe_path(tmp, addr);
772 buf_add_printf(path, "=%s", buf_string(tmp));
773 buf_pool_release(&tmp);
774 }
775}
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:570
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:216
static int addr_hook(struct Buffer *path, HookFlags type, struct Mailbox *m, struct Email *e)
Perform an address hook (get a path)
Definition: hook.c:712
#define MUTT_SAVE_HOOK
save-hook: set a default folder when saving an email
Definition: hook.h:41
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
Definition: index.c:662
void mutt_safe_path(struct Buffer *dest, const struct Address *a)
Make a safe filename from an email address.
Definition: muttlib.c:720
#define TAILQ_FIRST(head)
Definition: queue.h:723
An email address.
Definition: address.h:36
struct Envelope * env
Envelope information.
Definition: email.h:66
The header of an Email.
Definition: envelope.h:57
struct AddressList to
Email's 'To' list.
Definition: envelope.h:60
struct AddressList reply_to
Email's 'reply-to'.
Definition: envelope.h:64
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:61
struct AddressList from
Email's 'From' list.
Definition: envelope.h:59
A mailbox.
Definition: mailbox.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_delete_hooks()

void mutt_delete_hooks ( HookFlags  type)

Delete matching hooks.

Parameters
typeHook type to delete, see HookFlags

If MUTT_HOOK_NO_FLAGS is passed, all the hooks will be deleted.

Definition at line 375 of file hook.c.

376{
377 struct Hook *h = NULL;
378 struct Hook *tmp = NULL;
379
380 TAILQ_FOREACH_SAFE(h, &Hooks, entries, tmp)
381 {
382 if ((type == MUTT_HOOK_NO_FLAGS) || (type == h->type))
383 {
384 TAILQ_REMOVE(&Hooks, h, entries);
385 hook_free(&h);
386 }
387 }
388}
static void hook_free(struct Hook **ptr)
Free a Hook.
Definition: hook.c:83
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition: hook.h:36
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:735
#define TAILQ_REMOVE(head, elm, field)
Definition: queue.h:841
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_find_hook()

char * mutt_find_hook ( HookFlags  type,
const char *  pat 
)

Find a matching hook.

Parameters
typeHook type, see HookFlags
patPattern to match
Return values
ptrCommand string
Note
The returned string must not be freed.

Definition at line 645 of file hook.c.

646{
647 struct Hook *tmp = NULL;
648
649 TAILQ_FOREACH(tmp, &Hooks, entries)
650 {
651 if (tmp->type & type)
652 {
653 if (mutt_regex_match(&tmp->regex, pat))
654 return tmp->command;
655 }
656 }
657 return NULL;
658}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_folder_hook()

void mutt_folder_hook ( const char *  path,
const char *  desc 
)

Perform a folder hook.

Parameters
pathPath to potentially match
descDescription to potentially match

Definition at line 597 of file hook.c.

598{
599 if (!path && !desc)
600 return;
601
602 struct Hook *hook = NULL;
603 struct Buffer *err = buf_pool_get();
604
606
607 TAILQ_FOREACH(hook, &Hooks, entries)
608 {
609 if (!hook->command)
610 continue;
611
612 if (!(hook->type & MUTT_FOLDER_HOOK))
613 continue;
614
615 const char *match = NULL;
616 if (mutt_regex_match(&hook->regex, path))
617 match = path;
618 else if (mutt_regex_match(&hook->regex, desc))
619 match = desc;
620
621 if (match)
622 {
623 mutt_debug(LL_DEBUG1, "folder-hook '%s' matches '%s'\n", hook->regex.pattern, match);
624 mutt_debug(LL_DEBUG5, " %s\n", hook->command);
625 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
626 {
627 mutt_error("%s", buf_string(err));
628 break;
629 }
630 }
631 }
632 buf_pool_release(&err);
633
635}
static HookFlags CurrentHookType
The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.
Definition: hook.c:77
#define MUTT_FOLDER_HOOK
folder-hook: when entering a mailbox
Definition: hook.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_idxfmt_hook()

const char * mutt_idxfmt_hook ( const char *  name,
struct Mailbox m,
struct Email e 
)

Get index-format-hook format string.

Parameters
nameHook name
mMailbox
eEmail
Return values
ptrprintf(3)-like format string
NULLNo matching hook

Definition at line 960 of file hook.c.

961{
962 if (!IdxFmtHooks)
963 return NULL;
964
965 struct HookList *hl = mutt_hash_find(IdxFmtHooks, name);
966 if (!hl)
967 return NULL;
968
970
971 struct PatternCache cache = { 0 };
972 const char *fmtstring = NULL;
973 struct Hook *hook = NULL;
974
975 TAILQ_FOREACH(hook, hl, entries)
976 {
977 struct Pattern *pat = SLIST_FIRST(hook->pattern);
978 if ((mutt_pattern_exec(pat, 0, m, e, &cache) > 0) ^ hook->regex.pat_not)
979 {
980 fmtstring = hook->command;
981 break;
982 }
983 }
984
986
987 return fmtstring;
988}
bool mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition: exec.c:1127
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition: hash.c:362
static struct HashTable * IdxFmtHooks
All Index Format hooks.
Definition: hook.c:74
#define MUTT_IDXFMTHOOK
index-format-hook: customise the format of the index
Definition: hook.h:52
#define SLIST_FIRST(head)
Definition: queue.h:229
struct PatternList * pattern
Used for fcc,save,send-hook.
Definition: hook.c:65
Cache commonly-used patterns.
Definition: lib.h:117
A simple (non-regex) pattern.
Definition: lib.h:77
bool pat_not
do not match
Definition: regex3.h:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_message_hook()

void mutt_message_hook ( struct Mailbox m,
struct Email e,
HookFlags  type 
)

Perform a message hook.

Parameters
mMailbox
eEmail
typeHook type, see HookFlags

Definition at line 666 of file hook.c.

667{
668 struct Hook *hook = NULL;
669 struct PatternCache cache = { 0 };
670 struct Buffer *err = buf_pool_get();
671
672 CurrentHookType = type;
673
674 TAILQ_FOREACH(hook, &Hooks, entries)
675 {
676 if (!hook->command)
677 continue;
678
679 if (hook->type & type)
680 {
681 if ((mutt_pattern_exec(SLIST_FIRST(hook->pattern), 0, m, e, &cache) > 0) ^
682 hook->regex.pat_not)
683 {
684 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
685 {
686 mutt_error("%s", buf_string(err));
688 buf_pool_release(&err);
689
690 return;
691 }
692 /* Executing arbitrary commands could affect the pattern results,
693 * so the cache has to be wiped */
694 memset(&cache, 0, sizeof(cache));
695 }
696 }
697 }
698 buf_pool_release(&err);
699
701}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_select_fcc()

void mutt_select_fcc ( struct Buffer path,
struct Email e 
)

Select the FCC path for an email.

Parameters
pathBuffer for the path
eEmail

Definition at line 782 of file hook.c.

783{
784 buf_alloc(path, PATH_MAX);
785
786 if (addr_hook(path, MUTT_FCC_HOOK, NULL, e) != 0)
787 {
788 const struct Address *to = TAILQ_FIRST(&e->env->to);
789 const struct Address *cc = TAILQ_FIRST(&e->env->cc);
790 const struct Address *bcc = TAILQ_FIRST(&e->env->bcc);
791 const bool c_save_name = cs_subset_bool(NeoMutt->sub, "save_name");
792 const bool c_force_name = cs_subset_bool(NeoMutt->sub, "force_name");
793 const char *const c_record = cs_subset_string(NeoMutt->sub, "record");
794 if ((c_save_name || c_force_name) && (to || cc || bcc))
795 {
796 const struct Address *addr = to ? to : (cc ? cc : bcc);
797 struct Buffer *buf = buf_pool_get();
798 mutt_safe_path(buf, addr);
799 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
800 buf_concat_path(path, NONULL(c_folder), buf_string(buf));
801 buf_pool_release(&buf);
802 if (!c_force_name && (mx_access(buf_string(path), W_OK) != 0))
803 buf_strcpy(path, c_record);
804 }
805 else
806 {
807 buf_strcpy(path, c_record);
808 }
809 }
810 else
811 {
812 buf_fix_dptr(path);
813 }
814
815 buf_pretty_mailbox(path);
816}
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:194
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:407
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
Definition: buffer.c:484
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:349
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:292
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
#define MUTT_FCC_HOOK
fcc-hook: to save outgoing email
Definition: hook.h:40
#define PATH_MAX
Definition: mutt.h:41
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:556
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
Definition: mx.c:166
#define NONULL(x)
Definition: string2.h:37
struct AddressList bcc
Email's 'Bcc' list.
Definition: envelope.h:62
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_startup_shutdown_hook()

void mutt_startup_shutdown_hook ( HookFlags  type)

Execute any startup/shutdown hooks.

Parameters
typeHook 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 930 of file hook.c.

931{
932 struct Hook *hook = NULL;
933 struct Buffer err = buf_make(0);
934 char buf[256] = { 0 };
935
936 err.data = buf;
937 err.dsize = sizeof(buf);
938
939 TAILQ_FOREACH(hook, &Hooks, entries)
940 {
941 if (!(hook->command && (hook->type & type)))
942 continue;
943
944 if (parse_rc_line_cwd(hook->command, hook->source_file, &err) == MUTT_CMD_ERROR)
945 {
946 mutt_error("%s", err.data);
947 buf_reset(&err);
948 }
949 }
950}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:88
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:70
size_t dsize
Length of data.
Definition: buffer.h:37
char * data
Pointer to data.
Definition: buffer.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_timeout_hook()

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 898 of file hook.c.

899{
900 struct Hook *hook = NULL;
901 struct Buffer *err = buf_pool_get();
902
903 TAILQ_FOREACH(hook, &Hooks, entries)
904 {
905 if (!(hook->command && (hook->type & MUTT_TIMEOUT_HOOK)))
906 continue;
907
908 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
909 {
910 mutt_error("%s", buf_string(err));
911 buf_reset(err);
912
913 /* The hooks should be independent of each other, so even though this on
914 * failed, we'll carry on with the others. */
915 }
916 }
917 buf_pool_release(&err);
918
919 /* Delete temporary attachment files */
921}
#define MUTT_TIMEOUT_HOOK
timeout-hook: run a command periodically
Definition: hook.h:53
void mutt_temp_attachments_cleanup(void)
Delete all temporary attachments.
Definition: mutt_attach.c:1308
+ Here is the call graph for this function:
+ Here is the caller graph for this function: