mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
applied requested changes. Modified sapi::StatusOr to absl::StatusOr
This commit is contained in:
parent
99d8df5400
commit
811dbf8d74
1
oss-internship-2020/sapi_lodepng/.gitignore
vendored
1
oss-internship-2020/sapi_lodepng/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
build/
|
||||
.clang-format
|
||||
.cache
|
||||
|
|
|
@ -37,7 +37,8 @@ add_library(lodepng STATIC
|
|||
target_include_directories(lodepng PUBLIC "${PROJECT_BINARY_DIR}/lodepng")
|
||||
|
||||
# Build SAPI library
|
||||
set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
|
||||
#set(SAPI_ROOT "${PROJECT_SOURCE_DIR}/../.." CACHE PATH "Path to the Sandboxed API source tree")
|
||||
set(SAPI_ROOT "/usr/local/google/home/amedar/internship/sandboxed-api" CACHE PATH "Path to the Sandboxed API source tree")
|
||||
|
||||
add_subdirectory("${SAPI_ROOT}"
|
||||
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
|
||||
|
|
|
@ -4,7 +4,7 @@ Sandboxed version of the [LodePNG](https://github.com/lvandeve/lodepng) library,
|
|||
|
||||
## Details
|
||||
|
||||
With Sandboxed API, many of the library's functions can be sandboxed. However, they need the `extern "C"` keyword defined so that name mangling does not happen, which is why a fork of the **LodePNG** library is used. The only differences are found in the header file. An alternative to this is to define another library that wraps every needed function, specifying the required keyword.
|
||||
With Sandboxed API, many of the library's functions can be sandboxed. However, they need the `extern "C"` keyword defined so that name mangling does not happen, which is why a patch that adds it is used. The only differences are found in the header file. An alternative to this is to define another library that wraps every needed function, specifying the required keyword.
|
||||
|
||||
Even if many of the functions from the library can be sandboxed, there are some that are not supported (those which have `std::vector` parameters, overloaded functions etc.). If you really need these functions, a solution is to implement a custom library that wraps around these functions in order to make them compatible.
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ target_link_libraries(lodepng_unsandboxed PRIVATE
|
|||
lodepng
|
||||
sapi::sapi
|
||||
sandbox2::temp_file
|
||||
sandbox2::file_base
|
||||
sandbox2::fileops
|
||||
glog::glog
|
||||
)
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "helpers.h"
|
||||
|
||||
#include "sandboxed_api/sandbox2/util/temp_file.h"
|
||||
|
||||
std::vector<uint8_t> GenerateValues() {
|
||||
std::vector<uint8_t> image;
|
||||
image.reserve(kImgLen);
|
||||
|
@ -35,7 +37,7 @@ std::string CreateTempDirAtCWD() {
|
|||
CHECK(!cwd.empty()) << "Could not get current working directory";
|
||||
cwd.append("/");
|
||||
|
||||
sapi::StatusOr<std::string> result = sandbox2::CreateTempDir(cwd);
|
||||
absl::StatusOr<std::string> result = sandbox2::CreateTempDir(cwd);
|
||||
CHECK(result.ok()) << "Could not create temporary directory";
|
||||
return result.value();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void EncodeDecodeOneStep(SapiLodepngSandbox& sandbox, LodepngApi& api) {
|
|||
|
||||
sapi::v::ConstCStr sapi_filename("/output/out_generated1.png");
|
||||
|
||||
sapi::StatusOr<unsigned int> result = api.lodepng_encode32_file(
|
||||
absl::StatusOr<unsigned int> result = api.lodepng_encode32_file(
|
||||
sapi_filename.PtrBefore(), sapi_image.PtrBefore(), kWidth, kHeight);
|
||||
|
||||
CHECK(result.ok()) << "encode32_file call failed";
|
||||
|
@ -90,7 +90,7 @@ void EncodeDecodeTwoSteps(SapiLodepngSandbox& sandbox, LodepngApi& api) {
|
|||
sapi::v::IntBase<uint8_t*> sapi_png_ptr(0);
|
||||
|
||||
// Encode it into memory.
|
||||
sapi::StatusOr<unsigned int> result =
|
||||
absl::StatusOr<unsigned int> result =
|
||||
api.lodepng_encode32(sapi_png_ptr.PtrBoth(), sapi_pngsize.PtrBoth(),
|
||||
sapi_image.PtrBefore(), kWidth, kHeight);
|
||||
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
#include "helpers.h"
|
||||
#include "lodepng.h"
|
||||
#include "sandboxed_api/sandbox2/util/fileops.h"
|
||||
#include "sandboxed_api/sandbox2/util/path.h"
|
||||
|
||||
void EncodeDecodeOneStep(const std::string& images_path) {
|
||||
// Generate the values.
|
||||
std::vector<uint8_t> image = GenerateValues();
|
||||
|
||||
// Encode the image.
|
||||
const std::string filename = images_path + "/out_generated1.png";
|
||||
const std::string filename =
|
||||
sandbox2::file::JoinPath(images_path, "/out_generated1.png");
|
||||
unsigned int result =
|
||||
lodepng_encode32_file(filename.c_str(), image.data(), kWidth, kHeight);
|
||||
|
||||
|
@ -55,7 +57,8 @@ void EncodeDecodeTwoSteps(const std::string& images_path) {
|
|||
std::vector<uint8_t> image = GenerateValues();
|
||||
|
||||
// Encode the image into memory first.
|
||||
const std::string filename = images_path + "/out_generated2.png";
|
||||
const std::string filename =
|
||||
sandbox2::file::JoinPath(images_path, "/out_generated2.png");
|
||||
uint8_t* png;
|
||||
size_t pngsize;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user