1 | /** |
---|
2 | * @copyright |
---|
3 | * ==================================================================== |
---|
4 | * Copyright (c) 2000-2004, 2008 CollabNet. All rights reserved. |
---|
5 | * |
---|
6 | * This software is licensed as described in the file COPYING, which |
---|
7 | * you should have received as part of this distribution. The terms |
---|
8 | * are also available at http://subversion.tigris.org/license-1.html. |
---|
9 | * If newer versions of this license are posted there, you may use a |
---|
10 | * newer version instead, at your option. |
---|
11 | * |
---|
12 | * This software consists of voluntary contributions made by many |
---|
13 | * individuals. For exact contribution history, see the revision |
---|
14 | * history and logs, available at http://subversion.tigris.org/. |
---|
15 | * ==================================================================== |
---|
16 | * @endcopyright |
---|
17 | * |
---|
18 | * @file svn_base64.h |
---|
19 | * @brief Base64 encoding and decoding functions |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef SVN_BASE64_H |
---|
23 | #define SVN_BASE64_H |
---|
24 | |
---|
25 | #include <apr_pools.h> |
---|
26 | |
---|
27 | #include "svn_types.h" |
---|
28 | #include "svn_io.h" /* for svn_stream_t */ |
---|
29 | #include "svn_string.h" |
---|
30 | |
---|
31 | #ifdef __cplusplus |
---|
32 | extern "C" { |
---|
33 | #endif /* __cplusplus */ |
---|
34 | |
---|
35 | /** |
---|
36 | * |
---|
37 | * |
---|
38 | * @defgroup base64 Base64 encoding/decoding functions |
---|
39 | * |
---|
40 | * @{ |
---|
41 | */ |
---|
42 | |
---|
43 | /** Return a writable generic stream which will encode binary data in |
---|
44 | * base64 format and write the encoded data to @c output. Be sure to |
---|
45 | * close the stream when done writing in order to squeeze out the last |
---|
46 | * bit of encoded data. The stream is allocated in @c pool. |
---|
47 | */ |
---|
48 | svn_stream_t * |
---|
49 | svn_base64_encode(svn_stream_t *output, |
---|
50 | apr_pool_t *pool); |
---|
51 | |
---|
52 | /** Return a writable generic stream which will decode base64-encoded |
---|
53 | * data and write the decoded data to @c output. The stream is allocated |
---|
54 | * in @c pool. |
---|
55 | */ |
---|
56 | svn_stream_t * |
---|
57 | svn_base64_decode(svn_stream_t *output, |
---|
58 | apr_pool_t *pool); |
---|
59 | |
---|
60 | |
---|
61 | /** Encode an @c svn_stringbuf_t into base64. |
---|
62 | * |
---|
63 | * A simple interface for encoding base64 data assuming we have all of |
---|
64 | * it present at once. If @a break_lines is true, newlines will be |
---|
65 | * inserted periodically; otherwise the string will only consist of |
---|
66 | * base64 encoding characters. The returned string will be allocated |
---|
67 | * from @c pool. |
---|
68 | * |
---|
69 | * @since New in 1.6. |
---|
70 | */ |
---|
71 | const svn_string_t * |
---|
72 | svn_base64_encode_string2(const svn_string_t *str, |
---|
73 | svn_boolean_t break_lines, |
---|
74 | apr_pool_t *pool); |
---|
75 | |
---|
76 | /** |
---|
77 | * Same as svn_base64_encode_string2, but with @a break_lines always |
---|
78 | * TRUE. |
---|
79 | * |
---|
80 | * @deprecated Provided for backward compatibility with the 1.5 API. |
---|
81 | */ |
---|
82 | SVN_DEPRECATED |
---|
83 | const svn_string_t * |
---|
84 | svn_base64_encode_string(const svn_string_t *str, |
---|
85 | apr_pool_t *pool); |
---|
86 | |
---|
87 | /** Decode an @c svn_stringbuf_t from base64. |
---|
88 | * |
---|
89 | * A simple interface for decoding base64 data assuming we have all of |
---|
90 | * it present at once. The returned string will be allocated from @c |
---|
91 | * pool. |
---|
92 | * |
---|
93 | */ |
---|
94 | const svn_string_t * |
---|
95 | svn_base64_decode_string(const svn_string_t *str, |
---|
96 | apr_pool_t *pool); |
---|
97 | |
---|
98 | |
---|
99 | /** Return a base64-encoded checksum for finalized @c digest. |
---|
100 | * |
---|
101 | * @c digest contains @c APR_MD5_DIGESTSIZE bytes of finalized data. |
---|
102 | * Allocate the returned checksum in @c pool. |
---|
103 | * |
---|
104 | * @deprecated Provided for backward compatibility with the 1.5 API. |
---|
105 | */ |
---|
106 | SVN_DEPRECATED |
---|
107 | svn_stringbuf_t * |
---|
108 | svn_base64_from_md5(unsigned char digest[], |
---|
109 | apr_pool_t *pool); |
---|
110 | |
---|
111 | |
---|
112 | /** @} end group: Base64 encoding/decoding functions */ |
---|
113 | |
---|
114 | #ifdef __cplusplus |
---|
115 | } |
---|
116 | #endif /* __cplusplus */ |
---|
117 | |
---|
118 | #endif /* SVN_BASE64_H */ |
---|