Handling of email attachments. More...
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt_attach.h"
#include "lib.h"
#include "imap/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attach.h"
#include "cid.h"
#include "copy.h"
#include "globals.h"
#include "handler.h"
#include "mailcap.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
#include "rfc3676.h"
Go to the source code of this file.
Functions | |
int | mutt_get_tmp_attachment (struct Body *b) |
Get a temporary copy of an attachment. | |
int | mutt_compose_attachment (struct Body *b) |
Create an attachment. | |
bool | mutt_edit_attachment (struct Body *b) |
Edit an attachment. | |
void | mutt_check_lookup_list (struct Body *b, char *type, size_t len) |
Update the mime type. | |
static int | wait_interactive_filter (pid_t pid) |
Wait after an interactive filter. | |
int | mutt_view_attachment (FILE *fp, struct Body *b, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win) |
View an attachment. | |
int | mutt_pipe_attachment (FILE *fp, struct Body *b, const char *path, const char *outfile) |
Pipe an attachment to a command. | |
static FILE * | save_attachment_open (const char *path, enum SaveAttach opt) |
Open a file to write an attachment to. | |
int | mutt_save_attachment (FILE *fp, struct Body *b, const char *path, enum SaveAttach opt, struct Email *e) |
Save an attachment. | |
int | mutt_decode_save_attachment (FILE *fp, struct Body *b, const char *path, StateFlags flags, enum SaveAttach opt) |
Decode, then save an attachment. | |
int | mutt_print_attachment (FILE *fp, struct Body *b) |
Print out an attachment. | |
void | mutt_add_temp_attachment (const char *filename) |
Add file to list of temporary attachments. | |
void | mutt_temp_attachments_cleanup (void) |
Delete all temporary attachments. | |
Handling of email attachments.
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 mutt_attach.c.
int mutt_get_tmp_attachment | ( | struct Body * | b | ) |
Get a temporary copy of an attachment.
b | Attachment to copy |
0 | Success |
-1 | Error |
Definition at line 72 of file mutt_attach.c.
int mutt_compose_attachment | ( | struct Body * | b | ) |
Create an attachment.
b | Body of email |
1 | Require full screen redraw |
0 | Otherwise |
Definition at line 120 of file mutt_attach.c.
bool mutt_edit_attachment | ( | struct Body * | b | ) |
Edit an attachment.
b | Email containing attachment |
true | Editor found |
false | Editor not found |
Currently, this only works for send mode, as it assumes that the Body->filename actually contains the information. I'm not sure we want to deal with editing attachments we've already received, so this should be ok.
Returning 0 is useful to tell the calling menu to redraw
Definition at line 265 of file mutt_attach.c.
void mutt_check_lookup_list | ( | struct Body * | b, |
char * | type, | ||
size_t | len | ||
) |
Update the mime type.
b | Message attachment body |
type | Buffer with mime type of attachment in "type/subtype" format |
len | Buffer length |
Definition at line 343 of file mutt_attach.c.
|
static |
Wait after an interactive filter.
pid | Process id of the process to wait for |
num | Exit status of the process identified by pid |
-1 | Error |
This is used for filters that are actually interactive commands with input piped in: e.g. in mutt_view_attachment(), a mailcap entry without copiousoutput and without a s.
For those cases, we treat it like a blocking system command, and poll IMAP to keep connections open.
Definition at line 390 of file mutt_attach.c.
int mutt_view_attachment | ( | FILE * | fp, |
struct Body * | b, | ||
enum ViewAttachMode | mode, | ||
struct Email * | e, | ||
struct AttachCtx * | actx, | ||
struct MuttWindow * | win | ||
) |
View an attachment.
fp | Source file stream. Can be NULL |
b | The message body containing the attachment |
mode | How the attachment should be viewed, see ViewAttachMode |
e | Current Email. Can be NULL |
actx | Attachment context |
win | Window |
0 | The viewer is run and exited successfully |
-1 | Error |
num | Return value of mutt_do_pager() when it is used |
Display a message attachment using the viewer program configured in mailcap. If there is no mailcap entry for a file type, view the image as text. Viewer processes are opened and waited on synchronously so viewing an attachment this way will block the main neomutt process until the viewer process exits.
Definition at line 419 of file mutt_attach.c.
int mutt_pipe_attachment | ( | FILE * | fp, |
struct Body * | b, | ||
const char * | path, | ||
const char * | outfile | ||
) |
Pipe an attachment to a command.
fp | File to pipe into the command |
b | Attachment |
path | Path to command |
outfile | File to save output to |
1 | Success |
0 | Error |
Definition at line 739 of file mutt_attach.c.
|
static |
Open a file to write an attachment to.
path | Path to file to open |
opt | Save option, see SaveAttach |
ptr | File handle to attachment file |
Definition at line 887 of file mutt_attach.c.
int mutt_save_attachment | ( | FILE * | fp, |
struct Body * | b, | ||
const char * | path, | ||
enum SaveAttach | opt, | ||
struct Email * | e | ||
) |
Save an attachment.
fp | Source file stream. Can be NULL |
b | Email Body |
path | Where to save the attachment |
opt | Save option, see SaveAttach |
e | Current Email. Can be NULL |
0 | Success |
-1 | Error |
Definition at line 908 of file mutt_attach.c.
int mutt_decode_save_attachment | ( | FILE * | fp, |
struct Body * | b, | ||
const char * | path, | ||
StateFlags | flags, | ||
enum SaveAttach | opt | ||
) |
Decode, then save an attachment.
fp | File to read from (OPTIONAL) |
b | Attachment |
path | Path to save the Attachment to |
flags | Flags, e.g. STATE_DISPLAY |
opt | Save option, see SaveAttach |
0 | Success |
-1 | Error |
Definition at line 1042 of file mutt_attach.c.
int mutt_print_attachment | ( | FILE * | fp, |
struct Body * | b | ||
) |
Print out an attachment.
fp | File to write to |
b | Attachment |
1 | Success |
0 | Error |
Ok, the difference between send and receive: recv: Body->filename is a suggested name, and Mailbox|Email points to the attachment in mailbox which is encoded send: Body->filename points to the un-encoded file which contains the attachment
Definition at line 1142 of file mutt_attach.c.
void mutt_add_temp_attachment | ( | const char * | filename | ) |
Add file to list of temporary attachments.
filename | filename with full path |
Definition at line 1302 of file mutt_attach.c.
void mutt_temp_attachments_cleanup | ( | void | ) |
Delete all temporary attachments.
Definition at line 1310 of file mutt_attach.c.