#include "config.h"
#include <stdbool.h>
#include <string.h>
#include "mutt/lib.h"
#include "email/lib.h"
#include "body.h"
#include "lib.h"
#include "ncrypt/lib.h"
#include "mutt_globals.h"
#include "muttlib.h"
Go to the source code of this file.
|
static int | b64_init (struct B64Context *bctx) |
| Set up the base64 conversion. More...
|
|
static void | b64_flush (struct B64Context *bctx, FILE *fp_out) |
| Save the bytes to the file. More...
|
|
static void | b64_putc (struct B64Context *bctx, char c, FILE *fp_out) |
| Base64-encode one character. More...
|
|
static void | encode_base64 (struct FgetConv *fc, FILE *fp_out, int istext) |
| Base64-encode some data. More...
|
|
static void | encode_8bit (struct FgetConv *fc, FILE *fp_out) |
| Write the data as raw 8-bit data. More...
|
|
static void | encode_quoted (struct FgetConv *fc, FILE *fp_out, bool istext) |
| Encode text as quoted printable. More...
|
|
static bool | write_as_text_part (struct Body *b) |
| Should the Body be written as a text MIME part. More...
|
|
int | mutt_write_mime_body (struct Body *a, FILE *fp, struct ConfigSubset *sub) |
| Write a MIME part. More...
|
|
Write a MIME Email Body to a file
- Authors
-
- Copyright
- 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 http://www.gnu.org/licenses/.
Definition in file body.c.
◆ b64_init()
Set up the base64 conversion.
- Parameters
-
bctx | Cursor for the base64 conversion |
- Return values
-
Definition at line 55 of file body.c.
◆ b64_flush()
static void b64_flush |
( |
struct B64Context * |
bctx, |
|
|
FILE * |
fp_out |
|
) |
| |
|
static |
Save the bytes to the file.
- Parameters
-
bctx | Cursor for the base64 conversion |
fp_out | File to save the output |
Definition at line 69 of file body.c.
89 for (
size_t i = 0; i < ret; i++)
91 fputc(encoded[i], fp_out);
◆ b64_putc()
static void b64_putc |
( |
struct B64Context * |
bctx, |
|
|
char |
c, |
|
|
FILE * |
fp_out |
|
) |
| |
|
static |
Base64-encode one character.
- Parameters
-
bctx | Cursor for the base64 conversion |
c | Character to encode |
fp_out | File to save the output |
Definition at line 104 of file body.c.
◆ encode_base64()
static void encode_base64 |
( |
struct FgetConv * |
fc, |
|
|
FILE * |
fp_out, |
|
|
int |
istext |
|
) |
| |
|
static |
Base64-encode some data.
- Parameters
-
fc | Cursor for converting a file's encoding |
fp_out | File to store the result |
istext | Is the input text? |
Definition at line 118 of file body.c.
132 if (istext && (ch ==
'\n') && (ch1 !=
'\r'))
◆ encode_8bit()
static void encode_8bit |
( |
struct FgetConv * |
fc, |
|
|
FILE * |
fp_out |
|
) |
| |
|
static |
Write the data as raw 8-bit data.
- Parameters
-
fc | Cursor for converting a file's encoding |
fp_out | File to store the result |
Definition at line 146 of file body.c.
◆ encode_quoted()
static void encode_quoted |
( |
struct FgetConv * |
fc, |
|
|
FILE * |
fp_out, |
|
|
bool |
istext |
|
) |
| |
|
static |
Encode text as quoted printable.
- Parameters
-
fc | Cursor for converting a file's encoding |
fp_out | File to store the result |
istext | Is the input text? |
Definition at line 167 of file body.c.
170 char line[77], savechar;
175 if ((
linelen == 76) && ((istext && (c !=
'\n')) || !istext))
184 fputs(
"=\n", fp_out);
214 else if ((
linelen == 1) && (line[0] ==
'.'))
220 if ((c ==
'\n') && istext)
227 sprintf(line +
linelen - 1,
"=%2.2X", (
unsigned char) line[
linelen - 1]);
232 int savechar2 = line[
linelen - 1];
237 fprintf(fp_out,
"\n=%2.2X", (
unsigned char) savechar2);
248 else if ((c != 9) && ((c < 32) || (c > 126) || (c ==
'=')))
260 sprintf(line +
linelen,
"=%2.2X", (
unsigned char) c);
278 sprintf(line +
linelen - 1,
"=%2.2X", (
unsigned char) line[
linelen - 1]);
286 sprintf(line,
"=%2.2X", (
unsigned char) savechar);
◆ write_as_text_part()
static bool write_as_text_part |
( |
struct Body * |
b | ) |
|
|
static |
Should the Body be written as a text MIME part.
- Parameters
-
- Return values
-
true | If the Body should be written as text |
Definition at line 300 of file body.c.
◆ mutt_write_mime_body()
int mutt_write_mime_body |
( |
struct Body * |
a, |
|
|
FILE * |
fp, |
|
|
struct ConfigSubset * |
sub |
|
) |
| |
Write a MIME part.
- Parameters
-
a | Body to use |
fp | File to write to |
sub | Config Subset |
- Return values
-
Definition at line 314 of file body.c.
326 mutt_error(
_(
"No boundary parameter found [report this error]"));
334 fprintf(
fp,
"\n--%s\n", boundary);
341 fprintf(
fp,
"\n--%s--\n", boundary);
342 return ferror(
fp) ? -1 : 0;
349 fputs(
"Version: 1\n",
fp);
363 char send_charset[128];
390 return ferror(
fp) ? -1 : 0;
static void b64_flush(struct B64Context *bctx, FILE *fp_out)
Save the bytes to the file.
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
bool noconv
Don't do character set conversion.
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Cursor for the Base64 conversion.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
struct Body * next
next attachment in the list
#define MUTT_ICONV_NO_FLAGS
No flags are set.
static void encode_8bit(struct FgetConv *fc, FILE *fp_out)
Write the data as raw 8-bit data.
@ LL_DEBUG1
Log at debug level 1.
unsigned int encoding
content-transfer-encoding, ContentEncoding
char * subtype
content-type subtype
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
static int b64_init(struct B64Context *bctx)
Set up the base64 conversion.
static bool write_as_text_part(struct Body *b)
Should the Body be written as a text MIME part.
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen)
Convert raw bytes to null-terminated base64 string.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
int mutt_write_mime_body(struct Body *a, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
#define APPLICATION_PGP
Use PGP to encrypt/sign.
char * mutt_body_get_charset(struct Body *b, char *buf, size_t buflen)
Get a body's character set.
static void b64_putc(struct B64Context *bctx, char c, FILE *fp_out)
Base64-encode one character.
struct Body * parts
parts of a multipart or message/rfc822
char * charset
Send mode: charset of attached file as stored on disk.
#define mutt_debug(LEVEL,...)
static void encode_base64(struct FgetConv *fc, FILE *fp_out, int istext)
Base64-encode some data.
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
@ TYPE_APPLICATION
Type: 'application/*'.
void mutt_ch_fgetconv_close(struct FgetConv **fc)
Close an fgetconv handle.
@ ENC_BASE64
Base-64 encoded text.
@ TYPE_TEXT
Type: 'text/*'.
unsigned int type
content-type primary type, ContentType
bool mutt_is_text_part(struct Body *b)
Is this part of an email in plain text?
struct ParameterList parameter
parameters of the content-type
struct FgetConv * mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, uint8_t flags)
Prepare a file for charset conversion.
Cursor for converting a file's encoding.
@ TYPE_MULTIPART
Type: 'multipart/*'.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
int mutt_ch_fgetconv(struct FgetConv *fc)
Convert a file's character set.
static void encode_quoted(struct FgetConv *fc, FILE *fp_out, bool istext)
Encode text as quoted printable.
char * filename
when sending a message, this is the file to which this structure refers
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)