libsignal-protocol-c  master
ProtobufCBuffer Struct Reference

#include <protobuf-c.h>

Public Attributes

void(* append )(ProtobufCBuffer *buffer, size_t len, const uint8_t *data)
 

Detailed Description

Structure for defining a virtual append-only buffer. Used by protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized bytes.

ProtobufCBuffer "subclasses" may be defined on the stack. For example, to write to a FILE object:

typedef struct {
FILE *fp;
} BufferAppendToFile;
static void
my_buffer_file_append(ProtobufCBuffer *buffer,
size_t len,
const uint8_t *data)
{
BufferAppendToFile *file_buf = (BufferAppendToFile *) buffer;
fwrite(data, len, 1, file_buf->fp); // XXX: No error handling!
}

To use this new type of ProtobufCBuffer, it could be called as follows:

...
BufferAppendToFile tmp = {0};
tmp.base.append = my_buffer_file_append;
tmp.fp = fp;
...

Member Data Documentation

◆ append

void(* ProtobufCBuffer::append) (ProtobufCBuffer *buffer, size_t len, const uint8_t *data)

Append function. Consumes the len bytes stored at data.


The documentation for this struct was generated from the following file: