Lucciefr
Lua code caving, injection and exploration framework
Macros | Functions
mpkutils.h File Reference
#include "msgpack.h"

Go to the source code of this file.

Macros

#define msgpack_pack_string(pk, s)   msgpack_pack_lstring(pk, s, s ? strlen(s) : 0)
 macro to pack NUL-terminated string, uses strlen() to retrieve length
 
#define msgpack_pack_literal(pk, s)   msgpack_pack_lstring(pk, "" s, sizeof(s)-1)
 macro to pack a (constant) string literal
 
#define msgpack_object_from_string(object, s)   msgpack_object_from_lstring(object, s, s ? strlen(s) : 0)
 macro to create object from NUL-terminated string, uses strlen() for length
 
#define msgpack_object_from_literal(object, s)   msgpack_object_from_lstring(object, "" s, sizeof(s)-1)
 macro to create msgpack object from (constant) string literal
 

Functions

int msgpack_pack_lstring (msgpack_packer *pk, const char *str, size_t len)
 Pack string with a given length. More...
 
void msgpack_object_from_lstring (msgpack_object *object, const char *str, size_t len)
 Create msgpack object from string (with given length). More...
 
size_t msgpack_object_str_fwrite (msgpack_object_str str, FILE *stream)
 Write msgpack_object_str to a stream. More...
 

Function Documentation

void msgpack_object_from_lstring ( msgpack_object *  object,
const char *  str,
size_t  len 
)

Create msgpack object from string (with given length).

Also translates NULL to a "nil" object.

Note
This does not allocate any memory within the object, justs sets the str pointer!
size_t msgpack_object_str_fwrite ( msgpack_object_str  str,
FILE *  stream 
)

Write msgpack_object_str to a stream.

Since a string-type msgpack_object_str isn't NUL-terminated, it's a bit awkward to output; maybe this helps.

Returns
number of bytes written
int msgpack_pack_lstring ( msgpack_packer *  pk,
const char *  str,
size_t  len 
)

Pack string with a given length.

msgpack-c has an awful syntax for string packing (requiring two calls for string length and actual content), work around that - by introducing a cleaner "string + length" interface.