mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Move base64.h to the proper location.
Move base64.h to the proper location and put redirect header into the old place to be able to switch downstream users on new location. Bug: webrtc:8366 Change-Id: I5191fe631d32178d2efd1315ca9abd4250102291 Reviewed-on: https://webrtc-review.googlesource.com/88223 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24069}
This commit is contained in:
parent
5d7a4c6692
commit
a76af0ca2e
28 changed files with 208 additions and 171 deletions
|
@ -2,8 +2,6 @@ This source tree contains third party source code which is governed by third
|
|||
party licenses. Paths to the files and associated licenses are collected here.
|
||||
|
||||
Files governed by third party licenses:
|
||||
rtc_base/base64.cc
|
||||
rtc_base/base64.h
|
||||
rtc_base/sigslot.cc
|
||||
rtc_base/sigslot.h
|
||||
common_audio/fft4g.c
|
||||
|
@ -22,26 +20,6 @@ modules/audio_device/mac/portaudio/pa_ringbuffer.h
|
|||
Individual licenses for each file:
|
||||
-------------------------------------------------------------------------------
|
||||
Files:
|
||||
rtc_base/base64.cc
|
||||
rtc_base/base64.h
|
||||
|
||||
License:
|
||||
//*********************************************************************
|
||||
//* Base64 - a simple base64 encoder and decoder.
|
||||
//*
|
||||
//* Copyright (c) 1999, Bob Withers - bwit@pobox.com
|
||||
//*
|
||||
//* This code may be freely used for any purpose, either personal
|
||||
//* or commercial, provided the authors copyright notice remains
|
||||
//* intact.
|
||||
//*
|
||||
//* Enhancements by Stanley Yamane:
|
||||
//* o reverse lookup table for the decode function
|
||||
//* o reserve string buffer space in advance
|
||||
//*
|
||||
//*********************************************************************
|
||||
-------------------------------------------------------------------------------
|
||||
Files:
|
||||
rtc_base/sigslot.cc
|
||||
rtc_base/sigslot.h
|
||||
|
||||
|
|
|
@ -236,8 +236,8 @@ rtc_static_library("rtc_audio_video") {
|
|||
"../modules/video_coding:video_coding",
|
||||
"../modules/video_coding:video_coding_utility",
|
||||
"../rtc_base:audio_format_to_string",
|
||||
"../rtc_base:base64",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base/third_party/base64",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "modules/audio_processing/aec_dump/aec_dump_factory.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
#include "rtc_base/arraysize.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/byteorder.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/helpers.h"
|
||||
|
@ -42,6 +41,7 @@
|
|||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
|
|
|
@ -53,9 +53,9 @@ if (rtc_include_tests) {
|
|||
":desktop_capture_mock",
|
||||
":primitives",
|
||||
":screen_drawer",
|
||||
"../../rtc_base:base64",
|
||||
"../../rtc_base:rtc_base",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base/third_party/base64",
|
||||
"../../system_wrappers",
|
||||
"../../test:test_support",
|
||||
"../../test:video_test_support",
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include "modules/desktop_capture/mock_desktop_capturer_callback.h"
|
||||
#include "modules/desktop_capture/rgba_color.h"
|
||||
#include "modules/desktop_capture/screen_drawer.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
|
|
|
@ -163,7 +163,6 @@ rtc_static_library("video_coding") {
|
|||
"../../api/video:video_frame_i420",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../common_video",
|
||||
"../../rtc_base:base64",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
|
@ -172,6 +171,7 @@ rtc_static_library("video_coding") {
|
|||
"../../rtc_base:sequenced_task_checker",
|
||||
"../../rtc_base/experiments:alr_experiment",
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../rtc_base/third_party/base64",
|
||||
"../../rtc_base/time:timestamp_extrapolator",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -85,11 +85,11 @@ rtc_static_library("rtc_p2p") {
|
|||
"../api:libjingle_peerconnection_api",
|
||||
"../api:ortc_api",
|
||||
"../logging:ice_log",
|
||||
"../rtc_base:base64",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:safe_minmax",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../system_wrappers:field_trial_api",
|
||||
"../system_wrappers:metrics_api",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "p2p/base/portallocator.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/crc32.h"
|
||||
#include "rtc_base/helpers.h"
|
||||
|
@ -28,6 +27,7 @@
|
|||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -79,11 +79,11 @@ rtc_static_library("rtc_pc_base") {
|
|||
"../media:rtc_media_base",
|
||||
"../modules/rtp_rtcp:rtp_rtcp_format",
|
||||
"../p2p:rtc_p2p",
|
||||
"../rtc_base:base64",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_task_queue",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../system_wrappers:metrics_api",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
|
@ -197,12 +197,12 @@ rtc_static_library("peerconnection") {
|
|||
"../media:rtc_media_base",
|
||||
"../modules/congestion_controller/bbr",
|
||||
"../p2p:rtc_p2p",
|
||||
"../rtc_base:base64",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/experiments:congestion_controller_experiment",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../stats",
|
||||
"../system_wrappers",
|
||||
"../system_wrappers:field_trial_api",
|
||||
|
@ -478,9 +478,9 @@ if (rtc_include_tests) {
|
|||
"../api:mock_rtp",
|
||||
"../api/units:time_delta",
|
||||
"../logging:fake_rtc_event_log",
|
||||
"../rtc_base:base64",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/third_party/base64",
|
||||
"../test:fileutils",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
#include "pc/channelmanager.h"
|
||||
#include "pc/rtpmediautils.h"
|
||||
#include "pc/srtpfilter.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/helpers.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
#include "media/base/rtputils.h"
|
||||
#include "pc/srtpsession.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/byteorder.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "rtc_base/zero_memory.h"
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include "pc/rtptransport.h"
|
||||
#include "pc/srtpsession.h"
|
||||
#include "rtc_base/asyncpacketsocket.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/copyonwritebuffer.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "rtc_base/zero_memory.h"
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "pc/channel.h"
|
||||
#include "pc/peerconnection.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "pc/test/fakepeerconnectionforstats.h"
|
||||
#include "pc/test/fakevideotracksource.h"
|
||||
#include "pc/videotrack.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/fakesslidentity.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
using cricket::ConnectionInfo;
|
||||
|
|
|
@ -371,7 +371,6 @@ rtc_source_set("rtc_base_approved_generic") {
|
|||
data_deps = []
|
||||
deps = [
|
||||
":atomicops",
|
||||
":base64",
|
||||
":checks",
|
||||
":criticalsection",
|
||||
":logging",
|
||||
|
@ -390,6 +389,7 @@ rtc_source_set("rtc_base_approved_generic") {
|
|||
":type_traits",
|
||||
"../:typedefs",
|
||||
"system:arch",
|
||||
"third_party/base64",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
@ -495,9 +495,11 @@ if (is_mac && !build_with_chromium) {
|
|||
rtc_source_set("base64") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"base64.cc",
|
||||
"base64.h",
|
||||
]
|
||||
deps = [
|
||||
"third_party/base64",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("rtc_task_queue") {
|
||||
|
@ -723,11 +725,11 @@ rtc_static_library("rtc_base_generic") {
|
|||
libs = []
|
||||
defines = []
|
||||
deps = [
|
||||
":base64",
|
||||
":checks",
|
||||
":stringutils",
|
||||
"..:webrtc_common",
|
||||
"../api:array_view",
|
||||
"third_party/base64",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
@ -1160,7 +1162,6 @@ if (rtc_include_tests) {
|
|||
sources += [ "win/windows_version_unittest.cc" ]
|
||||
}
|
||||
deps = [
|
||||
":base64",
|
||||
":checks",
|
||||
":rate_limiter",
|
||||
":rtc_base",
|
||||
|
@ -1177,6 +1178,7 @@ if (rtc_include_tests) {
|
|||
"../test:fileutils",
|
||||
"../test:test_support",
|
||||
"memory:unittests",
|
||||
"third_party/base64",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,123 +1,14 @@
|
|||
/*
|
||||
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
//*********************************************************************
|
||||
//* C_Base64 - a simple base64 encoder and decoder.
|
||||
//*
|
||||
//* Copyright (c) 1999, Bob Withers - bwit@pobox.com
|
||||
//*
|
||||
//* This code may be freely used for any purpose, either personal
|
||||
//* or commercial, provided the authors copyright notice remains
|
||||
//* intact.
|
||||
//*********************************************************************
|
||||
|
||||
#ifndef RTC_BASE_BASE64_H_
|
||||
#define RTC_BASE_BASE64_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class Base64 {
|
||||
public:
|
||||
enum DecodeOption {
|
||||
DO_PARSE_STRICT = 1, // Parse only base64 characters
|
||||
DO_PARSE_WHITE = 2, // Parse only base64 and whitespace characters
|
||||
DO_PARSE_ANY = 3, // Parse all characters
|
||||
DO_PARSE_MASK = 3,
|
||||
|
||||
DO_PAD_YES = 4, // Padding is required
|
||||
DO_PAD_ANY = 8, // Padding is optional
|
||||
DO_PAD_NO = 12, // Padding is disallowed
|
||||
DO_PAD_MASK = 12,
|
||||
|
||||
DO_TERM_BUFFER = 16, // Must termiante at end of buffer
|
||||
DO_TERM_CHAR = 32, // May terminate at any character boundary
|
||||
DO_TERM_ANY = 48, // May terminate at a sub-character bit offset
|
||||
DO_TERM_MASK = 48,
|
||||
|
||||
// Strictest interpretation
|
||||
DO_STRICT = DO_PARSE_STRICT | DO_PAD_YES | DO_TERM_BUFFER,
|
||||
|
||||
DO_LAX = DO_PARSE_ANY | DO_PAD_ANY | DO_TERM_CHAR,
|
||||
};
|
||||
typedef int DecodeFlags;
|
||||
|
||||
static bool IsBase64Char(char ch);
|
||||
|
||||
// Get the char next to the |ch| from the Base64Table.
|
||||
// If the |ch| is the last one in the Base64Table then returns
|
||||
// the first one from the table.
|
||||
// Expects the |ch| be a base64 char.
|
||||
// The result will be saved in |next_ch|.
|
||||
// Returns true on success.
|
||||
static bool GetNextBase64Char(char ch, char* next_ch);
|
||||
|
||||
// Determines whether the given string consists entirely of valid base64
|
||||
// encoded characters.
|
||||
static bool IsBase64Encoded(const std::string& str);
|
||||
|
||||
static void EncodeFromArray(const void* data,
|
||||
size_t len,
|
||||
std::string* result);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::string* result,
|
||||
size_t* data_used);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::vector<char>* result,
|
||||
size_t* data_used);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::vector<uint8_t>* result,
|
||||
size_t* data_used);
|
||||
|
||||
// Convenience Methods
|
||||
static inline std::string Encode(const std::string& data) {
|
||||
std::string result;
|
||||
EncodeFromArray(data.data(), data.size(), &result);
|
||||
return result;
|
||||
}
|
||||
static inline std::string Decode(const std::string& data, DecodeFlags flags) {
|
||||
std::string result;
|
||||
DecodeFromArray(data.data(), data.size(), flags, &result, nullptr);
|
||||
return result;
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
DecodeFlags flags,
|
||||
std::string* result,
|
||||
size_t* data_used) {
|
||||
return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
DecodeFlags flags,
|
||||
std::vector<char>* result,
|
||||
size_t* data_used) {
|
||||
return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
|
||||
}
|
||||
|
||||
private:
|
||||
static const char Base64Table[];
|
||||
static const unsigned char DecodeTable[];
|
||||
|
||||
static size_t GetNextQuantum(DecodeFlags parse_flags,
|
||||
bool illegal_pads,
|
||||
const char* data,
|
||||
size_t len,
|
||||
size_t* dpos,
|
||||
unsigned char qbuf[4],
|
||||
bool* padded);
|
||||
template <typename T>
|
||||
static bool DecodeFromArrayTemplate(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
T* result,
|
||||
size_t* data_used);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_BASE64_H_
|
||||
// This is a temporary header file to move origin header from this location
|
||||
// to specified in include. Don't use this header directly, use included one
|
||||
// instead.
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
|
||||
// Protect against max macro inclusion.
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "rtc_base/arraysize.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/cryptstring.h"
|
||||
#include "rtc_base/httpcommon-inl.h"
|
||||
#include "rtc_base/httpcommon.h"
|
||||
#include "rtc_base/messagedigest.h"
|
||||
#include "rtc_base/socketaddress.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
#include "rtc_base/zero_memory.h"
|
||||
|
||||
namespace rtc {
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/opensslcertificate.h"
|
||||
#include "rtc_base/sslfingerprint.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/opensslidentity.h"
|
||||
#include "rtc_base/sslfingerprint.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
|
17
rtc_base/third_party/base64/BUILD.gn
vendored
Normal file
17
rtc_base/third_party/base64/BUILD.gn
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the ../../../LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("../../../webrtc.gni")
|
||||
|
||||
rtc_source_set("base64") {
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"base64.cc",
|
||||
"base64.h",
|
||||
]
|
||||
}
|
14
rtc_base/third_party/base64/LICENSE
vendored
Normal file
14
rtc_base/third_party/base64/LICENSE
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
//*********************************************************************
|
||||
//* Base64 - a simple base64 encoder and decoder.
|
||||
//*
|
||||
//* Copyright (c) 1999, Bob Withers - bwit@pobox.com
|
||||
//*
|
||||
//* This code may be freely used for any purpose, either personal
|
||||
//* or commercial, provided the authors copyright notice remains
|
||||
//* intact.
|
||||
//*
|
||||
//* Enhancements by Stanley Yamane:
|
||||
//* o reverse lookup table for the decode function
|
||||
//* o reserve string buffer space in advance
|
||||
//*
|
||||
//*********************************************************************
|
11
rtc_base/third_party/base64/README.chromium
vendored
Normal file
11
rtc_base/third_party/base64/README.chromium
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
Name: A simple base64 encoder and decoder
|
||||
Short Name: base64
|
||||
URL:
|
||||
Version: 0
|
||||
Date: 2018-06-20
|
||||
License: Custom license
|
||||
License File: LICENSE
|
||||
Security Critical: yes
|
||||
|
||||
Description:
|
||||
A simple base64 encoder and decoder
|
|
@ -14,10 +14,10 @@
|
|||
//*
|
||||
//*********************************************************************
|
||||
|
||||
#include "rtc_base/base64.h"
|
||||
#include "rtc_base/third_party/base64/base64.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
using std::vector;
|
||||
|
123
rtc_base/third_party/base64/base64.h
vendored
Normal file
123
rtc_base/third_party/base64/base64.h
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
|
||||
//*********************************************************************
|
||||
//* C_Base64 - a simple base64 encoder and decoder.
|
||||
//*
|
||||
//* Copyright (c) 1999, Bob Withers - bwit@pobox.com
|
||||
//*
|
||||
//* This code may be freely used for any purpose, either personal
|
||||
//* or commercial, provided the authors copyright notice remains
|
||||
//* intact.
|
||||
//*********************************************************************
|
||||
|
||||
#ifndef RTC_BASE_BASE64_H_
|
||||
#define RTC_BASE_BASE64_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class Base64 {
|
||||
public:
|
||||
enum DecodeOption {
|
||||
DO_PARSE_STRICT = 1, // Parse only base64 characters
|
||||
DO_PARSE_WHITE = 2, // Parse only base64 and whitespace characters
|
||||
DO_PARSE_ANY = 3, // Parse all characters
|
||||
DO_PARSE_MASK = 3,
|
||||
|
||||
DO_PAD_YES = 4, // Padding is required
|
||||
DO_PAD_ANY = 8, // Padding is optional
|
||||
DO_PAD_NO = 12, // Padding is disallowed
|
||||
DO_PAD_MASK = 12,
|
||||
|
||||
DO_TERM_BUFFER = 16, // Must termiante at end of buffer
|
||||
DO_TERM_CHAR = 32, // May terminate at any character boundary
|
||||
DO_TERM_ANY = 48, // May terminate at a sub-character bit offset
|
||||
DO_TERM_MASK = 48,
|
||||
|
||||
// Strictest interpretation
|
||||
DO_STRICT = DO_PARSE_STRICT | DO_PAD_YES | DO_TERM_BUFFER,
|
||||
|
||||
DO_LAX = DO_PARSE_ANY | DO_PAD_ANY | DO_TERM_CHAR,
|
||||
};
|
||||
typedef int DecodeFlags;
|
||||
|
||||
static bool IsBase64Char(char ch);
|
||||
|
||||
// Get the char next to the |ch| from the Base64Table.
|
||||
// If the |ch| is the last one in the Base64Table then returns
|
||||
// the first one from the table.
|
||||
// Expects the |ch| be a base64 char.
|
||||
// The result will be saved in |next_ch|.
|
||||
// Returns true on success.
|
||||
static bool GetNextBase64Char(char ch, char* next_ch);
|
||||
|
||||
// Determines whether the given string consists entirely of valid base64
|
||||
// encoded characters.
|
||||
static bool IsBase64Encoded(const std::string& str);
|
||||
|
||||
static void EncodeFromArray(const void* data,
|
||||
size_t len,
|
||||
std::string* result);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::string* result,
|
||||
size_t* data_used);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::vector<char>* result,
|
||||
size_t* data_used);
|
||||
static bool DecodeFromArray(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
std::vector<uint8_t>* result,
|
||||
size_t* data_used);
|
||||
|
||||
// Convenience Methods
|
||||
static inline std::string Encode(const std::string& data) {
|
||||
std::string result;
|
||||
EncodeFromArray(data.data(), data.size(), &result);
|
||||
return result;
|
||||
}
|
||||
static inline std::string Decode(const std::string& data, DecodeFlags flags) {
|
||||
std::string result;
|
||||
DecodeFromArray(data.data(), data.size(), flags, &result, nullptr);
|
||||
return result;
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
DecodeFlags flags,
|
||||
std::string* result,
|
||||
size_t* data_used) {
|
||||
return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
DecodeFlags flags,
|
||||
std::vector<char>* result,
|
||||
size_t* data_used) {
|
||||
return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
|
||||
}
|
||||
|
||||
private:
|
||||
static const char Base64Table[];
|
||||
static const unsigned char DecodeTable[];
|
||||
|
||||
static size_t GetNextQuantum(DecodeFlags parse_flags,
|
||||
bool illegal_pads,
|
||||
const char* data,
|
||||
size_t len,
|
||||
size_t* dpos,
|
||||
unsigned char qbuf[4],
|
||||
bool* padded);
|
||||
template <typename T>
|
||||
static bool DecodeFromArrayTemplate(const char* data,
|
||||
size_t len,
|
||||
DecodeFlags flags,
|
||||
T* result,
|
||||
size_t* data_used);
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_BASE64_H_
|
|
@ -47,6 +47,7 @@ LIB_TO_LICENSES_DICT = {
|
|||
'usrsctp': ['third_party/usrsctp/LICENSE'],
|
||||
'webrtc': ['LICENSE', 'LICENSE_THIRD_PARTY'],
|
||||
'zlib': ['third_party/zlib/LICENSE'],
|
||||
'base64': ['rtc_base/third_party/base64/LICENSE'],
|
||||
|
||||
# Compile time dependencies, no license needed:
|
||||
'yasm': [],
|
||||
|
|
Loading…
Reference in a new issue