Improve comments

This commit is contained in:
Federico Stazi 2020-08-07 09:46:55 +00:00
parent 05c0a4b004
commit 5be51fabbe
5 changed files with 12 additions and 29 deletions

View File

@ -19,24 +19,20 @@ project(curl_sandboxed)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
# add folder containing the non-sandboxed custom curl library # Add folder containing the non-sandboxed custom curl library
add_subdirectory(custom_curl) add_subdirectory(custom_curl)
# setup sandboxed api # Setup Sandboxed API
set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree") set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
set(SAPI_ENABLE_EXAMPLES OFF CACHE BOOL "") set(SAPI_ENABLE_EXAMPLES OFF CACHE BOOL "")
set(SAPI_ENABLE_TESTS OFF CACHE BOOL "") set(SAPI_ENABLE_TESTS OFF CACHE BOOL "")
add_subdirectory( add_subdirectory(
"${SAPI_ROOT}" "${SAPI_ROOT}"
"${CMAKE_BINARY_DIR}/sandboxed-api-build" "${CMAKE_BINARY_DIR}/sandboxed-api-build"
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
) )
# generate and include generated sapi header # Generate SAPI header
add_sapi_library(curl_sapi add_sapi_library(curl_sapi
FUNCTIONS curl_easy_cleanup FUNCTIONS curl_easy_cleanup
@ -71,10 +67,10 @@ add_sapi_library(curl_sapi
NAMESPACE "" NAMESPACE ""
) )
# Include generated SAPI header
target_include_directories(curl_sapi INTERFACE target_include_directories(curl_sapi INTERFACE
"${PROJECT_BINARY_DIR}" "${PROJECT_BINARY_DIR}"
) )
# add examples # Add examples
add_subdirectory(examples) add_subdirectory(examples)

View File

@ -12,22 +12,21 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# flags needed to build curl statically # Flags needed to build curl statically
set(CURL_HIDDEN_SYMBOLS OFF) set(CURL_HIDDEN_SYMBOLS OFF)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
add_subdirectory(curl) add_subdirectory(curl)
# Wrapper library including curl,
# adds the explicit versions of the variadic methods
add_library(custom_curl STATIC add_library(custom_curl STATIC
custom_curl.h custom_curl.h
custom_curl.cc custom_curl.cc
) )
set_target_properties(custom_curl set_target_properties(custom_curl
PROPERTIES LINKER_LANGUAGE C PROPERTIES LINKER_LANGUAGE C
) )
target_link_libraries(custom_curl target_link_libraries(custom_curl
CURL::libcurl CURL::libcurl
) )

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// wrapper for curl library used to implement variadic functions explicitly // Wrapper for curl library used to implement variadic methods explicitly
#ifndef CUSTOM_CURL_H #ifndef CUSTOM_CURL_H
#define CUSTOM_CURL_H #define CUSTOM_CURL_H

View File

@ -12,12 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# example 1: GET request, verbose # Example 1: GET request, verbose
add_executable(example1 add_executable(example1
example1.cc example1.cc
) )
target_link_libraries(example1 PRIVATE target_link_libraries(example1 PRIVATE
curl_sapi curl_sapi
sapi::sapi sapi::sapi

View File

@ -12,22 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include <libgen.h>
#include <syscall.h>
#include <iostream> #include <iostream>
#include "curl_sapi.sapi.h" #include "curl_sapi.sapi.h"
/*
int main() {
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1l);
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
*/
class CurlApiSandboxEx1 : public CurlSandbox { class CurlApiSandboxEx1 : public CurlSandbox {
std::unique_ptr<sandbox2::Policy> ModifyPolicy( std::unique_ptr<sandbox2::Policy> ModifyPolicy(
@ -44,6 +32,8 @@ class CurlApiSandboxEx1 : public CurlSandbox {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// GET http://example.com
CurlApiSandboxEx1 sandbox; CurlApiSandboxEx1 sandbox;
auto status_sandbox_init = sandbox.Init(); auto status_sandbox_init = sandbox.Init();