Skip to content

Commit

Permalink
cobs[r].c: add documentation to function implementations as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotterleben committed Oct 16, 2018
1 parent 3b2f7bc commit 6376877
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
* Functions
****************************************************************************/

/* COBS-encode a string of input bytes.
*
* dst_buf_ptr: The buffer into which the result will be written
* dst_buf_len: Length of the buffer into which the result will be written
* src_ptr: The byte string to be encoded
* src_len Length of the byte string to be encoded
*
* returns: A struct containing the success status of the encoding
* operation and the length of the result (that was written to
* dst_buf_ptr)
*/
cobs_encode_result cobs_encode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const uint8_t * src_ptr, size_t src_len)
{
cobs_encode_result result = { 0, COBS_ENCODE_OK };
Expand Down Expand Up @@ -111,6 +122,17 @@ cobs_encode_result cobs_encode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const u
}


/* Decode a COBS byte string.
*
* dst_buf_ptr: The buffer into which the result will be written
* dst_buf_len: Length of the buffer into which the result will be written
* src_ptr: The byte string to be decoded
* src_len Length of the byte string to be decoded
*
* returns: A struct containing the success status of the decoding
* operation and the length of the result (that was written to
* dst_buf_ptr)
*/
cobs_decode_result cobs_decode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const uint8_t * src_ptr, size_t src_len)
{
cobs_decode_result result = { 0, COBS_DECODE_OK };
Expand Down
22 changes: 22 additions & 0 deletions cobsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
* Functions
****************************************************************************/

/* COBS/R-encode a string of input bytes, which may save one byte of output.
*
* dst_buf_ptr: The buffer into which the result will be written
* dst_buf_len: Length of the buffer into which the result will be written
* src_ptr: The byte string to be encoded
* src_len Length of the byte string to be encoded
*
* returns: A struct containing the success status of the encoding
* operation and the length of the result (that was written to
* dst_buf_ptr)
*/
cobsr_encode_result cobsr_encode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const uint8_t * src_ptr, size_t src_len)
{
cobsr_encode_result result = { 0, COBSR_ENCODE_OK };
Expand Down Expand Up @@ -127,6 +138,17 @@ cobsr_encode_result cobsr_encode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const
}


/* Decode a COBS/R byte string.
*
* dst_buf_ptr: The buffer into which the result will be written
* dst_buf_len: Length of the buffer into which the result will be written
* src_ptr: The byte string to be decoded
* src_len Length of the byte string to be decoded
*
* returns: A struct containing the success status of the decoding
* operation and the length of the result (that was written to
* dst_buf_ptr)
*/
cobsr_decode_result cobsr_decode(uint8_t *dst_buf_ptr, size_t dst_buf_len, const uint8_t * src_ptr, size_t src_len)
{
cobsr_decode_result result = { 0, COBSR_DECODE_OK };
Expand Down

0 comments on commit 6376877

Please sign in to comment.