5 * Base32 encoding and decoding
7 * (c) 1997 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
43 typedef struct base32_ctx {
44 unsigned long accl, acch; /* Accumulator for output data */
45 unsigned qsz; /* Length of data queued */
46 unsigned lnlen; /* Length of the current line */
47 const char *indent; /* Newline-and-indent string */
48 unsigned maxline; /* Maximum permitted line length */
51 /*----- Functions provided ------------------------------------------------*/
53 /* --- @base32_encode@ --- *
55 * Arguments: @base32_ctx *ctx@ = pointer to a context block
56 * @const void *p@ = pointer to a source buffer
57 * @size_t sz@ = size of the source buffer
58 * @dstr *d@ = pointer to destination string
62 * Use: Encodes a binary string in base32. To flush out the final
63 * few characters (if necessary), pass a null source pointer.
66 extern void base32_encode(base32_ctx */*ctx*/,
67 const void */*p*/, size_t /*sz*/,
70 /* --- @base32_decode@ --- *
72 * Arguments: @base32_ctx *ctx@ = pointer to a context block
73 * @const void *p@ = pointer to a source buffer
74 * @size_t sz@ = size of the source buffer
75 * @dstr *d@ = pointer to destination string
79 * Use: Decodes a binary string in base32. To flush out the final
80 * few characters (if necessary), pass a null source pointer.
83 extern void base32_decode(base32_ctx */*ctx*/,
84 const void */*p*/, size_t /*sz*/,
87 /* --- @base32_init@ --- *
89 * Arguments: @base32_ctx *ctx@ = pointer to context block to initialize
93 * Use: Initializes a base32 context properly.
96 extern void base32_init(base32_ctx */*ctx*/);
98 /*----- That's all, folks -------------------------------------------------*/