-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfc.h
37 lines (32 loc) · 870 Bytes
/
cfc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef CFC_H
#define CFC_H
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include "log.h"
#include "bit_string.h"
/** \addtogroup cfc
* @{
*/
/**
* \brief Encode number using CFC
*
* This function can encode any 32bit unsigned number using CFC. It returns
* newly allocated \ref bit_string that must be freed by user when not needed
* anymore.
* \param l number to encode
* \return bit_string that contains CFC of l
*/
bit_string_t *cfc_encode(uint32_t l);
/**
* \brief Decode CFC encoded number
*
* This function decodes CFC encoded number.
* \param bs bit_string where CFC encoded number is stored
* \param offset offset where CFC encoded number begins. Updated to offset
* immediately after CFC encoded number.
* \return number that was encoded using CFC
*/
size_t cfc_decode(bit_string_t *bs, size_t *offset);
/** @} */
#endif