VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/base64.h@ 84294

Last change on this file since 84294 was 84294, checked in by vboxsync, 5 years ago

IPRT/base64: Put the UTF-16 code in separate file. Implemented decoding of UTF-16 strings. [missing file] bugref:9224

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: base64.h 84294 2020-05-13 16:25:00Z vboxsync $ */
2/** @file
3 * IPRT - Base64, MIME content transfer encoding, internal header.
4 */
5
6/*
7 * Copyright (C) 2009-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Defined Constants And Macros *
30*********************************************************************************************************************************/
31/** The line length used for encoding. */
32#define RTBASE64_LINE_LEN 64
33
34/** @name Special g_au8RTBase64CharToVal values
35 * @{ */
36#define BASE64_SPACE 0xc0
37#define BASE64_PAD 0xe0
38#define BASE64_INVALID 0xff
39/** @} */
40
41
42/*********************************************************************************************************************************
43* Global Variables *
44*********************************************************************************************************************************/
45extern DECLHIDDEN(const uint8_t) g_au8RTBase64CharToVal[256];
46extern DECLHIDDEN(const char) g_szRTBase64ValToChar[64+1];
47extern DECLHIDDEN(const size_t) g_acchRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1];
48extern DECLHIDDEN(const char) g_aachRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2];
49
50
51/*********************************************************************************************************************************
52* Internal Functions *
53*********************************************************************************************************************************/
54#ifdef RT_STRICT
55DECLHIDDEN(void) rtBase64Sanity(void);
56#endif
57
58
59/**
60 * Recalcs 6-bit to 8-bit and adjust for padding.
61 */
62DECLINLINE(ssize_t) rtBase64DecodedSizeRecalc(uint32_t c6Bits, unsigned cbPad)
63{
64 size_t cb;
65 if (c6Bits * 3 / 3 == c6Bits)
66 {
67 if ((c6Bits * 3 % 4) != 0)
68 return -1;
69 cb = c6Bits * 3 / 4;
70 }
71 else
72 {
73 if ((c6Bits * (uint64_t)3 % 4) != 0)
74 return -1;
75 cb = c6Bits * (uint64_t)3 / 4;
76 }
77
78 if (cb < cbPad)
79 return -1;
80 cb -= cbPad;
81 return cb;
82}
83
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette