NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
msn.h File Reference

IMAP MSN helper functions. More...

#include <stdlib.h>
+ Include dependency graph for msn.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void imap_msn_free (struct MSNArray *msn)
 Free the cache.
 
struct Emailimap_msn_get (const struct MSNArray *msn, size_t idx)
 Return the Email associated with an msn.
 
size_t imap_msn_highest (const struct MSNArray *msn)
 Return the highest MSN in use.
 
void imap_msn_remove (struct MSNArray *msn, size_t idx)
 Remove an entry from the cache.
 
void imap_msn_reserve (struct MSNArray *msn, size_t num)
 Create / reallocate the cache.
 
void imap_msn_set (struct MSNArray *msn, size_t idx, struct Email *e)
 Cache an Email into a given position.
 
size_t imap_msn_shrink (struct MSNArray *msn, size_t num)
 Remove a number of entries from the end of the cache.
 

Detailed Description

IMAP MSN helper functions.

Authors
  • Pietro Cerutti
  • 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 msn.h.

Function Documentation

◆ imap_msn_free()

void imap_msn_free ( struct MSNArray *  msn)

Free the cache.

Parameters
msnMSN structure

Definition at line 60 of file msn.c.

61{
62 ARRAY_FREE(msn);
63}
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
+ Here is the caller graph for this function:

◆ imap_msn_get()

struct Email * imap_msn_get ( const struct MSNArray *  msn,
size_t  idx 
)

Return the Email associated with an msn.

Parameters
msnMSN structure
idxIndex to retrieve
Return values
ptrPointer to Email or NULL

Definition at line 81 of file msn.c.

82{
83 struct Email **ep = ARRAY_GET(msn, idx);
84 return ep ? *ep : NULL;
85}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
The envelope/body of an email.
Definition: email.h:39
+ Here is the caller graph for this function:

◆ imap_msn_highest()

size_t imap_msn_highest ( const struct MSNArray *  msn)

Return the highest MSN in use.

Parameters
msnMSN structure
Return values
numThe highest MSN in use

Definition at line 70 of file msn.c.

71{
72 return ARRAY_SIZE(msn);
73}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
+ Here is the caller graph for this function:

◆ imap_msn_remove()

void imap_msn_remove ( struct MSNArray *  msn,
size_t  idx 
)

Remove an entry from the cache.

Parameters
msnMSN structure
idxIndex to invalidate

Definition at line 114 of file msn.c.

115{
116 struct Email **ep = ARRAY_GET(msn, idx);
117 if (ep)
118 *ep = NULL;
119}
+ Here is the caller graph for this function:

◆ imap_msn_reserve()

void imap_msn_reserve ( struct MSNArray *  msn,
size_t  num 
)

Create / reallocate the cache.

Parameters
msnMSN structure
numNumber of MSNs to make room for

Definition at line 42 of file msn.c.

43{
44 /* This is a conservative check to protect against a malicious imap
45 * server. Most likely size_t is bigger than an unsigned int, but
46 * if msn_count is this big, we have a serious problem. */
47 if (num >= (UINT_MAX / sizeof(struct Email *)))
48 {
49 mutt_error(_("Out of memory"));
50 mutt_exit(1);
51 }
52
53 ARRAY_RESERVE(msn, num);
54}
#define ARRAY_RESERVE(head, num)
Reserve memory for the array.
Definition: array.h:189
#define mutt_error(...)
Definition: logging2.h:92
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition: main.c:268
#define _(a)
Definition: message.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_msn_set()

void imap_msn_set ( struct MSNArray *  msn,
size_t  idx,
struct Email e 
)

Cache an Email into a given position.

Parameters
msnMSN structure
idxIndex in the cache
eEmail to cache

Definition at line 93 of file msn.c.

94{
95 ARRAY_SET(msn, idx, e);
96}
#define ARRAY_SET(head, idx, elem)
Set an element in the array.
Definition: array.h:123
+ Here is the caller graph for this function:

◆ imap_msn_shrink()

size_t imap_msn_shrink ( struct MSNArray *  msn,
size_t  num 
)

Remove a number of entries from the end of the cache.

Parameters
msnMSN structure
numNumber of entries to remove
Return values
numNumber of entries actually removed

Definition at line 104 of file msn.c.

105{
106 return ARRAY_SHRINK(msn, num);
107}
#define ARRAY_SHRINK(head, num)
Mark a number of slots at the end of the array as unused.
Definition: array.h:172
+ Here is the caller graph for this function: