Write a MIME Email Header to a file. More...
#include "config.h"#include <stdbool.h>#include <stdlib.h>#include <string.h>#include "mutt/lib.h"#include "address/lib.h"#include "config/lib.h"#include "email/lib.h"#include "gui/lib.h"#include "header.h"#include "globals.h"#include "autocrypt/lib.h"Go to the source code of this file.
Data Structures | |
| struct | UserHdrsOverride |
| Which headers have been overridden. More... | |
Enumerations | |
| enum | UserHdrsOverrideIdx { USERHDRS_OVERRIDE_CONTENT_TYPE , USERHDRS_OVERRIDE_USER_AGENT } |
| Headers that the user may override. More... | |
Functions | |
| static int | print_val (FILE *fp, const char *pfx, const char *value, CopyHeaderFlags chflags, size_t col) |
| Add pieces to an email header, wrapping where necessary. | |
| static int | fold_one_header (FILE *fp, const char *tag, const char *value, size_t vlen, const char *pfx, int wraplen, CopyHeaderFlags chflags) |
| Fold one header line. | |
| static char * | unfold_header (char *s) |
| Unfold a wrapped email header. | |
| static int | userhdrs_override_cmp (const void *a, const void *b) |
| Compare a user-defined header with an element of the UserhdrsOverrideHeaders list. | |
| static int | write_one_header (FILE *fp, int pfxw, int max, int wraplen, const char *pfx, const char *start, const char *end, CopyHeaderFlags chflags) |
| Write out one header line. | |
| static struct UserHdrsOverride | write_userhdrs (FILE *fp, const struct ListHead *userhdrs, bool privacy, struct ConfigSubset *sub) |
| Write user-defined headers and keep track of the interesting ones. | |
| int | mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, CopyHeaderFlags chflags, struct ConfigSubset *sub) |
| Write one header line to a file. | |
| void | mutt_write_references (const struct ListHead *r, FILE *fp, size_t trim) |
| Add the message references to a list. | |
| int | mutt_rfc822_write_header (FILE *fp, struct Envelope *env, struct Body *b, enum MuttWriteHeaderMode mode, bool privacy, bool hide_protected_subject, struct ConfigSubset *sub) |
| Write out one RFC822 header line. | |
| int | mutt_write_mime_header (struct Body *b, FILE *fp, struct ConfigSubset *sub) |
| Create a MIME header. | |
Variables | |
| static const char *const | UserhdrsOverrideHeaders [] |
| The next array/enum pair is used to to keep track of user headers that override pre-defined headers NeoMutt would emit. | |
Write a MIME Email Header to a file.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file header.c.
| enum UserHdrsOverrideIdx |
Headers that the user may override.
| Enumerator | |
|---|---|
| USERHDRS_OVERRIDE_CONTENT_TYPE | Override the "Content-Type". |
| USERHDRS_OVERRIDE_USER_AGENT | Override the "User-Agent". |
Definition at line 60 of file header.c.
|
static |
Add pieces to an email header, wrapping where necessary.
| fp | File to write to |
| pfx | Prefix for headers |
| value | Text to be added |
| chflags | Flags, see CopyHeaderFlags |
| col | Column that this text starts at |
| 0 | Success |
| -1 | Failure |
Definition at line 85 of file header.c.
|
static |
Fold one header line.
| fp | File to write to |
| tag | Header key, e.g. "From" |
| value | Header value |
| vlen | Length of the header value string |
| pfx | Prefix for header |
| wraplen | Column to wrap at |
| chflags | Flags, see CopyHeaderFlags |
| 0 | Success |
| -1 | Failure |
Definition at line 132 of file header.c.
|
static |
Unfold a wrapped email header.
| s | String to process |
| ptr | Unfolded string |
Definition at line 241 of file header.c.
|
static |
Compare a user-defined header with an element of the UserhdrsOverrideHeaders list.
| a | Pointer to the string containing the user-defined header |
| b | Pointer to an element of the UserhdrsOverrideHeaders list |
| -1 | a precedes b |
| 0 | a and b are identical |
| 1 | b precedes a |
Definition at line 278 of file header.c.
|
static |
Write out one header line.
| fp | File to write to |
| pfxw | Width of prefix string |
| max | Max width |
| wraplen | Column to wrap at |
| pfx | Prefix for header |
| start | Start of header line |
| end | End of header line |
| chflags | Flags, see CopyHeaderFlags |
| 0 | Success |
| -1 | Failure |
Definition at line 298 of file header.c.
|
static |
Write user-defined headers and keep track of the interesting ones.
| fp | FILE pointer where to write the headers |
| userhdrs | List of headers to write |
| privacy | Omit headers that could identify the user |
| sub | Config Subset |
| obj | UserHdrsOverride struct containing a bitmask of which unique headers were written |
Definition at line 368 of file header.c.
| int mutt_write_one_header | ( | FILE * | fp, |
| const char * | tag, | ||
| const char * | value, | ||
| const char * | pfx, | ||
| int | wraplen, | ||
| CopyHeaderFlags | chflags, | ||
| struct ConfigSubset * | sub ) |
Write one header line to a file.
| fp | File to write to |
| tag | Header key, e.g. "From" |
| value | Header value |
| pfx | Prefix for header |
| wraplen | Column to wrap at |
| chflags | Flags, see CopyHeaderFlags |
| sub | Config Subset |
| 0 | Success |
| -1 | Failure |
split several headers into individual ones and call write_one_header for each one
Definition at line 427 of file header.c.
| void mutt_write_references | ( | const struct ListHead * | r, |
| FILE * | fp, | ||
| size_t | trim ) |
Add the message references to a list.
| r | String List of references |
| fp | File to write to |
| trim | Trim the list to at most this many items |
Write the list in reverse because they are stored in reverse order when parsed to speed up threading.
Definition at line 526 of file header.c.
| int mutt_rfc822_write_header | ( | FILE * | fp, |
| struct Envelope * | env, | ||
| struct Body * | b, | ||
| enum MuttWriteHeaderMode | mode, | ||
| bool | privacy, | ||
| bool | hide_protected_subject, | ||
| struct ConfigSubset * | sub ) |
Write out one RFC822 header line.
| fp | File to write to |
| env | Envelope of email |
| b | Attachment |
| mode | Mode, see MuttWriteHeaderMode |
| privacy | If true, remove headers that might identify the user |
| hide_protected_subject | If true, replace subject header |
| sub | Config Subset |
| 0 | Success |
| -1 | Failure |
Likewise, all IDN processing should happen outside of this routine.
privacy true => will omit any headers which may identify the user. Output generated is suitable for being sent through anonymous remailer chains.
hide_protected_subject: replaces the Subject header with $crypt_protected_headers_subject in NORMAL or POSTPONE mode.
Definition at line 584 of file header.c.
| int mutt_write_mime_header | ( | struct Body * | b, |
| FILE * | fp, | ||
| struct ConfigSubset * | sub ) |
Create a MIME header.
| b | Body part |
| fp | File to write to |
| sub | Config Subset |
| 0 | Success |
| -1 | Failure |
Definition at line 763 of file header.c.
|
static |
The next array/enum pair is used to to keep track of user headers that override pre-defined headers NeoMutt would emit.
Keep the array sorted and in sync with the enum.
Definition at line 52 of file header.c.