]> mj.ucw.cz Git - libucw.git/blob - ucw/base224.h
Mapping of whole files: Converted to size_t.
[libucw.git] / ucw / base224.h
1 /*
2  *      UCW Library -- Base 224 Encoding & Decoding
3  *
4  *      (c) 2002 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifdef CONFIG_UCW_CLEAN_ABI
11 #define base224_decode ucw_base224_decode
12 #define base224_encode ucw_base224_encode
13 #endif
14
15 /**
16  * Encodes @len bytes of data pointed to by @src by base224 encoding.
17  * Stores them in @dest and returns the number of bytes the output
18  * takes.
19  */
20 uns base224_encode(byte *dest, const byte *src, uns len);
21 /**
22  * Decodes @len bytes of data pointed to by @src from base224 encoding.
23  * All invalid characters are ignored. The result is stored into @dest
24  * and length of the result is returned.
25  */
26 uns base224_decode(byte *dest, const byte *src, uns len);
27
28 /**
29  * Use this macro to calculate @base224_encode() output buffer size.
30  * It can happen 4 more bytes would be needed, this macro takes care
31  * of that.
32  */
33 #define BASE224_ENC_LENGTH(x) (((x)*8+38)/39*5)
34
35 /*
36  * When called for BASE224_IN_CHUNK-byte chunks, the result will be
37  * always BASE224_OUT_CHUNK bytes long. If a longer block is split
38  * to such chunks, the result will be identical.
39  */
40 #define BASE224_IN_CHUNK 39 /** Chunk size on the un-encoded side. **/
41 #define BASE224_OUT_CHUNK 40 /** Chunk size on the encoded side. **/