COBS is an escaping algorithm, taking input in the [0,255] range and producing output in the [1,255] range. In other words, it escapes all NUL bytes.
#include "common.h"
#include "cobs.h"
#include "walloc.h"
#include "override.h"
Defines | |
| #define | FINISH(x) |
| #define | FINISH() |
Functions | |
| gchar * | cobs_encodev (struct iovec *iov, gint iovcnt, size_t *retlen) |
| Encode vector `iov' of `iovcnt' elements, whose size is held in `retlen'. | |
| gchar * | cobs_encode (gchar *buf, size_t len, size_t *retlen) |
| Encode `len' bytes starting at `buf' into new allocated buffer. | |
| gboolean | cobs_decode_into (const gchar *buf, size_t len, gchar *out, size_t outlen, size_t *retlen) |
| Decode `len' bytes starting at `buf' into decoding buffer `out', which is `outlen' bytes long. | |
| gboolean | cobs_is_valid (const gchar *buf, size_t len) |
| Check whether supplied buffer forms a valid COBS encoding. | |
| gchar * | cobs_decode (gchar *buf, size_t len, size_t *retlen, gboolean inplace) |
| Decode `len' bytes starting at `buf' into new allocated buffer, unless `inplace' is true in which case decoding is done inplace. | |
| void | cobs_stream_init (cobs_stream_t *cs, gpointer data, size_t len) |
| Initialize an incremental COBS context, where data will be written in the supplied buffer. | |
| gboolean | cobs_stream_write (cobs_stream_t *cs, gpointer data, size_t len) |
| Add data to the COBS stream. | |
| size_t | cobs_stream_close (cobs_stream_t *cs, gboolean *saw_nul) |
| Close COBS stream: we have no more data to write. | |
| void | cobs_stream_invalidate (cobs_stream_t *cs) |
| Empty the descriptor, making it invalid. | |
| gboolean | cobs_stream_is_valid (cobs_stream_t *cs) |
| Check whether the stream descriptor is valid, for assertions. | |
|
|
Value: do { \ g_assert(cs->cp < cs->end); \ *cs->cp = cs->last_code = cs->code; \ cs->cp = cs->o++; \ cs->code = 0x1; \ } while (0) |
|
|
Value: do { \ *cp = last_code = (x); \ cp = o++; \ code = 0x1; \ } while (0) |
|
||||||||||||||||||||
|
Decode `len' bytes starting at `buf' into new allocated buffer, unless `inplace' is true in which case decoding is done inplace.
|
|
||||||||||||||||||||||||
|
Decode `len' bytes starting at `buf' into decoding buffer `out', which is `outlen' bytes long.
|
|
||||||||||||||||
|
Encode `len' bytes starting at `buf' into new allocated buffer.
|
|
||||||||||||||||
|
Encode vector `iov' of `iovcnt' elements, whose size is held in `retlen'.
|
|
||||||||||||
|
Check whether supplied buffer forms a valid COBS encoding.
|
|
||||||||||||
|
Close COBS stream: we have no more data to write.
|
|
||||||||||||||||
|
Initialize an incremental COBS context, where data will be written in the supplied buffer.
|
|
|
Empty the descriptor, making it invalid.
|
|
|
Check whether the stream descriptor is valid, for assertions.
|
|
||||||||||||||||
|
Add data to the COBS stream.
|
1.3.9.1