forked from indilib/indi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64.h
65 lines (51 loc) · 1.87 KB
/
base64.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#if 0
INDI
Copyright (C) 2003 Elwood C. Downey
This library is free software;
you can redistribute it and / or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY;
without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library;
if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
#endif
#pragma once
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup base64 Base 64 Functions: Convert from and to base64
*/
/*@{*/
/** \brief Convert bytes array to base64.
\param out output buffer in base64. The buffer size must be at least (4 * inlen / 3 + 4) bytes long.
\param in input binary buffer
\param inlen number of bytes to convert
\return 0 on success, -1 on failure.
*/
extern int to64frombits_s(unsigned char *out, const unsigned char *in, int inlen, size_t outlen);
#if defined(__GNUC__)
__attribute__((deprecated("unsafe function, use to64frombits_s instead")))
#endif
extern int to64frombits(unsigned char *out, const unsigned char *in, int inlen);
/** \brief Convert base64 to bytes array.
\param out output buffer in bytes. The buffer size must be at least (3 * size_of_in_buffer / 4) bytes long.
\param in input base64 buffer
\param inlen base64 buffer lenght
\return 0 on success, -1 on failure.
*/
extern int from64tobits(char *out, const char *in);
extern int from64tobits_fast(char *out, const char *in, int inlen);
/*@}*/
#ifdef __cplusplus
}
#endif