chiark / gitweb /
Build: Overhaul build system.
[mLib] / base64.h
CommitLineData
ceba1986 1/* -*-c-*-
2 *
8656dc50 3 * $Id: base64.h,v 1.4 2004/04/08 01:36:11 mdw Exp $
ceba1986 4 *
5 * Base64 encoding and decoding
6 *
7 * (c) 1997 Straylight/Edgeware
8 */
9
d4efbcd9 10/*----- Licensing notice --------------------------------------------------*
ceba1986 11 *
12 * This file is part of the mLib utilities library.
13 *
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.
d4efbcd9 18 *
ceba1986 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.
d4efbcd9 23 *
ceba1986 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,
27 * MA 02111-1307, USA.
28 */
29
c6e0eaf0 30#ifndef MLIB_BASE64_H
31#define MLIB_BASE64_H
ceba1986 32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/*----- Header files ------------------------------------------------------*/
38
39#include "dstr.h"
40
41/*----- Data structures ---------------------------------------------------*/
42
43typedef struct base64_ctx {
44 unsigned long acc; /* 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 */
49} base64_ctx;
50
51/*----- Functions provided ------------------------------------------------*/
52
53/* --- @base64_encode@ --- *
54 *
55 * Arguments: @base64_ctx *ctx@ = pointer to a context block
c601c4f1 56 * @const void *p@ = pointer to a source buffer
ceba1986 57 * @size_t sz@ = size of the source buffer
58 * @dstr *d@ = pointer to destination string
59 *
60 * Returns: ---
61 *
62 * Use: Encodes a binary string in base64. To flush out the final
63 * few characters (if necessary), pass a null source pointer.
64 */
65
66extern void base64_encode(base64_ctx */*ctx*/,
c601c4f1 67 const void */*p*/, size_t /*sz*/,
ceba1986 68 dstr */*d*/);
69
70/* --- @base64_decode@ --- *
71 *
72 * Arguments: @base64_ctx *ctx@ = pointer to a context block
c601c4f1 73 * @const void *p@ = pointer to a source buffer
ceba1986 74 * @size_t sz@ = size of the source buffer
75 * @dstr *d@ = pointer to destination string
76 *
77 * Returns: ---
78 *
79 * Use: Decodes a binary string in base64. To flush out the final
80 * few characters (if necessary), pass a null source pointer.
81 */
82
83extern void base64_decode(base64_ctx */*ctx*/,
c601c4f1 84 const void */*p*/, size_t /*sz*/,
ceba1986 85 dstr */*d*/);
86
87/* --- @base64_init@ --- *
88 *
89 * Arguments: @base64_ctx *ctx@ = pointer to context block to initialize
90 *
91 * Returns: ---
92 *
93 * Use: Initializes a base64 context properly.
94 */
95
96extern void base64_init(base64_ctx */*ctx*/);
97
98/*----- That's all, folks -------------------------------------------------*/
99
100#ifdef __cplusplus
101 }
102#endif
103
104#endif