Email-object serialiser. More...
#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "serialize.h"
Go to the source code of this file.
Functions | |
void | lazy_realloc (void *ptr, size_t size) |
Reallocate some memory. | |
unsigned char * | serial_dump_int (const unsigned int i, unsigned char *d, int *off) |
Pack an integer into a binary blob. | |
unsigned char * | serial_dump_uint32_t (const uint32_t s, unsigned char *d, int *off) |
Pack a uint32_t into a binary blob. | |
unsigned char * | serial_dump_uint64_t (const uint64_t s, unsigned char *d, int *off) |
Pack a uint64_t into a binary blob. | |
void | serial_restore_int (unsigned int *i, const unsigned char *d, int *off) |
Unpack an integer from a binary blob. | |
void | serial_restore_uint32_t (uint32_t *s, const unsigned char *d, int *off) |
Unpack an uint32_t from a binary blob. | |
void | serial_restore_uint64_t (uint64_t *s, const unsigned char *d, int *off) |
Unpack an uint64_t from a binary blob. | |
unsigned char * | serial_dump_char_size (const char *c, ssize_t size, unsigned char *d, int *off, bool convert) |
Pack a fixed-length string into a binary blob. | |
unsigned char * | serial_dump_char (const char *c, unsigned char *d, int *off, bool convert) |
Pack a variable-length string into a binary blob. | |
void | serial_restore_char (char **c, const unsigned char *d, int *off, bool convert) |
Unpack a variable-length string from a binary blob. | |
unsigned char * | serial_dump_address (const struct AddressList *al, unsigned char *d, int *off, bool convert) |
Pack an Address into a binary blob. | |
void | serial_restore_address (struct AddressList *al, const unsigned char *d, int *off, bool convert) |
Unpack an Address from a binary blob. | |
unsigned char * | serial_dump_stailq (const struct ListHead *l, unsigned char *d, int *off, bool convert) |
Pack a STAILQ into a binary blob. | |
void | serial_restore_stailq (struct ListHead *l, const unsigned char *d, int *off, bool convert) |
Unpack a STAILQ from a binary blob. | |
unsigned char * | serial_dump_buffer (const struct Buffer *buf, unsigned char *d, int *off, bool convert) |
Pack a Buffer into a binary blob. | |
void | serial_restore_buffer (struct Buffer *buf, const unsigned char *d, int *off, bool convert) |
Unpack a Buffer from a binary blob. | |
unsigned char * | serial_dump_parameter (const struct ParameterList *pl, unsigned char *d, int *off, bool convert) |
Pack a Parameter into a binary blob. | |
void | serial_restore_parameter (struct ParameterList *pl, const unsigned char *d, int *off, bool convert) |
Unpack a Parameter from a binary blob. | |
static uint32_t | body_pack_flags (const struct Body *b) |
Pack the Body flags into a uint32_t. | |
static void | body_unpack_flags (struct Body *b, uint32_t packed) |
Unpack the Body flags from a uint32_t. | |
unsigned char * | serial_dump_body (const struct Body *b, unsigned char *d, int *off, bool convert) |
Pack an Body into a binary blob. | |
void | serial_restore_body (struct Body *b, const unsigned char *d, int *off, bool convert) |
Unpack a Body from a binary blob. | |
unsigned char * | serial_dump_envelope (const struct Envelope *env, unsigned char *d, int *off, bool convert) |
Pack an Envelope into a binary blob. | |
void | serial_restore_envelope (struct Envelope *env, const unsigned char *d, int *off, bool convert) |
Unpack an Envelope from a binary blob. | |
unsigned char * | serial_dump_tags (const struct TagList *tl, unsigned char *d, int *off) |
Pack a TagList into a binary blob. | |
void | serial_restore_tags (struct TagList *tl, const unsigned char *d, int *off) |
Unpack a TagList from a binary blob. | |
Email-object serialiser.
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 serialize.c.
void lazy_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Reallocate some memory.
[in] | ptr | Pointer to resize |
[in] | size | Minimum size |
The minimum size is 4KiB to avoid repeated resizing.
Definition at line 50 of file serialize.c.
unsigned char * serial_dump_int | ( | const unsigned int | i, |
unsigned char * | d, | ||
int * | off | ||
) |
Pack an integer into a binary blob.
[in] | i | Integer to save |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
ptr | End of the newly packed binary |
Definition at line 67 of file serialize.c.
unsigned char * serial_dump_uint32_t | ( | const uint32_t | s, |
unsigned char * | d, | ||
int * | off | ||
) |
Pack a uint32_t into a binary blob.
[in] | s | uint32_t to save |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
ptr | End of the newly packed binary |
Definition at line 83 of file serialize.c.
unsigned char * serial_dump_uint64_t | ( | const uint64_t | s, |
unsigned char * | d, | ||
int * | off | ||
) |
Pack a uint64_t into a binary blob.
[in] | s | uint64_t to save |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
ptr | End of the newly packed binary |
Definition at line 99 of file serialize.c.
void serial_restore_int | ( | unsigned int * | i, |
const unsigned char * | d, | ||
int * | off | ||
) |
Unpack an integer from a binary blob.
[in] | i | Integer to write to |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
Definition at line 114 of file serialize.c.
void serial_restore_uint32_t | ( | uint32_t * | s, |
const unsigned char * | d, | ||
int * | off | ||
) |
Unpack an uint32_t from a binary blob.
[in] | s | uint32_t to write to |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
Definition at line 126 of file serialize.c.
void serial_restore_uint64_t | ( | uint64_t * | s, |
const unsigned char * | d, | ||
int * | off | ||
) |
Unpack an uint64_t from a binary blob.
[in] | s | uint64_t to write to |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
Definition at line 138 of file serialize.c.
unsigned char * serial_dump_char_size | ( | const char * | c, |
ssize_t | size, | ||
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack a fixed-length string into a binary blob.
[in] | c | String to pack |
[in] | d | Binary blob to add to |
[in] | size | Size of the string |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 153 of file serialize.c.
unsigned char * serial_dump_char | ( | const char * | c, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack a variable-length string into a binary blob.
[in] | c | String to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 190 of file serialize.c.
void serial_restore_char | ( | char ** | c, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack a variable-length string from a binary blob.
[out] | c | Store the unpacked string here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
Definition at line 202 of file serialize.c.
unsigned char * serial_dump_address | ( | const struct AddressList * | al, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack an Address into a binary blob.
[in] | al | AddressList to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 239 of file serialize.c.
void serial_restore_address | ( | struct AddressList * | al, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack an Address from a binary blob.
[out] | al | Store the unpacked AddressList here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 268 of file serialize.c.
unsigned char * serial_dump_stailq | ( | const struct ListHead * | l, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack a STAILQ into a binary blob.
[in] | l | List to read from |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 309 of file serialize.c.
void serial_restore_stailq | ( | struct ListHead * | l, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack a STAILQ from a binary blob.
[in] | l | List to add to |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 336 of file serialize.c.
unsigned char * serial_dump_buffer | ( | const struct Buffer * | buf, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack a Buffer into a binary blob.
[in] | buf | Buffer to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 359 of file serialize.c.
void serial_restore_buffer | ( | struct Buffer * | buf, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack a Buffer from a binary blob.
[out] | buf | Store the unpacked Buffer here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 382 of file serialize.c.
unsigned char * serial_dump_parameter | ( | const struct ParameterList * | pl, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack a Parameter into a binary blob.
[in] | pl | Parameter to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 406 of file serialize.c.
void serial_restore_parameter | ( | struct ParameterList * | pl, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack a Parameter from a binary blob.
[in] | pl | Store the unpacked Parameter here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 434 of file serialize.c.
|
inlinestatic |
Pack the Body flags into a uint32_t.
b | Body to pack |
num | uint32_t of packed flags |
Definition at line 459 of file serialize.c.
|
inlinestatic |
Unpack the Body flags from a uint32_t.
b | Body to unpack into |
packed | Packed flags |
Definition at line 489 of file serialize.c.
unsigned char * serial_dump_body | ( | const struct Body * | b, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack an Body into a binary blob.
[in] | b | Body to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 519 of file serialize.c.
void serial_restore_body | ( | struct Body * | b, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack a Body from a binary blob.
[in] | b | Store the unpacked Body here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 551 of file serialize.c.
unsigned char * serial_dump_envelope | ( | const struct Envelope * | env, |
unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Pack an Envelope into a binary blob.
[in] | env | Envelope to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted to utf-8 |
ptr | End of the newly packed binary |
Definition at line 586 of file serialize.c.
void serial_restore_envelope | ( | struct Envelope * | env, |
const unsigned char * | d, | ||
int * | off, | ||
bool | convert | ||
) |
Unpack an Envelope from a binary blob.
[in] | env | Store the unpacked Envelope here |
[in] | d | Binary blob to read from |
[in,out] | off | Offset into the blob |
[in] | convert | If true, the strings will be converted from utf-8 |
Definition at line 634 of file serialize.c.
unsigned char * serial_dump_tags | ( | const struct TagList * | tl, |
unsigned char * | d, | ||
int * | off | ||
) |
Pack a TagList into a binary blob.
[in] | tl | TagList to pack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
ptr | End of the newly packed binary |
Definition at line 688 of file serialize.c.
void serial_restore_tags | ( | struct TagList * | tl, |
const unsigned char * | d, | ||
int * | off | ||
) |
Unpack a TagList from a binary blob.
[in] | tl | TagList to unpack |
[in] | d | Binary blob to add to |
[in,out] | off | Offset into the blob |
Definition at line 713 of file serialize.c.