NeoMutt  2024-04-25-100-gcb3684
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 62 of file msn.c.

63{
64 ARRAY_FREE(msn);
65}
#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 83 of file msn.c.

84{
85 struct Email **ep = ARRAY_GET(msn, idx);
86 return ep ? *ep : NULL;
87}
#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 72 of file msn.c.

73{
74 return ARRAY_SIZE(msn);
75}
#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 116 of file msn.c.

117{
118 struct Email **ep = ARRAY_GET(msn, idx);
119 if (ep)
120 *ep = NULL;
121}
+ 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 44 of file msn.c.

45{
46 /* This is a conservative check to protect against a malicious imap
47 * server. Most likely size_t is bigger than an unsigned int, but
48 * if msn_count is this big, we have a serious problem. */
49 if (num >= (UINT_MAX / sizeof(struct Email *)))
50 {
51 mutt_error("%s", strerror(ENOMEM));
52 mutt_exit(1);
53 }
54
55 ARRAY_RESERVE(msn, num);
56}
#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:269
+ 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 95 of file msn.c.

96{
97 ARRAY_SET(msn, idx, e);
98}
#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 106 of file msn.c.

107{
108 return ARRAY_SHRINK(msn, num);
109}
#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: