From: Richard Russon Date: Sun, 7 May 2017 00:54:44 +0000 (+0100) Subject: build: split up mutt.h, protos.h X-Git-Tag: neomutt-20170526~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c186684a8133690e0969aa4cc9b69cef0906a510;p=neomutt build: split up mutt.h, protos.h Move various structs out of mutt.h into their own header files. Then run IWYU (include-what-you-use) on all files. --- diff --git a/Makefile.am b/Makefile.am index c6987ad05..c0a8313a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,19 +35,21 @@ BUILT_SOURCES = keymap_defs.h keymap_alldefs.h git_ver.h conststrings.c bin_PROGRAMS = mutt $(DOTLOCK_TARGET) $(PGPAUX_TARGET) -mutt_SOURCES = account.c addrbook.c alias.c ascii.c attach.c base64.c bcache.c \ - browser.c buffer.c buffy.c charset.c color.c commands.c \ - complete.c compose.c compress.c copy.c crypt_mod.c crypt_mod.h \ - crypt.c cryptglue.c curs_lib.c curs_main.c date.c edit.c \ - editmsg.c enter.c filter.c flags.c from.c getdomain.c group.c \ - handler.c hash.c hdrline.c headers.c help.c history.c hook.c \ - init.c keymap.c lib.c main.c mbox.c mbyte.c md5.c menu.c mh.c \ - muttlib.c mutt_idna.c mutt_sasl_plain.c mutt_socket.c \ - mutt_tunnel.c mx.c newsrc.c nntp.c pager.c parse.c pattern.c \ - pop.c pop_auth.c pop_lib.c postpone.c query.c recvattach.c \ - recvcmd.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c rfc822.c \ - safe_asprintf.c score.c send.c sendlib.c sidebar.c signal.c \ - smtp.c sort.c status.c system.c thread.c url.c version.c +mutt_SOURCES = account.c addrbook.c address.h alias.c alias.h ascii.c attach.c \ + base64.c bcache.c body.h browser.c buffer.c buffy.c charset.c color.c \ + commands.c complete.c compose.c compress.c content.h context.h copy.c \ + crypt.c cryptglue.c crypt_mod.c crypt_mod.h curs_lib.c curs_main.c \ + date.c edit.c editmsg.c enter.c enter_state.h envelope.h filter.c \ + flags.c format_flags.h from.c getdomain.c group.c handler.c hash.c \ + hdrline.c header.h headers.c help.c history.c hook.c init.c keymap.c \ + lib.c list.h main.c mbox.c mbyte.c mbyte_table.h md5.c menu.c mh.c \ + muttlib.c mutt_idna.c mutt_sasl_plain.c mutt_socket.c \ + mutt_tunnel.c mx.c newsrc.c nntp.c options.h pager.c parameter.h \ + parse.c pattern.c pattern.h pop.c pop_auth.c pop_lib.c postpone.c \ + query.c recvattach.c recvcmd.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ + rfc822.c safe_asprintf.c score.c send.c sendlib.c sidebar.c signal.c \ + smtp.c sort.c state.h status.c system.c thread.c thread.h url.c \ + version.c where.h nodist_mutt_SOURCES = $(BUILT_SOURCES) diff --git a/account.c b/account.c index 2b160783a..01cfc6bc9 100644 --- a/account.c +++ b/account.c @@ -18,8 +18,15 @@ /* remote host account manipulation (POP/IMAP) */ #include "config.h" +#include +#include #include "mutt.h" #include "account.h" +#include "ascii.h" +#include "globals.h" +#include "lib.h" +#include "options.h" +#include "protos.h" #include "url.h" /* mutt_account_match: compare account info (host/port/user) */ diff --git a/account.h b/account.h index 4a2c323e1..22aad95d1 100644 --- a/account.h +++ b/account.h @@ -20,7 +20,7 @@ #ifndef _MUTT_ACCOUNT_H #define _MUTT_ACCOUNT_H 1 -#include "url.h" +struct CissUrl; /* account types */ enum diff --git a/addrbook.c b/addrbook.c index a5cf16932..3d687a0f9 100644 --- a/addrbook.c +++ b/addrbook.c @@ -16,13 +16,23 @@ */ #include "config.h" -#include +#include +#include #include -#include -#include "mutt.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "format_flags.h" +#include "globals.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mapping.h" -#include "mutt_idna.h" +#include "mutt_curses.h" #include "mutt_menu.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" #define RSORT(x) (SortAlias & SORT_REVERSE) ? -x : x diff --git a/address.h b/address.h new file mode 100644 index 000000000..b303cd69a --- /dev/null +++ b/address.h @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_ADDRESS_H +#define _MUTT_ADDRESS_H 1 + +#include + +struct Address +{ +#ifdef EXACT_ADDRESS + char *val; /* value of address as parsed */ +#endif + char *personal; /* real name of address */ + char *mailbox; /* mailbox and host address */ + int group; /* group mailbox? */ + struct Address *next; + bool is_intl : 1; + bool intl_checked : 1; +}; + +#endif /* _MUTT_ADDRESS_H */ diff --git a/alias.c b/alias.c index f8207bbce..6c58647be 100644 --- a/alias.c +++ b/alias.c @@ -16,15 +16,30 @@ */ #include "config.h" -#include +#include #include +#include +#include +#include +#include #include +#include +#include #include "mutt.h" +#include "alias.h" +#include "address.h" +#include "ascii.h" +#include "charset.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "lib.h" +#include "list.h" #include "mutt_curses.h" #include "mutt_idna.h" -#include "mutt_regex.h" - -int mutt_check_alias_name(const char *s, char *dest, size_t destlen); +#include "options.h" +#include "protos.h" +#include "rfc822.h" struct Address *mutt_lookup_alias(const char *s) { @@ -222,6 +237,50 @@ static void recode_buf(char *buf, size_t buflen) FREE(&s); } +/* + * Sanity-check an alias name: Only characters which are non-special to both + * the RFC 822 and the mutt configuration parser are permitted. + */ +int check_alias_name(const char *s, char *dest, size_t destlen) +{ + wchar_t wc; + mbstate_t mb; + size_t l; + int rv = 0, bad = 0, dry = !dest || !destlen; + + memset(&mb, 0, sizeof(mbstate_t)); + + if (!dry) + destlen--; + for (; s && *s && (dry || destlen) && (l = mbrtowc(&wc, s, MB_CUR_MAX, &mb)) != 0; + s += l, destlen -= l) + { + bad = l == (size_t)(-1) || l == (size_t)(-2); /* conversion error */ + bad = bad || (!dry && l > destlen); /* too few room for mb char */ + if (l == 1) + bad = bad || (strchr("-_+=.", *s) == NULL && !iswalnum(wc)); + else + bad = bad || !iswalnum(wc); + if (bad) + { + if (dry) + return -1; + if (l == (size_t)(-1)) + memset(&mb, 0, sizeof(mbstate_t)); + *dest++ = '_'; + rv = -1; + } + else if (!dry) + { + memcpy(dest, s, l); + dest += l; + } + } + if (!dry) + *dest = 0; + return rv; +} + void mutt_create_alias(struct Envelope *cur, struct Address *iadr) { struct Alias *new = NULL, *t = NULL; @@ -250,7 +309,7 @@ void mutt_create_alias(struct Envelope *cur, struct Address *iadr) tmp[0] = '\0'; /* Don't suggest a bad alias name in the event of a strange local part. */ - mutt_check_alias_name(tmp, buf, sizeof(buf)); + check_alias_name(tmp, buf, sizeof(buf)); retry_name: /* L10N: prompt to add a new alias */ @@ -264,7 +323,7 @@ retry_name: return; } - if (mutt_check_alias_name(buf, fixed, sizeof(fixed))) + if (check_alias_name(buf, fixed, sizeof(fixed))) { switch (mutt_yesorno(_("Warning: This alias name may not work. Fix it?"), MUTT_YES)) { @@ -364,7 +423,7 @@ retry_name: fputc('\n', rc); } - if (mutt_check_alias_name(new->name, NULL, 0)) + if (check_alias_name(new->name, NULL, 0)) mutt_quote_filename(buf, sizeof(buf), new->name); else strfcpy(buf, new->name, sizeof(buf)); @@ -391,50 +450,6 @@ fseek_err: return; } -/* - * Sanity-check an alias name: Only characters which are non-special to both - * the RFC 822 and the mutt configuration parser are permitted. - */ -int mutt_check_alias_name(const char *s, char *dest, size_t destlen) -{ - wchar_t wc; - mbstate_t mb; - size_t l; - int rv = 0, bad = 0, dry = !dest || !destlen; - - memset(&mb, 0, sizeof(mbstate_t)); - - if (!dry) - destlen--; - for (; s && *s && (dry || destlen) && (l = mbrtowc(&wc, s, MB_CUR_MAX, &mb)) != 0; - s += l, destlen -= l) - { - bad = l == (size_t)(-1) || l == (size_t)(-2); /* conversion error */ - bad = bad || (!dry && l > destlen); /* too few room for mb char */ - if (l == 1) - bad = bad || (strchr("-_+=.", *s) == NULL && !iswalnum(wc)); - else - bad = bad || !iswalnum(wc); - if (bad) - { - if (dry) - return -1; - if (l == (size_t)(-1)) - memset(&mb, 0, sizeof(mbstate_t)); - *dest++ = '_'; - rv = -1; - } - else if (!dry) - { - memcpy(dest, s, l); - dest += l; - } - } - if (!dry) - *dest = 0; - return rv; -} - /* * This routine looks to see if the user has an alias defined for the given * address. diff --git a/alias.h b/alias.h new file mode 100644 index 000000000..46480c688 --- /dev/null +++ b/alias.h @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_ALIAS_H +#define _MUTT_ALIAS_H 1 + +#include + +struct Envelope; +struct Address; + +struct Alias +{ + struct Alias *self; /* XXX - ugly hack */ + char *name; + struct Address *addr; + struct Alias *next; + bool tagged; + bool del; + short num; +}; + +struct Address *mutt_lookup_alias(const char *s); +struct Address *mutt_expand_aliases(struct Address *a); +void mutt_expand_aliases_env(struct Envelope *env); +struct Address *mutt_get_address(struct Envelope *env, char **pfxp); +void mutt_create_alias(struct Envelope *cur, struct Address *iadr); + +#endif /* _MUTT_ALIAS_H */ diff --git a/ascii.c b/ascii.c index d4bec6a07..89442f992 100644 --- a/ascii.c +++ b/ascii.c @@ -23,7 +23,6 @@ #include "config.h" #include -#include #include "ascii.h" int ascii_strcasecmp(const char *a, const char *b) diff --git a/attach.c b/attach.c index 5ed0ddcaa..339c24f9d 100644 --- a/attach.c +++ b/attach.c @@ -17,27 +17,33 @@ */ #include "config.h" -#include #include #include -#include +#include #include #include -#include #include #include "mutt.h" #include "attach.h" +#include "ascii.h" +#include "body.h" +#include "context.h" #include "copy.h" #include "filter.h" -#include "keymap.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" -#include "mutt_menu.h" #include "mx.h" +#include "options.h" #include "pager.h" +#include "protos.h" #include "rfc1524.h" +#include "state.h" int mutt_get_tmp_attachment(struct Body *a) { diff --git a/attach.h b/attach.h index 2c541200e..6a40bd0e1 100644 --- a/attach.h +++ b/attach.h @@ -20,7 +20,12 @@ #ifndef _MUTT_ATTACH_H #define _MUTT_ATTACH_H 1 -#include "mutt_menu.h" +#include +#include + +struct Menu; +struct Header; +struct Body; struct AttachPtr { diff --git a/base64.c b/base64.c index 3fe249886..10d6eadf9 100644 --- a/base64.c +++ b/base64.c @@ -35,7 +35,7 @@ */ #include "config.h" -#include "mutt.h" +#include #include "mime.h" #define BAD -1 diff --git a/bcache.c b/bcache.c index 10041a7eb..1fe7400bc 100644 --- a/bcache.c +++ b/bcache.c @@ -19,13 +19,16 @@ #include "config.h" #include #include +#include #include +#include #include -#include -#include "mutt.h" +#include #include "bcache.h" #include "account.h" +#include "globals.h" #include "lib.h" +#include "protos.h" #include "url.h" static int mutt_bcache_move(struct BodyCache *bcache, const char *id, const char *newid); diff --git a/bcache.h b/bcache.h index 4b2bebb19..cb1ef605a 100644 --- a/bcache.h +++ b/bcache.h @@ -19,12 +19,9 @@ #ifndef _MUTT_BCACHE_H #define _MUTT_BCACHE_H 1 -#include "account.h" - -/* - * support for body cache - */ +#include +struct Account; struct BodyCache; /* diff --git a/body.h b/body.h new file mode 100644 index 000000000..bc9d918de --- /dev/null +++ b/body.h @@ -0,0 +1,102 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_BODY_H +#define _MUTT_BODY_H 1 + +#include +#include +#include + +struct Body +{ + char *xtype; /* content-type if x-unknown */ + char *subtype; /* content-type subtype */ + struct Parameter *parameter; /* parameters of the content-type */ + char *description; /* content-description */ + char *form_name; /* Content-Disposition form-data name param */ + long hdr_offset; /* offset in stream where the headers begin. + * this info is used when invoking metamail, + * where we need to send the headers of the + * attachment + */ + LOFF_T offset; /* offset where the actual data begins */ + LOFF_T length; /* length (in bytes) of attachment */ + char *filename; /* when sending a message, this is the file + * to which this structure refers + */ + char *d_filename; /* filename to be used for the + * content-disposition header. + * If NULL, filename is used + * instead. + */ + char *charset; /* charset of attached file */ + struct Content *content; /* structure used to store detailed info about + * the content of the attachment. this is used + * to determine what content-transfer-encoding + * is required when sending mail. + */ + struct Body *next; /* next attachment in the list */ + struct Body *parts; /* parts of a multipart or message/rfc822 */ + struct Header *hdr; /* header information for message/rfc822 */ + + struct AttachPtr *aptr; /* Menu information, used in recvattach.c */ + + signed short attach_count; + + time_t stamp; /* time stamp of last + * encoding update. + */ + + unsigned int type : 4; /* content-type primary type */ + unsigned int encoding : 3; /* content-transfer-encoding */ + unsigned int disposition : 2; /* content-disposition */ + bool use_disp : 1; /* Content-Disposition uses filename= ? */ + bool unlink : 1; /* flag to indicate the file named by + * "filename" should be unlink()ed before + * free()ing this structure + */ + bool tagged : 1; + bool deleted : 1; /* attachment marked for deletion */ + + bool noconv : 1; /* don't do character set conversion */ + bool force_charset : 1; + /* send mode: don't adjust the character + * set when in send-mode. + */ + bool is_signed_data : 1; /* A lot of MUAs don't indicate + S/MIME signed-data correctly, + e.g. they use foo.p7m even for + the name of signed data. This + flag is used to keep track of + the actual message type. It + gets set during the verification + (which is done if the encryption + try failed) and check by the + function to figure the type of + the message. */ + + bool goodsig : 1; /* good cryptographic signature */ + bool warnsig : 1; /* maybe good signature */ + bool badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */ + + bool collapsed : 1; /* used by recvattach */ + bool attach_qualifies : 1; + +}; + +#endif /* _MUTT_BODY_H */ diff --git a/browser.c b/browser.c index 5891bef5c..8f03f6500 100644 --- a/browser.c +++ b/browser.c @@ -19,21 +19,43 @@ #include #include #include +#include +#include +#include #include +#include +#include +#include +#include #include #include #include +#include #include #include "mutt.h" #include "browser.h" +#include "account.h" #include "attach.h" #include "buffy.h" +#include "charset.h" +#include "context.h" +#include "format_flags.h" +#include "globals.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mailbox.h" #include "mapping.h" +#include "mbyte.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_regex.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" +#include "url.h" #ifdef USE_IMAP #include "imap/imap.h" #endif diff --git a/browser.h b/browser.h index 029db3f1d..5b608f378 100644 --- a/browser.h +++ b/browser.h @@ -18,9 +18,9 @@ #ifndef _MUTT_BROWSER_H #define _MUTT_BROWSER_H 1 -#ifdef USE_NNTP -#include "nntp.h" -#endif +#include +#include +#include struct folder_file { diff --git a/buffer.c b/buffer.c index f418445f8..2627587a9 100644 --- a/buffer.c +++ b/buffer.c @@ -13,10 +13,13 @@ * this program. If not, see . */ +#include "config.h" +#include #include #include #include #include +#include #include "buffer.h" #include "filter.h" #include "lib.h" diff --git a/buffer.h b/buffer.h index b73fd67b6..57d57c0b0 100644 --- a/buffer.h +++ b/buffer.h @@ -16,7 +16,7 @@ #ifndef _MUTT_BUFFER_H #define _MUTT_BUFFER_H 1 -#include +#include struct Buffer { diff --git a/buffy.c b/buffy.c index e4768cff4..73bee2ed2 100644 --- a/buffy.c +++ b/buffy.c @@ -17,19 +17,25 @@ */ #include "config.h" -#include #include +#include #include +#include #include #include -#include #include -#include "mutt.h" #include "buffy.h" +#include "buffer.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mailbox.h" #include "mutt_curses.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" +#include "protos.h" #ifdef USE_SIDEBAR #include "sidebar.h" #endif diff --git a/buffy.h b/buffy.h index f69678c88..a6dfd2bd8 100644 --- a/buffy.h +++ b/buffy.h @@ -18,6 +18,14 @@ #ifndef _MUTT_BUFFY_H #define _MUTT_BUFFY_H 1 +#include +#include +#include +#include +#include "where.h" + +struct stat; + /* parameter to mutt_parse_mailboxes */ #define MUTT_MAILBOXES 1 #define MUTT_UNMAILBOXES 2 diff --git a/charset.c b/charset.c index ccf06ceef..f4ff183e1 100644 --- a/charset.c +++ b/charset.c @@ -17,16 +17,17 @@ #include "config.h" #include -#include #include #include +#include #include -#include #include -#include -#include #include "mutt.h" #include "charset.h" +#include "ascii.h" +#include "globals.h" +#include "lib.h" +#include "protos.h" #ifndef EILSEQ #define EILSEQ EINVAL diff --git a/color.c b/color.c index 684eccc9d..e04271127 100644 --- a/color.c +++ b/color.c @@ -16,13 +16,26 @@ */ #include "config.h" -#include +#include +#include +#include #include #include #include "mutt.h" +#include "ascii.h" +#include "buffer.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "lib.h" #include "mapping.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_regex.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" /* globals */ int *ColorQuote; diff --git a/commands.c b/commands.c index 40b1e7893..e6869a3f8 100644 --- a/commands.c +++ b/commands.c @@ -19,19 +19,29 @@ #include "config.h" #include #include -#include +#include +#include +#include +#include #include #include -#include -#include #include -#include #include -#include #include "mutt.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "buffer.h" #include "buffy.h" +#include "context.h" #include "copy.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "lib.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" @@ -39,7 +49,11 @@ #include "mutt_idna.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" #include "pager.h" +#include "parameter.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" #ifdef USE_IMAP #include "imap/imap.h" diff --git a/complete.c b/complete.c index 3f3a976b6..2e3502b27 100644 --- a/complete.c +++ b/complete.c @@ -18,10 +18,13 @@ #include "config.h" #include #include +#include #include #include -#include -#include "mutt.h" +#include "globals.h" +#include "lib.h" +#include "options.h" +#include "protos.h" #ifdef USE_IMAP #include "imap/imap.h" #include "mailbox.h" diff --git a/compose.c b/compose.c index 71047576a..d9680b1d4 100644 --- a/compose.c +++ b/compose.c @@ -18,22 +18,40 @@ #include "config.h" #include -#include +#include +#include +#include +#include #include #include -#include #include #include "mutt.h" +#include "alias.h" #include "attach.h" -#include "charset.h" +#include "body.h" +#include "content.h" +#include "context.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mapping.h" #include "mime.h" +#include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" #include "mutt_menu.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "rfc1524.h" +#include "rfc822.h" #include "sort.h" #ifdef MIXMASTER #include "remailer.h" @@ -42,6 +60,8 @@ #include "nntp.h" #endif +struct Address; + static const char *There_are_no_attachments = N_("There are no attachments."); #define CHECK_COUNT \ @@ -126,9 +146,6 @@ static void snd_entry(char *b, size_t blen, struct Menu *menu, int num) MUTT_FORMAT_STAT_FILE | MUTT_FORMAT_ARROWCURSOR); } - -#include "mutt_crypt.h" - static void redraw_crypt_lines(struct Header *msg) { SETCOLOR(MT_COLOR_COMPOSE_HEADER); diff --git a/compress.c b/compress.c index 44f3b129a..94efd5725 100644 --- a/compress.c +++ b/compress.c @@ -17,15 +17,24 @@ */ #include "config.h" -#include +#include +#include #include #include #include #include "mutt.h" #include "compress.h" +#include "context.h" +#include "format_flags.h" +#include "globals.h" +#include "lib.h" #include "mailbox.h" #include "mutt_curses.h" #include "mx.h" +#include "options.h" +#include "protos.h" + +struct Header; /* Notes: * Any references to compressed files also apply to encrypted files. diff --git a/compress.h b/compress.h index 6c30da9f1..6dec213f4 100644 --- a/compress.h +++ b/compress.h @@ -19,6 +19,11 @@ #ifndef _MUTT_COMPRESS_H #define _MUTT_COMPRESS_H 1 +#include +#include "mx.h" + +struct Context; + bool mutt_comp_can_append(struct Context *ctx); bool mutt_comp_can_read(const char *path); int mutt_comp_valid_command(const char *cmd); diff --git a/content.h b/content.h new file mode 100644 index 000000000..4cf5928f4 --- /dev/null +++ b/content.h @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_CONTENT_H +#define _MUTT_CONTENT_H 1 + +#include + +/* Information that helps in determining the Content-* of an attachment */ +struct Content +{ + long hibin; /* 8-bit characters */ + long lobin; /* unprintable 7-bit chars (eg., control chars) */ + long crlf; /* '\r' and '\n' characters */ + long ascii; /* number of ascii chars */ + long linemax; /* length of the longest line in the file */ + bool space : 1; /* whitespace at the end of lines? */ + bool binary : 1; /* long lines, or CR not in CRLF pair */ + bool from : 1; /* has a line beginning with "From "? */ + bool dot : 1; /* has a line consisting of a single dot? */ + bool cr : 1; /* has CR, even when in a CRLF pair */ +}; + +#endif /* _MUTT_CONTENT_H */ diff --git a/context.h b/context.h new file mode 100644 index 000000000..1f7ee52f7 --- /dev/null +++ b/context.h @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_CONTEXT_H +#define _MUTT_CONTEXT_H 1 + +#include +#include +#include +#include + +/* ACL Rights */ +enum +{ + MUTT_ACL_LOOKUP = 0, + MUTT_ACL_READ, + MUTT_ACL_SEEN, + MUTT_ACL_WRITE, + MUTT_ACL_INSERT, + MUTT_ACL_POST, + MUTT_ACL_CREATE, + MUTT_ACL_DELMX, + MUTT_ACL_DELETE, + MUTT_ACL_EXPUNGE, + MUTT_ACL_ADMIN, + + RIGHTSMAX +}; + +struct Context +{ + char *path; + char *realpath; /* used for buffy comparison and the sidebar */ + FILE *fp; + time_t atime; + time_t mtime; + off_t size; + off_t vsize; + char *pattern; /* limit pattern string */ + struct Pattern *limit_pattern; /* compiled limit pattern */ + struct Header **hdrs; + struct Header *last_tag; /* last tagged msg. used to link threads */ + struct MuttThread *tree; /* top of thread tree */ + struct Hash *id_hash; /* hash table by msg id */ + struct Hash *subj_hash; /* hash table by subject */ + struct Hash *thread_hash; /* hash table for threading */ + struct Hash *label_hash; /* hash table for x-labels */ + int *v2r; /* mapping from virtual to real msgno */ + int hdrmax; /* number of pointers in hdrs */ + int msgcount; /* number of messages in the mailbox */ + int vcount; /* the number of virtual messages */ + int tagged; /* how many messages are tagged? */ + int new; /* how many new messages? */ + int unread; /* how many unread messages? */ + int deleted; /* how many deleted messages */ + int flagged; /* how many flagged messages */ + int msgnotreadyet; /* which msg "new" in pager, -1 if none */ + + struct Menu *menu; /* needed for pattern compilation */ + + short magic; /* mailbox type */ + + unsigned char rights[(RIGHTSMAX + 7) / 8]; /* ACL bits */ + + bool locked : 1; /* is the mailbox locked? */ + bool changed : 1; /* mailbox has been modified */ + bool readonly : 1; /* don't allow changes to the mailbox */ + bool dontwrite : 1; /* don't write the mailbox on close */ + bool append : 1; /* mailbox is opened in append mode */ + bool quiet : 1; /* inhibit status messages? */ + bool collapsed : 1; /* are all threads collapsed? */ + bool closing : 1; /* mailbox is being closed */ + bool peekonly : 1; /* just taking a glance, revert atime */ + +#ifdef USE_COMPRESSED + void *compress_info; /* compressed mbox module private data */ +#endif /* USE_COMPRESSED */ + + /* driver hooks */ + void *data; /* driver specific data */ + struct mx_ops *mx_ops; +}; + +#endif /* _MUTT_CONTEXT_H */ diff --git a/copy.c b/copy.c index 367c3170e..b88116170 100644 --- a/copy.c +++ b/copy.c @@ -17,18 +17,31 @@ #include "config.h" #include -#include +#include +#include #include -#include #include "mutt.h" #include "copy.h" +#include "address.h" +#include "ascii.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "rfc2047.h" +#include "rfc822.h" +#include "state.h" #ifdef USE_NOTMUCH #include "mutt_notmuch.h" #endif diff --git a/copy.h b/copy.h index d1d2fe563..4b24babdc 100644 --- a/copy.h +++ b/copy.h @@ -18,6 +18,12 @@ #ifndef _MUTT_COPY_H #define _MUTT_COPY_H 1 +#include + +struct Body; +struct Header; +struct Context; + /* flags to _mutt_copy_message */ #define MUTT_CM_NOHEADER (1 << 0) /* don't copy the message header */ #define MUTT_CM_PREFIX (1 << 1) /* quote the message */ diff --git a/crypt.c b/crypt.c index ffcf3065d..7f6f846e9 100644 --- a/crypt.c +++ b/crypt.c @@ -21,22 +21,31 @@ */ #include "config.h" -#include -#include +#include #include -#include +#include +#include #include -#include -#include -#include -#include -#include +#include #include "mutt.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "content.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" - +#include "options.h" +#include "protos.h" +#include "rfc822.h" +#include "state.h" /* print the current time to avoid spoofing of the signature output */ void crypt_current_time(struct State *s, char *app_name) @@ -75,6 +84,7 @@ void crypt_forget_passphrase(void) #if (!defined(DEBUG)) +#include static void disable_coredumps(void) { struct rlimit rl = { 0, 0 }; diff --git a/crypt_gpgme.c b/crypt_gpgme.c index eca92df56..36ce99b71 100644 --- a/crypt_gpgme.c +++ b/crypt_gpgme.c @@ -25,24 +25,43 @@ #include "config.h" #include #include +#include #include #include +#include +#include #include +#include +#include #include #include -#include #include -#include -#include +#include #include #include "mutt.h" -#include "copy.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "charset.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "options.h" #include "pager.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" +#include "state.h" #define PKA_NOTATION_NAME "pka-address@gnupg.org" #define is_pka_notation(notation) \ @@ -4411,8 +4430,8 @@ static char *find_keys(struct Address *adrlist, unsigned int app, int oppenc_mod bypass_selection: keylist_size += mutt_strlen(keyID) + 4 + 1; safe_realloc(&keylist, keylist_size); - sprintf(keylist + keylist_used, "%s0x%s%s", - keylist_used ? " " : "", keyID, forced_valid ? "!" : ""); + sprintf(keylist + keylist_used, "%s0x%s%s", keylist_used ? " " : "", + keyID, forced_valid ? "!" : ""); keylist_used = mutt_strlen(keylist); key_selected = 1; diff --git a/crypt_gpgme.h b/crypt_gpgme.h index 899e37133..7d3118f68 100644 --- a/crypt_gpgme.h +++ b/crypt_gpgme.h @@ -18,7 +18,12 @@ #ifndef _MUTT_CRYPT_GPGME_H #define _MUTT_CRYPT_GPGME_H 1 -#include "mutt_crypt.h" +#include + +struct Address; +struct Body; +struct Header; +struct State; void pgp_gpgme_init(void); void smime_gpgme_init(void); diff --git a/crypt_mod.c b/crypt_mod.c index 4eaa7c4d9..022ee7976 100644 --- a/crypt_mod.c +++ b/crypt_mod.c @@ -17,6 +17,7 @@ #include "config.h" #include "crypt_mod.h" +#include "lib.h" /* A type of a variable to keep track of registered crypto modules. */ struct CryptModule diff --git a/crypt_mod.h b/crypt_mod.h index f5976a5fc..24256c0c8 100644 --- a/crypt_mod.h +++ b/crypt_mod.h @@ -18,11 +18,16 @@ #ifndef _MUTT_CRYPT_MOD_H #define _MUTT_CRYPT_MOD_H 1 -#include "mutt.h" +#include #include "mutt_crypt.h" -#define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_##identifier) +struct Address; +struct Body; +struct Envelope; +struct Header; +struct State; +#define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_##identifier) /* Type definitions for crypto module functions. diff --git a/crypt_mod_pgp_classic.c b/crypt_mod_pgp_classic.c index 245cc4061..6b218d52f 100644 --- a/crypt_mod_pgp_classic.c +++ b/crypt_mod_pgp_classic.c @@ -20,9 +20,16 @@ */ #include "config.h" +#include #include "crypt_mod.h" +#include "mutt_crypt.h" #include "pgp.h" +struct Address; +struct Body; +struct Header; +struct State; + static void crypt_mod_pgp_void_passphrase(void) { pgp_void_passphrase(); diff --git a/crypt_mod_pgp_gpgme.c b/crypt_mod_pgp_gpgme.c index 013062467..cd1a07ca8 100644 --- a/crypt_mod_pgp_gpgme.c +++ b/crypt_mod_pgp_gpgme.c @@ -16,12 +16,19 @@ */ /* - This is a crytpo module wrapping the gpgme based pgp code. + This is a crypto module wrapping the gpgme based pgp code. */ #include "config.h" +#include #include "crypt_gpgme.h" #include "crypt_mod.h" +#include "mutt_crypt.h" + +struct Address; +struct Body; +struct Header; +struct State; static void crypt_mod_pgp_init(void) { @@ -102,28 +109,28 @@ static void crypt_mod_pgp_set_sender(const char *sender) } struct crypt_module_specs crypt_mod_pgp_gpgme = { - APPLICATION_PGP, - { - /* Common. */ - crypt_mod_pgp_init, crypt_mod_pgp_void_passphrase, crypt_mod_pgp_valid_passphrase, - crypt_mod_pgp_decrypt_mime, crypt_mod_pgp_application_handler, - crypt_mod_pgp_encrypted_handler, crypt_mod_pgp_findkeys, crypt_mod_pgp_sign_message, - crypt_mod_pgp_verify_one, crypt_mod_pgp_send_menu, crypt_mod_pgp_set_sender, - - /* PGP specific. */ - crypt_mod_pgp_encrypt_message, + APPLICATION_PGP, + { + /* Common. */ + crypt_mod_pgp_init, crypt_mod_pgp_void_passphrase, crypt_mod_pgp_valid_passphrase, + crypt_mod_pgp_decrypt_mime, crypt_mod_pgp_application_handler, + crypt_mod_pgp_encrypted_handler, crypt_mod_pgp_findkeys, crypt_mod_pgp_sign_message, + crypt_mod_pgp_verify_one, crypt_mod_pgp_send_menu, crypt_mod_pgp_set_sender, + + /* PGP specific. */ + crypt_mod_pgp_encrypt_message, #ifdef HAVE_GPGME_OP_EXPORT_KEYS - crypt_mod_pgp_make_key_attachment, + crypt_mod_pgp_make_key_attachment, #else - NULL, + NULL, #endif - crypt_mod_pgp_check_traditional, NULL, /* pgp_traditional_encryptsign */ - NULL, /* pgp_invoke_getkeys */ - crypt_mod_pgp_invoke_import, NULL, /* pgp_extract_keys_from_attachment_list */ - - NULL, /* smime_getkeys */ - NULL, /* smime_verify_sender */ - NULL, /* smime_build_smime_entity */ - NULL, /* smime_invoke_import */ - }, + crypt_mod_pgp_check_traditional, NULL, /* pgp_traditional_encryptsign */ + NULL, /* pgp_invoke_getkeys */ + crypt_mod_pgp_invoke_import, NULL, /* pgp_extract_keys_from_attachment_list */ + + NULL, /* smime_getkeys */ + NULL, /* smime_verify_sender */ + NULL, /* smime_build_smime_entity */ + NULL, /* smime_invoke_import */ + }, }; diff --git a/crypt_mod_smime_classic.c b/crypt_mod_smime_classic.c index cf8d3409e..eb54fcfbd 100644 --- a/crypt_mod_smime_classic.c +++ b/crypt_mod_smime_classic.c @@ -20,9 +20,17 @@ */ #include "config.h" +#include #include "crypt_mod.h" +#include "mutt_crypt.h" #include "smime.h" +struct Address; +struct Body; +struct Envelope; +struct Header; +struct State; + static void crypt_mod_smime_void_passphrase(void) { smime_void_passphrase(); diff --git a/crypt_mod_smime_gpgme.c b/crypt_mod_smime_gpgme.c index efc11c44f..cfa67d828 100644 --- a/crypt_mod_smime_gpgme.c +++ b/crypt_mod_smime_gpgme.c @@ -16,12 +16,19 @@ */ /* - This is a crytpo module wrapping the gpgme based smime code. + This is a crypto module wrapping the gpgme based smime code. */ #include "config.h" +#include #include "crypt_gpgme.h" #include "crypt_mod.h" +#include "mutt_crypt.h" + +struct Address; +struct Body; +struct Header; +struct State; static void crypt_mod_smime_init(void) { diff --git a/cryptglue.c b/cryptglue.c index 6f757416a..7a0074d57 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -28,9 +28,19 @@ modules. */ #include "config.h" -#include "mutt.h" +#include #include "crypt_mod.h" +#include "globals.h" +#include "lib.h" #include "mutt_crypt.h" +#include "options.h" +#include "protos.h" + +struct Address; +struct Body; +struct Envelope; +struct Header; +struct State; /* diff --git a/curs_lib.c b/curs_lib.c index 6862fd8c3..545af1cc6 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -17,22 +17,35 @@ */ #include "config.h" +#include #include #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include -#include #include -#include #include +#include #include "mutt.h" +#include "enter_state.h" +#include "globals.h" +#include "keymap_defs.h" +#include "lib.h" #include "mbyte.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_regex.h" +#include "options.h" #include "pager.h" +#include "protos.h" #ifdef HAVE_ISWBLANK #include #endif diff --git a/curs_main.c b/curs_main.c index 65924aab6..fe1bfd9f3 100644 --- a/curs_main.c +++ b/curs_main.c @@ -18,22 +18,38 @@ #include "config.h" #include #include -#include +#include +#include +#include +#include #include #include -#include -#include -#include #include "mutt.h" +#include "alias.h" +#include "body.h" #include "buffy.h" +#include "context.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mapping.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_socket.h" #include "mx.h" -#include "mx.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "sort.h" +#include "thread.h" #ifdef USE_SIDEBAR #include "sidebar.h" #endif @@ -1665,7 +1681,7 @@ int mutt_index_menu(void) } break; - /* -------------------------------------------------------------------- +/* -------------------------------------------------------------------- * The following operations can be performed inside of the pager. */ diff --git a/date.c b/date.c index 9d1f9d546..b7573a639 100644 --- a/date.c +++ b/date.c @@ -17,7 +17,7 @@ #include "config.h" #include -#include "mutt.h" +#include /* returns the seconds east of UTC given `g' and its corresponding gmtime() representation */ diff --git a/dotlock.c b/dotlock.c index d2506bea5..30c5b3420 100644 --- a/dotlock.c +++ b/dotlock.c @@ -17,14 +17,12 @@ */ #include "config.h" -#include #include #include #include #include #include #include -#include #include #include #include diff --git a/edit.c b/edit.c index 5c2673673..6a1337f01 100644 --- a/edit.c +++ b/edit.c @@ -20,15 +20,25 @@ #include "config.h" #include #include -#include +#include #include +#include #include -#include #include #include #include "mutt.h" +#include "alias.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_idna.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" /* * SLcurses_waddnstr() can't take a "const char *", so this is only diff --git a/editmsg.c b/editmsg.c index 4c116c7b9..7027e2424 100644 --- a/editmsg.c +++ b/editmsg.c @@ -19,12 +19,23 @@ #include "config.h" #include +#include +#include +#include +#include #include #include +#include #include "mutt.h" +#include "context.h" #include "copy.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mailbox.h" #include "mx.h" +#include "options.h" +#include "protos.h" /* * return value: diff --git a/enter.c b/enter.c index cd932cc38..f07a336c5 100644 --- a/enter.c +++ b/enter.c @@ -17,12 +17,22 @@ */ #include "config.h" +#include +#include #include +#include +#include #include "mutt.h" +#include "enter_state.h" +#include "globals.h" #include "history.h" #include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "mbyte.h" #include "mutt_curses.h" -#include "mutt_menu.h" +#include "options.h" +#include "protos.h" /* redraw flags for mutt_enter_string() */ enum diff --git a/enter_state.h b/enter_state.h new file mode 100644 index 000000000..a1fc46bb6 --- /dev/null +++ b/enter_state.h @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_ENTER_STATE_H +#define _MUTT_ENTER_STATE_H 1 + +#include +#include "lib.h" + +struct EnterState +{ + wchar_t *wbuf; + size_t wbuflen; + size_t lastchar; + size_t curpos; + size_t begin; + int tabs; +}; + +static inline struct EnterState *mutt_new_enter_state(void) +{ + return safe_calloc(1, sizeof(struct EnterState)); +} + +#endif /* _MUTT_ENTER_STATE_H */ diff --git a/envelope.h b/envelope.h new file mode 100644 index 000000000..07dced0ba --- /dev/null +++ b/envelope.h @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_ENVELOPE_H +#define _MUTT_ENVELOPE_H 1 + +#include +#include "lib.h" + +struct Envelope +{ + struct Address *return_path; + struct Address *from; + struct Address *to; + struct Address *cc; + struct Address *bcc; + struct Address *sender; + struct Address *reply_to; + struct Address *mail_followup_to; + struct Address *x_original_to; + char *list_post; /* this stores a mailto URL, or nothing */ + char *subject; + char *real_subj; /* offset of the real subject */ + char *disp_subj; /* display subject (modified copy of subject) */ + char *message_id; + char *supersedes; + char *date; + char *x_label; + char *organization; +#ifdef USE_NNTP + char *newsgroups; + char *xref; + char *followup_to; + char *x_comment_to; +#endif + struct Buffer *spam; + struct List *references; /* message references (in reverse order) */ + struct List *in_reply_to; /* in-reply-to header content */ + struct List *userhdrs; /* user defined headers */ + int kwtypes; + + bool irt_changed : 1; /* In-Reply-To changed to link/break threads */ + bool refs_changed : 1; /* References changed to break thread */ +}; + +static inline struct Envelope *mutt_new_envelope(void) +{ + return safe_calloc(1, sizeof(struct Envelope)); +} + +#endif /* _MUTT_ENVELOPE_H */ diff --git a/filter.c b/filter.c index 8ecb67a8d..4603bcb06 100644 --- a/filter.c +++ b/filter.c @@ -19,9 +19,9 @@ #include #include #include -#include "mutt.h" #include "filter.h" #include "mutt_curses.h" +#include "protos.h" /* Invokes a command on a pipe and optionally connects its stdin and stdout * to the specified handles. diff --git a/flags.c b/flags.c index c76791d80..959721a8f 100644 --- a/flags.c +++ b/flags.c @@ -16,11 +16,20 @@ */ #include "config.h" +#include +#include #include "mutt.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" +#include "thread.h" void _mutt_set_flag(struct Context *ctx, struct Header *h, int flag, int bf, int upd_ctx) { diff --git a/format_flags.h b/format_flags.h new file mode 100644 index 000000000..2de8861a9 --- /dev/null +++ b/format_flags.h @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_FORMAT_FLAGS_H +#define _MUTT_FORMAT_FLAGS_H 1 + +#include + +/* flags for mutt_FormatString() */ +typedef enum { + MUTT_FORMAT_FORCESUBJ = (1 << 0), /* print the subject even if unchanged */ + MUTT_FORMAT_TREE = (1 << 1), /* draw the thread tree */ + MUTT_FORMAT_MAKEPRINT = (1 << 2), /* make sure that all chars are printable */ + MUTT_FORMAT_OPTIONAL = (1 << 3), + MUTT_FORMAT_STAT_FILE = (1 << 4), /* used by mutt_attach_fmt */ + MUTT_FORMAT_ARROWCURSOR = (1 << 5), /* reserve space for arrow_cursor */ + MUTT_FORMAT_INDEX = (1 << 6), /* this is a main index entry */ + MUTT_FORMAT_NOFILTER = (1 << 7) /* do not allow filtering on this pass */ +} format_flag; + +typedef const char *format_t(char *, size_t, size_t, int, char, const char *, + const char *, const char *, const char *, + unsigned long, format_flag); + +void mutt_FormatString(char *dest, /* output buffer */ + size_t destlen, /* output buffer len */ + size_t col, /* starting column (nonzero when called recursively) */ + int cols, /* maximum columns */ + const char *src, /* template string */ + format_t *callback, /* callback for processing */ + unsigned long data, /* callback data */ + format_flag flags); /* callback flags */ + +#endif /* _MUTT_FORMAT_FLAGS_H */ diff --git a/from.c b/from.c index 405bfc3b6..ff8d6a066 100644 --- a/from.c +++ b/from.c @@ -17,8 +17,14 @@ #include "config.h" #include +#include +#include #include -#include "mutt.h" +#include +#include "ascii.h" +#include "globals.h" +#include "lib.h" +#include "protos.h" static const char *next_word(const char *s) { diff --git a/functions.h b/functions.h index 987c4a913..20f9263de 100644 --- a/functions.h +++ b/functions.h @@ -35,6 +35,10 @@ #ifdef _MAKEDOC #include "config.h" #include "doc/makedoc_defs.h" +#else +#include +#include "keymap.h" +#include "keymap_defs.h" #endif // clang-format off diff --git a/gen_defs b/gen_defs index a8367c8a8..cc719c0cb 100755 --- a/gen_defs +++ b/gen_defs @@ -1,5 +1,8 @@ #!/bin/sh +echo '#ifndef _MUTT_KEYMAP_DEFS_H' +echo '#define _MUTT_KEYMAP_DEFS_H 1' +echo '' echo '/* Automatically generated by gen_defs. Do not edit! */' echo '' @@ -29,5 +32,6 @@ for mode in help defs; do echo '' fi done +echo '#endif /* _MUTT_KEYMAP_DEFS_H */' exit 0 diff --git a/getdomain.c b/getdomain.c index 2dfebf77b..79cb81183 100644 --- a/getdomain.c +++ b/getdomain.c @@ -19,10 +19,9 @@ #include #include #include -#include +#include #include -#include "mutt.h" - +#include "lib.h" int getdnsdomainname(char *d, size_t len) { diff --git a/globals.h b/globals.h index ca4615cde..4124d4d03 100644 --- a/globals.h +++ b/globals.h @@ -18,6 +18,18 @@ #ifndef _MUTT_GLOBALS_H #define _MUTT_GLOBALS_H 1 +#include +#include "lib.h" +#include "where.h" + +#ifdef MAIN_C +/* so that global vars get included */ +#include "git_ver.h" +#include "mutt_crypt.h" +#include "mx.h" +#include "sort.h" +#endif /* MAIN_C */ + WHERE void (*mutt_error)(const char *, ...); WHERE void (*mutt_message)(const char *, ...); @@ -212,13 +224,6 @@ WHERE struct RxList *NoSpamList INITVAL(0); WHERE struct ReplaceList *SubjectRxList INITVAL(0); -/* bit vector for boolean variables */ -#ifdef MAIN_C -unsigned char Options[(OPTMAX + 7) / 8]; -#else -extern unsigned char Options[]; -#endif - /* bit vector for the yes/no/ask variable type */ #ifdef MAIN_C unsigned char QuadOptions[(OPT_MAX * 2 + 7) / 8]; @@ -357,14 +362,4 @@ extern const char *const Weekdays[]; extern const char *const Months[]; #endif -#ifdef MAIN_C -/* so that global vars get included */ -#include "buffy.h" -#include "git_ver.h" -#include "mutt_crypt.h" -#include "mutt_regex.h" -#include "mx.h" -#include "sort.h" -#endif /* MAIN_C */ - #endif /* _MUTT_GLOBALS_H */ diff --git a/gnupgparse.c b/gnupgparse.c index 4bc10cd83..d48dbebb9 100644 --- a/gnupgparse.c +++ b/gnupgparse.c @@ -29,18 +29,22 @@ #include "config.h" #include #include +#include #include -#include #include -#include -#include #include #include #include "mutt.h" #include "charset.h" #include "filter.h" +#include "globals.h" +#include "lib.h" #include "mime.h" +#include "mutt_crypt.h" +#include "options.h" #include "pgp.h" +#include "pgplib.h" +#include "protos.h" /**************** * Read the GNUPG keys. For now we read the complete keyring by @@ -373,7 +377,7 @@ struct PgpKeyInfo *pgp_get_candidates(pgp_ring_t keyring, struct List *hints) FILE *fp = NULL; pid_t thepid; char buf[LONG_STRING]; - struct PgpKeyInfo *db = NULL, **kend, *k = NULL, *kk = NULL, *mainkey = NULL; + struct PgpKeyInfo *db = NULL, **kend = NULL, *k = NULL, *kk = NULL, *mainkey = NULL; int is_sub; int devnull; diff --git a/group.c b/group.c index 56c444b6c..afdd9c81b 100644 --- a/group.c +++ b/group.c @@ -17,18 +17,16 @@ */ #include "config.h" -#include -#include #include -#include -#include -#include -#include #include "mutt.h" -#include "charset.h" -#include "mbyte.h" -#include "mutt_curses.h" -#include "mutt_regex.h" +#include "group.h" +#include "address.h" +#include "globals.h" +#include "hash.h" +#include "lib.h" +#include "list.h" +#include "protos.h" +#include "rfc822.h" struct Group *mutt_pattern_group(const char *k) { diff --git a/group.h b/group.h index 9ce9f4949..1d509ea91 100644 --- a/group.h +++ b/group.h @@ -19,9 +19,27 @@ #ifndef _MUTT_GROUP_H #define _MUTT_GROUP_H 1 +#include + +struct Address; +struct Buffer; + #define MUTT_GROUP 0 #define MUTT_UNGROUP 1 +struct Group +{ + struct Address *as; + struct RxList *rs; + char *name; +}; + +struct GroupContext +{ + struct Group *g; + struct GroupContext *next; +}; + void mutt_group_context_add(struct GroupContext **ctx, struct Group *group); void mutt_group_context_destroy(struct GroupContext **ctx); void mutt_group_context_add_adrlist(struct GroupContext *ctx, struct Address *a); @@ -33,4 +51,6 @@ int mutt_group_context_clear(struct GroupContext **ctx); int mutt_group_context_remove_rx(struct GroupContext *ctx, const char *s); int mutt_group_context_remove_adrlist(struct GroupContext *ctx, struct Address *a); +struct Group *mutt_pattern_group(const char *k); + #endif /* _MUTT_GROUP_H */ diff --git a/handler.c b/handler.c index c488bef70..d0662ee10 100644 --- a/handler.c +++ b/handler.c @@ -16,22 +16,39 @@ */ #include "config.h" +#include #include +#include +#include +#include +#include +#include #include #include #include -#include +#include #include +#include +#include #include "mutt.h" +#include "ascii.h" +#include "body.h" #include "charset.h" #include "copy.h" #include "filter.h" +#include "globals.h" #include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" +#include "options.h" +#include "protos.h" #include "rfc1524.h" #include "rfc3676.h" +#include "state.h" #define BUFI_SIZE 1000 #define BUFO_SIZE 2000 diff --git a/hash.c b/hash.c index 004eb096f..12a44c61f 100644 --- a/hash.c +++ b/hash.c @@ -18,9 +18,8 @@ #include "config.h" #include #include -#include -#include -#include "mutt.h" +#include "hash.h" +#include "lib.h" #define SOMEPRIME 149711 diff --git a/hash.h b/hash.h index dcb3746b4..4965bdf60 100644 --- a/hash.h +++ b/hash.h @@ -18,6 +18,8 @@ #ifndef _MUTT_HASH_H #define _MUTT_HASH_H 1 +#include + union hash_key { const char *strkey; unsigned int intkey; diff --git a/hcache/bdb.c b/hcache/bdb.c index 26ffada34..c9683f4ce 100644 --- a/hcache/bdb.c +++ b/hcache/bdb.c @@ -22,8 +22,14 @@ #include #include #include -#include "mutt.h" +#include +#include +#include +#include +#include #include "backend.h" +#include "globals.h" +#include "lib.h" #include "mx.h" struct HcacheDbCtx diff --git a/hcache/gdbm.c b/hcache/gdbm.c index 305991da5..db527d805 100644 --- a/hcache/gdbm.c +++ b/hcache/gdbm.c @@ -19,9 +19,11 @@ */ #include "config.h" +#include #include -#include "mutt.h" #include "backend.h" +#include "globals.h" +#include "lib.h" static void *hcache_gdbm_open(const char *path) { diff --git a/hcache/hcache.c b/hcache/hcache.c index 236b448c1..9a85f80f4 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -26,11 +26,32 @@ #endif #include +#include +#include +#include +#include +#include +#include #include -#include "hcache.h" +#include +#include "address.h" #include "backend.h" +#include "body.h" +#include "buffer.h" +#include "charset.h" +#include "envelope.h" +#include "globals.h" +#include "hcache.h" #include "hcversion.h" +#include "header.h" +#include "lib.h" +#include "list.h" +#include "mbyte.h" #include "md5.h" +#include "mutt_regex.h" +#include "parameter.h" +#include "protos.h" +#include "rfc822.h" static unsigned int hcachever = 0x0; diff --git a/hcache/hcache.h b/hcache/hcache.h index a5b8c9f4c..cbb92dfa0 100644 --- a/hcache/hcache.h +++ b/hcache/hcache.h @@ -21,9 +21,9 @@ #ifndef _MUTT_HCACHE_H #define _MUTT_HCACHE_H 1 -#include "mutt.h" +#include -struct header_cache; +struct Header; typedef struct header_cache header_cache_t; typedef int (*hcache_namer_t)(const char *path, char *dest, size_t dlen); diff --git a/hcache/kc.c b/hcache/kc.c index 0f70762e5..08be9be88 100644 --- a/hcache/kc.c +++ b/hcache/kc.c @@ -20,8 +20,11 @@ #include "config.h" #include -#include "mutt.h" +#include +#include #include "backend.h" +#include "lib.h" +#include "options.h" static void *hcache_kyotocabinet_open(const char *path) { diff --git a/hcache/lmdb.c b/hcache/lmdb.c index 5a64d70c5..29fef9dac 100644 --- a/hcache/lmdb.c +++ b/hcache/lmdb.c @@ -19,6 +19,7 @@ */ #include "config.h" +#include #include #include "backend.h" #include "lib.h" diff --git a/hcache/qdbm.c b/hcache/qdbm.c index d4918b2c4..609fdd670 100644 --- a/hcache/qdbm.c +++ b/hcache/qdbm.c @@ -19,11 +19,12 @@ */ #include "config.h" -#include +#include #include #include -#include "mutt.h" #include "backend.h" +#include "lib.h" +#include "options.h" static void *hcache_qdbm_open(const char *path) { diff --git a/hcache/tc.c b/hcache/tc.c index c360b86f2..c7040648d 100644 --- a/hcache/tc.c +++ b/hcache/tc.c @@ -19,9 +19,12 @@ */ #include "config.h" +#include #include -#include "mutt.h" +#include #include "backend.h" +#include "lib.h" +#include "options.h" static void *hcache_tokyocabinet_open(const char *path) { diff --git a/hdrline.c b/hdrline.c index 0a275d5dc..b82dd1ea3 100644 --- a/hdrline.c +++ b/hdrline.c @@ -20,14 +20,31 @@ #include "config.h" #include #include +#include +#include #include #include +#include #include "mutt.h" -#include "charset.h" +#include "address.h" +#include "body.h" +#include "buffer.h" +#include "context.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" +#include "mbyte_table.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" +#include "thread.h" #ifdef USE_NOTMUCH #include "mutt_notmuch.h" #endif diff --git a/header.h b/header.h new file mode 100644 index 000000000..f2804c565 --- /dev/null +++ b/header.h @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_HEADER_H +#define _MUTT_HEADER_H 1 + +#include +#include +#include +#include "lib.h" + +struct Header +{ + unsigned int security : 12; /* bit 0-8: flags, bit 9,10: application. + see: mutt_crypt.h pgplib.h, smime.h */ + + bool mime : 1; /* has a MIME-Version header? */ + bool flagged : 1; /* marked important? */ + bool tagged : 1; + bool deleted : 1; + bool purge : 1; /* skip trash folder when deleting */ + bool quasi_deleted : 1; /* deleted from mutt, but not modified on disk */ + bool changed : 1; + bool attach_del : 1; /* has an attachment marked for deletion */ + bool old : 1; + bool read : 1; + bool expired : 1; /* already expired? */ + bool superseded : 1; /* got superseded? */ + bool replied : 1; + bool subject_changed : 1; /* used for threading */ + bool threaded : 1; /* used for threading */ + bool display_subject : 1; /* used for threading */ + bool recip_valid : 1; /* is_recipient is valid */ + bool active : 1; /* message is not to be removed */ + bool trash : 1; /* message is marked as trashed on disk. + * This flag is used by the maildir_trash + * option. + */ + bool xlabel_changed : 1; /* editable - used for syncing */ + + /* timezone of the sender of this message */ + unsigned int zhours : 5; + unsigned int zminutes : 6; + bool zoccident : 1; + + /* bits used for caching when searching */ + bool searched : 1; + bool matched : 1; + + /* tells whether the attachment count is valid */ + bool attach_valid : 1; + + /* the following are used to support collapsing threads */ + bool collapsed : 1; /* is this message part of a collapsed thread? */ + bool limited : 1; /* is this message in a limited view? */ + size_t num_hidden; /* number of hidden messages in this view */ + + short recipient; /* user_is_recipient()'s return value, cached */ + + int pair; /* color-pair to use when displaying in the index */ + + time_t date_sent; /* time when the message was sent (UTC) */ + time_t received; /* time when the message was placed in the mailbox */ + LOFF_T offset; /* where in the stream does this message begin? */ + int lines; /* how many lines in the body of this message? */ + int index; /* the absolute (unsorted) message number */ + int msgno; /* number displayed to the user */ + int virtual; /* virtual message number */ + int score; + struct Envelope *env; /* envelope information */ + struct Body *content; /* list of MIME parts */ + char *path; + + char *tree; /* character string to print thread tree */ + struct MuttThread *thread; + + /* Number of qualifying attachments in message, if attach_valid */ + short attach_total; + +#ifdef MIXMASTER + struct List *chain; +#endif + +#ifdef USE_POP + int refno; /* message number on server */ +#endif + +#if defined(USE_POP) || defined(USE_IMAP) || defined(USE_NNTP) || defined(USE_NOTMUCH) + void *data; /* driver-specific data */ + void (*free_cb)(struct Header *); /* driver-specific data free function */ +#endif + + char *maildir_flags; /* unknown maildir flags */ +}; + +static inline struct Header *mutt_new_header(void) +{ + return safe_calloc(1, sizeof(struct Header)); +} + +#endif /* _MUTT_HEADER_H */ diff --git a/headers.c b/headers.c index dd12bc7b8..74045dc88 100644 --- a/headers.c +++ b/headers.c @@ -17,12 +17,27 @@ #include "config.h" #include +#include +#include #include -#include +#include #include +#include #include "mutt.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mutt_crypt.h" #include "mutt_idna.h" +#include "options.h" +#include "protos.h" void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, char *fcc, size_t fcclen) { diff --git a/help.c b/help.c index e5b331362..48c6e35f9 100644 --- a/help.c +++ b/help.c @@ -18,13 +18,23 @@ #define HELP_C #include "config.h" +#include #include +#include +#include +#include #include -#include "mutt.h" +#include +#include "globals.h" #include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mapping.h" +#include "mbyte.h" #include "mutt_curses.h" +#include "options.h" #include "pager.h" +#include "protos.h" static const struct binding_t *help_lookup_function(int op, int menu) { diff --git a/history.c b/history.c index eb9307601..11aaa92ab 100644 --- a/history.c +++ b/history.c @@ -16,8 +16,15 @@ */ #include "config.h" -#include "mutt.h" +#include +#include +#include +#include #include "history.h" +#include "charset.h" +#include "globals.h" +#include "lib.h" +#include "protos.h" struct history { diff --git a/history.h b/history.h index cd8610b5d..0a8c46390 100644 --- a/history.h +++ b/history.h @@ -18,7 +18,7 @@ #ifndef _MUTT_HISTORY_H #define _MUTT_HISTORY_H 1 -enum history_class +typedef enum history_class { HC_CMD, HC_ALIAS, @@ -29,12 +29,10 @@ enum history_class HC_MBOX, /* insert new items here to keep history file working */ HC_LAST -}; +} history_class_t; #define HC_FIRST HC_CMD -typedef enum history_class history_class_t; - void mutt_init_history(void); void mutt_read_histfile(void); void mutt_history_add(history_class_t hclass, const char *s, int save); diff --git a/hook.c b/hook.c index 64a61fa4a..76d4025d6 100644 --- a/hook.c +++ b/hook.c @@ -18,12 +18,26 @@ #include "config.h" #include #include -#include +#include +#include +#include #include #include #include "mutt.h" +#include "address.h" +#include "buffer.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mutt_crypt.h" +#include "mutt_regex.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #ifdef USE_COMPRESSED #include "compress.h" #endif diff --git a/imap/auth.c b/imap/auth.c index afca140f2..6bd2cf8d6 100644 --- a/imap/auth.c +++ b/imap/auth.c @@ -20,9 +20,12 @@ /* IMAP login/authentication code */ #include "config.h" -#include "imap_private.h" -#include "mutt.h" +#include #include "auth.h" +#include "ascii.h" +#include "globals.h" +#include "lib.h" +#include "protos.h" static const struct ImapAuth imap_authenticators[] = { { imap_auth_plain, "plain" }, diff --git a/imap/auth.h b/imap/auth.h index 7edd7973c..bc50e3421 100644 --- a/imap/auth.h +++ b/imap/auth.h @@ -21,13 +21,14 @@ #ifndef _MUTT_IMAP_AUTH_H #define _MUTT_IMAP_AUTH_H 1 +struct ImapData; + typedef enum { IMAP_AUTH_SUCCESS = 0, IMAP_AUTH_FAILURE, IMAP_AUTH_UNAVAIL } imap_auth_res_t; - struct ImapAuth { /* do authentication, using named method or any available if method is NULL */ diff --git a/imap/auth_anon.c b/imap/auth_anon.c index c3d19f7e0..d71ce38c1 100644 --- a/imap/auth_anon.c +++ b/imap/auth_anon.c @@ -19,8 +19,13 @@ #include "config.h" #include "imap_private.h" -#include "mutt.h" +#include "account.h" #include "auth.h" +#include "globals.h" +#include "lib.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" /* this is basically a stripped-down version of the cram-md5 method. */ imap_auth_res_t imap_auth_anon(struct ImapData *idata, const char *method) diff --git a/imap/auth_cram.c b/imap/auth_cram.c index 9bc198615..b51481d1b 100644 --- a/imap/auth_cram.c +++ b/imap/auth_cram.c @@ -18,10 +18,17 @@ /* IMAP login/authentication code */ #include "config.h" +#include +#include #include "imap_private.h" -#include "mutt.h" +#include "account.h" #include "auth.h" +#include "globals.h" +#include "lib.h" #include "md5.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" #define MD5_BLOCK_LEN 64 #define MD5_DIGEST_LEN 16 diff --git a/imap/auth_gss.c b/imap/auth_gss.c index 81734991f..0d74790e1 100644 --- a/imap/auth_gss.c +++ b/imap/auth_gss.c @@ -19,9 +19,16 @@ #include "config.h" #include +#include +#include #include "imap_private.h" -#include "mutt.h" +#include "account.h" #include "auth.h" +#include "globals.h" +#include "lib.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" #ifdef HAVE_HEIMDAL #include #define gss_nt_service_name GSS_C_NT_HOSTBASED_SERVICE diff --git a/imap/auth_login.c b/imap/auth_login.c index b91ab4e93..28f1c5e15 100644 --- a/imap/auth_login.c +++ b/imap/auth_login.c @@ -18,9 +18,15 @@ /* plain LOGIN support */ #include "config.h" +#include #include "imap_private.h" -#include "mutt.h" +#include "account.h" #include "auth.h" +#include "globals.h" +#include "lib.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" /* imap_auth_login: Plain LOGIN support */ imap_auth_res_t imap_auth_login(struct ImapData *idata, const char *method) diff --git a/imap/auth_plain.c b/imap/auth_plain.c index 9f7a85fdd..ccf4994dc 100644 --- a/imap/auth_plain.c +++ b/imap/auth_plain.c @@ -20,9 +20,13 @@ #include "config.h" #include "imap_private.h" -#include "mutt.h" +#include "account.h" #include "auth.h" +#include "globals.h" +#include "lib.h" #include "mutt_sasl_plain.h" +#include "mutt_socket.h" +#include "protos.h" /* imap_auth_plain: SASL PLAIN support */ imap_auth_res_t imap_auth_plain(struct ImapData *idata, const char *method) diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index ba760393f..6a441e1a2 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -21,10 +21,18 @@ #include #include #include +#include +#include #include "imap_private.h" -#include "mutt.h" +#include "account.h" +#include "ascii.h" #include "auth.h" +#include "globals.h" +#include "lib.h" #include "mutt_sasl.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" /* imap_auth_sasl: Default authenticator if available. */ imap_auth_res_t imap_auth_sasl(struct ImapData *idata, const char *method) diff --git a/imap/browse.c b/imap/browse.c index 90d3cfe45..f93426b2c 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -19,11 +19,23 @@ /* Mutt browser support routines */ #include "config.h" -#include -#include +#include +#include +#include +#include +#include #include "imap_private.h" #include "mutt.h" +#include "account.h" +#include "browser.h" #include "buffy.h" +#include "context.h" +#include "globals.h" +#include "imap/imap.h" +#include "lib.h" +#include "mutt_regex.h" +#include "options.h" +#include "protos.h" /* imap_add_folder: * add a folder name to the browser list, formatting it as necessary. diff --git a/imap/command.c b/imap/command.c index 6ceb96d33..7a36db3c6 100644 --- a/imap/command.c +++ b/imap/command.c @@ -22,12 +22,30 @@ #include "config.h" #include +#include +#include #include +#include +#include #include "imap_private.h" -#include "mutt.h" +#include "account.h" +#include "ascii.h" +#include "buffer.h" #include "buffy.h" +#include "context.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "imap/imap.h" +#include "lib.h" +#include "mailbox.h" +#include "message.h" #include "mutt_menu.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" +#include "url.h" #define IMAP_CMD_BUFSIZE 512 diff --git a/imap/imap.c b/imap/imap.c index 974257296..975de38d5 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -21,19 +21,40 @@ #include "config.h" #include +#include +#include +#include #include #include -#include -#include +#include #include #include "imap_private.h" #include "mutt.h" -#include "browser.h" +#include "imap.h" +#include "account.h" +#include "ascii.h" +#include "bcache.h" +#include "body.h" +#include "buffer.h" #include "buffy.h" +#include "context.h" +#include "envelope.h" #include "globals.h" +#include "hash.h" +#include "header.h" +#include "imap/imap.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" +#include "message.h" +#include "mutt_curses.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "sort.h" +#include "url.h" #ifdef USE_HCACHE #include "hcache/hcache.h" #endif diff --git a/imap/imap.h b/imap/imap.h index 9052ffcc4..816a5386a 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -19,9 +19,15 @@ #ifndef _MUTT_IMAP_H #define _MUTT_IMAP_H 1 +#include +#include #include "account.h" -#include "browser.h" -#include "mailbox.h" + +struct Header; +struct Pattern; +struct Context; +struct Message; +struct browser_state; /* -- data structures -- */ struct ImapMbox diff --git a/imap/imap_private.h b/imap/imap_private.h index e77c9c0f6..8479fe095 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -19,16 +19,23 @@ #ifndef _MUTT_IMAP_PRIVATE_H #define _MUTT_IMAP_PRIVATE_H 1 -#include "account.h" -#include "bcache.h" -#include "imap.h" -#include "message.h" -#include "mutt_curses.h" -#include "mutt_socket.h" +#include +#include +#include #ifdef USE_HCACHE #include "hcache/hcache.h" #endif +struct Account; +struct Buffer; +struct Context; +struct Header; +struct ImapHeaderData; +struct ImapMbox; +struct List; +struct Message; +struct Progress; + /* -- symbols -- */ #define IMAP_PORT 143 #define IMAP_SSL_PORT 993 diff --git a/imap/message.c b/imap/message.c index e55cfde86..15da1af30 100644 --- a/imap/message.c +++ b/imap/message.c @@ -20,12 +20,33 @@ #include "config.h" #include -#include +#include +#include #include +#include +#include #include "imap_private.h" #include "mutt.h" +#include "message.h" +#include "account.h" +#include "ascii.h" #include "bcache.h" +#include "body.h" +#include "buffer.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "imap/imap.h" +#include "lib.h" +#include "list.h" +#include "mailbox.h" +#include "mutt_curses.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" #ifdef USE_HCACHE #include "hcache/hcache.h" #endif diff --git a/imap/message.h b/imap/message.h index 086cb70f4..d16ec9ba7 100644 --- a/imap/message.h +++ b/imap/message.h @@ -21,6 +21,9 @@ #ifndef _MUTT_IMAP_MESSAGE_H #define _MUTT_IMAP_MESSAGE_H 1 +#include +#include + /* -- data structures -- */ /* IMAP-specific header data, stored as Header->data */ struct ImapHeaderData diff --git a/imap/utf7.c b/imap/utf7.c index e5ef686b2..7d98bcca7 100644 --- a/imap/utf7.c +++ b/imap/utf7.c @@ -16,9 +16,11 @@ */ #include "config.h" +#include #include "imap_private.h" -#include "mutt.h" #include "charset.h" +#include "globals.h" +#include "lib.h" // clang-format off static const int Index_64[128] = { diff --git a/imap/util.c b/imap/util.c index c01a2167c..34a985afa 100644 --- a/imap/util.c +++ b/imap/util.c @@ -25,12 +25,30 @@ #include #include #include +#include #include -#include +#include #include +#include +#include #include "imap_private.h" #include "mutt.h" +#include "account.h" +#include "ascii.h" +#include "bcache.h" +#include "buffer.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "imap/imap.h" +#include "lib.h" +#include "list.h" +#include "mailbox.h" +#include "message.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "url.h" #ifdef USE_HCACHE #include "hcache/hcache.h" diff --git a/init.c b/init.c index c3910b835..1a9390157 100644 --- a/init.c +++ b/init.c @@ -18,22 +18,42 @@ #include "config.h" #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include +#include #include -#include #include +#include #include "mutt.h" #include "init.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "buffer.h" #include "charset.h" +#include "context.h" +#include "envelope.h" #include "filter.h" #include "group.h" +#include "hash.h" +#include "hcache/hcache.h" +#include "header.h" #include "history.h" #include "keymap.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mapping.h" #include "mbyte.h" +#include "mbyte_table.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" @@ -41,10 +61,10 @@ #include "mutt_regex.h" #include "mx.h" #include "myvar.h" +#include "options.h" +#include "pattern.h" +#include "rfc822.h" #include "version.h" -#ifdef USE_SSL -#include "mutt_ssl.h" -#endif #ifdef USE_NOTMUCH #include "mutt_notmuch.h" #endif diff --git a/init.h b/init.h index b9dde2e15..29882d4a0 100644 --- a/init.h +++ b/init.h @@ -23,20 +23,27 @@ #include "config.h" #include "doc/makedoc_defs.h" #else +#include +#include "mutt.h" +#include "buffy.h" +#include "globals.h" +#include "group.h" +#include "mapping.h" +#include "mutt_commands.h" +#include "mutt_options.h" +#include "mutt_regex.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" #ifdef USE_LUA #include "mutt_lua.h" #endif #endif -#include "buffy.h" +struct Buffer; #ifndef _MAKEDOC -#include "group.h" -#include "mutt_commands.h" -#include "mutt_options.h" - /* flags to parse_set() */ #define MUTT_SET_INV (1 << 0) /* default is to invert all vars */ #define MUTT_SET_UNSET (1 << 1) /* default is to unset all vars */ diff --git a/keymap.c b/keymap.c index c531f6740..d705d461d 100644 --- a/keymap.c +++ b/keymap.c @@ -17,15 +17,23 @@ #include "config.h" #include +#include +#include +#include #include #include -#include "mutt.h" #include "keymap.h" +#include "ascii.h" +#include "buffer.h" #include "functions.h" +#include "globals.h" +#include "keymap_defs.h" +#include "lib.h" #include "mapping.h" #include "mutt_crypt.h" #include "mutt_curses.h" -#include "mutt_menu.h" +#include "options.h" +#include "protos.h" #ifdef USE_IMAP #include "imap/imap.h" #endif diff --git a/keymap.h b/keymap.h index 5de4a9cd8..287305eba 100644 --- a/keymap.h +++ b/keymap.h @@ -18,6 +18,7 @@ #ifndef _MUTT_KEYMAP_H #define _MUTT_KEYMAP_H 1 +#include #include "mapping.h" /* maximal length of a key binding sequence used for buffer in km_bindkey */ @@ -114,6 +115,4 @@ extern const struct binding_t OpSmime[]; extern const struct binding_t OpMix[]; #endif -#include "keymap_defs.h" - #endif /* _MUTT_KEYMAP_H */ diff --git a/lib.c b/lib.c index e35663af3..959f39f8e 100644 --- a/lib.c +++ b/lib.c @@ -27,12 +27,14 @@ #include #include #include -#include +#include +#include +#include #include #include #include #include -#include +#include #include #include "lib.h" diff --git a/lib.h b/lib.h index 3b8c06275..ec3edd5ae 100644 --- a/lib.h +++ b/lib.h @@ -23,18 +23,9 @@ #include #include -#include -#include -#include #include #include -#include #include -#include -#include -#ifndef _POSIX_PATH_MAX -#include -#endif #ifdef ENABLE_NLS #include diff --git a/list.h b/list.h new file mode 100644 index 000000000..d83bf73e6 --- /dev/null +++ b/list.h @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_LIST_H +#define _MUTT_LIST_H 1 + +#include "lib.h" + +struct List +{ + char *data; + struct List *next; +}; + +static inline struct List *mutt_new_list(void) +{ + return safe_calloc(1, sizeof(struct List)); +} + +#endif /* _MUTT_LIST_H */ diff --git a/mailbox.h b/mailbox.h index fd7532d24..910cfee24 100644 --- a/mailbox.h +++ b/mailbox.h @@ -18,6 +18,13 @@ #ifndef _MUTT_MAILBOX_H #define _MUTT_MAILBOX_H 1 +#include +#include +#include + +struct Header; +struct Context; + /* flags for mutt_open_mailbox() */ #define MUTT_NOSORT (1 << 0) /* do not sort the mailbox after opening it */ #define MUTT_APPEND (1 << 1) /* open mailbox for appending messages */ diff --git a/main.c b/main.c index ea3b4d97f..7464ce417 100644 --- a/main.c +++ b/main.c @@ -21,18 +21,36 @@ #include "config.h" #include +#include +#include #include +#include +#include #include #include #include -#include #include #include "mutt.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "buffy.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" #include "keymap.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" +#include "mutt_regex.h" +#include "mutt_socket.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" #include "url.h" #include "version.h" #ifdef USE_SIDEBAR @@ -44,19 +62,10 @@ #ifdef USE_IMAP #include "imap/imap.h" #endif -#ifdef USE_HCACHE -#include "hcache/hcache.h" -#endif #ifdef USE_NNTP #include "nntp.h" #endif -#ifdef HAVE_STRINGPREP_H -#include -#elif defined(HAVE_IDN_STRINGPREP_H) -#include -#endif - char **envlist; void mutt_exit(int code) diff --git a/mapping.h b/mapping.h index f7cb5ac47..91c85c746 100644 --- a/mapping.h +++ b/mapping.h @@ -18,7 +18,7 @@ #ifndef _MUTT_MAPPING_H #define _MUTT_MAPPING_H 1 -#include +#include struct mapping_t { diff --git a/mbox.c b/mbox.c index 4d5f9069f..c933254f5 100644 --- a/mbox.c +++ b/mbox.c @@ -18,20 +18,36 @@ /* This file contains code to parse ``mbox'' and ``mmdf'' style mailboxes */ #include "config.h" -#include -#include #include -#include -#include +#include +#include +#include +#include #include +#include #include #include #include "mutt.h" +#include "address.h" +#include "body.h" +#include "buffy.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mutt_curses.h" #include "mx.h" +#include "options.h" +#include "parameter.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" +#include "thread.h" /* struct used by mutt_sync_mailbox() to store new offsets */ struct m_update_t diff --git a/mbyte.c b/mbyte.c index af3ee2f59..9dba90170 100644 --- a/mbyte.c +++ b/mbyte.c @@ -20,13 +20,18 @@ */ #include "config.h" -#include #include +#include #include -#include "mutt.h" +#include +#include #include "mbyte.h" +#include "ascii.h" #include "buffer.h" #include "charset.h" +#include "lib.h" +#include "options.h" +#include "protos.h" #ifndef EILSEQ #define EILSEQ EINVAL diff --git a/mbyte.h b/mbyte.h index 6ce1ad3e3..171d54dc5 100644 --- a/mbyte.h +++ b/mbyte.h @@ -16,11 +16,11 @@ #ifndef _MUTT_MBYTE_H #define _MUTT_MBYTE_H 1 +#include +#include #include -#ifdef HAVE_WC_FUNCS -#include -#else +#ifndef HAVE_WC_FUNCS #ifdef towupper #undef towupper #endif @@ -54,10 +54,10 @@ wint_t towlower(wint_t wc); int wcwidth(wchar_t wc); #endif /* !HAVE_WC_FUNCS */ - void mutt_set_charset(char *charset); extern int Charset_is_utf8; wchar_t replacement_char(void); bool is_display_corrupting_utf8(wchar_t wc); +int mutt_filter_unprintable(char **s); #endif /* _MUTT_MBYTE_H */ diff --git a/mbyte_table.h b/mbyte_table.h new file mode 100644 index 000000000..b7f8d6192 --- /dev/null +++ b/mbyte_table.h @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_MBYTE_TABLE_H +#define _MUTT_MBYTE_TABLE_H 1 + +/* multibyte character table. + * Allows for direct access to the individual multibyte characters in a + * string. This is used for the Flagchars, Fromchars, StChars and Tochars + * option types. */ +struct MbCharTable +{ + int len; /* number of characters */ + char **chars; /* the array of multibyte character strings */ + char *segmented_str; /* each chars entry points inside this string */ + char *orig_str; +}; + +#endif /* _MUTT_MBYTE_TABLE_H */ diff --git a/md5.h b/md5.h index fb8c03bc5..bb64fea76 100644 --- a/md5.h +++ b/md5.h @@ -25,9 +25,8 @@ #ifndef _MUTT_MD5_H #define _MUTT_MD5_H 1 -#include +#include #include -#include typedef uint32_t md5_uint32; diff --git a/menu.c b/menu.c index 5ec9549ca..a85ebc426 100644 --- a/menu.c +++ b/menu.c @@ -16,10 +16,27 @@ */ #include "config.h" +#include +#include +#include +#include +#include +#include +#include #include "mutt.h" -#include "mbyte.h" +#include "context.h" +#include "globals.h" +#include "hash.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_regex.h" +#include "mbyte.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #ifdef USE_SIDEBAR #include "sidebar.h" #endif diff --git a/mh.c b/mh.c index 9cf8cc5b6..9d77f76dc 100644 --- a/mh.c +++ b/mh.c @@ -27,25 +27,34 @@ #include #include #include +#include #include +#include #include #include #include #include #include -#include +#include #include #include #include "mutt.h" +#include "body.h" #include "buffy.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" #include "mailbox.h" #include "mutt_curses.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" -#ifdef USE_NOTMUCH -#include "mutt_notmuch.h" -#endif +#include "thread.h" #ifdef USE_NOTMUCH #include "mutt_notmuch.h" #endif diff --git a/mutt.h b/mutt.h index c8efd903c..1d43de11c 100644 --- a/mutt.h +++ b/mutt.h @@ -19,25 +19,16 @@ #ifndef _MUTT_H #define _MUTT_H 1 -#include -#include #include -#include -#include -#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include "charset.h" -#include "hash.h" -#include "rfc822.h" -#ifndef _POSIX_PATH_MAX -#include -#endif + +struct List; +struct ReplaceList; +struct RxList; +struct State; /* On OS X 10.5.x, wide char functions are inlined by default breaking * --without-wc-funcs compilation @@ -46,11 +37,6 @@ #define _DONT_USE_CTYPE_INLINE_ #endif -#include -#ifdef HAVE_WC_FUNCS -#include -#endif - /* PATH_MAX is undefined on the hurd */ #if !defined(PATH_MAX) && defined(_POSIX_PATH_MAX) #define PATH_MAX _POSIX_PATH_MAX @@ -71,18 +57,6 @@ #define fgetc fgetc_unlocked #endif -/* nifty trick I stole from ELM 2.5alpha. */ -#ifdef MAIN_C -#define WHERE -#define INITVAL(x) = x -#else -#define WHERE extern -#define INITVAL(x) -#endif - -#include "buffer.h" -#include "mutt_regex.h" - /* flags for mutt_enter_string() */ #define MUTT_ALIAS 1 /* do alias "completion" by calling up the alias-menu */ #define MUTT_FILE (1 << 1) /* do file completion */ @@ -101,18 +75,6 @@ /* flags for _mutt_system() */ #define MUTT_DETACH_PROCESS 1 /* detach subprocess from group */ -/* flags for mutt_FormatString() */ -typedef enum { - MUTT_FORMAT_FORCESUBJ = (1 << 0), /* print the subject even if unchanged */ - MUTT_FORMAT_TREE = (1 << 1), /* draw the thread tree */ - MUTT_FORMAT_MAKEPRINT = (1 << 2), /* make sure that all chars are printable */ - MUTT_FORMAT_OPTIONAL = (1 << 3), - MUTT_FORMAT_STAT_FILE = (1 << 4), /* used by mutt_attach_fmt */ - MUTT_FORMAT_ARROWCURSOR = (1 << 5), /* reserve space for arrow_cursor */ - MUTT_FORMAT_INDEX = (1 << 6), /* this is a main index entry */ - MUTT_FORMAT_NOFILTER = (1 << 7) /* do not allow filtering on this pass */ -} format_flag; - /* types for mutt_add_hook() */ #define MUTT_FOLDERHOOK (1 << 0) #define MUTT_MBOXHOOK (1 << 1) @@ -331,295 +293,6 @@ enum #define MUTT_X_MOZILLA_KEYS (1 << 2) /* tbird */ #define MUTT_KEYWORDS (1 << 3) /* rfc2822 */ -/* boolean vars */ -enum -{ - OPTALLOW8BIT, - OPTALLOWANSI, - OPTARROWCURSOR, - OPTASCIICHARS, - OPTASKBCC, - OPTASKCC, - OPTASKFOLLOWUP, - OPTASKXCOMMENTTO, - OPTATTACHSPLIT, - OPTAUTOEDIT, - OPTAUTOTAG, - OPTBEEP, - OPTBEEPNEW, - OPTBOUNCEDELIVERED, - OPTBRAILLEFRIENDLY, - OPTCHECKMBOXSIZE, - OPTCHECKNEW, - OPTCOLLAPSEALL, - OPTCOLLAPSEUNREAD, - OPTCONFIRMAPPEND, - OPTCONFIRMCREATE, - OPTDELETEUNTAG, - OPTDIGESTCOLLAPSE, - OPTDUPTHREADS, - OPTEDITHDRS, - OPTENCODEFROM, - OPTENVFROM, - OPTFASTREPLY, - OPTFCCCLEAR, - OPTFLAGSAFE, - OPTFOLLOWUPTO, - OPTFORCENAME, - OPTFORWDECODE, - OPTFORWQUOTE, - OPTFORWREF, -#ifdef USE_HCACHE - OPTHCACHEVERIFY, -#if defined(HAVE_QDBM) || defined(HAVE_TC) || defined(HAVE_KC) - OPTHCACHECOMPRESS, -#endif /* HAVE_QDBM */ -#endif - OPTHDRS, - OPTHEADER, - OPTHEADERCOLORPARTIAL, - OPTHELP, - OPTHIDDENHOST, - OPTHIDELIMITED, - OPTHIDEMISSING, - OPTHIDETHREADSUBJECT, - OPTHIDETOPLIMITED, - OPTHIDETOPMISSING, - OPTHONORDISP, - OPTIGNORELWS, - OPTIGNORELISTREPLYTO, -#ifdef USE_IMAP - OPTIMAPCHECKSUBSCRIBED, - OPTIMAPIDLE, - OPTIMAPLSUB, - OPTIMAPPASSIVE, - OPTIMAPPEEK, - OPTIMAPSERVERNOISE, -#endif -#ifdef USE_SSL -#ifndef USE_SSL_GNUTLS - OPTSSLSYSTEMCERTS, - OPTSSLV2, -#endif /* USE_SSL_GNUTLS */ - OPTSSLV3, - OPTTLSV1, - OPTTLSV1_1, - OPTTLSV1_2, - OPTSSLFORCETLS, - OPTSSLVERIFYDATES, - OPTSSLVERIFYHOST, -#if defined(USE_SSL_OPENSSL) && defined(HAVE_SSL_PARTIAL_CHAIN) - OPTSSLVERIFYPARTIAL, -#endif /* USE_SSL_OPENSSL */ -#endif /* defined(USE_SSL) */ - OPTIMPLICITAUTOVIEW, - OPTINCLUDEONLYFIRST, - OPTKEEPFLAGGED, - OPTKEYWORDSLEGACY, - OPTKEYWORDSSTANDARD, - OPTMAILCAPSANITIZE, - OPTMAILCHECKRECENT, - OPTMAILCHECKSTATS, - OPTMAILDIRTRASH, - OPTMAILDIRCHECKCUR, - OPTMARKERS, - OPTMARKOLD, - OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ - OPTMENUMOVEOFF, /* allow menu to scroll past last entry */ -#if defined(USE_IMAP) || defined(USE_POP) - OPTMESSAGECACHECLEAN, -#endif - OPTMETAKEY, /* interpret ALT-x as ESC-x */ - OPTMETOO, - OPTMHPURGE, - OPTMIMEFORWDECODE, -#ifdef USE_NNTP - OPTMIMESUBJECT, /* encode subject line with RFC2047 */ -#endif - OPTNARROWTREE, - OPTPAGERSTOP, - OPTPIPEDECODE, - OPTPIPESPLIT, -#ifdef USE_POP - OPTPOPAUTHTRYALL, - OPTPOPLAST, -#endif - OPTPOSTPONEENCRYPT, - OPTPRINTDECODE, - OPTPRINTSPLIT, - OPTPROMPTAFTER, - OPTREADONLY, - OPTREFLOWSPACEQUOTES, - OPTREFLOWTEXT, - OPTREPLYSELF, - OPTREPLYWITHXORIG, - OPTRESOLVE, - OPTRESUMEDRAFTFILES, - OPTRESUMEEDITEDDRAFTFILES, - OPTREVALIAS, - OPTREVNAME, - OPTREVREAL, - OPTRFC2047PARAMS, - OPTSAVEADDRESS, - OPTSAVEEMPTY, - OPTSAVENAME, - OPTSCORE, -#ifdef USE_SIDEBAR - OPTSIDEBAR, - OPTSIDEBARFOLDERINDENT, - OPTSIDEBARNEWMAILONLY, - OPTSIDEBARNEXTNEWWRAP, - OPTSIDEBARSHORTPATH, - OPTSIDEBARONRIGHT, -#endif - OPTSIGDASHES, - OPTSIGONTOP, - OPTSORTRE, - OPTSPAMSEP, - OPTSTATUSONTOP, - OPTSTRICTTHREADS, - OPTSUSPEND, - OPTTEXTFLOWED, - OPTTHOROUGHSRC, - OPTTHREADRECEIVED, - OPTTILDE, - OPTTSENABLED, - OPTUNCOLLAPSEJUMP, - OPTUNCOLLAPSENEW, - OPTUSE8BITMIME, - OPTUSEDOMAIN, - OPTUSEFROM, - OPTUSEGPGAGENT, -#ifdef HAVE_LIBIDN - OPTIDNDECODE, - OPTIDNENCODE, -#endif -#ifdef HAVE_GETADDRINFO - OPTUSEIPV6, -#endif - OPTWAITKEY, - OPTWEED, - OPTWRAP, - OPTWRAPSEARCH, - OPTWRITEBCC, /* write out a bcc header? */ - OPTXMAILER, - - OPTCRYPTUSEGPGME, - OPTCRYPTUSEPKA, - - /* PGP options */ - - OPTCRYPTAUTOSIGN, - OPTCRYPTAUTOENCRYPT, - OPTCRYPTAUTOPGP, - OPTCRYPTAUTOSMIME, - OPTCRYPTCONFIRMHOOK, - OPTCRYPTOPPORTUNISTICENCRYPT, - OPTCRYPTREPLYENCRYPT, - OPTCRYPTREPLYSIGN, - OPTCRYPTREPLYSIGNENCRYPTED, - OPTCRYPTTIMESTAMP, - OPTSMIMEISDEFAULT, - OPTASKCERTLABEL, - OPTSDEFAULTDECRYPTKEY, - OPTPGPIGNORESUB, - OPTPGPCHECKEXIT, - OPTPGPLONGIDS, - OPTPGPAUTODEC, - OPTPGPRETAINABLESIG, - OPTPGPSTRICTENC, - OPTFORWDECRYPT, - OPTPGPSHOWUNUSABLE, - OPTPGPAUTOINLINE, - OPTPGPREPLYINLINE, - -/* news options */ - -#ifdef USE_NNTP - OPTSHOWNEWNEWS, - OPTSHOWONLYUNREAD, - OPTSAVEUNSUB, - OPTLISTGROUP, - OPTLOADDESC, - OPTXCOMMENTTO, -#endif - - /* pseudo options */ - - OPTAUXSORT, /* (pseudo) using auxiliary sort function */ - OPTFORCEREFRESH, /* (pseudo) refresh even during macros */ - OPTLOCALES, /* (pseudo) set if user has valid locale definition */ - OPTNOCURSES, /* (pseudo) when sending in batch mode */ - OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */ - OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */ - OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */ - OPTSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals () */ - OPTSYSSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals_system () */ - OPTNEEDRESORT, /* (pseudo) used to force a re-sort */ - OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */ - OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */ - OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ - OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ - OPTATTACHMSG, /* (pseudo) used by attach-message */ - OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ - OPTKEEPQUIET, /* (pseudo) shut up the message and refresh - * functions while we are executing an - * external program. - */ - OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */ - OPTREDRAWTREE, /* (pseudo) redraw the thread tree */ - OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */ - OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ - OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */ - -#ifdef USE_NNTP - OPTNEWS, /* (pseudo) used to change reader mode */ - OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ -#endif -#ifdef USE_NOTMUCH - OPTVIRTSPOOLFILE, - OPTNOTMUCHRECORD, -#endif - - OPTMAX -}; - -#define mutt_bit_alloc(n) calloc((n + 7) / 8, sizeof(char)) -#define mutt_bit_set(v, n) v[n / 8] |= (1 << (n % 8)) -#define mutt_bit_unset(v, n) v[n / 8] &= ~(1 << (n % 8)) -#define mutt_bit_toggle(v, n) v[n / 8] ^= (1 << (n % 8)) -#define mutt_bit_isset(v, n) (v[n / 8] & (1 << (n % 8))) - -#define set_option(x) mutt_bit_set(Options, x) -#define unset_option(x) mutt_bit_unset(Options, x) -#define toggle_option(x) mutt_bit_toggle(Options, x) -#define option(x) mutt_bit_isset(Options, x) - -struct List -{ - char *data; - struct List *next; -}; - -struct RxList -{ - struct Regex *rx; - struct RxList *next; -}; - -struct ReplaceList -{ - struct Regex *rx; - int nmatch; - char *template; - struct ReplaceList *next; -}; - -static inline struct List *mutt_new_list(void) -{ - return safe_calloc(1, sizeof(struct List)); -} - void mutt_free_list(struct List **list); void mutt_free_rx_list(struct RxList **list); void mutt_free_replace_list(struct ReplaceList **list); @@ -640,452 +313,9 @@ const char *mutt_front_list(struct List *head); void mutt_init(int skip_sys_rc, struct List *commands); -struct Alias -{ - struct Alias *self; /* XXX - ugly hack */ - char *name; - struct Address *addr; - struct Alias *next; - bool tagged; - bool del; - short num; -}; - -struct Envelope -{ - struct Address *return_path; - struct Address *from; - struct Address *to; - struct Address *cc; - struct Address *bcc; - struct Address *sender; - struct Address *reply_to; - struct Address *mail_followup_to; - struct Address *x_original_to; - char *list_post; /* this stores a mailto URL, or nothing */ - char *subject; - char *real_subj; /* offset of the real subject */ - char *disp_subj; /* display subject (modified copy of subject) */ - char *message_id; - char *supersedes; - char *date; - char *x_label; - char *organization; -#ifdef USE_NNTP - char *newsgroups; - char *xref; - char *followup_to; - char *x_comment_to; -#endif - struct Buffer *spam; - struct List *references; /* message references (in reverse order) */ - struct List *in_reply_to; /* in-reply-to header content */ - struct List *userhdrs; /* user defined headers */ - int kwtypes; - - bool irt_changed : 1; /* In-Reply-To changed to link/break threads */ - bool refs_changed : 1; /* References changed to break thread */ -}; - -static inline struct Envelope *mutt_new_envelope(void) -{ - return safe_calloc(1, sizeof(struct Envelope)); -} - -struct Parameter -{ - char *attribute; - char *value; - struct Parameter *next; -}; - -static inline struct Parameter *mutt_new_parameter(void) -{ - return safe_calloc(1, sizeof(struct Parameter)); -} - -/* Information that helps in determining the Content-* of an attachment */ -struct Content -{ - long hibin; /* 8-bit characters */ - long lobin; /* unprintable 7-bit chars (eg., control chars) */ - long crlf; /* '\r' and '\n' characters */ - long ascii; /* number of ascii chars */ - long linemax; /* length of the longest line in the file */ - bool space : 1; /* whitespace at the end of lines? */ - bool binary : 1; /* long lines, or CR not in CRLF pair */ - bool from : 1; /* has a line beginning with "From "? */ - bool dot : 1; /* has a line consisting of a single dot? */ - bool cr : 1; /* has CR, even when in a CRLF pair */ -}; - -struct Body -{ - char *xtype; /* content-type if x-unknown */ - char *subtype; /* content-type subtype */ - struct Parameter *parameter; /* parameters of the content-type */ - char *description; /* content-description */ - char *form_name; /* Content-Disposition form-data name param */ - long hdr_offset; /* offset in stream where the headers begin. - * this info is used when invoking metamail, - * where we need to send the headers of the - * attachment - */ - LOFF_T offset; /* offset where the actual data begins */ - LOFF_T length; /* length (in bytes) of attachment */ - char *filename; /* when sending a message, this is the file - * to which this structure refers - */ - char *d_filename; /* filename to be used for the - * content-disposition header. - * If NULL, filename is used - * instead. - */ - char *charset; /* charset of attached file */ - struct Content *content; /* structure used to store detailed info about - * the content of the attachment. this is used - * to determine what content-transfer-encoding - * is required when sending mail. - */ - struct Body *next; /* next attachment in the list */ - struct Body *parts; /* parts of a multipart or message/rfc822 */ - struct Header *hdr; /* header information for message/rfc822 */ - - struct AttachPtr *aptr; /* Menu information, used in recvattach.c */ - - signed short attach_count; - - time_t stamp; /* time stamp of last - * encoding update. - */ - - unsigned int type : 4; /* content-type primary type */ - unsigned int encoding : 3; /* content-transfer-encoding */ - unsigned int disposition : 2; /* content-disposition */ - bool use_disp : 1; /* Content-Disposition uses filename= ? */ - bool unlink : 1; /* flag to indicate the file named by - * "filename" should be unlink()ed before - * free()ing this structure - */ - bool tagged : 1; - bool deleted : 1; /* attachment marked for deletion */ - - bool noconv : 1; /* don't do character set conversion */ - bool force_charset : 1; - /* send mode: don't adjust the character - * set when in send-mode. - */ - bool is_signed_data : 1; /* A lot of MUAs don't indicate - S/MIME signed-data correctly, - e.g. they use foo.p7m even for - the name of signed data. This - flag is used to keep track of - the actual message type. It - gets set during the verification - (which is done if the encryption - try failed) and check by the - function to figure the type of - the message. */ - - bool goodsig : 1; /* good cryptographic signature */ - bool warnsig : 1; /* maybe good signature */ - bool badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */ - - bool collapsed : 1; /* used by recvattach */ - bool attach_qualifies : 1; - -}; - -struct Header -{ - unsigned int security : 12; /* bit 0-8: flags, bit 9,10: application. - see: mutt_crypt.h pgplib.h, smime.h */ - - bool mime : 1; /* has a MIME-Version header? */ - bool flagged : 1; /* marked important? */ - bool tagged : 1; - bool deleted : 1; - bool purge : 1; /* skip trash folder when deleting */ - bool quasi_deleted : 1; /* deleted from mutt, but not modified on disk */ - bool changed : 1; - bool attach_del : 1; /* has an attachment marked for deletion */ - bool old : 1; - bool read : 1; - bool expired : 1; /* already expired? */ - bool superseded : 1; /* got superseded? */ - bool replied : 1; - bool subject_changed : 1; /* used for threading */ - bool threaded : 1; /* used for threading */ - bool display_subject : 1; /* used for threading */ - bool recip_valid : 1; /* is_recipient is valid */ - bool active : 1; /* message is not to be removed */ - bool trash : 1; /* message is marked as trashed on disk. - * This flag is used by the maildir_trash - * option. - */ - bool xlabel_changed : 1; /* editable - used for syncing */ - - /* timezone of the sender of this message */ - unsigned int zhours : 5; - unsigned int zminutes : 6; - bool zoccident : 1; - - /* bits used for caching when searching */ - bool searched : 1; - bool matched : 1; - - /* tells whether the attachment count is valid */ - bool attach_valid : 1; - - /* the following are used to support collapsing threads */ - bool collapsed : 1; /* is this message part of a collapsed thread? */ - bool limited : 1; /* is this message in a limited view? */ - size_t num_hidden; /* number of hidden messages in this view */ - - short recipient; /* user_is_recipient()'s return value, cached */ - - int pair; /* color-pair to use when displaying in the index */ - - time_t date_sent; /* time when the message was sent (UTC) */ - time_t received; /* time when the message was placed in the mailbox */ - LOFF_T offset; /* where in the stream does this message begin? */ - int lines; /* how many lines in the body of this message? */ - int index; /* the absolute (unsorted) message number */ - int msgno; /* number displayed to the user */ - int virtual; /* virtual message number */ - int score; - struct Envelope *env; /* envelope information */ - struct Body *content; /* list of MIME parts */ - char *path; - - char *tree; /* character string to print thread tree */ - struct MuttThread *thread; - - /* Number of qualifying attachments in message, if attach_valid */ - short attach_total; - -#ifdef MIXMASTER - struct List *chain; -#endif - -#ifdef USE_POP - int refno; /* message number on server */ -#endif - -#if defined(USE_POP) || defined(USE_IMAP) || defined(USE_NNTP) || defined(USE_NOTMUCH) - void *data; /* driver-specific data */ - void (*free_cb)(struct Header *); /* driver-specific data free function */ -#endif - - char *maildir_flags; /* unknown maildir flags */ -}; - -static inline struct Header *mutt_new_header(void) -{ - return safe_calloc(1, sizeof(struct Header)); -} - -struct MuttThread -{ - bool fake_thread : 1; - bool duplicate_thread : 1; - bool sort_children : 1; - bool check_subject : 1; - bool visible : 1; - bool deep : 1; - unsigned int subtree_visible : 2; - bool next_subtree_visible : 1; - struct MuttThread *parent; - struct MuttThread *child; - struct MuttThread *next; - struct MuttThread *prev; - struct Header *message; - struct Header *sort_key; -}; - - /* flag to mutt_pattern_comp() */ #define MUTT_FULL_MSG (1 << 0) /* enable body and header matching */ -typedef enum { - MUTT_MATCH_FULL_ADDRESS = 1 -} pattern_exec_flag; - -struct Group -{ - struct Address *as; - struct RxList *rs; - char *name; -}; - -struct GroupContext -{ - struct Group *g; - struct GroupContext *next; -}; - -struct Pattern -{ - short op; - bool not : 1; - bool alladdr : 1; - bool stringmatch : 1; - bool groupmatch : 1; - bool ign_case : 1; /* ignore case for local stringmatch searches */ - bool isalias : 1; - int min; - int max; - struct Pattern *next; - struct Pattern *child; /* arguments to logical op */ - union { - regex_t *rx; - struct Group *g; - char *str; - } p; -}; - -/* This is used when a message is repeatedly pattern matched against. - * e.g. for color, scoring, hooks. It caches a few of the potentially slow - * operations. - * Each entry has a value of 0 = unset, 1 = false, 2 = true - */ -struct PatternCache -{ - int list_all; /* ^~l */ - int list_one; /* ~l */ - int sub_all; /* ^~u */ - int sub_one; /* ~u */ - int pers_recip_all; /* ^~p */ - int pers_recip_one; /* ~p */ - int pers_from_all; /* ^~P */ - int pers_from_one; /* ~P */ -}; - -/* ACL Rights */ -enum -{ - MUTT_ACL_LOOKUP = 0, - MUTT_ACL_READ, - MUTT_ACL_SEEN, - MUTT_ACL_WRITE, - MUTT_ACL_INSERT, - MUTT_ACL_POST, - MUTT_ACL_CREATE, - MUTT_ACL_DELMX, - MUTT_ACL_DELETE, - MUTT_ACL_EXPUNGE, - MUTT_ACL_ADMIN, - - RIGHTSMAX -}; - -struct Context; -struct Message; - -/* - * struct mx_ops - a structure to store operations on a mailbox - * The following operations are mandatory: - * - open - * - close - * - check - * - * Optional operations - * - open_new_msg - */ -struct mx_ops -{ - int (*open)(struct Context *ctx); - int (*open_append)(struct Context *ctx, int flags); - int (*close)(struct Context *ctx); - int (*check)(struct Context *ctx, int *index_hint); - int (*sync)(struct Context *ctx, int *index_hint); - int (*open_msg)(struct Context *ctx, struct Message *msg, int msgno); - int (*close_msg)(struct Context *ctx, struct Message *msg); - int (*commit_msg)(struct Context *ctx, struct Message *msg); - int (*open_new_msg)(struct Message *msg, struct Context *ctx, struct Header *hdr); -}; - -#include "mutt_menu.h" - -struct Context -{ - char *path; - char *realpath; /* used for buffy comparison and the sidebar */ - FILE *fp; - time_t atime; - time_t mtime; - off_t size; - off_t vsize; - char *pattern; /* limit pattern string */ - struct Pattern *limit_pattern; /* compiled limit pattern */ - struct Header **hdrs; - struct Header *last_tag; /* last tagged msg. used to link threads */ - struct MuttThread *tree; /* top of thread tree */ - struct Hash *id_hash; /* hash table by msg id */ - struct Hash *subj_hash; /* hash table by subject */ - struct Hash *thread_hash; /* hash table for threading */ - struct Hash *label_hash; /* hash table for x-labels */ - int *v2r; /* mapping from virtual to real msgno */ - int hdrmax; /* number of pointers in hdrs */ - int msgcount; /* number of messages in the mailbox */ - int vcount; /* the number of virtual messages */ - int tagged; /* how many messages are tagged? */ - int new; /* how many new messages? */ - int unread; /* how many unread messages? */ - int deleted; /* how many deleted messages */ - int flagged; /* how many flagged messages */ - int msgnotreadyet; /* which msg "new" in pager, -1 if none */ - - struct Menu *menu; /* needed for pattern compilation */ - - short magic; /* mailbox type */ - - unsigned char rights[(RIGHTSMAX + 7) / 8]; /* ACL bits */ - - bool locked : 1; /* is the mailbox locked? */ - bool changed : 1; /* mailbox has been modified */ - bool readonly : 1; /* don't allow changes to the mailbox */ - bool dontwrite : 1; /* don't write the mailbox on close */ - bool append : 1; /* mailbox is opened in append mode */ - bool quiet : 1; /* inhibit status messages? */ - bool collapsed : 1; /* are all threads collapsed? */ - bool closing : 1; /* mailbox is being closed */ - bool peekonly : 1; /* just taking a glance, revert atime */ - -#ifdef USE_COMPRESSED - void *compress_info; /* compressed mbox module private data */ -#endif /* USE_COMPRESSED */ - - /* driver hooks */ - void *data; /* driver specific data */ - struct mx_ops *mx_ops; -}; - -struct State -{ - FILE *fpin; - FILE *fpout; - char *prefix; - int flags; -}; - -/* used by enter.c */ - -struct EnterState -{ - wchar_t *wbuf; - size_t wbuflen; - size_t lastchar; - size_t curpos; - size_t begin; - int tabs; -}; - -static inline struct EnterState *mutt_new_enter_state(void) -{ - return safe_calloc(1, sizeof(struct EnterState)); -} - /* flags for the State struct */ #define MUTT_DISPLAY (1 << 0) /* output is displayed to the user */ #define MUTT_VERIFY (1 << 1) /* perform signature verification */ @@ -1116,23 +346,6 @@ struct AttachMatch regex_t minor_rx; }; -/* multibyte character table. - * Allows for direct access to the individual multibyte characters in a - * string. This is used for the Flagchars, Fromchars, StChars and Tochars - * option types. */ -struct MbCharTable -{ - int len; /* number of characters */ - char **chars; /* the array of multibyte character strings */ - char *segmented_str; /* each chars entry points inside this string */ - char *orig_str; -}; - #define MUTT_PARTS_TOPLEVEL (1 << 0) /* is the top-level part */ -#include "ascii.h" -#include "globals.h" -#include "lib.h" -#include "protos.h" - #endif /* _MUTT_H */ diff --git a/mutt_commands.h b/mutt_commands.h index 81c75e30d..f1c17dd3a 100644 --- a/mutt_commands.h +++ b/mutt_commands.h @@ -18,7 +18,7 @@ #ifndef _MUTT_COMMANDS_H #define _MUTT_COMMANDS_H 1 -#include "mutt.h" +struct Buffer; struct command_t { diff --git a/mutt_crypt.h b/mutt_crypt.h index 38441a46a..71fd8e47b 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -24,7 +24,15 @@ #ifndef _MUTT_CRYPT_H #define _MUTT_CRYPT_H 1 -#include "mutt.h" +#include +#include + +struct Address; +struct Body; +struct Envelope; +struct Header; +struct State; + /* FIXME: They should be pointer to anonymous structures for better information hiding. */ @@ -91,12 +99,11 @@ #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN | KEYFLAG_CANENCRYPT | KEYFLAG_PREFER_ENCRYPTION | KEYFLAG_PREFER_SIGNING) -enum pgp_ring +typedef enum pgp_ring { PGP_PUBRING, PGP_SECRING -}; -typedef enum pgp_ring pgp_ring_t; +} pgp_ring_t; /* Some prototypes -- old crypt.h. */ diff --git a/mutt_curses.h b/mutt_curses.h index 61a94eb66..137fb284a 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -19,6 +19,10 @@ #ifndef _MUTT_CURSES_H #define _MUTT_CURSES_H 1 +#include +#include "lib.h" +#include "options.h" + #ifdef USE_SLANG_CURSES #ifndef unix /* this symbol is not defined by the hp-ux compiler (sigh) */ @@ -68,8 +72,6 @@ #endif /* USE_SLANG_CURSES */ -#include "lib.h" - /* AIX defines ``lines'' in , but it's used as a var name in * various places in Mutt */ diff --git a/mutt_idna.c b/mutt_idna.c index 151b4c5f6..5bb554f3f 100644 --- a/mutt_idna.c +++ b/mutt_idna.c @@ -16,9 +16,18 @@ */ #include "config.h" -#include "mutt.h" +#include +#include +#include +#include #include "mutt_idna.h" +#include "address.h" +#include "ascii.h" #include "charset.h" +#include "envelope.h" +#include "globals.h" +#include "lib.h" +#include "options.h" #ifdef HAVE_LIBIDN static bool check_idn(char *domain) diff --git a/mutt_idna.h b/mutt_idna.h index d1db69bc2..ae125eae5 100644 --- a/mutt_idna.h +++ b/mutt_idna.h @@ -18,14 +18,8 @@ #ifndef _MUTT_IDNA_H #define _MUTT_IDNA_H 1 -#include "charset.h" -#include "rfc822.h" - -#ifdef HAVE_IDNA_H -#include -#elif defined(HAVE_IDN_IDNA_H) -#include -#endif +struct Envelope; +struct Address; #define MI_MAY_BE_IRREVERSIBLE (1 << 0) diff --git a/mutt_lua.c b/mutt_lua.c index defbe458a..725ccfb1a 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -22,11 +22,20 @@ #include #include #include +#include +#include #include "mutt.h" #include "mutt_lua.h" +#include "buffer.h" +#include "globals.h" +#include "lib.h" +#include "mailbox.h" +#include "mbyte_table.h" #include "mutt_commands.h" #include "mutt_options.h" -#include "mx.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" static int _handle_panic(lua_State *l) { diff --git a/mutt_lua.h b/mutt_lua.h index fee32c9b5..f63e89088 100644 --- a/mutt_lua.h +++ b/mutt_lua.h @@ -18,7 +18,7 @@ #ifndef _MUTT_LUA_H #define _MUTT_LUA_H 1 -#include "mutt.h" +struct Buffer; int mutt_lua_parse(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err); int mutt_lua_source_file(struct Buffer *tmp, struct Buffer *s, unsigned long data, struct Buffer *err); diff --git a/mutt_menu.h b/mutt_menu.h index b92d2c841..ec14acfd4 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -22,9 +22,9 @@ #ifndef _MUTT_MENU_H #define _MUTT_MENU_H 1 -#include "keymap.h" -#include "mutt_curses.h" -#include "mutt_regex.h" +#include +#include +#include #define REDRAW_INDEX (1 << 0) #define REDRAW_MOTION (1 << 1) @@ -136,6 +136,4 @@ int mutt_menu_loop(struct Menu *menu); void index_make_entry(char *s, size_t l, struct Menu *menu, int num); int index_color(int index_no); -bool mutt_limit_current_thread(struct Header *h); - #endif /* _MUTT_MENU_H */ diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 0b0f10116..3cfaf5aa3 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -37,27 +37,31 @@ #include "config.h" #include -#include #include -#include +#include #include #include -#include +#include #include -#include #include +#include +#include #include -#include #include "mutt.h" #include "mutt_notmuch.h" +#include "body.h" #include "buffy.h" -#include "copy.h" -#include "keymap.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" #include "mailbox.h" #include "mutt_curses.h" #include "mx.h" -#include "rfc2047.h" -#include "sort.h" +#include "protos.h" +#include "thread.h" #include "url.h" #ifdef LIBNOTMUCH_CHECK_VERSION diff --git a/mutt_notmuch.h b/mutt_notmuch.h index 4fd09ee46..ef755078b 100644 --- a/mutt_notmuch.h +++ b/mutt_notmuch.h @@ -18,7 +18,12 @@ #ifndef _MUTT_NOTMUCH_H #define _MUTT_NOTMUCH_H 1 +#include #include +#include "mx.h" + +struct Context; +struct Header; int nm_read_entire_thread(struct Context *ctx, struct Header *h); diff --git a/mutt_options.h b/mutt_options.h index 8fccb21fb..0c4399909 100644 --- a/mutt_options.h +++ b/mutt_options.h @@ -18,7 +18,9 @@ #ifndef _MUTT_OPTIONS_H #define _MUTT_OPTIONS_H 1 -#include "mutt.h" +#include + +struct Buffer; #define DT_MASK 0x0f #define DT_BOOL 1 /* boolean option */ diff --git a/mutt_regex.h b/mutt_regex.h index 08b779bd3..1ffb4e994 100644 --- a/mutt_regex.h +++ b/mutt_regex.h @@ -23,6 +23,7 @@ #define _MUTT_REGEX_H 1 #include +#include "where.h" /* this is a non-standard option supported by Solaris 2.5.x which allows * patterns of the form \<...\> @@ -41,6 +42,20 @@ struct Regex int not; /* do not match */ }; +struct RxList +{ + struct Regex *rx; + struct RxList *next; +}; + +struct ReplaceList +{ + struct Regex *rx; + int nmatch; + char *template; + struct ReplaceList *next; +}; + WHERE struct Regex Mask; WHERE struct Regex QuoteRegexp; WHERE struct Regex ReplyRegexp; diff --git a/mutt_sasl.c b/mutt_sasl.c index a0df24686..2a3fc9ab4 100644 --- a/mutt_sasl.c +++ b/mutt_sasl.c @@ -20,13 +20,16 @@ #include "config.h" #include #include -#include #include +#include +#include #include -#include "mutt.h" #include "mutt_sasl.h" #include "account.h" +#include "lib.h" #include "mutt_socket.h" +#include "options.h" +#include "protos.h" static int getnameinfo_err(int ret) { diff --git a/mutt_sasl.h b/mutt_sasl.h index 2afc89744..6230ebff1 100644 --- a/mutt_sasl.h +++ b/mutt_sasl.h @@ -20,9 +20,13 @@ #ifndef _MUTT_SASL_H #define _MUTT_SASL_H 1 +#include #include -#include "mutt_socket.h" +typedef struct sasl_conn sasl_conn_t; +typedef struct sasl_interact sasl_interact_t; +typedef unsigned sasl_ssf_t; +struct Connection; int mutt_sasl_client_new(struct Connection *conn, sasl_conn_t **saslconn); int mutt_sasl_interact(sasl_interact_t *interaction); diff --git a/mutt_sasl_plain.c b/mutt_sasl_plain.c index 41ff5aa01..ec12a4b24 100644 --- a/mutt_sasl_plain.c +++ b/mutt_sasl_plain.c @@ -16,8 +16,10 @@ */ #include "config.h" -#include "mutt.h" +#include #include "mutt_sasl_plain.h" +#include "lib.h" +#include "protos.h" size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd, const char *authz, const char *user, const char *pass) diff --git a/mutt_socket.c b/mutt_socket.c index d60858aab..dbdd323f0 100644 --- a/mutt_socket.c +++ b/mutt_socket.c @@ -20,19 +20,20 @@ #include "config.h" #include #include +#include #include #include -#include +#include #include #include #include -#include -#include #include -#include "mutt.h" #include "mutt_socket.h" -#include "mutt_idna.h" +#include "globals.h" #include "mutt_tunnel.h" +#include "options.h" +#include "protos.h" +#include "url.h" #ifdef USE_SSL #include "mutt_ssl.h" #endif diff --git a/mutt_socket.h b/mutt_socket.h index d603d8bf9..6d18e4e6a 100644 --- a/mutt_socket.h +++ b/mutt_socket.h @@ -19,6 +19,7 @@ #ifndef _MUTT_SOCKET_H #define _MUTT_SOCKET_H 1 +#include #include "account.h" #include "lib.h" diff --git a/mutt_ssl.c b/mutt_ssl.c index bc81499b9..bd9ae0296 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -16,20 +16,38 @@ */ #include "config.h" +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include #include +#include #include #include #include +#include +#include #include +#include +#include #include "mutt.h" #include "mutt_ssl.h" -#include "mutt_curses.h" -#include "mutt_idna.h" +#include "account.h" +#include "globals.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mutt_menu.h" #include "mutt_socket.h" +#include "options.h" +#include "protos.h" /* Just in case OpenSSL doesn't define DEVRANDOM */ #ifndef DEVRANDOM diff --git a/mutt_ssl.h b/mutt_ssl.h index b7fa54912..3a9eecf6d 100644 --- a/mutt_ssl.h +++ b/mutt_ssl.h @@ -18,9 +18,9 @@ #ifndef _MUTT_SSL_H #define _MUTT_SSL_H 1 -#include "mutt_socket.h" - #ifdef USE_SSL +struct Connection; + int mutt_ssl_starttls(struct Connection *conn); int mutt_ssl_socket_setup(struct Connection *conn); #endif diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 4f4462600..5b11abae0 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -19,12 +19,23 @@ #include "config.h" #include #include +#include +#include +#include +#include +#include +#include #include "mutt.h" -#include "mutt_curses.h" +#include "account.h" +#include "globals.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mutt_menu.h" #include "mutt_regex.h" #include "mutt_socket.h" -#include "mutt_ssl.h" +#include "options.h" +#include "protos.h" /* certificate error bitmap values */ #define CERTERR_VALID 0 diff --git a/mutt_tunnel.c b/mutt_tunnel.c index 47fd3f827..77716283b 100644 --- a/mutt_tunnel.c +++ b/mutt_tunnel.c @@ -20,12 +20,18 @@ #include #include #include +#include #include #include #include +#include #include "mutt.h" #include "mutt_tunnel.h" +#include "account.h" +#include "globals.h" +#include "lib.h" #include "mutt_socket.h" +#include "protos.h" /* -- data types -- */ struct TunnelData diff --git a/mutt_tunnel.h b/mutt_tunnel.h index a017e1cab..bc1980dfe 100644 --- a/mutt_tunnel.h +++ b/mutt_tunnel.h @@ -16,7 +16,7 @@ #ifndef _MUTT_TUNNEL_H #define _MUTT_TUNNEL_H 1 -#include "mutt_socket.h" +struct Connection; int mutt_tunnel_socket_setup(struct Connection *conn); diff --git a/muttlib.c b/muttlib.c index 797beba70..eaef0fbbb 100644 --- a/muttlib.c +++ b/muttlib.c @@ -17,32 +17,54 @@ */ #include "config.h" +#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include #include #include #include +#include #include "mutt.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" #include "buffer.h" +#include "charset.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" +#include "mutt_regex.h" #include "mx.h" +#include "options.h" +#include "parameter.h" +#include "protos.h" +#include "rfc822.h" +#include "state.h" #include "url.h" #ifdef USE_IMAP #include "imap/imap.h" #endif -#ifdef USE_NOTMUCH -#include "mutt_notmuch.h" -#endif #ifdef HAVE_SYS_SYSCALL_H #include #endif @@ -1102,13 +1124,13 @@ int mutt_check_overwrite(const char *attname, const char *path, char *fname, case 3: /* all */ mutt_str_replace(directory, fname); break; - case 1: /* yes */ + case 1: /* yes */ FREE(directory); break; - case -1: /* abort */ + case -1: /* abort */ FREE(directory); return -1; - case 2: /* no */ + case 2: /* no */ FREE(directory); return 1; } diff --git a/mx.c b/mx.c index c33cb0494..a60fdb250 100644 --- a/mx.c +++ b/mx.c @@ -17,25 +17,38 @@ */ #include "config.h" -#include -#include #include #include +#include #include #include #include #include +#include #include #include #include "mutt.h" #include "mx.h" +#include "address.h" +#include "ascii.h" +#include "body.h" #include "buffy.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" #include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mailbox.h" #include "mutt_crypt.h" -#include "rfc2047.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "sort.h" +#include "thread.h" #include "url.h" #ifdef USE_SIDEBAR #include "sidebar.h" @@ -1051,10 +1064,6 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint) return 0; } -#ifdef USE_NOTMUCH -#include "mutt_notmuch.h" -#endif - /* update a Context structure's internal tables. */ void mx_update_tables(struct Context *ctx, int committing) { diff --git a/mx.h b/mx.h index a11c1da8c..f2ea8e4c1 100644 --- a/mx.h +++ b/mx.h @@ -24,8 +24,40 @@ #ifndef _MUTT_MX_H #define _MUTT_MX_H 1 -#include "buffy.h" -#include "mailbox.h" +#include +#include +#include "where.h" +#ifdef USE_HCACHE +#include "hcache/hcache.h" +#endif + +struct Header; +struct Context; +struct Message; +struct stat; + +/* + * struct mx_ops - a structure to store operations on a mailbox + * The following operations are mandatory: + * - open + * - close + * - check + * + * Optional operations + * - open_new_msg + */ +struct mx_ops +{ + int (*open)(struct Context *ctx); + int (*open_append)(struct Context *ctx, int flags); + int (*close)(struct Context *ctx); + int (*check)(struct Context *ctx, int *index_hint); + int (*sync)(struct Context *ctx, int *index_hint); + int (*open_msg)(struct Context *ctx, struct Message *msg, int msgno); + int (*close_msg)(struct Context *ctx, struct Message *msg); + int (*commit_msg)(struct Context *ctx, struct Message *msg); + int (*open_new_msg)(struct Message *msg, struct Context *ctx, struct Header *hdr); +}; /* supported mailbox formats */ enum @@ -60,7 +92,6 @@ bool maildir_update_flags(struct Context *ctx, struct Header *o, struct Header * void maildir_flags(char *dest, size_t destlen, struct Header *hdr); #ifdef USE_HCACHE -#include "hcache/hcache.h" int mh_sync_mailbox_message(struct Context *ctx, int msgno, header_cache_t *hc); #else int mh_sync_mailbox_message(struct Context *ctx, int msgno); diff --git a/myvar.h b/myvar.h index 911c85377..6d602341b 100644 --- a/myvar.h +++ b/myvar.h @@ -16,7 +16,7 @@ #ifndef _MUTT_MYVAR_H #define _MUTT_MYVAR_H 1 -#include +#include const char *myvar_get(const char *var); int var_to_string(int idx, char *val, size_t len); diff --git a/newsrc.c b/newsrc.c index b4a2e4cc8..e63c53bd6 100644 --- a/newsrc.c +++ b/newsrc.c @@ -18,29 +18,38 @@ */ #include "config.h" -#include #include #include -#include +#include +#include +#include #include #include -#include +#include #include #include "mutt.h" +#include "account.h" #include "bcache.h" -#include "mailbox.h" -#include "mime.h" +#include "context.h" +#include "format_flags.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" #include "mutt_curses.h" +#include "mutt_socket.h" #include "mx.h" #include "nntp.h" -#include "rfc1524.h" -#include "rfc2047.h" -#include "rfc822.h" +#include "options.h" +#include "protos.h" #include "sort.h" +#include "url.h" #ifdef USE_HCACHE #include "hcache/hcache.h" #endif +struct BodyCache; + /* Find NntpData for given newsgroup or add it */ static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *group) { diff --git a/nntp.c b/nntp.c index f6a79da3b..dd116a2ce 100644 --- a/nntp.c +++ b/nntp.c @@ -19,19 +19,29 @@ #include "config.h" #include -#include +#include #include #include #include "mutt.h" #include "nntp.h" +#include "account.h" +#include "bcache.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" #include "mailbox.h" -#include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" +#include "mutt_socket.h" #include "mx.h" -#include "rfc1524.h" -#include "rfc2047.h" -#include "sort.h" +#include "options.h" +#include "protos.h" +#include "thread.h" +#include "url.h" #ifdef USE_SSL #include "mutt_ssl.h" #endif diff --git a/nntp.h b/nntp.h index d5715486f..63deab7f2 100644 --- a/nntp.h +++ b/nntp.h @@ -20,16 +20,22 @@ #ifndef _MUTT_NNTP_H #define _MUTT_NNTP_H 1 +#include #include +#include #include #include -#include "bcache.h" -#include "mailbox.h" -#include "mutt_socket.h" +#include "format_flags.h" +#include "where.h" +#include "mx.h" #ifdef USE_HCACHE #include "hcache/hcache.h" #endif +struct Account; +struct Header; +struct Context; + #define NNTP_PORT 119 #define NNTP_SSL_PORT 563 diff --git a/options.h b/options.h new file mode 100644 index 000000000..cff3bb63d --- /dev/null +++ b/options.h @@ -0,0 +1,292 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_OPTIONS_H_ +#define _MUTT_OPTIONS_H_ 1 + +/* boolean vars */ +enum +{ + OPTALLOW8BIT, + OPTALLOWANSI, + OPTARROWCURSOR, + OPTASCIICHARS, + OPTASKBCC, + OPTASKCC, + OPTASKFOLLOWUP, + OPTASKXCOMMENTTO, + OPTATTACHSPLIT, + OPTAUTOEDIT, + OPTAUTOTAG, + OPTBEEP, + OPTBEEPNEW, + OPTBOUNCEDELIVERED, + OPTBRAILLEFRIENDLY, + OPTCHECKMBOXSIZE, + OPTCHECKNEW, + OPTCOLLAPSEALL, + OPTCOLLAPSEUNREAD, + OPTCONFIRMAPPEND, + OPTCONFIRMCREATE, + OPTDELETEUNTAG, + OPTDIGESTCOLLAPSE, + OPTDUPTHREADS, + OPTEDITHDRS, + OPTENCODEFROM, + OPTENVFROM, + OPTFASTREPLY, + OPTFCCCLEAR, + OPTFLAGSAFE, + OPTFOLLOWUPTO, + OPTFORCENAME, + OPTFORWDECODE, + OPTFORWQUOTE, + OPTFORWREF, +#ifdef USE_HCACHE + OPTHCACHEVERIFY, +#if defined(HAVE_QDBM) || defined(HAVE_TC) || defined(HAVE_KC) + OPTHCACHECOMPRESS, +#endif /* HAVE_QDBM */ +#endif + OPTHDRS, + OPTHEADER, + OPTHEADERCOLORPARTIAL, + OPTHELP, + OPTHIDDENHOST, + OPTHIDELIMITED, + OPTHIDEMISSING, + OPTHIDETHREADSUBJECT, + OPTHIDETOPLIMITED, + OPTHIDETOPMISSING, + OPTHONORDISP, + OPTIGNORELWS, + OPTIGNORELISTREPLYTO, +#ifdef USE_IMAP + OPTIMAPCHECKSUBSCRIBED, + OPTIMAPIDLE, + OPTIMAPLSUB, + OPTIMAPPASSIVE, + OPTIMAPPEEK, + OPTIMAPSERVERNOISE, +#endif +#ifdef USE_SSL +#ifndef USE_SSL_GNUTLS + OPTSSLSYSTEMCERTS, + OPTSSLV2, +#endif /* USE_SSL_GNUTLS */ + OPTSSLV3, + OPTTLSV1, + OPTTLSV1_1, + OPTTLSV1_2, + OPTSSLFORCETLS, + OPTSSLVERIFYDATES, + OPTSSLVERIFYHOST, +#if defined(USE_SSL_OPENSSL) && defined(HAVE_SSL_PARTIAL_CHAIN) + OPTSSLVERIFYPARTIAL, +#endif /* USE_SSL_OPENSSL */ +#endif /* defined(USE_SSL) */ + OPTIMPLICITAUTOVIEW, + OPTINCLUDEONLYFIRST, + OPTKEEPFLAGGED, + OPTKEYWORDSLEGACY, + OPTKEYWORDSSTANDARD, + OPTMAILCAPSANITIZE, + OPTMAILCHECKRECENT, + OPTMAILCHECKSTATS, + OPTMAILDIRTRASH, + OPTMAILDIRCHECKCUR, + OPTMARKERS, + OPTMARKOLD, + OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ + OPTMENUMOVEOFF, /* allow menu to scroll past last entry */ +#if defined(USE_IMAP) || defined(USE_POP) + OPTMESSAGECACHECLEAN, +#endif + OPTMETAKEY, /* interpret ALT-x as ESC-x */ + OPTMETOO, + OPTMHPURGE, + OPTMIMEFORWDECODE, +#ifdef USE_NNTP + OPTMIMESUBJECT, /* encode subject line with RFC2047 */ +#endif + OPTNARROWTREE, + OPTPAGERSTOP, + OPTPIPEDECODE, + OPTPIPESPLIT, +#ifdef USE_POP + OPTPOPAUTHTRYALL, + OPTPOPLAST, +#endif + OPTPOSTPONEENCRYPT, + OPTPRINTDECODE, + OPTPRINTSPLIT, + OPTPROMPTAFTER, + OPTREADONLY, + OPTREFLOWSPACEQUOTES, + OPTREFLOWTEXT, + OPTREPLYSELF, + OPTREPLYWITHXORIG, + OPTRESOLVE, + OPTRESUMEDRAFTFILES, + OPTRESUMEEDITEDDRAFTFILES, + OPTREVALIAS, + OPTREVNAME, + OPTREVREAL, + OPTRFC2047PARAMS, + OPTSAVEADDRESS, + OPTSAVEEMPTY, + OPTSAVENAME, + OPTSCORE, +#ifdef USE_SIDEBAR + OPTSIDEBAR, + OPTSIDEBARFOLDERINDENT, + OPTSIDEBARNEWMAILONLY, + OPTSIDEBARNEXTNEWWRAP, + OPTSIDEBARSHORTPATH, + OPTSIDEBARONRIGHT, +#endif + OPTSIGDASHES, + OPTSIGONTOP, + OPTSORTRE, + OPTSPAMSEP, + OPTSTATUSONTOP, + OPTSTRICTTHREADS, + OPTSUSPEND, + OPTTEXTFLOWED, + OPTTHOROUGHSRC, + OPTTHREADRECEIVED, + OPTTILDE, + OPTTSENABLED, + OPTUNCOLLAPSEJUMP, + OPTUNCOLLAPSENEW, + OPTUSE8BITMIME, + OPTUSEDOMAIN, + OPTUSEFROM, + OPTUSEGPGAGENT, +#ifdef HAVE_LIBIDN + OPTIDNDECODE, + OPTIDNENCODE, +#endif +#ifdef HAVE_GETADDRINFO + OPTUSEIPV6, +#endif + OPTWAITKEY, + OPTWEED, + OPTWRAP, + OPTWRAPSEARCH, + OPTWRITEBCC, /* write out a bcc header? */ + OPTXMAILER, + + OPTCRYPTUSEGPGME, + OPTCRYPTUSEPKA, + + /* PGP options */ + + OPTCRYPTAUTOSIGN, + OPTCRYPTAUTOENCRYPT, + OPTCRYPTAUTOPGP, + OPTCRYPTAUTOSMIME, + OPTCRYPTCONFIRMHOOK, + OPTCRYPTOPPORTUNISTICENCRYPT, + OPTCRYPTREPLYENCRYPT, + OPTCRYPTREPLYSIGN, + OPTCRYPTREPLYSIGNENCRYPTED, + OPTCRYPTTIMESTAMP, + OPTSMIMEISDEFAULT, + OPTASKCERTLABEL, + OPTSDEFAULTDECRYPTKEY, + OPTPGPIGNORESUB, + OPTPGPCHECKEXIT, + OPTPGPLONGIDS, + OPTPGPAUTODEC, + OPTPGPRETAINABLESIG, + OPTPGPSTRICTENC, + OPTFORWDECRYPT, + OPTPGPSHOWUNUSABLE, + OPTPGPAUTOINLINE, + OPTPGPREPLYINLINE, + +/* news options */ + +#ifdef USE_NNTP + OPTSHOWNEWNEWS, + OPTSHOWONLYUNREAD, + OPTSAVEUNSUB, + OPTLISTGROUP, + OPTLOADDESC, + OPTXCOMMENTTO, +#endif + + /* pseudo options */ + + OPTAUXSORT, /* (pseudo) using auxiliary sort function */ + OPTFORCEREFRESH, /* (pseudo) refresh even during macros */ + OPTLOCALES, /* (pseudo) set if user has valid locale definition */ + OPTNOCURSES, /* (pseudo) when sending in batch mode */ + OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */ + OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */ + OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */ + OPTSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals () */ + OPTSYSSIGNALSBLOCKED, /* (pseudo) using by mutt_block_signals_system () */ + OPTNEEDRESORT, /* (pseudo) used to force a re-sort */ + OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */ + OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */ + OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ + OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ + OPTATTACHMSG, /* (pseudo) used by attach-message */ + OPTHIDEREAD, /* (pseudo) whether or not hide read messages */ + OPTKEEPQUIET, /* (pseudo) shut up the message and refresh + * functions while we are executing an + * external program. + */ + OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */ + OPTREDRAWTREE, /* (pseudo) redraw the thread tree */ + OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */ + OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ + OPTIGNOREMACROEVENTS, /* (pseudo) don't process macro/push/exec events while set */ + +#ifdef USE_NNTP + OPTNEWS, /* (pseudo) used to change reader mode */ + OPTNEWSSEND, /* (pseudo) used to change behavior when posting */ +#endif +#ifdef USE_NOTMUCH + OPTVIRTSPOOLFILE, + OPTNOTMUCHRECORD, +#endif + + OPTMAX +}; + +#define mutt_bit_alloc(n) calloc((n + 7) / 8, sizeof(char)) +#define mutt_bit_set(v, n) v[n / 8] |= (1 << (n % 8)) +#define mutt_bit_unset(v, n) v[n / 8] &= ~(1 << (n % 8)) +#define mutt_bit_toggle(v, n) v[n / 8] ^= (1 << (n % 8)) +#define mutt_bit_isset(v, n) (v[n / 8] & (1 << (n % 8))) + +/* bit vector for boolean variables */ +#ifdef MAIN_C +unsigned char Options[(OPTMAX + 7) / 8]; +#else +extern unsigned char Options[]; +#endif + +#define set_option(x) mutt_bit_set(Options, x) +#define unset_option(x) mutt_bit_unset(Options, x) +#define toggle_option(x) mutt_bit_toggle(Options, x) +#define option(x) mutt_bit_isset(Options, x) + +#endif /* _MUTT_OPTIONS_H_ */ diff --git a/pager.c b/pager.c index 30efceb52..0282a346c 100644 --- a/pager.c +++ b/pager.c @@ -16,16 +16,31 @@ */ #include "config.h" +#include #include #include -#include +#include +#include +#include +#include +#include #include #include #include +#include #include "mutt.h" #include "pager.h" +#include "alias.h" #include "attach.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" #include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mailbox.h" #include "mapping.h" #include "mbyte.h" @@ -33,10 +48,17 @@ #include "mutt_curses.h" #include "mutt_menu.h" #include "mutt_regex.h" +#include "mx.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "sort.h" #ifdef USE_SIDEBAR #include "sidebar.h" #endif +#ifdef USE_NNTP +#include "nntp.h" +#endif #define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT) @@ -1156,12 +1178,6 @@ static int fill_buffer(FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char * return b_read; } -#ifdef USE_NNTP -#include "mx.h" -#include "nntp.h" -#endif - - static int format_line(struct line_t **lineInfo, int n, unsigned char *buf, int flags, struct AnsiAttr *pa, int cnt, int *pspace, int *pvch, int *pcol, int *pspecial, struct MuttWindow *pager_window) diff --git a/pager.h b/pager.h index cc59ef5d1..81759c3ba 100644 --- a/pager.h +++ b/pager.h @@ -18,7 +18,10 @@ #ifndef _MUTT_PAGER_H #define _MUTT_PAGER_H 1 -#include "attach.h" +#include + +struct Context; +struct Menu; /* dynamic internal flags */ #define MUTT_SHOWFLAT (1 << 0) diff --git a/parameter.h b/parameter.h new file mode 100644 index 000000000..21b78566b --- /dev/null +++ b/parameter.h @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_PARAMETER_H +#define _MUTT_PARAMETER_H 1 + +#include "lib.h" + +struct Parameter +{ + char *attribute; + char *value; + struct Parameter *next; +}; + +static inline struct Parameter *mutt_new_parameter(void) +{ + return safe_calloc(1, sizeof(struct Parameter)); +} + +#endif /* _MUTT_PARAMETER_H */ diff --git a/parse.c b/parse.c index df9a2860b..345944047 100644 --- a/parse.c +++ b/parse.c @@ -17,19 +17,37 @@ #include "config.h" #include +#include +#include +#include #include #include -#include +#include #include "mutt.h" +#include "ascii.h" +#include "body.h" #include "buffer.h" +#include "charset.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_regex.h" +#include "options.h" +#include "parameter.h" +#include "protos.h" #include "rfc2047.h" #include "rfc2231.h" +#include "rfc822.h" #include "url.h" +struct Address; +struct Context; + /* Reads an arbitrarily long header field, and looks ahead for continuation * lines. ``line'' must point to a dynamically allocated string; it is * increased if more space is required to fit the whole line. diff --git a/pattern.c b/pattern.c index 9fe9c9eef..54f383375 100644 --- a/pattern.c +++ b/pattern.c @@ -16,21 +16,45 @@ */ #include "config.h" +#include #include +#include +#include +#include #include +#include +#include #include #include #include +#include #include +#include +#include #include "mutt.h" +#include "pattern.h" +#include "address.h" +#include "ascii.h" +#include "body.h" +#include "buffer.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "globals.h" #include "group.h" -#include "keymap.h" +#include "header.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" -#include "mapping.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "mutt_regex.h" +#include "options.h" +#include "protos.h" +#include "state.h" +#include "thread.h" #ifdef USE_IMAP #include "imap/imap.h" #include "mx.h" diff --git a/pattern.h b/pattern.h new file mode 100644 index 000000000..aaaa2a2c7 --- /dev/null +++ b/pattern.h @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_PATTERN_H +#define _MUTT_PATTERN_H 1 + +#include +#include +#include +#include "lib.h" + +struct Address; +struct Buffer; +struct Header; +struct Context; + +struct Pattern +{ + short op; + bool not : 1; + bool alladdr : 1; + bool stringmatch : 1; + bool groupmatch : 1; + bool ign_case : 1; /* ignore case for local stringmatch searches */ + bool isalias : 1; + int min; + int max; + struct Pattern *next; + struct Pattern *child; /* arguments to logical op */ + union { + regex_t *rx; + struct Group *g; + char *str; + } p; +}; + +typedef enum { + MUTT_MATCH_FULL_ADDRESS = 1 +} pattern_exec_flag; + +/* This is used when a message is repeatedly pattern matched against. + * e.g. for color, scoring, hooks. It caches a few of the potentially slow + * operations. + * Each entry has a value of 0 = unset, 1 = false, 2 = true + */ +struct PatternCache +{ + int list_all; /* ^~l */ + int list_one; /* ~l */ + int sub_all; /* ^~u */ + int sub_one; /* ~u */ + int pers_recip_all; /* ^~p */ + int pers_recip_one; /* ~p */ + int pers_from_all; /* ^~P */ + int pers_from_one; /* ~P */ +}; + +static inline struct Pattern *new_pattern(void) +{ + return safe_calloc(1, sizeof(struct Pattern)); +} + +int mutt_pattern_exec(struct Pattern *pat, pattern_exec_flag flags, + struct Context *ctx, struct Header *h, struct PatternCache *cache); +struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer *err); +void mutt_check_simple(char *s, size_t len, const char *simple); +void mutt_pattern_free(struct Pattern **pat); + +int mutt_which_case(const char *s); +int mutt_is_list_recipient(int alladdr, struct Address *a1, struct Address *a2); +int mutt_is_list_cc(int alladdr, struct Address *a1, struct Address *a2); +int mutt_pattern_func(int op, char *prompt); +int mutt_search_command(int cur, int op); + +bool mutt_limit_current_thread(struct Header *h); + +#endif /* _MUTT_PATTERN_H */ diff --git a/pgp.c b/pgp.c index 4c23a90de..02e0bc8e2 100644 --- a/pgp.c +++ b/pgp.c @@ -26,25 +26,35 @@ */ #include "config.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include +#include #include #include "mutt.h" #include "pgp.h" -#include "copy.h" +#include "address.h" +#include "ascii.h" +#include "body.h" +#include "charset.h" #include "filter.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" -#include "mutt_menu.h" - +#include "mutt_regex.h" +#include "options.h" +#include "pgplib.h" +#include "protos.h" +#include "rfc822.h" +#include "state.h" char PgpPass[LONG_STRING]; time_t PgpExptime = 0; /* when does the cached passphrase expire? */ @@ -1280,8 +1290,7 @@ char *pgp_find_keys(struct Address *adrlist, int oppenc_mode) bypass_selection: keylist_size += mutt_strlen(keyID) + 4; safe_realloc(&keylist, keylist_size); - sprintf(keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", - keyID); + sprintf(keylist + keylist_used, "%s0x%s", keylist_used ? " " : "", keyID); keylist_used = mutt_strlen(keylist); key_selected = 1; diff --git a/pgp.h b/pgp.h index edfb08a01..99f1e6057 100644 --- a/pgp.h +++ b/pgp.h @@ -22,11 +22,17 @@ #ifdef CRYPT_BACKEND_CLASSIC_PGP +#include +#include +#include #include "mutt_crypt.h" -#include "pgplib.h" - -/* prototypes */ +struct Address; +struct Body; +struct Header; +struct List; +struct PgpKeyInfo; +struct State; bool pgp_use_gpg_agent(void); diff --git a/pgpinvoke.c b/pgpinvoke.c index 224fbe472..b887fc6a5 100644 --- a/pgpinvoke.c +++ b/pgpinvoke.c @@ -21,18 +21,21 @@ #include "config.h" #include +#include #include -#include #include -#include -#include -#include #include -#include "mutt.h" +#include "address.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "lib.h" +#include "list.h" +#include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" #include "pgp.h" +#include "protos.h" #include "rfc822.h" /* diff --git a/pgpkey.c b/pgpkey.c index a5e6fc88e..965a2936f 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -18,21 +18,38 @@ #include "config.h" #include +#include #include +#include +#include #include #include #include -#include +#include #include #include "mutt.h" +#include "address.h" +#include "body.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mime.h" +#include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "options.h" #include "pager.h" #include "pgp.h" +#include "pgplib.h" +#include "protos.h" +#include "rfc822.h" #include "sort.h" +struct List; + struct pgp_cache { char *what; diff --git a/pgplib.c b/pgplib.c index 14034e5a8..09230cd05 100644 --- a/pgplib.c +++ b/pgplib.c @@ -18,14 +18,10 @@ /* Generally useful, pgp-related functions. */ #include "config.h" -#include -#include -#include -#include -#include -#include "mutt.h" +#include #include "pgplib.h" #include "lib.h" +#include "mutt_crypt.h" const char *pgp_pkalgbytype(unsigned char type) { diff --git a/pgplib.h b/pgplib.h index cb29128b9..de8230119 100644 --- a/pgplib.h +++ b/pgplib.h @@ -21,8 +21,9 @@ #ifdef CRYPT_BACKEND_CLASSIC_PGP -#include "mutt_crypt.h" - +#include +#include +#include "lib.h" struct PgpSignature { diff --git a/pgpmicalg.c b/pgpmicalg.c index bc3c98665..bda842c5b 100644 --- a/pgpmicalg.c +++ b/pgpmicalg.c @@ -21,13 +21,16 @@ #include "config.h" #include +#include +#include #include -#include #include +#include #include "mutt.h" -#include "charset.h" -#include "pgp.h" +#include "lib.h" #include "pgppacket.h" +#include "protos.h" +#include "state.h" static const struct { diff --git a/pgppacket.c b/pgppacket.c index 64bd6ae74..c64ba2c67 100644 --- a/pgppacket.c +++ b/pgppacket.c @@ -18,13 +18,7 @@ #include "config.h" #include #include -#include -#include -#include -/* yuck, we were including this one somewhere below. */ -#include "mutt.h" #include "lib.h" -#include "pgppacket.h" #define CHUNKSIZE 1024 diff --git a/pgppacket.h b/pgppacket.h index 967a46982..1ee77c6f3 100644 --- a/pgppacket.h +++ b/pgppacket.h @@ -23,6 +23,8 @@ #ifndef _MUTT_PGPPACKET_H #define _MUTT_PGPPACKET_H 1 +#include + enum packet_tags { PT_RES0 = 0, /* reserved */ diff --git a/pgppubring.c b/pgppubring.c index 009905612..c295b4591 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -31,7 +31,8 @@ */ #include "config.h" -#include +#include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include "lib.h" #include "md5.h" +#include "mutt_crypt.h" #include "pgplib.h" #include "pgppacket.h" #include "sha1.h" diff --git a/pop.c b/pop.c index 95d4209cc..188114606 100644 --- a/pop.c +++ b/pop.c @@ -18,14 +18,30 @@ #include "config.h" #include +#include +#include +#include #include #include #include "mutt.h" #include "pop.h" +#include "account.h" #include "bcache.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" +#include "mailbox.h" #include "mutt_crypt.h" #include "mutt_curses.h" +#include "mutt_socket.h" #include "mx.h" +#include "options.h" +#include "protos.h" +#include "url.h" #ifdef USE_HCACHE #include "hcache/hcache.h" #endif diff --git a/pop.h b/pop.h index 876d95b4f..d25235a21 100644 --- a/pop.h +++ b/pop.h @@ -18,10 +18,13 @@ #ifndef _MUTT_POP_H #define _MUTT_POP_H 1 -#include "bcache.h" -#include "mailbox.h" -#include "mutt_curses.h" -#include "mutt_socket.h" +#include +#include +#include "mx.h" + +struct Account; +struct Context; +struct Progress; #define POP_PORT 110 #define POP_SSL_PORT 995 diff --git a/pop_auth.c b/pop_auth.c index 71e549874..afe8902bc 100644 --- a/pop_auth.c +++ b/pop_auth.c @@ -16,12 +16,19 @@ */ #include "config.h" +#include +#include #include -#include -#include "mutt.h" +#include "account.h" +#include "ascii.h" +#include "globals.h" +#include "lib.h" #include "md5.h" -#include "mx.h" +#include "mutt_socket.h" +#include "options.h" #include "pop.h" +#include "protos.h" +#include "rfc822.h" #ifdef USE_SASL #include #include diff --git a/pop_lib.c b/pop_lib.c index 0fc6b2dab..cbd9044fb 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -16,15 +16,25 @@ */ #include "config.h" -#include #include #include #include +#include +#include +#include #include -#include #include "mutt.h" -#include "mx.h" +#include "account.h" +#include "ascii.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "mutt_curses.h" +#include "mutt_socket.h" +#include "options.h" #include "pop.h" +#include "protos.h" #include "url.h" #ifdef USE_SSL #include "mutt_ssl.h" diff --git a/postpone.c b/postpone.c index bbb05128d..3f58a4f9c 100644 --- a/postpone.c +++ b/postpone.c @@ -17,17 +17,36 @@ */ #include "config.h" -#include +#include +#include +#include #include #include +#include #include #include "mutt.h" +#include "ascii.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mapping.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_menu.h" +#include "options.h" +#include "protos.h" #include "sort.h" +#include "state.h" +#include "thread.h" #ifdef USE_IMAP #include "imap/imap.h" #endif diff --git a/protos.h b/protos.h index 01784b0c6..0f6144b50 100644 --- a/protos.h +++ b/protos.h @@ -19,8 +19,34 @@ #ifndef _MUTT_PROTOS_H #define _MUTT_PROTOS_H 1 -#include -#include "mbyte.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "format_flags.h" +#include "options.h" + +struct Address; +struct Alias; +struct Body; +struct Buffer; +struct Context; +struct EnterState; +struct Envelope; +struct Header; +struct List; +struct Parameter; +struct Regex; +struct ReplaceList; +struct RxList; +struct State; + +struct stat; +struct passwd; #define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#') @@ -45,34 +71,8 @@ void mutt_make_string_info(char *dst, size_t dstlen, int cols, const char *s, void mutt_free_opts(void); -#define mutt_system(x) _mutt_system(x, 0) int _mutt_system(const char *cmd, int flags); - -#define mutt_next_thread(x) _mutt_aside_thread(x, 1, 0) -#define mutt_previous_thread(x) _mutt_aside_thread(x, 0, 0) -#define mutt_next_subthread(x) _mutt_aside_thread(x, 1, 1) -#define mutt_previous_subthread(x) _mutt_aside_thread(x, 0, 1) -int _mutt_aside_thread(struct Header *hdr, short dir, short subthreads); - -#define mutt_collapse_thread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_COLLAPSE) -#define mutt_uncollapse_thread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_UNCOLLAPSE) -#define mutt_get_hidden(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_GET_HIDDEN) -#define mutt_thread_contains_unread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_UNREAD) -#define mutt_thread_next_unread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_NEXT_UNREAD) -int _mutt_traverse_thread(struct Context *ctx, struct Header *cur, int flag); - -typedef const char *format_t(char *, size_t, size_t, int, char, const char *, - const char *, const char *, const char *, - unsigned long, format_flag); - -void mutt_FormatString(char *dest, /* output buffer */ - size_t destlen, /* output buffer len */ - size_t col, /* starting column (nonzero when called recursively) */ - int cols, /* maximum columns */ - const char *src, /* template string */ - format_t *callback, /* callback for processing */ - unsigned long data, /* callback data */ - format_flag flags); /* callback flags */ +#define mutt_system(x) _mutt_system(x, 0) void mutt_parse_content_type(char *s, struct Body *ct); void mutt_generate_boundary(struct Parameter **parm); @@ -93,11 +93,8 @@ int quadoption(int opt); char *mutt_extract_message_id(const char *s, const char **saveptr); struct Address *mutt_default_from(void); -struct Address *mutt_get_address(struct Envelope *env, char **pfxp); -struct Address *mutt_lookup_alias(const char *s); struct Address *mutt_remove_duplicates(struct Address *addr); struct Address *mutt_remove_xrefs(struct Address *a, struct Address *b); -struct Address *mutt_expand_aliases(struct Address *a); struct Address *mutt_parse_adrlist(struct Address *p, const char *s); struct Body *mutt_make_file_attach(const char *path); @@ -111,8 +108,6 @@ struct Body *mutt_read_mime_header(FILE *fp, int digest); struct Content *mutt_get_content_info(const char *fname, struct Body *b); -struct Hash *mutt_make_id_hash(struct Context *ctx); - char *mutt_read_rfc822_line(FILE *f, char *line, size_t *linelen); struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr, short user_hdrs, short weed); @@ -137,7 +132,6 @@ char *_mutt_expand_path(char *s, size_t slen, int rx); char *mutt_find_hook(int type, const char *pat); char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw); char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b); -const char *mutt_get_name(struct Address *a); char *mutt_get_parameter(const char *s, struct Parameter *p); struct List *mutt_crypt_hook(struct Address *adr); char *mutt_make_date(char *s, size_t len); @@ -149,8 +143,6 @@ const char *mutt_make_version(void); const char *mutt_fqdn(short may_hide_host); -struct Group *mutt_pattern_group(const char *k); - struct Regex *mutt_compile_regexp(const char *s, int flags); void mutt_account_hook(const char *url); @@ -164,7 +156,6 @@ void mutt_block_signals(void); void mutt_block_signals_system(void); int mutt_body_handler(struct Body *b, struct State *s); int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to); -void mutt_break_thread(struct Header *hdr); void mutt_buffy(char *s, size_t slen); int mutt_buffy_list(void); void mutt_canonical_charset(char *dest, size_t dlen, const char *name); @@ -172,7 +163,6 @@ int mutt_count_body_parts(struct Context *ctx, struct Header *hdr); void mutt_check_rescore(struct Context *ctx); void mutt_clear_error(void); void mutt_clear_pager_position(void); -void mutt_create_alias(struct Envelope *cur, struct Address *iadr); void mutt_decode_attachment(struct Body *b, struct State *s); void mutt_decode_base64(struct State *s, long len, int istext, iconv_t cd); void mutt_default_save(char *path, size_t pathlen, struct Header *hdr); @@ -184,7 +174,6 @@ void mutt_edit_headers(const char *editor, const char *body, struct Header *msg, char *fcc, size_t fcclen); char **mutt_envlist(void); void mutt_envlist_set(const char *name, const char *value, bool overwrite); -int mutt_filter_unprintable(char **s); int mutt_label_message(struct Header *hdr); void mutt_make_label_hash(struct Context *ctx); void mutt_label_hash_add(struct Context *ctx, struct Header *hdr); @@ -195,7 +184,6 @@ void mutt_curses_message(const char *fmt, ...); void mutt_encode_descriptions(struct Body *b, short recurse); void mutt_encode_path(char *dest, size_t dlen, const char *src); void mutt_enter_command(void); -void mutt_expand_aliases_env(struct Envelope *env); void mutt_expand_file_fmt(char *dest, size_t destlen, const char *fmt, const char *src); void mutt_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *src); void mutt_fix_reply_recipients(struct Envelope *env); @@ -215,7 +203,6 @@ void mutt_free_header(struct Header **h); void mutt_free_parameter(struct Parameter **p); void mutt_free_regexp(struct Regex **pp); void mutt_help(int menu); -void mutt_draw_tree(struct Context *ctx); void mutt_check_lookup_list(struct Body *b, char *type, int len); void mutt_make_attribution(struct Context *ctx, struct Header *cur, FILE *out); void mutt_make_forward_subject(struct Envelope *env, struct Context *ctx, struct Header *cur); @@ -263,7 +250,6 @@ void mutt_update_encoding(struct Body *a); void mutt_version(void); void mutt_view_attachments(struct Header *hdr); void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int display); -void mutt_set_virtual(struct Context *ctx); int mutt_add_to_rx_list(struct RxList **list, const char *s, int flags, struct Buffer *err); bool mutt_addr_is_user(struct Address *addr); int mutt_addwch(wchar_t wc); @@ -303,7 +289,6 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags); int mutt_chscmp(const char *s, const char *chs); #define mutt_is_utf8(a) mutt_chscmp(a, "utf-8") #define mutt_is_us_ascii(a) mutt_chscmp(a, "us-ascii") -int mutt_parent_message(struct Context *ctx, struct Header *hdr, int find_root); int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Header *newhdr, struct Header *hdr, short resend); int mutt_resend_message(FILE *fp, struct Context *ctx, struct Header *cur); int mutt_compose_to_sender(struct Header *hdr); @@ -328,15 +313,11 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres const char *msg, int eightbit); bool mutt_is_mail_list(struct Address *addr); bool mutt_is_message_type(int type, const char *subtype); -int mutt_is_list_cc(int alladdr, struct Address *a1, struct Address *a2); -int mutt_is_list_recipient(int alladdr, struct Address *a1, struct Address *a2); bool mutt_is_subscribed_list(struct Address *addr); bool mutt_is_text_part(struct Body *b); -int mutt_link_threads(struct Header *cur, struct Header *last, struct Context *ctx); int mutt_lookup_mime_type(struct Body *att, const char *path); bool mutt_match_rx_list(const char *s, struct RxList *l); bool mutt_match_spam_list(const char *s, struct ReplaceList *l, char *text, int textsize); -int mutt_messages_in_thread(struct Context *ctx, struct Header *hdr, int flag); int mutt_multi_choice(char *prompt, char *letters); bool mutt_needs_mailcap(struct Body *m); int mutt_num_postponed(int force); @@ -356,7 +337,6 @@ int mutt_parse_rfc822_line(struct Envelope *e, struct Header *hdr, char *line, c int mutt_parse_score(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); int mutt_parse_unscore(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); -int mutt_pattern_func(int op, char *prompt); int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfile); int mutt_print_attachment(FILE *fp, struct Body *a); int mutt_query_complete(char *buf, size_t buflen); @@ -364,7 +344,6 @@ int mutt_query_variables(struct List *queries); int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct Header *hdr); int _mutt_save_message(struct Header *h, struct Context *ctx, int delete, int decode, int decrypt); int mutt_save_message(struct Header *h, int delete, int decode, int decrypt); -int mutt_search_command(int cur, int op); #ifdef USE_SMTP int mutt_smtp_send(const struct Address *from, const struct Address *to, const struct Address *cc, const struct Address *bcc, const char *msgfile, int eightbit); @@ -376,7 +355,6 @@ int mutt_strwidth(const char *s); int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, struct Header *cur, int flags); int mutt_thread_set_flag(struct Header *hdr, int flag, int bf, int subthread); void mutt_update_num_postponed(void); -int mutt_which_case(const char *s); int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, int post, char *fcc, char **finalpath); int mutt_write_multiple_fcc(const char *path, struct Header *hdr, const char *msgid, @@ -420,17 +398,6 @@ int mutt_wctoutf8(char *s, unsigned int c, size_t buflen); #define IsWPrint(wc) (iswprint(wc) || (option(OPTLOCALES) ? 0 : (wc >= 0xa0))) #endif -static inline struct Pattern *new_pattern(void) -{ - return safe_calloc(1, sizeof(struct Pattern)); -} - -int mutt_pattern_exec(struct Pattern *pat, pattern_exec_flag flags, - struct Context *ctx, struct Header *h, struct PatternCache *cache); -struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer *err); -void mutt_check_simple(char *s, size_t len, const char *simple); -void mutt_pattern_free(struct Pattern **pat); - int getdnsdomainname(char *, size_t); /* unsorted */ diff --git a/query.c b/query.c index 66c94aa07..c71afa13c 100644 --- a/query.c +++ b/query.c @@ -16,14 +16,30 @@ */ #include "config.h" -#include -#include +#include +#include +#include +#include +#include #include +#include #include "mutt.h" +#include "address.h" +#include "alias.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mapping.h" +#include "mutt_curses.h" #include "mutt_idna.h" #include "mutt_menu.h" +#include "protos.h" +#include "rfc822.h" struct Query { diff --git a/recvattach.c b/recvattach.c index 781fb03bb..fd31fe8e6 100644 --- a/recvattach.c +++ b/recvattach.c @@ -17,16 +17,26 @@ */ #include "config.h" -#include -#include -#include +#include +#include +#include +#include #include #include -#include #include #include "mutt.h" +#include "ascii.h" #include "attach.h" +#include "body.h" +#include "context.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mailbox.h" #include "mapping.h" #include "mime.h" @@ -34,7 +44,10 @@ #include "mutt_curses.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "rfc1524.h" +#include "state.h" static const char *Mailbox_is_read_only = N_("Mailbox is read-only."); diff --git a/recvcmd.c b/recvcmd.c index 3411971c7..b4ff7cd8b 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -16,13 +16,25 @@ */ #include "config.h" +#include +#include +#include +#include #include "mutt.h" +#include "alias.h" #include "attach.h" +#include "body.h" #include "copy.h" -#include "mapping.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_idna.h" -#include "mutt_menu.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" +#include "state.h" /* some helper functions to verify that we are exclusively operating * on message/rfc822 attachments diff --git a/remailer.c b/remailer.c index c172d0bee..c14793157 100644 --- a/remailer.c +++ b/remailer.c @@ -21,18 +21,29 @@ #include "config.h" #include +#include #include -#include #include -#include -#include +#include #include "mutt.h" #include "remailer.h" +#include "address.h" +#include "ascii.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" +#include "list.h" #include "mapping.h" #include "mutt_curses.h" #include "mutt_menu.h" -#include "mutt_regex.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" struct coord { diff --git a/remailer.h b/remailer.h index e627e1791..34fb263de 100644 --- a/remailer.h +++ b/remailer.h @@ -22,6 +22,11 @@ #ifndef _MUTT_REMAILER_H #define _MUTT_REMAILER_H 1 +#include + +struct List; +struct Header; + #ifdef MIXMASTER #define MIX_CAP_COMPRESS (1 << 0) diff --git a/resize.c b/resize.c index 02c350abf..ff287d492 100644 --- a/resize.c +++ b/resize.c @@ -17,10 +17,10 @@ #include "config.h" #include +#include #include -#include #include -#include "mutt.h" +#include "lib.h" #include "mutt_curses.h" #ifdef HAVE_SYS_IOCTL_H #include diff --git a/rfc1524.c b/rfc1524.c index c677c1392..d2727e450 100644 --- a/rfc1524.c +++ b/rfc1524.c @@ -26,15 +26,18 @@ */ #include "config.h" -#include -#include -#include +#include +#include #include -#include -#include #include #include "mutt.h" #include "rfc1524.h" +#include "ascii.h" +#include "body.h" +#include "globals.h" +#include "lib.h" +#include "options.h" +#include "protos.h" /* The command semantics include the following: * %s is the filename that contains the mail body data diff --git a/rfc1524.h b/rfc1524.h index 6e5fd7d66..6d4f58639 100644 --- a/rfc1524.h +++ b/rfc1524.h @@ -18,6 +18,11 @@ #ifndef _MUTT_RFC1524_H #define _MUTT_RFC1524_H 1 +#include +#include + +struct Body; + struct Rfc1524MailcapEntry { char *command; diff --git a/rfc2047.c b/rfc2047.c index 2f3c38607..f4986e17a 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -19,13 +19,18 @@ #include "config.h" #include #include -#include -#include +#include #include -#include "mutt.h" #include "rfc2047.h" +#include "address.h" +#include "ascii.h" #include "charset.h" +#include "globals.h" +#include "lib.h" +#include "mbyte.h" #include "mime.h" +#include "options.h" +#include "protos.h" /* If you are debugging this file, comment out the following line. */ /* #define NDEBUG */ diff --git a/rfc2047.h b/rfc2047.h index 28152b6c4..4b122b2af 100644 --- a/rfc2047.h +++ b/rfc2047.h @@ -18,6 +18,10 @@ #ifndef _MUTT_RFC2047_H #define _MUTT_RFC2047_H 1 +#include + +struct Address; + char *mutt_choose_charset(const char *fromcode, const char *charsets, char *u, size_t ulen, char **d, size_t *dlen); int convert_nonmime_string(char **ps); diff --git a/rfc2231.c b/rfc2231.c index c934bcf0d..13cc3f54e 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -27,12 +27,18 @@ #include "config.h" #include +#include #include #include -#include "mutt.h" #include "rfc2231.h" #include "charset.h" +#include "globals.h" +#include "lib.h" +#include "mbyte.h" #include "mime.h" +#include "options.h" +#include "parameter.h" +#include "protos.h" #include "rfc2047.h" struct rfc2231_parameter diff --git a/rfc2231.h b/rfc2231.h index e9e3d4c66..353f84fb1 100644 --- a/rfc2231.h +++ b/rfc2231.h @@ -18,6 +18,8 @@ #ifndef _MUTT_RFC2231_H #define _MUTT_RFC2231_H 1 +struct Parameter; + void rfc2231_decode_parameters(struct Parameter **headp); int rfc2231_encode_string(char **pd); diff --git a/rfc3676.c b/rfc3676.c index 9d9ed969a..97a34259a 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -21,16 +21,21 @@ /* This file was originally part of mutt-ng */ #include "config.h" -#include -#include +#include +#include +#include #include -#include -#include #include #include "mutt.h" #include "ascii.h" +#include "body.h" +#include "globals.h" +#include "header.h" #include "lib.h" #include "mutt_curses.h" +#include "options.h" +#include "protos.h" +#include "state.h" #define FLOWED_MAX 72 diff --git a/rfc3676.h b/rfc3676.h index 8c57def8f..0d473e6a3 100644 --- a/rfc3676.h +++ b/rfc3676.h @@ -22,7 +22,9 @@ #ifndef _MUTT_RFC3676_H #define _MUTT_RFC3676_H 1 -#include "mutt.h" +struct Body; +struct Header; +struct State; /* body handler implementing RfC 3676 for format=flowed */ int rfc3676_handler(struct Body *a, struct State *s); diff --git a/rfc822.c b/rfc822.c index b41a95279..37b60f6b9 100644 --- a/rfc822.c +++ b/rfc822.c @@ -17,12 +17,12 @@ */ #include "config.h" -#include +#include #include +#include "rfc822.h" +#include "ascii.h" -#ifndef TESTING -#include "mutt.h" -#else +#ifdef TESTING #define safe_strdup strdup #define safe_malloc malloc #define FREE(x) safe_free(x) diff --git a/rfc822.h b/rfc822.h index 7a985a70e..b648b836c 100644 --- a/rfc822.h +++ b/rfc822.h @@ -19,6 +19,9 @@ #ifndef _MUTT_RFC822_H #define _MUTT_RFC822_H 1 +#include +#include +#include "address.h" #include "lib.h" /* possible values for RFC822Error */ @@ -32,19 +35,6 @@ enum ERR_BAD_ADDR_SPEC }; -struct Address -{ -#ifdef EXACT_ADDRESS - char *val; /* value of address as parsed */ -#endif - char *personal; /* real name of address */ - char *mailbox; /* mailbox and host address */ - int group; /* group mailbox? */ - struct Address *next; - bool is_intl : 1; - bool intl_checked : 1; -}; - void rfc822_dequote_comment(char *s); void rfc822_free_address(struct Address **p); void rfc822_qualify(struct Address *addr, const char *host); diff --git a/safe_asprintf.c b/safe_asprintf.c index c498f8b53..36c7cf846 100644 --- a/safe_asprintf.c +++ b/safe_asprintf.c @@ -15,6 +15,7 @@ * this program. If not, see . */ +#include #include #include "lib.h" @@ -78,7 +79,7 @@ int safe_asprintf(char **strp, const char *fmt, ...) /* reduce space to just that which was used. note that 'n' does not * include the terminal nul char. */ - if (n == 0) /* convention is to use NULL for zero-length strings. */ + if (n == 0) /* convention is to use NULL for zero-length strings. */ FREE(strp); else if (n != rlen - 1) safe_realloc(strp, n + 1); diff --git a/score.c b/score.c index 2d035f088..b56cfb12e 100644 --- a/score.c +++ b/score.c @@ -19,7 +19,16 @@ #include #include #include "mutt.h" +#include "buffer.h" +#include "context.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "lib.h" #include "mutt_menu.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "sort.h" struct Score diff --git a/send.c b/send.c index 0e02cf40c..1743eb0f7 100644 --- a/send.c +++ b/send.c @@ -17,28 +17,42 @@ #include "config.h" #include -#include #include +#include #include -#include +#include +#include +#include #include #include -#include -#include #include #include -#include #include "mutt.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" +#include "context.h" #include "copy.h" +#include "envelope.h" #include "filter.h" -#include "keymap.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" +#include "mutt_regex.h" +#include "options.h" +#include "pattern.h" +#include "protos.h" #include "rfc2047.h" #include "rfc3676.h" +#include "rfc822.h" +#include "sort.h" #include "url.h" #ifdef USE_NNTP #include "mx.h" diff --git a/sendlib.c b/sendlib.c index 4e91ef428..33bbec121 100644 --- a/sendlib.c +++ b/sendlib.c @@ -18,28 +18,52 @@ #define _SENDLIB_C 1 #include "config.h" +#include #include #include #include +#include +#include +#include #include +#include +#include #include #include #include #include +#include #include +#include #include "mutt.h" +#include "address.h" +#include "ascii.h" +#include "body.h" #include "buffy.h" #include "charset.h" +#include "content.h" +#include "context.h" #include "copy.h" +#include "envelope.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "lib.h" +#include "list.h" #include "mailbox.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_idna.h" #include "mx.h" +#include "options.h" #include "pager.h" +#include "parameter.h" +#include "protos.h" #include "rfc2047.h" #include "rfc2231.h" +#include "rfc822.h" +#include "state.h" #ifdef USE_NNTP #include "nntp.h" #endif diff --git a/sha1.h b/sha1.h index 9f51a7120..dcaeb12ab 100644 --- a/sha1.h +++ b/sha1.h @@ -8,7 +8,7 @@ #ifndef _MUTT_SHA1_H #define _MUTT_SHA1_H 1 -#include +#include struct Sha1Ctx { diff --git a/sidebar.c b/sidebar.c index d24fbd22d..16047c72f 100644 --- a/sidebar.c +++ b/sidebar.c @@ -19,13 +19,23 @@ */ #include "config.h" +#include +#include +#include +#include #include "mutt.h" #include "sidebar.h" #include "buffy.h" -#include "keymap.h" +#include "context.h" +#include "format_flags.h" +#include "globals.h" +#include "keymap_defs.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" #ifdef USE_NOTMUCH #include "mutt_notmuch.h" diff --git a/sidebar.h b/sidebar.h index 40d970ea0..fc3360dca 100644 --- a/sidebar.h +++ b/sidebar.h @@ -20,8 +20,8 @@ #ifndef _MUTT_SIDEBAR_H #define _MUTT_SIDEBAR_H 1 -#include "mutt.h" -#include "buffy.h" +struct Context; +struct Buffy; void mutt_sb_change_mailbox(int op); void mutt_sb_draw(void); diff --git a/signal.c b/signal.c index fe8a09bfb..c7ff83ec5 100644 --- a/signal.c +++ b/signal.c @@ -18,10 +18,13 @@ #include "config.h" #include #include +#include +#include #include -#include -#include "mutt.h" +#include "globals.h" +#include "lib.h" #include "mutt_curses.h" +#include "options.h" static sigset_t Sigset; static sigset_t SigsetSys; @@ -35,7 +38,7 @@ static void exit_handler(int sig) curs_set(1); endwin(); /* just to be safe */ - /* +/* * if sys_siglist is not defined, HAVE_DECL_SYS_SIGLIST will be set to 0 * so we must check it with #if and not #ifdef */ diff --git a/smime.c b/smime.c index 56270263f..9e242c4e3 100644 --- a/smime.c +++ b/smime.c @@ -18,23 +18,36 @@ */ #include "config.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include -#include -#include -#include +#include #include "mutt.h" #include "smime.h" +#include "address.h" +#include "alias.h" +#include "ascii.h" +#include "body.h" #include "copy.h" +#include "envelope.h" #include "filter.h" +#include "format_flags.h" +#include "globals.h" +#include "header.h" +#include "keymap.h" +#include "keymap_defs.h" +#include "lib.h" #include "mime.h" #include "mutt_crypt.h" #include "mutt_curses.h" #include "mutt_menu.h" +#include "options.h" +#include "protos.h" +#include "rfc822.h" +#include "state.h" struct smime_command_context { diff --git a/smime.h b/smime.h index 0065c7f56..1ab132444 100644 --- a/smime.h +++ b/smime.h @@ -21,7 +21,13 @@ #ifdef CRYPT_BACKEND_CLASSIC_SMIME -#include "mutt_crypt.h" +#include + +struct Address; +struct Body; +struct Envelope; +struct Header; +struct State; struct SmimeKey { diff --git a/smtp.c b/smtp.c index 0842e3cc5..e0fccffe5 100644 --- a/smtp.c +++ b/smtp.c @@ -21,11 +21,22 @@ #include "config.h" #include #include +#include #include +#include #include +#include #include "mutt.h" +#include "account.h" +#include "address.h" +#include "ascii.h" +#include "globals.h" +#include "lib.h" #include "mutt_curses.h" #include "mutt_socket.h" +#include "options.h" +#include "protos.h" +#include "url.h" #ifdef USE_SSL #include "mutt_ssl.h" #endif diff --git a/sort.c b/sort.c index ca50f708b..730397e59 100644 --- a/sort.c +++ b/sort.c @@ -16,13 +16,22 @@ */ #include "config.h" -#include #include #include -#include #include "mutt.h" #include "sort.h" +#include "address.h" +#include "body.h" +#include "buffer.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "header.h" +#include "lib.h" #include "mutt_idna.h" +#include "options.h" +#include "protos.h" +#include "thread.h" #ifdef USE_NNTP #include "mx.h" #include "nntp.h" diff --git a/sort.h b/sort.h index 2257791c2..a08fcebf0 100644 --- a/sort.h +++ b/sort.h @@ -18,6 +18,12 @@ #ifndef _MUTT_SORT_H #define _MUTT_SORT_H 1 +#include "mapping.h" +#include "where.h" + +struct Address; +struct Context; + #define SORT_DATE 1 /* the date the mail was sent. */ #define SORT_SIZE 2 #define SORT_SUBJECT 3 @@ -59,11 +65,8 @@ typedef int sort_t(const void *, const void *); sort_t *mutt_get_sort_func(int method); -void mutt_clear_threads(struct Context *ctx); void mutt_sort_headers(struct Context *ctx, int init); -void mutt_sort_threads(struct Context *ctx, int init); int mutt_select_sort(int reverse); -struct MuttThread *mutt_sort_subthreads(struct MuttThread *thread, int init); WHERE short BrowserSort INITVAL(SORT_SUBJECT); WHERE short Sort INITVAL(SORT_DATE); @@ -74,7 +77,8 @@ WHERE short SidebarSortMethod INITVAL(SORT_ORDER); /* FIXME: This one does not belong to here */ WHERE short PgpSortKeys INITVAL(SORT_ADDRESS); -#include "mapping.h" extern const struct mapping_t SortMethods[]; +const char *mutt_get_name(struct Address *a); + #endif /* _MUTT_SORT_H */ diff --git a/state.h b/state.h new file mode 100644 index 000000000..2885b0d29 --- /dev/null +++ b/state.h @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_STATE_H +#define _MUTT_STATE_H 1 + +#include + +struct State +{ + FILE *fpin; + FILE *fpout; + char *prefix; + int flags; +}; + +#endif /* _MUTT_STATE_H */ diff --git a/status.c b/status.c index c15f87a83..d793a500d 100644 --- a/status.c +++ b/status.c @@ -16,14 +16,18 @@ */ #include "config.h" -#include -#include -#include -#include "mutt.h" +#include +#include "context.h" +#include "format_flags.h" +#include "globals.h" +#include "lib.h" #include "mapping.h" +#include "mbyte_table.h" #include "mutt_curses.h" #include "mutt_menu.h" #include "mx.h" +#include "options.h" +#include "protos.h" #include "sort.h" #ifdef USE_NOTMUCH #include "mutt_notmuch.h" diff --git a/system.c b/system.c index 44844984c..23b20f06e 100644 --- a/system.c +++ b/system.c @@ -16,16 +16,17 @@ */ #include "config.h" +#include #include #include -#include -#include #include #include "mutt.h" +#include "protos.h" #ifdef USE_IMAP -#include #include "imap/imap.h" #endif +#include +#include int _mutt_system(const char *cmd, int flags) { diff --git a/thread.c b/thread.c index 49f3b2ba9..5a0935a74 100644 --- a/thread.c +++ b/thread.c @@ -16,9 +16,22 @@ */ #include "config.h" -#include +#include +#include #include +#include #include "mutt.h" +#include "thread.h" +#include "body.h" +#include "context.h" +#include "envelope.h" +#include "globals.h" +#include "hash.h" +#include "header.h" +#include "lib.h" +#include "list.h" +#include "options.h" +#include "protos.h" #include "sort.h" #define VISIBLE(hdr, ctx) \ diff --git a/thread.h b/thread.h new file mode 100644 index 000000000..86d59a7ab --- /dev/null +++ b/thread.h @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_THREAD_H +#define _MUTT_THREAD_H 1 + +#include + +struct Context; +struct Header; + +struct MuttThread +{ + bool fake_thread : 1; + bool duplicate_thread : 1; + bool sort_children : 1; + bool check_subject : 1; + bool visible : 1; + bool deep : 1; + unsigned int subtree_visible : 2; + bool next_subtree_visible : 1; + struct MuttThread *parent; + struct MuttThread *child; + struct MuttThread *next; + struct MuttThread *prev; + struct Header *message; + struct Header *sort_key; +}; + +int _mutt_aside_thread(struct Header *hdr, short dir, short subthreads); +#define mutt_next_thread(x) _mutt_aside_thread(x, 1, 0) +#define mutt_previous_thread(x) _mutt_aside_thread(x, 0, 0) +#define mutt_next_subthread(x) _mutt_aside_thread(x, 1, 1) +#define mutt_previous_subthread(x) _mutt_aside_thread(x, 0, 1) + +int _mutt_traverse_thread(struct Context *ctx, struct Header *cur, int flag); +#define mutt_collapse_thread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_COLLAPSE) +#define mutt_uncollapse_thread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_UNCOLLAPSE) +#define mutt_get_hidden(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_GET_HIDDEN) +#define mutt_thread_contains_unread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_UNREAD) +#define mutt_thread_next_unread(x, y) _mutt_traverse_thread(x, y, MUTT_THREAD_NEXT_UNREAD) + +void mutt_break_thread(struct Header *hdr); +int mutt_link_threads(struct Header *cur, struct Header *last, struct Context *ctx); +int mutt_messages_in_thread(struct Context *ctx, struct Header *hdr, int flag); +void mutt_draw_tree(struct Context *ctx); + +void mutt_clear_threads(struct Context *ctx); +struct MuttThread *mutt_sort_subthreads(struct MuttThread *thread, int init); +void mutt_sort_threads(struct Context *ctx, int init); +int mutt_parent_message(struct Context *ctx, struct Header *hdr, int find_root); +void mutt_set_virtual(struct Context *ctx); +struct Hash *mutt_make_id_hash(struct Context *ctx); + +#endif /* _MUTT_THREAD_H */ diff --git a/url.c b/url.c index 19da9618c..55216f925 100644 --- a/url.c +++ b/url.c @@ -21,11 +21,19 @@ #include "config.h" #include +#include +#include #include "mutt.h" #include "url.h" +#include "ascii.h" +#include "envelope.h" +#include "globals.h" +#include "lib.h" #include "mapping.h" #include "mime.h" +#include "protos.h" #include "rfc2047.h" +#include "rfc822.h" static const struct mapping_t UrlMap[] = { { "file", U_FILE }, { "imap", U_IMAP }, { "imaps", U_IMAPS }, diff --git a/url.h b/url.h index a0ddaf25b..e76f7272d 100644 --- a/url.h +++ b/url.h @@ -16,7 +16,9 @@ #ifndef _MUTT_URL_H #define _MUTT_URL_H 1 -#include "mutt.h" +#include + +struct Envelope; typedef enum url_scheme { U_FILE, diff --git a/utf8.c b/utf8.c index 84398e3a2..73b9fcd48 100644 --- a/utf8.c +++ b/utf8.c @@ -14,8 +14,8 @@ */ #include "config.h" +#include #include -#include #ifndef EILSEQ #define EILSEQ EINVAL diff --git a/version.c b/version.c index e1aa8ab4f..c1645fbea 100644 --- a/version.c +++ b/version.c @@ -18,9 +18,11 @@ */ #include "config.h" +#include #include #include #include +#include #include "lib.h" #ifdef HAVE_STRINGPREP_H #include diff --git a/version.h b/version.h index bd71b6fae..674c5d354 100644 --- a/version.h +++ b/version.h @@ -18,6 +18,8 @@ #ifndef _MUTT_VERSION_H #define _MUTT_VERSION_H 1 +#include + void print_version(void); void print_copyright(void); bool feature_enabled(const char *name); diff --git a/wcscasecmp.c b/wcscasecmp.c index 9510a9944..8c8fce732 100644 --- a/wcscasecmp.c +++ b/wcscasecmp.c @@ -16,8 +16,8 @@ */ #include "config.h" -#include "mutt.h" -#include "mbyte.h" +#include +#include int wcscasecmp(const wchar_t *a, const wchar_t *b) { diff --git a/wcwidth.c b/wcwidth.c index e40d49a3e..f5c6080cd 100644 --- a/wcwidth.c +++ b/wcwidth.c @@ -21,9 +21,7 @@ */ #include "config.h" -#include -#include "mutt.h" -#include "mbyte.h" +#include /* The following two functions define the column width of an ISO 10646 * character as follows: diff --git a/where.h b/where.h new file mode 100644 index 000000000..7e59f0104 --- /dev/null +++ b/where.h @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2017 Richard Russon + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 2 of the License, or (at your option) any later + * version. + * + * 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 . + */ + +#ifndef _MUTT_WHERE_H +#define _MUTT_WHERE_H 1 + +#ifdef MAIN_C +#define WHERE +#define INITVAL(x) = x +#else +#define WHERE extern +#define INITVAL(x) +#endif + +#endif /* _MUTT_WHERE_H */