NeoMutt  2024-03-23-147-g885fbc
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
attach.h File Reference

Handling of email attachments. More...

#include <stdbool.h>
#include <stdio.h>
#include "expando/lib.h"
+ Include dependency graph for attach.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  AttachPtr
 An email to which things will be attached. More...
 
struct  AttachCtx
 A set of attachments. More...
 

Enumerations

enum  ExpandoDataAttach { ED_ATT_CHARSET = 1 , ED_ATT_NUMBER , ED_ATT_TREE }
 Expando UIDs for Attachments. More...
 

Functions

void mutt_actx_add_attach (struct AttachCtx *actx, struct AttachPtr *attach)
 Add an Attachment to an Attachment Context.
 
void mutt_actx_ins_attach (struct AttachCtx *actx, struct AttachPtr *attach, int aidx)
 Insert an Attachment into an Attachment Context at Specified Index.
 
void mutt_actx_add_body (struct AttachCtx *actx, struct Body *b)
 Add an email body to an Attachment Context.
 
void mutt_actx_add_fp (struct AttachCtx *actx, FILE *fp_new)
 Save a File handle to the Attachment Context.
 
void mutt_actx_free (struct AttachCtx **ptr)
 Free an Attachment Context.
 
void mutt_actx_entries_free (struct AttachCtx *actx)
 Free entries in an Attachment Context.
 
struct AttachCtxmutt_actx_new (void)
 Create a new Attachment Context.
 
void mutt_aptr_free (struct AttachPtr **ptr)
 Free an Attachment Pointer.
 
struct AttachPtrmutt_aptr_new (void)
 Create a new Attachment Pointer.
 
void attach_arrow (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 
void attach_C (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Charset - Implements ExpandoRenderData::get_string() -.
 
void attach_c (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Requires conversion flag - Implements ExpandoRenderData::get_string() -.
 
void attach_D (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Deleted - Implements ExpandoRenderData::get_string() -.
 
void attach_d (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Description - Implements ExpandoRenderData::get_string() -.
 
void attach_e (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: MIME type - Implements ExpandoRenderData::get_string() -.
 
void attach_F (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Filename in header - Implements ExpandoRenderData::get_string() -.
 
void attach_f (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Filename - Implements ExpandoRenderData::get_string() -.
 
void attach_I (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Disposition flag - Implements ExpandoRenderData::get_string() -.
 
void attach_M (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: MIME subtype - Implements ExpandoRenderData::get_string() -.
 
void attach_m (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Major MIME type - Implements ExpandoRenderData::get_string() -.
 
void attach_Q (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Attachment counting - Implements ExpandoRenderData::get_string() -.
 
void attach_s (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Size - Implements ExpandoRenderData::get_string() -.
 
void attach_T (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Tree characters - Implements ExpandoRenderData::get_string() -.
 
void attach_t (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Is Tagged - Implements ExpandoRenderData::get_string() -.
 
void attach_u (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Attachment: Unlink flag - Implements ExpandoRenderData::get_string() -.
 
long attach_n_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Attachment: Index number - Implements ExpandoRenderData::get_number() -.
 
long attach_X_num (const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
 Attachment: Number of MIME parts - Implements ExpandoRenderData::get_number() -.
 

Detailed Description

Handling of email attachments.

Authors
  • Richard Russon

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 attach.h.

Enumeration Type Documentation

◆ ExpandoDataAttach

Expando UIDs for Attachments.

See also
ED_ATTACH, ExpandoDomain
Enumerator
ED_ATT_CHARSET 

AttachPtr.body.

ED_ATT_NUMBER 

AttachPtr.num.

ED_ATT_TREE 

AttachPtr.tree.

Definition at line 54 of file attach.h.

55{
56 ED_ATT_CHARSET = 1,
59};
@ ED_ATT_NUMBER
AttachPtr.num.
Definition: attach.h:57
@ ED_ATT_TREE
AttachPtr.tree.
Definition: attach.h:58
@ ED_ATT_CHARSET
AttachPtr.body.
Definition: attach.h:56

Function Documentation

◆ mutt_actx_add_attach()

void mutt_actx_add_attach ( struct AttachCtx actx,
struct AttachPtr attach 
)

Add an Attachment to an Attachment Context.

Parameters
actxAttachment context
attachAttachment to add

Definition at line 65 of file attach.c.

66{
67 const int grow = 5;
68
69 if (!actx || !attach)
70 return;
71
72 if (actx->idxlen == actx->idxmax)
73 {
74 actx->idxmax += grow;
75 mutt_mem_realloc(&actx->idx, actx->idxmax * sizeof(struct AttachPtr *));
76 mutt_mem_realloc(&actx->v2r, actx->idxmax * sizeof(short));
77
78 memset(&actx->idx[actx->idxlen], 0, grow * sizeof(struct AttachPtr *));
79 memset(&actx->v2r[actx->idxlen], 0, grow * sizeof(short));
80 }
81
82 actx->idx[actx->idxlen++] = attach;
83}
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:69
short idxmax
Size of attachment array.
Definition: attach.h:71
short idxlen
Number of attachmentes.
Definition: attach.h:70
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:73
An email to which things will be attached.
Definition: attach.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_ins_attach()

void mutt_actx_ins_attach ( struct AttachCtx actx,
struct AttachPtr attach,
int  aidx 
)

Insert an Attachment into an Attachment Context at Specified Index.

Parameters
actxAttachment context
attachAttachment to insert
aidxIndex to insert attachment at

Definition at line 91 of file attach.c.

92{
93 if (!actx || !attach)
94 return;
95
96 if ((aidx < 0) || (aidx > actx->idxmax))
97 return;
98
99 if (actx->idxlen == actx->idxmax)
100 {
101 actx->idxmax += 5;
102 mutt_mem_realloc(&actx->idx, sizeof(struct AttachPtr *) * actx->idxmax);
103 mutt_mem_realloc(&actx->v2r, sizeof(short) * actx->idxmax);
104 for (int i = actx->idxlen; i < actx->idxmax; i++)
105 actx->idx[i] = NULL;
106 }
107
108 actx->idxlen++;
109
110 for (int i = actx->idxlen - 1; i > aidx; i--)
111 actx->idx[i] = actx->idx[i - 1];
112
113 actx->idx[aidx] = attach;
114}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_add_body()

void mutt_actx_add_body ( struct AttachCtx actx,
struct Body b 
)

Add an email body to an Attachment Context.

Parameters
actxAttachment context
bEmail Body to add

Definition at line 142 of file attach.c.

143{
144 if (!actx || !b)
145 return;
146
147 if (actx->body_len == actx->body_max)
148 {
149 actx->body_max += 5;
150 mutt_mem_realloc(&actx->body_idx, sizeof(struct Body *) * actx->body_max);
151 for (int i = actx->body_len; i < actx->body_max; i++)
152 actx->body_idx[i] = NULL;
153 }
154
155 actx->body_idx[actx->body_len++] = b;
156}
short body_len
Number of Body parts.
Definition: attach.h:81
struct Body ** body_idx
Extra struct Body* used for decryption.
Definition: attach.h:80
short body_max
Size of Body array.
Definition: attach.h:82
The body of an email.
Definition: body.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_add_fp()

void mutt_actx_add_fp ( struct AttachCtx actx,
FILE *  fp_new 
)

Save a File handle to the Attachment Context.

Parameters
actxAttachment context
fp_newFile handle to save

Definition at line 121 of file attach.c.

122{
123 if (!actx || !fp_new)
124 return;
125
126 if (actx->fp_len == actx->fp_max)
127 {
128 actx->fp_max += 5;
129 mutt_mem_realloc(&actx->fp_idx, sizeof(FILE *) * actx->fp_max);
130 for (int i = actx->fp_len; i < actx->fp_max; i++)
131 actx->fp_idx[i] = NULL;
132 }
133
134 actx->fp_idx[actx->fp_len++] = fp_new;
135}
short fp_max
Size of FILE array.
Definition: attach.h:78
short fp_len
Number of FILE handles.
Definition: attach.h:77
FILE ** fp_idx
Extra FILE* used for decryption.
Definition: attach.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_free()

void mutt_actx_free ( struct AttachCtx **  ptr)

Free an Attachment Context.

Parameters
[out]ptrAttachment context

Definition at line 198 of file attach.c.

199{
200 if (!ptr || !*ptr)
201 return;
202
203 struct AttachCtx *actx = *ptr;
204
206 FREE(&actx->idx);
207 FREE(&actx->v2r);
208 FREE(&actx->fp_idx);
209 FREE(&actx->body_idx);
210 FREE(ptr);
211}
void mutt_actx_entries_free(struct AttachCtx *actx)
Free entries in an Attachment Context.
Definition: attach.c:162
#define FREE(x)
Definition: memory.h:45
A set of attachments.
Definition: attach.h:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_entries_free()

void mutt_actx_entries_free ( struct AttachCtx actx)

Free entries in an Attachment Context.

Parameters
actxAttachment context

Definition at line 162 of file attach.c.

163{
164 if (!actx)
165 return;
166
167 for (int i = 0; i < actx->idxlen; i++)
168 {
169 if (actx->idx[i]->body)
170 actx->idx[i]->body->aptr = NULL;
171 mutt_aptr_free(&actx->idx[i]);
172 }
173 actx->idxlen = 0;
174 actx->vcount = 0;
175
176 for (int i = 0; i < actx->fp_len; i++)
177 mutt_file_fclose(&actx->fp_idx[i]);
178 actx->fp_len = 0;
179
180 for (int i = 0; i < actx->body_len; i++)
181 mutt_body_free(&actx->body_idx[i]);
182 actx->body_len = 0;
183}
void mutt_aptr_free(struct AttachPtr **ptr)
Free an Attachment Pointer.
Definition: attach.c:49
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:58
#define mutt_file_fclose(FP)
Definition: file.h:147
short vcount
The number of virtual attachments.
Definition: attach.h:74
struct Body * body
Attachment.
Definition: attach.h:38
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:74
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_actx_new()

struct AttachCtx * mutt_actx_new ( void  )

Create a new Attachment Context.

Return values
ptrNew Attachment Context

Definition at line 189 of file attach.c.

190{
191 return mutt_mem_calloc(1, sizeof(struct AttachCtx));
192}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_aptr_free()

void mutt_aptr_free ( struct AttachPtr **  ptr)

Free an Attachment Pointer.

Parameters
[out]ptrAttachment Pointer

Definition at line 49 of file attach.c.

50{
51 if (!ptr || !*ptr)
52 return;
53
54 struct AttachPtr *aptr = *ptr;
55 FREE(&aptr->tree);
56
57 FREE(ptr);
58}
char * tree
Tree characters to display.
Definition: attach.h:41
+ Here is the caller graph for this function:

◆ mutt_aptr_new()

struct AttachPtr * mutt_aptr_new ( void  )

Create a new Attachment Pointer.

Return values
ptrNew Attachment Pointer

Definition at line 40 of file attach.c.

41{
42 return mutt_mem_calloc(1, sizeof(struct AttachPtr));
43}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_arrow()

void attach_arrow ( const struct ExpandoNode node,
void *  data,
MuttFormatFlags  flags,
int  max_cols,
struct Buffer buf 
)