NeoMutt  2025-09-05-55-g97fc89
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

GUI display the mailboxes in a side panel. More...

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

Go to the source code of this file.

Functions

int attach_body_count (struct Body *b, bool recurse)
 Count bodies.
 
bool attach_body_parent (struct Body *start, struct Body *start_parent, struct Body *body, struct Body **body_parent)
 Find the parent of a body.
 
struct Bodyattach_body_ancestor (struct Body *start, struct Body *body, const char *subtype)
 Find the ancestor of a body with specified subtype.
 
bool attach_body_previous (struct Body *start, struct Body *body, struct Body **previous)
 Find the previous body of a body.
 
enum CommandResult parse_attachments (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'attachments' command - Implements Command::parse() -.
 
enum CommandResult parse_unattachments (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unattachments' command - Implements Command::parse() -.
 

Variables

const struct ExpandoRenderCallback AttachRenderCallbacks []
 Callbacks for Attachment Expandos.
 

Detailed Description

GUI display the mailboxes in a side panel.

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

Function Documentation

◆ attach_body_count()

int attach_body_count ( struct Body * body,
bool recurse )

Count bodies.

Parameters
bodyBody to start counting from
recurseWhether to recurse into groups or not
Return values
numNumber of bodies
-1Failure

Definition at line 42 of file lib.c.

43{
44 if (!body)
45 return -1;
46
47 int bodies = 0;
48
49 for (struct Body *b = body; b; b = b->next)
50 {
51 bodies++;
52 if (recurse)
53 {
54 if (b->parts)
55 bodies += attach_body_count(b->parts, true);
56 }
57 }
58
59 return bodies;
60}
int attach_body_count(struct Body *body, bool recurse)
Count bodies.
Definition lib.c:42
The body of an email.
Definition body.h:36
struct Body * next
next attachment in the list
Definition body.h:72
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_body_parent()

bool attach_body_parent ( struct Body * start,
struct Body * start_parent,
struct Body * body,
struct Body ** body_parent )

Find the parent of a body.

Parameters
[in]startBody to start search from
[in]start_parentParent of start Body pointer (or NULL if none)
[in]bodyBody to find parent of
[out]body_parentBody Parent if found
Return values
trueParent body found
falseParent body not found

Definition at line 71 of file lib.c.

73{
74 if (!start || !body)
75 return false;
76
77 struct Body *b = start;
78
79 if (b->parts)
80 {
81 if (b->parts == body)
82 {
83 *body_parent = b;
84 return true;
85 }
86 }
87 while (b)
88 {
89 if (b == body)
90 {
91 *body_parent = start_parent;
92 if (start_parent)
93 return true;
94 else
95 return false;
96 }
97 if (b->parts)
98 {
99 if (attach_body_parent(b->parts, b, body, body_parent))
100 return true;
101 }
102 b = b->next;
103 }
104
105 return false;
106}
bool attach_body_parent(struct Body *start, struct Body *start_parent, struct Body *body, struct Body **body_parent)
Find the parent of a body.
Definition lib.c:71
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_body_ancestor()

struct Body * attach_body_ancestor ( struct Body * start,
struct Body * body,
const char * subtype )

Find the ancestor of a body with specified subtype.

Parameters
[in]startBody to start search from
[in]bodyBody to find ancestor of
[in]subtypeMime subtype of ancestor to find
Return values
ptrBody ancestor if found
NULLIf ancestor body not found

Definition at line 116 of file lib.c.

117{
118 if (!start || !body)
119 return NULL;
120
121 struct Body *b = body;
122 struct Body *b_parent = NULL;
123
124 while (attach_body_parent(start, NULL, b, &b_parent))
125 {
126 if (mutt_str_equal(subtype, b_parent->subtype))
127 return b_parent;
128 b = b_parent;
129 }
130
131 return NULL;
132}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
char * subtype
content-type subtype
Definition body.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_body_previous()

bool attach_body_previous ( struct Body * start,
struct Body * body,
struct Body ** previous )

Find the previous body of a body.

Parameters
[in]startBody to start search from
[in]bodyBody to find previous body of
[out]previousPrevious Body if found
Return values
truePrevious body found
falsePrevious body not found

Definition at line 142 of file lib.c.

143{
144 if (!start || !body)
145 return false;
146
147 struct Body *b = start;
148
149 while (b)
150 {
151 if (b->next == body)
152 {
153 *previous = b;
154 return true;
155 }
156 if (b->parts)
157 {
158 if (attach_body_previous(b->parts, body, previous))
159 return true;
160 }
161 b = b->next;
162 }
163
164 return false;
165}
bool attach_body_previous(struct Body *start, struct Body *body, struct Body **previous)
Find the previous body of a body.
Definition lib.c:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AttachRenderCallbacks

const struct ExpandoRenderCallback AttachRenderCallbacks[]
extern

Callbacks for Attachment Expandos.

See also
AttachFormatDef, ExpandoDataAttach, ExpandoDataBody, ExpandoDataGlobal

Definition at line 375 of file expando.c.

375 {
376 // clang-format off
377
381
386 { ED_BODY, ED_BOD_FILE, body_file, NULL },
396
397 { -1, -1, NULL, NULL },
398 // clang-format on
399};
@ 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
@ ED_BODY
Body ED_BOD_ ExpandoDataBody.
Definition domain.h:38
@ ED_ATTACH
Attach ED_ATT_ ExpandoDataAttach.
Definition domain.h:36
@ ED_BOD_DESCRIPTION
Body.description.
Definition body.h:106
@ ED_BOD_CHARSET_CONVERT
Body.type.
Definition body.h:104
@ ED_BOD_DELETED
Body.deleted.
Definition body.h:105
@ ED_BOD_UNLINK
Body.unlink.
Definition body.h:115
@ ED_BOD_FILE_SIZE
Body.filename.
Definition body.h:110
@ ED_BOD_DISPOSITION
Body.disposition.
Definition body.h:107
@ ED_BOD_ATTACH_QUALIFIES
Body.attach_qualifies.
Definition body.h:103
@ ED_BOD_MIME_MAJOR
Body.type, Body.xtype.
Definition body.h:112
@ ED_BOD_TAGGED
Body.tagged.
Definition body.h:114
@ ED_BOD_ATTACH_COUNT
Body.attach_count.
Definition body.h:102
@ ED_BOD_FILE
Body.filename.
Definition body.h:108
@ ED_BOD_MIME_MINOR
Body.subtype.
Definition body.h:113
@ ED_BOD_FILE_DISPOSITION
Body.d_filename.
Definition body.h:109
@ ED_BOD_MIME_ENCODING
Body.encoding.
Definition body.h:111
static long body_deleted_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Deleted - Implements get_number_t -.
Definition expando.c:148
static long body_tagged_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Is Tagged - Implements get_number_t -.
Definition expando.c:342
static long body_file_size_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Size - Implements get_number_t -.
Definition expando.c:280
static long attach_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Index number - Implements get_number_t -.
Definition expando.c:64
static long body_attach_count_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Number of MIME parts - Implements get_number_t -.
Definition expando.c:88
static long body_unlink_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Unlink flag - Implements get_number_t -.
Definition expando.c:364
static long body_attach_qualifies_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Body: Attachment counting - Implements get_number_t -.
Definition expando.c:112
static void body_deleted(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Deleted - Implements get_string_t -.
Definition expando.c:135
static void body_file_size(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Size - Implements get_string_t -.
Definition expando.c:259
static void body_tagged(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Is Tagged - Implements get_string_t -.
Definition expando.c:329
static void body_disposition(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Disposition flag - Implements get_string_t -.
Definition expando.c:192
static void body_charset_convert(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Requires conversion flag - Implements get_string_t -.
Definition expando.c:122
static void attach_tree(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Tree characters - Implements get_string_t -.
Definition expando.c:74
static void attach_charset(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Charset - Implements get_string_t -.
Definition expando.c:48
static void body_mime_major(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Major MIME type - Implements get_string_t -.
Definition expando.c:305
static void body_file_disposition(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Filename in header - Implements get_string_t -.
Definition expando.c:241
static void body_description(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Description - Implements get_string_t -.
Definition expando.c:157
static void body_mime_encoding(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: MIME type - Implements get_string_t -.
Definition expando.c:293
static void body_file(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Filename - Implements get_string_t -.
Definition expando.c:217
static void body_mime_minor(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: MIME subtype - Implements get_string_t -.
Definition expando.c:317
static void body_unlink(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Unlink flag - Implements get_string_t -.
Definition expando.c:351
static void body_attach_qualifies(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Body: Attachment counting - Implements get_string_t -.
Definition expando.c:99