source: azure_iot_hub/trunk/azure_iohub/c-utility/inc/azure_c_shared_utility/azure_base64.h@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 3.4 KB
Line 
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4/** @file base64.h
5* @brief Prototypes for functions related to encoding/decoding
6* a @c buffer using standard base64 encoding.
7*/
8
9#ifndef BASE64_H
10#define BASE64_H
11
12#include "azure_c_shared_utility/strings.h"
13#include "azure_c_shared_utility/buffer_.h"
14
15#ifdef __cplusplus
16#include <cstddef>
17extern "C" {
18#else
19#include <stddef.h>
20#endif
21
22#include "azure_c_shared_utility/umock_c_prod.h"
23
24
25/**
26 * @brief Base64 encodes a buffer and returns the resulting string.
27 *
28 * @param input The buffer that needs to be base64 encoded.
29 *
30 * Base64_Encode takes as a parameter a pointer to a BUFFER. If @p input is @c NULL then
31 * @c Base64_Encode returns @c NULL. The size of the BUFFER pointed to by @p input may
32 * be zero. If when allocating memory to produce the encoding a failure occurs, then @c
33 * Base64_Encode returns @c NULL. Otherwise
34 * @c Base64_Encode returns a pointer to a STRING. That string contains the
35 * base 64 encoding of the @p input. This encoding of @p input will not contain embedded
36 * line feeds.
37 *
38 * @return A @c STRING_HANDLE containing the base64 encoding of @p input.
39 */
40MOCKABLE_FUNCTION(, STRING_HANDLE, Azure_Base64_Encode, BUFFER_HANDLE, input);
41
42/**
43 * @brief Base64 encodes the buffer pointed to by @p source and returns the resulting string.
44 *
45 * @param source The buffer that needs to be base64 encoded.
46 * @param size The size.
47 *
48 * This function produces a @c STRING_HANDLE containing the base64 encoding of the
49 * buffer pointed to by @p source, having the size as given by
50 * @p size. If @p source is @c NULL then @c Base64_Encode_Bytes returns @c NULL
51 * If @p source is not @c NULL and @p size is zero, then @c Base64_Encode_Bytes produces
52 * an empty @c STRING_HANDLE. Otherwise, @c Base64_Encode_Bytes produces a
53 * @c STRING_HANDLE containing the Base64 representation of the buffer. In case of
54 * any errors, @c Base64_Encode_Bytes returns @c NULL.].
55 *
56 * @return @c NULL in case an error occurs or a @c STRING_HANDLE containing the base64 encoding
57 * of @p input.
58 *
59 */
60MOCKABLE_FUNCTION(, STRING_HANDLE, Azure_Base64_Encode_Bytes, const unsigned char*, source, size_t, size);
61
62/**
63 * @brief Base64 decodes the buffer pointed to by @p source and returns the resulting buffer.
64 *
65 * @param source A base64 encoded string buffer.
66 *
67 * This function decodes the string pointed at by @p source using base64 decoding and
68 * returns the resulting buffer. If @p source is @c NULL then
69 * @c Azure_Base64_Decode returns NULL. If the string pointed to by @p source is zero
70 * length then the handle returned refers to a zero length buffer. If there is any
71 * memory allocation failure during the decode or if the source string has an invalid
72 * length for a base 64 encoded string then @c Azure_Base64_Decode returns @c NULL.
73 *
74 * @return A @c BUFFER_HANDLE pointing to a buffer containing the result of base64 decoding @p
75 * source.
76 */
77MOCKABLE_FUNCTION(, BUFFER_HANDLE, Azure_Base64_Decode, const char*, source);
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* BASE64_H */
Note: See TracBrowser for help on using the repository browser.