Merge branch 'vendor/OPENSSL'
[dragonfly.git] / contrib / bind-9.3 / lib / isc / include / isc / base64.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: base64.h,v 1.15.206.1 2004/03/06 08:14:38 marka Exp $ */
19
20 #ifndef ISC_BASE64_H
21 #define ISC_BASE64_H 1
22
23 #include <isc/lang.h>
24 #include <isc/types.h>
25
26 ISC_LANG_BEGINDECLS
27
28 /***
29  *** Functions
30  ***/
31
32 isc_result_t
33 isc_base64_totext(isc_region_t *source, int wordlength,
34                   const char *wordbreak, isc_buffer_t *target);
35 /*
36  * Convert data into base64 encoded text.
37  *
38  * Notes:
39  *      The base64 encoded text in 'target' will be divided into
40  *      words of at most 'wordlength' characters, separated by
41  *      the 'wordbreak' string.  No parentheses will surround
42  *      the text.
43  *
44  * Requires:
45  *      'source' is a region containing binary data
46  *      'target' is a text buffer containing available space
47  *      'wordbreak' points to a null-terminated string of
48  *              zero or more whitespace characters
49  *
50  * Ensures:
51  *      target will contain the base64 encoded version of the data
52  *      in source.  The 'used' pointer in target will be advanced as
53  *      necessary.
54  */
55
56 isc_result_t
57 isc_base64_decodestring(const char *cstr, isc_buffer_t *target);
58 /*
59  * Decode a null-terminated base64 string.
60  *
61  * Requires:
62  *      'cstr' is non-null.
63  *      'target' is a valid buffer.
64  *
65  * Returns:
66  *      ISC_R_SUCCESS   -- the entire decoded representation of 'cstring'
67  *                         fit in 'target'.
68  *      ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding.
69  *
70  *      Other error returns are any possible error code from:
71  *              isc_lex_create(),
72  *              isc_lex_openbuffer(),
73  *              isc_base64_tobuffer().
74  */
75
76 isc_result_t
77 isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
78 /*
79  * Convert base64 encoded text from a lexer context into data.
80  *
81  * Requires:
82  *      'lex' is a valid lexer context
83  *      'target' is a buffer containing binary data
84  *      'length' is an integer
85  *
86  * Ensures:
87  *      target will contain the data represented by the base64 encoded
88  *      string parsed by the lexer.  No more than length bytes will be read,
89  *      if length is positive.  The 'used' pointer in target will be
90  *      advanced as necessary.
91  */
92
93
94
95 ISC_LANG_ENDDECLS
96
97 #endif /* ISC_BASE64_H */