From: Kevin McCarthy Date: Tue, 25 Jun 2019 21:25:33 +0000 (-0700) Subject: Convert Commands to use the union pointer_long_t too. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=793e0fc2c88a168cd551a749fb3dcc6998691f7e;p=mutt Convert Commands to use the union pointer_long_t too. As with MuttVars, Commands was using an unsigned long to hold pointers as well as enums. Convert to use the same union type of MuttVars. Adjust command functions data parameter type to the union. Since these are used outside init.c, relocate the union definition to mutt.h. Although the number of functions affected was long, most of them did not need much adjustment. Many of them made no use of the parameter. Those that did were easily cast into an added "data" variable at the top. --- diff --git a/buffy.c b/buffy.c index 2d80638e..6389f1f9 100644 --- a/buffy.c +++ b/buffy.c @@ -253,12 +253,13 @@ static void buffy_free (BUFFY **mailbox) FREE (mailbox); /* __FREE_CHECKED__ */ } -int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, union pointer_long_t udata, BUFFER *err) { BUFFY **tmp,*tmp1; struct stat sb; char f1[PATH_MAX]; char *p; + long data = udata.l; while (MoreArgs (s)) { diff --git a/color.c b/color.c index b527450d..c5fc9ce2 100644 --- a/color.c +++ b/color.c @@ -403,28 +403,26 @@ parse_color_name (const char *s, int *col, int *attr, int is_fg, BUFFER *err) */ static int -_mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err, - short parse_uncolor); +_mutt_parse_uncolor (BUFFER *buf, BUFFER *s, BUFFER *err, short parse_uncolor); #ifdef HAVE_COLOR -int mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, +int mutt_parse_uncolor (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { - return _mutt_parse_uncolor(buf, s, data, err, 1); + return _mutt_parse_uncolor(buf, s, err, 1); } #endif -int mutt_parse_unmono (BUFFER *buf, BUFFER *s, unsigned long data, +int mutt_parse_unmono (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { - return _mutt_parse_uncolor(buf, s, data, err, 0); + return _mutt_parse_uncolor(buf, s, err, 0); } -static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, - BUFFER *err, short parse_uncolor) +static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, BUFFER *err, short parse_uncolor) { int object = 0, is_index = 0, do_cache = 0; COLOR_LINE *tmp, *last = NULL; @@ -878,7 +876,7 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, #ifdef HAVE_COLOR -int mutt_parse_color(BUFFER *buff, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_color(BUFFER *buff, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int dry_run = 0; @@ -890,7 +888,7 @@ int mutt_parse_color(BUFFER *buff, BUFFER *s, unsigned long data, BUFFER *err) #endif -int mutt_parse_mono(BUFFER *buff, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_mono(BUFFER *buff, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int dry_run = 0; diff --git a/hook.c b/hook.c index aae37cbb..3b339d8d 100644 --- a/hook.c +++ b/hook.c @@ -48,7 +48,7 @@ static HASH *IdxFmtHooks = NULL; static int current_hook_type = 0; -int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { HOOK *ptr; BUFFER command, pattern; @@ -56,6 +56,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) regex_t *rx = NULL; pattern_t *pat = NULL; char path[_POSIX_PATH_MAX]; + long data = udata.l; mutt_buffer_init (&pattern); mutt_buffer_init (&command); @@ -289,12 +290,13 @@ static void delete_idxfmt_hooks (void) hash_destroy (&IdxFmtHooks, delete_idxfmt_hooklist); } -int mutt_parse_idxfmt_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_idxfmt_hook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { HOOK *hooks, *ptr; BUFFER *name, *pattern, *fmtstring; int rc = -1, not = 0; pattern_t *pat = NULL; + long data = udata.l; name = mutt_buffer_pool_get (); pattern = mutt_buffer_pool_get (); @@ -387,7 +389,7 @@ out: return rc; } -int mutt_parse_unhook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_unhook (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { while (MoreArgs (s)) { diff --git a/init.c b/init.c index 75bbaee8..1a2b933a 100644 --- a/init.c +++ b/init.c @@ -651,7 +651,7 @@ static mbchar_table *parse_mbchar_table (const char *s) return t; } -static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unignore (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { do { @@ -668,7 +668,7 @@ static int parse_unignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *e return 0; } -static int parse_ignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_ignore (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { do { @@ -681,19 +681,20 @@ static int parse_ignore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err return 0; } -static int parse_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { + LIST **data = udata.p; do { mutt_extract_token (buf, s, 0); - add_to_list ((LIST **) data, buf->data); + add_to_list (data, buf->data); } while (MoreArgs (s)); return 0; } -static int parse_echo (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_echo (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { if (!MoreArgs (s)) { @@ -719,7 +720,7 @@ static void _alternates_clean (void) } } -static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_alternates (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { group_context_t *gc = NULL; @@ -729,7 +730,7 @@ static int parse_alternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER { mutt_extract_token (buf, s, 0); - if (parse_group_context (&gc, buf, s, data, err) == -1) + if (parse_group_context (&gc, buf, s, err) == -1) goto bail; mutt_remove_from_rx_list (&UnAlternates, buf->data); @@ -750,7 +751,7 @@ bail: return -1; } -static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unalternates (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { _alternates_clean(); do @@ -768,9 +769,9 @@ static int parse_unalternates (BUFFER *buf, BUFFER *s, unsigned long data, BUFFE return 0; } -static int parse_replace_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_replace_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { - REPLACE_LIST **list = (REPLACE_LIST **)data; + REPLACE_LIST **list = (REPLACE_LIST **)udata.p; BUFFER templ; memset(&templ, 0, sizeof(templ)); @@ -801,9 +802,9 @@ static int parse_replace_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFE return 0; } -static int parse_unreplace_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unreplace_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { - REPLACE_LIST **list = (REPLACE_LIST **)data; + REPLACE_LIST **list = (REPLACE_LIST **)udata.p; /* First token is a regexp. */ if (!MoreArgs(s)) @@ -837,31 +838,32 @@ static void clear_subject_mods (void) } -static int parse_subjectrx_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_subjectrx_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int rc; - rc = parse_replace_list(buf, s, data, err); + rc = parse_replace_list(buf, s, udata, err); if (rc == 0) clear_subject_mods(); return rc; } -static int parse_unsubjectrx_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unsubjectrx_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int rc; - rc = parse_unreplace_list(buf, s, data, err); + rc = parse_unreplace_list(buf, s, udata, err); if (rc == 0) clear_subject_mods(); return rc; } -static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_spam_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { BUFFER templ; + long data = udata.l; mutt_buffer_init (&templ); @@ -934,8 +936,9 @@ static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER * } -static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unlist (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { + LIST **data = udata.p; do { mutt_extract_token (buf, s, 0); @@ -944,10 +947,10 @@ static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err */ if (mutt_strcmp (buf->data, "*") == 0) { - mutt_free_list ((LIST **) data); + mutt_free_list (data); break; } - remove_from_list ((LIST **) data, buf->data); + remove_from_list (data, buf->data); } while (MoreArgs (s)); @@ -960,25 +963,27 @@ static int parse_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err * is disabled. */ #ifdef USE_SIDEBAR -static int parse_path_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_path_list (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { char path[_POSIX_PATH_MAX]; + LIST **data = udata.p; do { mutt_extract_token (buf, s, 0); strfcpy (path, buf->data, sizeof (path)); mutt_expand_path (path, sizeof (path)); - add_to_list ((LIST **) data, path); + add_to_list (data, path); } while (MoreArgs (s)); return 0; } -static int parse_path_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_path_unlist (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { char path[_POSIX_PATH_MAX]; + LIST **data = udata.p; do { @@ -988,12 +993,12 @@ static int parse_path_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER */ if (mutt_strcmp (buf->data, "*") == 0) { - mutt_free_list ((LIST **) data); + mutt_free_list (data); break; } strfcpy (path, buf->data, sizeof (path)); mutt_expand_path (path, sizeof (path)); - remove_from_list ((LIST **) data, path); + remove_from_list (data, path); } while (MoreArgs (s)); @@ -1001,7 +1006,7 @@ static int parse_path_unlist (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER } #endif /* USE_SIDEBAR */ -static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_lists (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { group_context_t *gc = NULL; @@ -1009,7 +1014,7 @@ static int parse_lists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) { mutt_extract_token (buf, s, 0); - if (parse_group_context (&gc, buf, s, data, err) == -1) + if (parse_group_context (&gc, buf, s, err) == -1) goto bail; mutt_remove_from_rx_list (&UnMailLists, buf->data); @@ -1034,17 +1039,18 @@ typedef enum group_state_t { NONE, RX, ADDR } group_state_t; -static int parse_group (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_group (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { group_context_t *gc = NULL; group_state_t state = NONE; ADDRESS *addr = NULL; char *estr = NULL; + long data = udata.l; do { mutt_extract_token (buf, s, 0); - if (parse_group_context (&gc, buf, s, data, err) == -1) + if (parse_group_context (&gc, buf, s, err) == -1) goto bail; if (data == MUTT_UNGROUP && !mutt_strcasecmp (buf->data, "*")) @@ -1082,7 +1088,7 @@ static int parse_group (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) if (mutt_addrlist_to_intl (addr, &estr)) { snprintf (err->data, err->dsize, _("%sgroup: warning: bad IDN '%s'.\n"), - data == 1 ? "un" : "", estr); + data == MUTT_UNGROUP ? "un" : "", estr); FREE (&estr); rfc822_free_address (&addr); goto bail; @@ -1292,7 +1298,7 @@ static int print_attach_list (LIST *lp, char op, char *name) } -static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_attachments (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { char op, *category; LIST **listp; @@ -1348,7 +1354,7 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER return parse_attach_list(buf, s, listp, err); } -static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unattachments (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { char op, *p; LIST **listp; @@ -1390,7 +1396,7 @@ static int parse_unattachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFF return parse_unattach_list(buf, s, listp, err); } -static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unlists (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { hash_destroy (&AutoSubscribeCache, NULL); do @@ -1408,7 +1414,7 @@ static int parse_unlists (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er return 0; } -static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_subscribe (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { group_context_t *gc = NULL; @@ -1416,7 +1422,7 @@ static int parse_subscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER * { mutt_extract_token (buf, s, 0); - if (parse_group_context (&gc, buf, s, data, err) == -1) + if (parse_group_context (&gc, buf, s, err) == -1) goto bail; mutt_remove_from_rx_list (&UnMailLists, buf->data); @@ -1439,7 +1445,7 @@ bail: return -1; } -static int parse_unsubscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unsubscribe (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { hash_destroy (&AutoSubscribeCache, NULL); do @@ -1456,7 +1462,7 @@ static int parse_unsubscribe (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER return 0; } -static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_unalias (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { ALIAS *tmp, *last = NULL; @@ -1503,7 +1509,7 @@ static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er return 0; } -static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_alias (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { ALIAS *tmp = Aliases; ALIAS *last = NULL; @@ -1518,7 +1524,7 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) mutt_extract_token (buf, s, 0); - if (parse_group_context (&gc, buf, s, data, err) == -1) + if (parse_group_context (&gc, buf, s, err) == -1) return -1; /* check to see if an alias with this name already exists */ @@ -1594,7 +1600,7 @@ bail: } static int -parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +parse_unmy_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { LIST *last = NULL; LIST *tmp = UserHeader; @@ -1640,7 +1646,7 @@ parse_unmy_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) return 0; } -static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_my_hdr (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { LIST *tmp; size_t keylen; @@ -1982,11 +1988,12 @@ void mutt_envlist_set (const char *name, const char *value, int overwrite) } } -static int parse_setenv(BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_setenv(BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int query, unset, len; char *name, **save, **envp = envlist; int count = 0; + long data = udata.l; query = 0; unset = data & MUTT_SET_UNSET; @@ -2080,13 +2087,14 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) return 0; } -static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_set (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int query, unset, inv, reset, r = 0; int idx = -1; const char *p; char scratch[_POSIX_PATH_MAX]; char* myvar; + long data = udata.l; while (MoreArgs (s)) { @@ -2755,7 +2763,7 @@ static int source_rc (const char *rcfile, BUFFER *err) #undef MAXERRS -static int parse_source (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_source (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER *err) { char path[_POSIX_PATH_MAX]; @@ -3547,6 +3555,7 @@ void mutt_init (int skip_sys_rc, LIST *commands) if ((p = getenv ("REPLYTO")) != NULL) { BUFFER buf, token; + union pointer_long_t udata = {.l=0}; snprintf (buffer, sizeof (buffer), "Reply-To: %s", p); @@ -3555,7 +3564,7 @@ void mutt_init (int skip_sys_rc, LIST *commands) buf.dsize = mutt_strlen (buffer); mutt_buffer_init (&token); - parse_my_hdr (&token, &buf, 0, &err); + parse_my_hdr (&token, &buf, udata, &err); FREE (&token.data); } @@ -3692,11 +3701,11 @@ int mutt_get_hook_type (const char *name) for (c = Commands ; c->name ; c++) if ((c->func == mutt_parse_hook || c->func == mutt_parse_idxfmt_hook) && ascii_strcasecmp (c->name, name) == 0) - return c->data; + return c->data.l; return 0; } -static int parse_group_context (group_context_t **ctx, BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +static int parse_group_context (group_context_t **ctx, BUFFER *buf, BUFFER *s, BUFFER *err) { while (!mutt_strcasecmp (buf->data, "-group")) { diff --git a/init.h b/init.h index fd813b0c..7d530ef5 100644 --- a/init.h +++ b/init.h @@ -72,12 +72,6 @@ #define R_BOTH (R_INDEX | R_PAGER) #define R_RESORT_BOTH (R_RESORT | R_RESORT_SUB) -union pointer_long_t -{ - void *p; - long l; -}; - struct option_t { char *option; @@ -86,8 +80,6 @@ struct option_t union pointer_long_t data; union pointer_long_t init; /* initial value */ }; - -#define UL (unsigned long) #endif /* _MAKEDOC */ #ifndef ISPELL @@ -4328,133 +4320,133 @@ const struct mapping_t SortSidebarMethods[] = { /* functions used to parse commands in a rc file */ -static int parse_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_spam_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_spam_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unlist (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); #ifdef USE_SIDEBAR -static int parse_path_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_path_unlist (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_path_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_path_unlist (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); #endif /* USE_SIDEBAR */ -static int parse_group (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_group (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); -static int parse_lists (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_echo (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_set (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_setenv (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_my_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unmy_hdr (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_subscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unsubscribe (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_attachments (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unattachments (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_lists (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unlists (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_alias (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unalias (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_echo (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_ignore (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unignore (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_source (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_set (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_setenv (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_my_hdr (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unmy_hdr (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_subscribe (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unsubscribe (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_attachments (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unattachments (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); -static int parse_replace_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unreplace_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_subjectrx_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unsubjectrx_list (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_alternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); -static int parse_unalternates (BUFFER *, BUFFER *, unsigned long, BUFFER *); +static int parse_replace_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unreplace_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_subjectrx_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unsubjectrx_list (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_alternates (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +static int parse_unalternates (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); /* Parse -group arguments */ -static int parse_group_context (group_context_t **ctx, BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err); +static int parse_group_context (group_context_t **ctx, BUFFER *buf, BUFFER *s, BUFFER *err); struct command_t { char *name; - int (*func) (BUFFER *, BUFFER *, unsigned long, BUFFER *); - unsigned long data; + int (*func) (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); + union pointer_long_t data; }; const struct command_t Commands[] = { - { "alternates", parse_alternates, 0 }, - { "unalternates", parse_unalternates, 0 }, + { "alternates", parse_alternates, {.l=0} }, + { "unalternates", parse_unalternates, {.l=0} }, #ifdef USE_SOCKET - { "account-hook", mutt_parse_hook, MUTT_ACCOUNTHOOK }, + { "account-hook", mutt_parse_hook, {.l=MUTT_ACCOUNTHOOK} }, #endif - { "alias", parse_alias, 0 }, - { "attachments", parse_attachments, 0 }, - { "unattachments",parse_unattachments,0 }, - { "auto_view", parse_list, UL &AutoViewList }, - { "alternative_order", parse_list, UL &AlternativeOrderList}, - { "bind", mutt_parse_bind, 0 }, - { "charset-hook", mutt_parse_hook, MUTT_CHARSETHOOK }, + { "alias", parse_alias, {.l=0} }, + { "attachments", parse_attachments, {.l=0} }, + { "unattachments", parse_unattachments, {.l=0} }, + { "auto_view", parse_list, {.p=&AutoViewList} }, + { "alternative_order", parse_list, {.p=&AlternativeOrderList} }, + { "bind", mutt_parse_bind, {.l=0} }, + { "charset-hook", mutt_parse_hook, {.l=MUTT_CHARSETHOOK} }, #ifdef HAVE_COLOR - { "color", mutt_parse_color, 0 }, - { "uncolor", mutt_parse_uncolor, 0 }, + { "color", mutt_parse_color, {.l=0} }, + { "uncolor", mutt_parse_uncolor, {.l=0} }, #endif - { "echo", parse_echo, 0 }, - { "exec", mutt_parse_exec, 0 }, - { "fcc-hook", mutt_parse_hook, MUTT_FCCHOOK }, - { "fcc-save-hook", mutt_parse_hook, MUTT_FCCHOOK | MUTT_SAVEHOOK }, - { "folder-hook", mutt_parse_hook, MUTT_FOLDERHOOK }, + { "echo", parse_echo, {.l=0} }, + { "exec", mutt_parse_exec, {.l=0} }, + { "fcc-hook", mutt_parse_hook, {.l=MUTT_FCCHOOK} }, + { "fcc-save-hook", mutt_parse_hook, {.l=MUTT_FCCHOOK | MUTT_SAVEHOOK} }, + { "folder-hook", mutt_parse_hook, {.l=MUTT_FOLDERHOOK} }, #ifdef USE_COMPRESSED - { "open-hook", mutt_parse_hook, MUTT_OPENHOOK }, - { "close-hook", mutt_parse_hook, MUTT_CLOSEHOOK }, - { "append-hook", mutt_parse_hook, MUTT_APPENDHOOK }, + { "open-hook", mutt_parse_hook, {.l=MUTT_OPENHOOK} }, + { "close-hook", mutt_parse_hook, {.l=MUTT_CLOSEHOOK} }, + { "append-hook", mutt_parse_hook, {.l=MUTT_APPENDHOOK} }, #endif - { "group", parse_group, MUTT_GROUP }, - { "ungroup", parse_group, MUTT_UNGROUP }, - { "hdr_order", parse_list, UL &HeaderOrderList }, + { "group", parse_group, {.l=MUTT_GROUP} }, + { "ungroup", parse_group, {.l=MUTT_UNGROUP} }, + { "hdr_order", parse_list, {.p=&HeaderOrderList} }, #ifdef HAVE_ICONV - { "iconv-hook", mutt_parse_hook, MUTT_ICONVHOOK }, + { "iconv-hook", mutt_parse_hook, {.l=MUTT_ICONVHOOK} }, #endif - { "ignore", parse_ignore, 0 }, - { "index-format-hook",mutt_parse_idxfmt_hook, MUTT_IDXFMTHOOK }, - { "lists", parse_lists, 0 }, - { "macro", mutt_parse_macro, 0 }, - { "mailboxes", mutt_parse_mailboxes, MUTT_MAILBOXES }, - { "unmailboxes", mutt_parse_mailboxes, MUTT_UNMAILBOXES }, - { "mailto_allow", parse_list, UL &MailtoAllow }, - { "unmailto_allow", parse_unlist, UL &MailtoAllow }, - { "message-hook", mutt_parse_hook, MUTT_MESSAGEHOOK }, - { "mbox-hook", mutt_parse_hook, MUTT_MBOXHOOK }, - { "mime_lookup", parse_list, UL &MimeLookupList }, - { "unmime_lookup", parse_unlist, UL &MimeLookupList }, - { "mono", mutt_parse_mono, 0 }, - { "my_hdr", parse_my_hdr, 0 }, - { "pgp-hook", mutt_parse_hook, MUTT_CRYPTHOOK }, - { "crypt-hook", mutt_parse_hook, MUTT_CRYPTHOOK }, - { "push", mutt_parse_push, 0 }, - { "reply-hook", mutt_parse_hook, MUTT_REPLYHOOK }, - { "reset", parse_set, MUTT_SET_RESET }, - { "save-hook", mutt_parse_hook, MUTT_SAVEHOOK }, - { "score", mutt_parse_score, 0 }, - { "send-hook", mutt_parse_hook, MUTT_SENDHOOK }, - { "send2-hook", mutt_parse_hook, MUTT_SEND2HOOK }, - { "set", parse_set, 0 }, - { "setenv", parse_setenv, 0 }, + { "ignore", parse_ignore, {.l=0} }, + { "index-format-hook",mutt_parse_idxfmt_hook, {.l=MUTT_IDXFMTHOOK} }, + { "lists", parse_lists, {.l=0} }, + { "macro", mutt_parse_macro, {.l=0} }, + { "mailboxes", mutt_parse_mailboxes, {.l=MUTT_MAILBOXES} }, + { "unmailboxes", mutt_parse_mailboxes, {.l=MUTT_UNMAILBOXES} }, + { "mailto_allow", parse_list, {.p=&MailtoAllow} }, + { "unmailto_allow", parse_unlist, {.p=&MailtoAllow} }, + { "message-hook", mutt_parse_hook, {.l=MUTT_MESSAGEHOOK} }, + { "mbox-hook", mutt_parse_hook, {.l=MUTT_MBOXHOOK} }, + { "mime_lookup", parse_list, {.p=&MimeLookupList} }, + { "unmime_lookup", parse_unlist, {.p=&MimeLookupList} }, + { "mono", mutt_parse_mono, {.l=0} }, + { "my_hdr", parse_my_hdr, {.l=0} }, + { "pgp-hook", mutt_parse_hook, {.l=MUTT_CRYPTHOOK} }, + { "crypt-hook", mutt_parse_hook, {.l=MUTT_CRYPTHOOK} }, + { "push", mutt_parse_push, {.l=0} }, + { "reply-hook", mutt_parse_hook, {.l=MUTT_REPLYHOOK} }, + { "reset", parse_set, {.l=MUTT_SET_RESET} }, + { "save-hook", mutt_parse_hook, {.l=MUTT_SAVEHOOK} }, + { "score", mutt_parse_score, {.l=0} }, + { "send-hook", mutt_parse_hook, {.l=MUTT_SENDHOOK} }, + { "send2-hook", mutt_parse_hook, {.l=MUTT_SEND2HOOK} }, + { "set", parse_set, {.l=0} }, + { "setenv", parse_setenv, {.l=0} }, #ifdef USE_SIDEBAR - { "sidebar_whitelist",parse_path_list, UL &SidebarWhitelist }, - { "unsidebar_whitelist",parse_path_unlist, UL &SidebarWhitelist }, + { "sidebar_whitelist",parse_path_list, {.p=&SidebarWhitelist} }, + { "unsidebar_whitelist",parse_path_unlist, {.p=&SidebarWhitelist} }, #endif - { "source", parse_source, 0 }, - { "spam", parse_spam_list, MUTT_SPAM }, - { "nospam", parse_spam_list, MUTT_NOSPAM }, - { "subscribe", parse_subscribe, 0 }, - { "subjectrx", parse_subjectrx_list, UL &SubjectRxList }, - { "unsubjectrx", parse_unsubjectrx_list, UL &SubjectRxList }, - { "toggle", parse_set, MUTT_SET_INV }, - { "unalias", parse_unalias, 0 }, - { "unalternative_order",parse_unlist, UL &AlternativeOrderList }, - { "unauto_view", parse_unlist, UL &AutoViewList }, - { "unhdr_order", parse_unlist, UL &HeaderOrderList }, - { "unhook", mutt_parse_unhook, 0 }, - { "unignore", parse_unignore, 0 }, - { "unlists", parse_unlists, 0 }, - { "unmono", mutt_parse_unmono, 0 }, - { "unmy_hdr", parse_unmy_hdr, 0 }, - { "unscore", mutt_parse_unscore, 0 }, - { "unset", parse_set, MUTT_SET_UNSET }, - { "unsetenv", parse_setenv, MUTT_SET_UNSET }, - { "unsubscribe", parse_unsubscribe, 0 }, - { NULL, NULL, 0 } + { "source", parse_source, {.l=0} }, + { "spam", parse_spam_list, {.l=MUTT_SPAM} }, + { "nospam", parse_spam_list, {.l=MUTT_NOSPAM} }, + { "subscribe", parse_subscribe, {.l=0} }, + { "subjectrx", parse_subjectrx_list, {.p=&SubjectRxList} }, + { "unsubjectrx", parse_unsubjectrx_list, {.p=&SubjectRxList} }, + { "toggle", parse_set, {.l=MUTT_SET_INV} }, + { "unalias", parse_unalias, {.l=0} }, + { "unalternative_order",parse_unlist, {.p=&AlternativeOrderList} }, + { "unauto_view", parse_unlist, {.p=&AutoViewList} }, + { "unhdr_order", parse_unlist, {.p=&HeaderOrderList} }, + { "unhook", mutt_parse_unhook, {.l=0} }, + { "unignore", parse_unignore, {.l=0} }, + { "unlists", parse_unlists, {.l=0} }, + { "unmono", mutt_parse_unmono, {.l=0} }, + { "unmy_hdr", parse_unmy_hdr, {.l=0} }, + { "unscore", mutt_parse_unscore, {.l=0} }, + { "unset", parse_set, {.l=MUTT_SET_UNSET} }, + { "unsetenv", parse_setenv, {.l=MUTT_SET_UNSET} }, + { "unsubscribe", parse_unsubscribe, {.l=0} }, + { NULL, NULL, {.l=0} } }; diff --git a/keymap.c b/keymap.c index 2d1e7c03..adea4224 100644 --- a/keymap.c +++ b/keymap.c @@ -897,7 +897,7 @@ void km_error_key (int menu) return; } -int mutt_parse_push (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_push (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int r = 0; @@ -1022,7 +1022,7 @@ const struct binding_t *km_get_table (int menu) } /* bind menu-name '' function-name */ -int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_bind (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { const struct binding_t *bindings = NULL; char *key; @@ -1070,7 +1070,7 @@ int mutt_parse_bind (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) } /* macro */ -int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_macro (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int menu[sizeof(Menus)/sizeof(struct mapping_t)-1], r = -1, nummenus, i; char *seq = NULL; @@ -1121,7 +1121,7 @@ int mutt_parse_macro (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) } /* exec function-name */ -int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_exec (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { int ops[128]; int nops = 0; diff --git a/mutt.h b/mutt.h index 46302cca..dcc3a2f1 100644 --- a/mutt.h +++ b/mutt.h @@ -289,7 +289,14 @@ enum MUTT_SAVE_OVERWRITE }; +/* used by init.h MuttVars and Commands dispatch functions */ /* possible arguments to set_quadoption() */ +union pointer_long_t +{ + void *p; + long l; +}; + enum { MUTT_NO, diff --git a/protos.h b/protos.h index 14e32f41..02829bf2 100644 --- a/protos.h +++ b/protos.h @@ -354,23 +354,23 @@ int mutt_messages_in_thread (CONTEXT *, HEADER *, int); int mutt_multi_choice (char *prompt, char *letters); int mutt_needs_mailcap (BODY *); int mutt_num_postponed (int); -int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_hook (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_idxfmt_hook (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_macro (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_mailboxes (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_mono (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_push (BUFFER *, BUFFER *, unsigned long, BUFFER *); +int mutt_parse_bind (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_exec (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_color (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_uncolor (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_hook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_idxfmt_hook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_macro (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_mailboxes (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_mono (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_unmono (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_push (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); int mutt_parse_rc_line (/* const */ char *, BUFFER *, BUFFER *); int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short user_hdrs, short weed, short do_2047, LIST **lastp); -int mutt_parse_score (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_unscore (BUFFER *, BUFFER *, unsigned long, BUFFER *); -int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *); +int mutt_parse_score (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_unscore (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); +int mutt_parse_unhook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); int mutt_pattern_func (int, char *); int mutt_pipe_attachment (FILE *, BODY *, const char *, char *); int mutt_print_attachment (FILE *, BODY *); diff --git a/score.c b/score.c index 4f164e1d..06669474 100644 --- a/score.c +++ b/score.c @@ -64,7 +64,7 @@ void mutt_check_rescore (CONTEXT *ctx) unset_option (OPTNEEDRESCORE); } -int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_score (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { SCORE *ptr, *last; char *pattern, *pc; @@ -158,7 +158,7 @@ void mutt_score_message (CONTEXT *ctx, HEADER *hdr, int upd_ctx) _mutt_set_flag (ctx, hdr, MUTT_FLAG, 1, upd_ctx); } -int mutt_parse_unscore (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +int mutt_parse_unscore (BUFFER *buf, BUFFER *s, union pointer_long_t udata, BUFFER *err) { SCORE *tmp, *last = NULL;