chiark / gitweb /
Add new `rest' argument for `str_split'.
[mLib] / base64.h
CommitLineData
ceba1986 1/* -*-c-*-
2 *
c601c4f1 3 * $Id: base64.h,v 1.2 1999/05/18 21:45:27 mdw Exp $
ceba1986 4 *
5 * Base64 encoding and decoding
6 *
7 * (c) 1997 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
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.
18 *
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.
23 *
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
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: base64.h,v $
c601c4f1 33 * Revision 1.2 1999/05/18 21:45:27 mdw
34 * Allow Base64 encode and decode of arbitrary rubbish.
35 *
ceba1986 36 * Revision 1.1 1999/05/17 20:35:00 mdw
37 * Base64 encoding and decoding support.
38 *
39 */
40
41#ifndef BASE64_H
42#define BASE64_H
43
44#ifdef __cplusplus
45 extern "C" {
46#endif
47
48/*----- Header files ------------------------------------------------------*/
49
50#include "dstr.h"
51
52/*----- Data structures ---------------------------------------------------*/
53
54typedef struct base64_ctx {
55 unsigned long acc; /* Accumulator for output data */
56 unsigned qsz; /* Length of data queued */
57 unsigned lnlen; /* Length of the current line */
58 const char *indent; /* Newline-and-indent string */
59 unsigned maxline; /* Maximum permitted line length */
60} base64_ctx;
61
62/*----- Functions provided ------------------------------------------------*/
63
64/* --- @base64_encode@ --- *
65 *
66 * Arguments: @base64_ctx *ctx@ = pointer to a context block
c601c4f1 67 * @const void *p@ = pointer to a source buffer
ceba1986 68 * @size_t sz@ = size of the source buffer
69 * @dstr *d@ = pointer to destination string
70 *
71 * Returns: ---
72 *
73 * Use: Encodes a binary string in base64. To flush out the final
74 * few characters (if necessary), pass a null source pointer.
75 */
76
77extern void base64_encode(base64_ctx */*ctx*/,
c601c4f1 78 const void */*p*/, size_t /*sz*/,
ceba1986 79 dstr */*d*/);
80
81/* --- @base64_decode@ --- *
82 *
83 * Arguments: @base64_ctx *ctx@ = pointer to a context block
c601c4f1 84 * @const void *p@ = pointer to a source buffer
ceba1986 85 * @size_t sz@ = size of the source buffer
86 * @dstr *d@ = pointer to destination string
87 *
88 * Returns: ---
89 *
90 * Use: Decodes a binary string in base64. To flush out the final
91 * few characters (if necessary), pass a null source pointer.
92 */
93
94extern void base64_decode(base64_ctx */*ctx*/,
c601c4f1 95 const void */*p*/, size_t /*sz*/,
ceba1986 96 dstr */*d*/);
97
98/* --- @base64_init@ --- *
99 *
100 * Arguments: @base64_ctx *ctx@ = pointer to context block to initialize
101 *
102 * Returns: ---
103 *
104 * Use: Initializes a base64 context properly.
105 */
106
107extern void base64_init(base64_ctx */*ctx*/);
108
109/*----- That's all, folks -------------------------------------------------*/
110
111#ifdef __cplusplus
112 }
113#endif
114
115#endif