NeoMutt  2024-11-14-138-ge5ca67
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 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.
 

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 52 of file attach.h.

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

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, struct AttachPtr *);
76 MUTT_MEM_REALLOC(&actx->v2r, actx->idxmax, 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}
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition: memory.h:43
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:67
short idxmax
Size of attachment array.
Definition: attach.h:69
short idxlen
Number of attachmentes.
Definition: attach.h:68
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:71
An email to which things will be attached.
Definition: attach.h:35
+ 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, actx->idxmax, struct AttachPtr *);
103 MUTT_MEM_REALLOC(&actx->v2r, actx->idxmax, short);
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 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, actx->body_max, struct Body *);
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:79
struct Body ** body_idx
Extra struct Body* used for decryption.
Definition: attach.h:78
short body_max
Size of Body array.
Definition: attach.h:80
The body of an email.
Definition: body.h:36
+ 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, actx->fp_max, FILE *);
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:76
short fp_len
Number of FILE handles.
Definition: attach.h:75
FILE ** fp_idx
Extra FILE* used for decryption.
Definition: attach.h:74
+ 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:55
A set of attachments.
Definition: attach.h:63
+ 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:138
short vcount
The number of virtual attachments.
Definition: attach.h:72
struct Body * body
Attachment.
Definition: attach.h:36
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:75
+ 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, struct AttachCtx);
192}
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
+ 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:39
+ 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, struct AttachPtr);
43}
+ Here is the caller graph for this function: