libevent  2.2.1
Event notification library
Functions
tag.h File Reference

Helper functions for reading and writing tagged data onto buffers. More...

#include <event2/visibility.h>
#include <event2/event-config.h>
#include <event2/util.h>

Go to the source code of this file.

Functions

EVENT2_EXPORT_SYMBOL int evtag_consume (struct evbuffer *evbuf)
 
EVENT2_EXPORT_SYMBOL void evtag_encode_int (struct evbuffer *evbuf, ev_uint32_t number)
 Encode an integer and store it in an evbuffer. More...
 
EVENT2_EXPORT_SYMBOL void evtag_encode_int64 (struct evbuffer *evbuf, ev_uint64_t number)
 
EVENT2_EXPORT_SYMBOL void evtag_init (void)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal (struct evbuffer *evbuf, ev_uint32_t tag, const void *data, ev_uint32_t len)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal_buffer (struct evbuffer *evbuf, ev_uint32_t tag, struct evbuffer *data)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal_int (struct evbuffer *evbuf, ev_uint32_t tag, ev_uint32_t integer)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal_int64 (struct evbuffer *evbuf, ev_uint32_t tag, ev_uint64_t integer)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal_string (struct evbuffer *buf, ev_uint32_t tag, const char *string)
 
EVENT2_EXPORT_SYMBOL void evtag_marshal_timeval (struct evbuffer *evbuf, ev_uint32_t tag, struct timeval *tv)
 
EVENT2_EXPORT_SYMBOL int evtag_payload_length (struct evbuffer *evbuf, ev_uint32_t *plength)
 
EVENT2_EXPORT_SYMBOL int evtag_peek (struct evbuffer *evbuf, ev_uint32_t *ptag)
 
EVENT2_EXPORT_SYMBOL int evtag_peek_length (struct evbuffer *evbuf, ev_uint32_t *plength)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal (struct evbuffer *src, ev_uint32_t *ptag, struct evbuffer *dst)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_fixed (struct evbuffer *src, ev_uint32_t need_tag, void *data, size_t len)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_header (struct evbuffer *evbuf, ev_uint32_t *ptag)
 Unmarshals the header and returns the length of the payload. More...
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_int (struct evbuffer *evbuf, ev_uint32_t need_tag, ev_uint32_t *pinteger)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_int64 (struct evbuffer *evbuf, ev_uint32_t need_tag, ev_uint64_t *pinteger)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_string (struct evbuffer *evbuf, ev_uint32_t need_tag, char **pstring)
 
EVENT2_EXPORT_SYMBOL int evtag_unmarshal_timeval (struct evbuffer *evbuf, ev_uint32_t need_tag, struct timeval *ptv)
 

Detailed Description

Helper functions for reading and writing tagged data onto buffers.

Function Documentation

◆ evtag_encode_int()

EVENT2_EXPORT_SYMBOL void evtag_encode_int ( struct evbuffer evbuf,
ev_uint32_t  number 
)

Encode an integer and store it in an evbuffer.

We encode integers by nybbles; the first nibble contains the number of significant nibbles - 1; this allows us to encode up to 64-bit integers. This function is byte-order independent.

Parameters
evbufevbuffer to store the encoded number
numbera 32-bit integer

◆ evtag_unmarshal_header()

EVENT2_EXPORT_SYMBOL int evtag_unmarshal_header ( struct evbuffer evbuf,
ev_uint32_t *  ptag 
)

Unmarshals the header and returns the length of the payload.

Parameters
evbufthe buffer from which to unmarshal data
ptaga pointer in which the tag id is being stored
Returns
-1 on failure or the number of bytes in the remaining payload.