nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | /** |
||
3 | * `b64.h' - b64 |
||
4 | * |
||
5 | * copyright (c) 2014 joseph werle |
||
6 | * |
||
7 | * License: |
||
8 | * The MIT License (MIT) |
||
9 | * |
||
10 | * Copyright (c) 2014 Little Star Media, Inc. |
||
11 | * |
||
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
13 | * of this software and associated documentation files (the "Software"), to deal |
||
14 | * in the Software without restriction, including without limitation the rights |
||
15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
16 | * copies of the Software, and to permit persons to whom the Software is |
||
17 | * furnished to do so, subject to the following conditions: |
||
18 | * |
||
19 | * The above copyright notice and this permission notice shall be included in all |
||
20 | * copies or substantial portions of the Software. |
||
21 | * |
||
22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
28 | * SOFTWARE. |
||
29 | */ |
||
30 | |||
31 | #ifndef B64_H |
||
32 | #define B64_H 1 |
||
33 | |||
34 | /** |
||
35 | * Memory allocation functions to use. You can define b64_malloc and |
||
36 | * b64_realloc to custom functions if you want. |
||
37 | */ |
||
38 | |||
39 | #ifndef b64_malloc |
||
40 | # define b64_malloc(ptr) malloc(ptr) |
||
41 | #endif |
||
42 | #ifndef b64_realloc |
||
43 | # define b64_realloc(ptr, size) realloc(ptr, size) |
||
44 | #endif |
||
45 | |||
46 | /** |
||
47 | * Base64 index table. |
||
48 | */ |
||
49 | |||
50 | static const char b64_table[] = { |
||
51 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', |
||
52 | 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', |
||
53 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', |
||
54 | 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', |
||
55 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', |
||
56 | 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
||
57 | 'w', 'x', 'y', 'z', '0', '1', '2', '3', |
||
58 | '4', '5', '6', '7', '8', '9', '+', '/' |
||
59 | }; |
||
60 | |||
61 | #ifdef __cplusplus |
||
62 | extern "C" { |
||
63 | #endif |
||
64 | |||
65 | /** |
||
66 | * Encode `unsigned char *' source with `size_t' size. |
||
67 | * Returns a `char *' base64 encoded string. |
||
68 | */ |
||
69 | |||
70 | char * |
||
71 | b64_encode (const unsigned char *, size_t); |
||
72 | |||
73 | /** |
||
74 | * Dencode `char *' source with `size_t' size. |
||
75 | * Returns a `unsigned char *' base64 decoded string. |
||
76 | */ |
||
77 | unsigned char * |
||
78 | b64_decode (const char *, size_t); |
||
79 | |||
80 | /** |
||
81 | * Dencode `char *' source with `size_t' size. |
||
82 | * Returns a `unsigned char *' base64 decoded string + size of decoded string. |
||
83 | */ |
||
84 | unsigned char * |
||
85 | b64_decode_ex (const char *, size_t, size_t *); |
||
86 | |||
87 | #ifdef __cplusplus |
||
88 | } |
||
89 | #endif |
||
90 | |||
91 | #endif |