3 * $Id: base64.h,v 1.1 1999/05/17 20:35:00 mdw Exp $
5 * Base64 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,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 1999/05/17 20:35:00 mdw
34 * Base64 encoding and decoding support.
45 /*----- Header files ------------------------------------------------------*/
49 /*----- Data structures ---------------------------------------------------*/
51 typedef struct base64_ctx {
52 unsigned long acc; /* Accumulator for output data */
53 unsigned qsz; /* Length of data queued */
54 unsigned lnlen; /* Length of the current line */
55 const char *indent; /* Newline-and-indent string */
56 unsigned maxline; /* Maximum permitted line length */
59 /*----- Functions provided ------------------------------------------------*/
61 /* --- @base64_encode@ --- *
63 * Arguments: @base64_ctx *ctx@ = pointer to a context block
64 * @const unsigned char *src@ = pointer to a source buffer
65 * @size_t sz@ = size of the source buffer
66 * @dstr *d@ = pointer to destination string
70 * Use: Encodes a binary string in base64. To flush out the final
71 * few characters (if necessary), pass a null source pointer.
74 extern void base64_encode(base64_ctx */*ctx*/,
75 const unsigned char */*src*/, size_t /*sz*/,
78 /* --- @base64_decode@ --- *
80 * Arguments: @base64_ctx *ctx@ = pointer to a context block
81 * @const unsigned char *src@ = pointer to a source buffer
82 * @size_t sz@ = size of the source buffer
83 * @dstr *d@ = pointer to destination string
87 * Use: Decodes a binary string in base64. To flush out the final
88 * few characters (if necessary), pass a null source pointer.
91 extern void base64_decode(base64_ctx */*ctx*/,
92 const unsigned char */*src*/, size_t /*sz*/,
95 /* --- @base64_init@ --- *
97 * Arguments: @base64_ctx *ctx@ = pointer to context block to initialize
101 * Use: Initializes a base64 context properly.
104 extern void base64_init(base64_ctx */*ctx*/);
106 /*----- That's all, folks -------------------------------------------------*/