1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // A minimal "hello world" style example of how to use Sandboxed API. This
16 // example does not include any error handling and will simply abort if
17 // something goes wrong.
18 // As the library function that is being called into is pure computation (i.e.
19 // does not issue any syscalls), the restricted default sandbox policy is being
20 // used.
21
22 #include <cstdlib>
23 #include <iostream>
24
25 // Generated header
26 #include "hello_sapi.sapi.h" // NOLINT(build/include)
27
main()28 int main() {
29 std::cout << "Calling into a sandboxee to add two numbers...\n";
30
31 HelloSandbox sandbox;
32 sandbox.Init().IgnoreError();
33
34 HelloApi api(&sandbox);
35 std::cout << " 1000 + 337 = " << api.AddTwoIntegers(1000, 337).value()
36 << "\n";
37
38 return EXIT_SUCCESS;
39 }
40