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