xref: /minix3/external/bsd/bind/dist/lib/isccc/include/isccc/base64.h (revision 00b67f09dd46474d133c95011a48590a8e8f94c7)
1 /*	$NetBSD: base64.h,v 1.4 2014/12/10 04:38:01 christos Exp $	*/
2 
3 /*
4  * Portions Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
5  * Portions Copyright (C) 2001  Internet Software Consortium.
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
13  * OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
14  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  *
19  * Portions Copyright (C) 2001  Nominum, Inc.
20  *
21  * Permission to use, copy, modify, and/or distribute this software for any
22  * purpose with or without fee is hereby granted, provided that the above
23  * copyright notice and this permission notice appear in all copies.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL
26  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
27  * OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
28  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
29  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
30  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
31  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32  */
33 
34 /* Id: base64.h,v 1.10 2007/08/28 07:20:43 tbox Exp  */
35 
36 #ifndef ISCCC_BASE64_H
37 #define ISCCC_BASE64_H 1
38 
39 /*! \file isccc/base64.h */
40 
41 #include <isc/lang.h>
42 #include <isccc/types.h>
43 
44 ISC_LANG_BEGINDECLS
45 
46 /***
47  *** Functions
48  ***/
49 
50 isc_result_t
51 isccc_base64_encode(isccc_region_t *source, int wordlength,
52 		  const char *wordbreak, isccc_region_t *target);
53 /*%<
54  * Convert data into base64 encoded text.
55  *
56  * Notes:
57  *\li	The base64 encoded text in 'target' will be divided into
58  *	words of at most 'wordlength' characters, separated by
59  * 	the 'wordbreak' string.  No parentheses will surround
60  *	the text.
61  *
62  * Requires:
63  *\li	'source' is a region containing binary data.
64  *\li	'target' is a text region containing available space.
65  *\li	'wordbreak' points to a null-terminated string of
66  *		zero or more whitespace characters.
67  */
68 
69 isc_result_t
70 isccc_base64_decode(const char *cstr, isccc_region_t *target);
71 /*%<
72  * Decode a null-terminated base64 string.
73  *
74  * Requires:
75  *\li	'cstr' is non-null.
76  *\li	'target' is a valid region.
77  *
78  * Returns:
79  *\li	#ISC_R_SUCCESS	-- the entire decoded representation of 'cstring'
80  *			   fit in 'target'.
81  *\li	#ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding.
82  *\li	#ISC_R_NOSPACE	-- 'target' is not big enough.
83  */
84 
85 ISC_LANG_ENDDECLS
86 
87 #endif /* ISCCC_BASE64_H */
88