├── tests ├── fibonacci │ ├── stdin │ └── golden │ │ ├── stdin │ │ └── default ├── run.sh └── benchmark │ └── plot.py ├── demos ├── fibonacci │ ├── go │ │ ├── go.mod │ │ ├── main.go │ │ └── LICENSE │ ├── rust │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── main.rs │ │ └── LICENSE │ ├── java │ │ ├── README.md │ │ ├── fibonacci.java │ │ └── LICENSE │ ├── Enarx.toml │ ├── assemblyscript │ │ └── fibo.ts │ ├── typescript │ │ └── index.ts │ ├── javascript │ │ └── index.js │ ├── ruby │ │ ├── fibonacci.rb │ │ └── LICENSE │ ├── c# │ │ ├── Program.cs │ │ └── LICENSE │ ├── swift │ │ └── fibonacci.swift │ ├── c++ │ │ ├── fibonacci.cpp │ │ └── LICENSE │ ├── c │ │ ├── fibonacci.c │ │ └── LICENSE │ ├── grain │ │ └── fibonacci.gr │ └── zig │ │ ├── build.zig │ │ ├── src │ │ └── main.zig │ │ └── LICENSE ├── chat-client │ ├── web-ui │ │ ├── README.md │ │ ├── LICENSE │ │ ├── index.html │ │ ├── script.js │ │ └── style.css │ ├── rust │ │ ├── .cargo │ │ │ └── config │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ ├── c++ │ │ ├── README.md │ │ ├── process_assets.py │ │ ├── assets │ │ │ ├── index.html │ │ │ ├── script.js │ │ │ └── style.css │ │ └── main.cpp │ ├── Enarx.toml │ └── c │ │ └── main.c ├── chat-server │ ├── rust │ │ ├── .cargo │ │ │ └── config │ │ ├── Cargo.toml │ │ └── src │ │ │ └── main.rs │ └── Enarx.toml └── README.md ├── examples ├── rust │ ├── std │ │ └── tcp-client │ │ │ ├── Cargo.toml │ │ │ ├── Cargo.lock │ │ │ ├── Enarx.toml │ │ │ ├── README.md │ │ │ └── src │ │ │ └── main.rs │ ├── tokio │ │ ├── http │ │ │ ├── src │ │ │ │ ├── fireworks.gif │ │ │ │ ├── index.html │ │ │ │ ├── date.rs │ │ │ │ ├── main.rs │ │ │ │ ├── protocol.rs │ │ │ │ └── enarx-white.svg │ │ │ ├── .cargo │ │ │ │ └── config │ │ │ ├── Enarx.toml │ │ │ ├── Cargo.toml │ │ │ ├── README.md │ │ │ └── LICENSE │ │ └── echo-tcp │ │ │ ├── .cargo │ │ │ └── config │ │ │ ├── Enarx.toml │ │ │ ├── Cargo.toml │ │ │ ├── src │ │ │ └── main.rs │ │ │ ├── README.md │ │ │ └── Cargo.lock │ ├── README.md │ └── mio │ │ └── echo-tcp │ │ ├── Enarx.toml │ │ ├── Cargo.toml │ │ ├── Cargo.lock │ │ ├── README.md │ │ └── src │ │ └── main.rs ├── c │ └── README.md ├── c# │ └── README.md ├── c++ │ └── README.md ├── go │ └── README.md ├── ruby │ └── README.md ├── zig │ └── README.md ├── grain │ └── README.md ├── swift │ └── README.md ├── javascript │ └── README.md ├── typescript │ └── README.md ├── assemblyscript │ └── README.md └── README.md ├── .gitignore ├── .github ├── CODEOWNERS └── workflows │ ├── automerge.yml │ ├── commisery.yml │ ├── nix-update.yml │ └── build.yml ├── .gitmodules └── README.md /tests/fibonacci/stdin: -------------------------------------------------------------------------------- 1 | 25 2 | -------------------------------------------------------------------------------- /demos/fibonacci/go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/enarx/codex/demos/fibonacci/go 2 | 3 | go 1.17 4 | -------------------------------------------------------------------------------- /demos/chat-client/web-ui/README.md: -------------------------------------------------------------------------------- 1 | # Chat Web UI 2 | 3 | Web user interface for a chat client. 4 | -------------------------------------------------------------------------------- /tests/fibonacci/golden/stdin: -------------------------------------------------------------------------------- 1 | Enter a non-negative number: 2 | Fibonacci sequence number at index 25 is 75025 3 | -------------------------------------------------------------------------------- /examples/rust/std/tcp-client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "std-tcp-client" 3 | version = "0.1.0" 4 | edition = "2021" 5 | -------------------------------------------------------------------------------- /tests/fibonacci/golden/default: -------------------------------------------------------------------------------- 1 | Fibonacci sequence number at index 7 is 13 2 | Fibonacci sequence number at index 21 is 10946 3 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/fireworks.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/enarx/codex/HEAD/examples/rust/tokio/http/src/fireworks.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/rust/**/target/ 2 | **/zig/**/zig-cache/ 3 | **/zig/**/zig-out/ 4 | *.wasm 5 | .idea/ 6 | .vscode/ 7 | a.out 8 | result 9 | -------------------------------------------------------------------------------- /demos/chat-server/rust/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-wasi" 3 | 4 | [target.wasm32-wasi] 5 | runner = ["enarx", "run", "--wasmcfgfile", "Enarx.toml"] 6 | rustflags = [ "--cfg", "tokio_unstable"] 7 | -------------------------------------------------------------------------------- /demos/fibonacci/rust/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "fibonacci" 7 | version = "0.3.0" 8 | -------------------------------------------------------------------------------- /examples/c/README.md: -------------------------------------------------------------------------------- 1 | # C Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with C](https://enarx.dev/docs/WebAssembly/C). 4 | -------------------------------------------------------------------------------- /demos/chat-client/rust/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-wasi" 3 | 4 | [target.wasm32-wasi] 5 | runner = ["enarx", "run", "--wasmcfgfile", "../Enarx.toml"] 6 | rustflags = [ "--cfg", "tokio_unstable"] 7 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-wasi" 3 | 4 | [target.wasm32-wasi] 5 | runner = ["wasmtime", "run", "--tcplisten", "127.0.0.1:8080"] 6 | rustflags = [ "--cfg", "tokio_unstable"] 7 | -------------------------------------------------------------------------------- /examples/c#/README.md: -------------------------------------------------------------------------------- 1 | # C# Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with C#](https://enarx.dev/docs/WebAssembly/dotnet). 4 | -------------------------------------------------------------------------------- /examples/c++/README.md: -------------------------------------------------------------------------------- 1 | # C++ Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with C++](https://enarx.dev/docs/WebAssembly/C++). 4 | -------------------------------------------------------------------------------- /examples/go/README.md: -------------------------------------------------------------------------------- 1 | # Go Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Go](https://enarx.dev/docs/WebAssembly/Golang). 4 | -------------------------------------------------------------------------------- /examples/ruby/README.md: -------------------------------------------------------------------------------- 1 | # Ruby Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Ruby](https://enarx.dev/docs/WebAssembly/Ruby). 4 | -------------------------------------------------------------------------------- /examples/rust/README.md: -------------------------------------------------------------------------------- 1 | # Rust Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Rust](https://enarx.dev/docs/WebAssembly/Rust). 4 | -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-wasi" 3 | 4 | [target.wasm32-wasi] 5 | runner = ["wasmtime", "run", "--tcplisten", "127.0.0.1:12345"] 6 | rustflags = [ "--cfg", "tokio_unstable"] 7 | -------------------------------------------------------------------------------- /examples/zig/README.md: -------------------------------------------------------------------------------- 1 | # Zig Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Zig](https://enarx.dev/docs/WebAssembly/Zig). 4 | -------------------------------------------------------------------------------- /demos/chat-client/c++/README.md: -------------------------------------------------------------------------------- 1 | Compile to WASM first, then run with --wasmcfgfile directed to Enarx.toml 2 | Use the --webinterface argument in the Enarx.toml to switch to a web interface (enabled by default), at localhost:50010 -------------------------------------------------------------------------------- /examples/grain/README.md: -------------------------------------------------------------------------------- 1 | # Grain Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Grain](https://enarx.dev/docs/WebAssembly/Grain). 4 | -------------------------------------------------------------------------------- /examples/rust/std/tcp-client/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "std-tcp-client" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /examples/swift/README.md: -------------------------------------------------------------------------------- 1 | # Swift Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Swift](https://enarx.dev/docs/WebAssembly/Swift). 4 | -------------------------------------------------------------------------------- /demos/fibonacci/java/README.md: -------------------------------------------------------------------------------- 1 | # Java Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with Java](https://enarx.dev/docs/WebAssembly/Java). 4 | -------------------------------------------------------------------------------- /demos/fibonacci/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fibonacci" 3 | version = "0.3.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Each line is a file pattern followed by one or more owners. 2 | # Owners will be automatically notified about new PRs and 3 | # an owner's approval is required to merge to protected branches. 4 | * @enarx/codeowners 5 | -------------------------------------------------------------------------------- /demos/chat-server/Enarx.toml: -------------------------------------------------------------------------------- 1 | [[files]] 2 | kind = "stdin" 3 | 4 | [[files]] 5 | kind = "stdout" 6 | 7 | [[files]] 8 | kind = "stderr" 9 | 10 | [[files]] 11 | name = "ingest" 12 | kind = "listen" 13 | port = 50000 14 | prot = "tcp" 15 | -------------------------------------------------------------------------------- /examples/javascript/README.md: -------------------------------------------------------------------------------- 1 | # JavaScript Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with JavaScript](https://enarx.dev/docs/WebAssembly/JavaScript). 4 | -------------------------------------------------------------------------------- /examples/typescript/README.md: -------------------------------------------------------------------------------- 1 | # TypeScript Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with TypeScript](https://enarx.dev/docs/WebAssembly/TypeScript). 4 | -------------------------------------------------------------------------------- /demos/fibonacci/Enarx.toml: -------------------------------------------------------------------------------- 1 | # Arguments 2 | args = [ 3 | "7", 4 | "21" 5 | ] 6 | 7 | # Pre-opened file descriptors 8 | [[files]] 9 | kind = "stdin" 10 | 11 | [[files]] 12 | kind = "stdout" 13 | 14 | [[files]] 15 | kind = "stderr" 16 | -------------------------------------------------------------------------------- /demos/fibonacci/assemblyscript/fibo.ts: -------------------------------------------------------------------------------- 1 | import "wasi"; 2 | 3 | export function fibo(n: i32): i32 { 4 | if (n == 0 || n == 1) return n; 5 | return fibo(n - 1) + fibo(n - 2); 6 | } 7 | 8 | let res = fibo(7); 9 | console.log(res.toString()); 10 | -------------------------------------------------------------------------------- /examples/assemblyscript/README.md: -------------------------------------------------------------------------------- 1 | # AssemblyScript Examples 2 | 3 | For setting up your environment and installing the necessary tools, see [the Enarx documentation on using WebAssembly with AssemblyScript](https://enarx.dev/docs/WebAssembly/AssemblyScript). 4 | -------------------------------------------------------------------------------- /examples/rust/mio/echo-tcp/Enarx.toml: -------------------------------------------------------------------------------- 1 | [[files]] 2 | kind = "stdin" 3 | 4 | [[files]] 5 | kind = "stdout" 6 | 7 | [[files]] 8 | kind = "stderr" 9 | 10 | [[files]] 11 | kind = "listen" 12 | prot = "tcp" 13 | port = 10000 14 | name = "TEST_TCP_LISTEN" 15 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | name: Auto merge 2 | on: 3 | pull_request_target 4 | 5 | jobs: 6 | auto-merge: 7 | permissions: 8 | pull-requests: write 9 | contents: write 10 | uses: enarx/.github/.github/workflows/automerge.yml@main 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "demos/cryptle/rust"] 2 | path = demos/cryptle/rust 3 | url = https://github.com/enarx/cryptle.git 4 | [submodule "demos/green-house-monitor/c#"] 5 | path = "demos/green-house-monitor/c#" 6 | url = https://github.com/enarx/GreenhouseMonitor.git 7 | -------------------------------------------------------------------------------- /examples/rust/std/tcp-client/Enarx.toml: -------------------------------------------------------------------------------- 1 | [[files]] 2 | kind = "stdin" 3 | 4 | [[files]] 5 | kind = "stdout" 6 | 7 | [[files]] 8 | kind = "stderr" 9 | 10 | [[files]] 11 | name = "CONNECT" 12 | kind = "connect" 13 | prot = "tcp" 14 | host = "127.0.0.1" 15 | port = 10010 16 | -------------------------------------------------------------------------------- /tests/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$#" -lt 2 ]; then 4 | echo "Usage: $0 GOLDEN [enarx run arguments]" 5 | exit 1 6 | fi 7 | 8 | golden="${1}" 9 | shift 1 10 | 11 | set -ex 12 | enarx run "${@}" | { read line; while read line; do echo $line; done } | diff "${golden}" - 13 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/Enarx.toml: -------------------------------------------------------------------------------- 1 | steward = "https://attest.profian.com" 2 | 3 | [[files]] 4 | kind = "stdin" 5 | 6 | [[files]] 7 | kind = "stdout" 8 | 9 | [[files]] 10 | kind = "stderr" 11 | 12 | [[files]] 13 | kind = "listen" 14 | port = 10020 15 | name = "TCP_LISTEN" 16 | prot = "tcp" 17 | -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/Enarx.toml: -------------------------------------------------------------------------------- 1 | #steward = "https://attest.profian.com" 2 | 3 | [[files]] 4 | kind = "stdin" 5 | 6 | [[files]] 7 | kind = "stdout" 8 | 9 | [[files]] 10 | kind = "stderr" 11 | 12 | [[files]] 13 | name = "LISTEN" 14 | kind = "listen" 15 | port = 10010 16 | prot = "tcp" 17 | #prot = "tls" 18 | -------------------------------------------------------------------------------- /.github/workflows/commisery.yml: -------------------------------------------------------------------------------- 1 | name: Commisery 2 | on: 3 | pull_request: 4 | types: [edited, opened, synchronize, reopened] 5 | 6 | permissions: 7 | contents: read 8 | pull-requests: write 9 | issues: write 10 | 11 | jobs: 12 | commit-message: 13 | uses: enarx/.github/.github/workflows/commisery.yml@main 14 | -------------------------------------------------------------------------------- /demos/fibonacci/typescript/index.ts: -------------------------------------------------------------------------------- 1 | function fibonacci(num: number) { 2 | var a: number = 1; 3 | var b: number = 0; 4 | var temp: number; 5 | while (num >= 0) { 6 | temp = a; 7 | a = a + b; 8 | b = temp; 9 | num--; 10 | } 11 | console.log("Fibonacci Term is:", b); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /.github/workflows/nix-update.yml: -------------------------------------------------------------------------------- 1 | name: Update Nix flake 2 | 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | workflow_dispatch: 7 | 8 | jobs: 9 | nix-update: 10 | permissions: 11 | contents: write 12 | pull-requests: write 13 | secrets: inherit 14 | uses: enarx/.github/.github/workflows/nix-update.yml@main 15 | -------------------------------------------------------------------------------- /examples/rust/mio/echo-tcp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mio-echo-tcp" 3 | version = "0.2.0" 4 | edition = "2021" 5 | license = "MIT" 6 | 7 | [target.'cfg(any(unix, target_os="wasi"))'.dependencies] 8 | env_logger = { version = "0.9.0", default-features = false } 9 | mio = { version = "0.8.3", features = ["os-poll", "net"], default-features = false } 10 | -------------------------------------------------------------------------------- /demos/chat-client/Enarx.toml: -------------------------------------------------------------------------------- 1 | [[files]] 2 | kind = "stdin" 3 | 4 | [[files]] 5 | kind = "stdout" 6 | 7 | [[files]] 8 | kind = "stderr" 9 | 10 | [[files]] 11 | name = "server" 12 | kind = "connect" 13 | port = 50000 14 | prot = "tcp" 15 | host = "127.0.0.1" 16 | 17 | [[files]] 18 | name = "web" 19 | kind = "listen" 20 | port = 50010 21 | prot = "tcp" 22 | host = "127.0.0.1" -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tokio-echo-tcp" 3 | version = "0.2.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | tokio = { version = "1.24.2", default-features = false, features = ["net", "rt", "macros", "io-util", "io-std"] } 11 | -------------------------------------------------------------------------------- /demos/fibonacci/java/fibonacci.java: -------------------------------------------------------------------------------- 1 | package wasi; 2 | 3 | public class Fibonacci { 4 | public static void main(String[] args) { 5 | int n = Integer.parseInt(args[0]); 6 | System.out.println(fib(n)); 7 | } 8 | 9 | private static int fib(int n) 10 | { 11 | if (n <= 1) 12 | return n; 13 | return fib(n - 1) + fib(n - 2); 14 | } 15 | } -------------------------------------------------------------------------------- /demos/fibonacci/javascript/index.js: -------------------------------------------------------------------------------- 1 | //Simple Program to calculate Fibonacci Sequence of an Integer Input 2 | function fibonacci(){ 3 | var num = 10; 4 | var a = 1, b = 0, temp; 5 | 6 | while (num >= 0){ 7 | temp = a; 8 | a = a + b; 9 | b = temp; 10 | num--; 11 | } 12 | console.log("Fibonacci result is: ",b); 13 | 14 | } 15 | 16 | var Shopify = { 17 | main: fibonacci 18 | }; 19 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Enarx Examples 2 | 3 | This directory contains small, focused code examples that demonstrate how to perform 4 | specific tasks in the context of Enarx. 5 | 6 | The examples within this directory are categorized by programming language. 7 | Within each language's directory, you will also find instructions on how to install 8 | and run the tools necessary to compile that language to a WebAssembly module. 9 | -------------------------------------------------------------------------------- /demos/chat-client/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chat-client" 3 | version = "0.1.0" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | anyhow = "1.0.57" 9 | futures = { version = "0.3.25", features = ["io-compat"] } 10 | tokio = { version = "1.24.2", default-features = false, features = ["net", "rt", "macros"] } 11 | tokio-stream = { version = "0.1.11", default-features = false, features = ["net", "io-util", "sync"] } 12 | -------------------------------------------------------------------------------- /demos/chat-server/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chat-server" 3 | version = "0.1.1" 4 | edition = "2021" 5 | publish = false 6 | 7 | [dependencies] 8 | anyhow = "1.0.57" 9 | futures = { version = "0.3.25", features = ["io-compat"] } 10 | tokio = { version = "1.24.2", default-features = false, features = ["net", "rt", "macros"] } 11 | tokio-stream = { version = "0.1.11", default-features = false, features = ["net", "io-util", "sync"] } 12 | ulid = "1.0.0" 13 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tokio-http" 3 | version = "0.2.0" 4 | publish = false 5 | edition = "2021" 6 | 7 | [dependencies] 8 | tokio = { version = "1.24.2", features = ["net", "rt", "macros"] } 9 | tokio-util = { version = "0.7.4", features = ["codec"] } 10 | tokio-stream = "0.1.11" 11 | 12 | bytes = "1.0.0" 13 | futures = { version = "0.3.0", features = ["thread-pool"]} 14 | 15 | http = "0.2" 16 | httparse = "1.0" 17 | httpdate = "1.0" 18 | -------------------------------------------------------------------------------- /demos/fibonacci/ruby/fibonacci.rb: -------------------------------------------------------------------------------- 1 | def FibonacciSequence( n ) 2 | return n if ( 0..1 ).include? n 3 | ( FibonacciSequence( n - 1 ) + FibonacciSequence( n - 2 ) ) 4 | end 5 | 6 | puts "Ruby - Fibonacci sequence example" 7 | 8 | if ARGV.length > 0 9 | ARGV.each { |arg| 10 | n = arg.to_i 11 | puts "Fibonacci sequence number at index #{n} is #{FibonacciSequence(n)}" 12 | } 13 | else 14 | puts "Enter a non-negative number:" 15 | n = ARGF.gets.to_i 16 | puts "Fibonacci sequence number at index #{n} is #{FibonacciSequence(n)}" 17 | end 18 | -------------------------------------------------------------------------------- /demos/fibonacci/c#/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyFirstWasiApp 4 | { 5 | public class Program 6 | { 7 | 8 | public void fibonacci(ref int num){ 9 | int a=1,b=0,temp; 10 | while(num >= 0){ 11 | temp=a; 12 | a=a+b; 13 | b=temp; 14 | num--; 15 | } 16 | Console.WriteLine("Fibonacci Term is: "+b); 17 | } 18 | 19 | public static void Main(string[] args) 20 | { 21 | Program p = new Program(); 22 | int num=10; 23 | p.fibonacci(ref num); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /demos/chat-client/c++/process_assets.py: -------------------------------------------------------------------------------- 1 | # Python script from https://github.com/rjzak/web_wordpuzzle 2 | 3 | ASSETS = ( ("index_page", open("assets/index.html", "rb").read()), ("script", open("assets/script.js", "rb").read()), ("style", open("assets/style.css", "rb").read()) ) 4 | 5 | output_file = open("assets.h", "w") 6 | 7 | output_file.write("//This is an auto-generated file generated from the process_asets.py script\n\n") 8 | 9 | for asset in ASSETS: 10 | name = asset[0] 11 | data = asset[1] 12 | output_file.write("unsigned char %s[%d]= {" % (name, len(data))); 13 | output_file.write(",".join(["0x%02X"%x for x in data])) 14 | output_file.write("};\n") 15 | 16 | 17 | output_file.close() -------------------------------------------------------------------------------- /tests/benchmark/plot.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import subprocess 3 | import sys 4 | 5 | ret = [] 6 | for prog in sys.argv[1:]: 7 | ret.append([[], []]) 8 | for _ in range(10): # run 10 times 9 | s = subprocess.run(['time', '--format', "%e %M", 'enarx', 'deploy', prog], capture_output=True) 10 | if s.returncode != 0: 11 | print(s.stderr.decode('utf-8')) 12 | exit(1) 13 | s = s.stderr.decode('utf-8').split() 14 | ret[-1][0].append(float(s[0])) # time 15 | ret[-1][1].append(float(s[1])/1000) # memory 16 | 17 | fig, ax = plt.subplots() 18 | for lang, data in zip(sys.argv[1:], ret): 19 | ax.scatter(*data, label=lang) 20 | 21 | ax.legend() 22 | ax.set_xlabel('Time (s)') 23 | ax.set_ylabel('Memory (MB)') 24 | plt.show() 25 | -------------------------------------------------------------------------------- /demos/fibonacci/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env::args; 2 | use std::io::stdin; 3 | 4 | fn fib(n: u32) -> u32 { 5 | match n { 6 | 0 => 0, 7 | 1 => 1, 8 | n => fib(n - 1) + fib(n - 2), 9 | } 10 | } 11 | 12 | fn main() { 13 | println!("Rust - Fibonacci sequence example"); 14 | 15 | let mut args: Vec<_> = args().skip(1).collect(); 16 | 17 | if args.is_empty() { 18 | println!("Enter a non-negative number:"); 19 | let mut idx = String::new(); 20 | stdin().read_line(&mut idx).expect("Failed to read line"); 21 | args.push(idx); 22 | } 23 | 24 | for arg in args { 25 | let idx = arg.trim().parse().expect("Failed to parse number"); 26 | println!("Fibonacci sequence number at index {} is {}", idx, fib(idx)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /demos/fibonacci/swift/fibonacci.swift: -------------------------------------------------------------------------------- 1 | func fib(n: UInt) -> UInt { 2 | if n <= 1 { 3 | return n 4 | } 5 | 6 | return fib(n: n-1) + fib(n: n-2) 7 | } 8 | 9 | print("Swift - Fibonacci sequence example\n") 10 | 11 | let arguments = CommandLine.arguments 12 | 13 | var n:UInt 14 | if (arguments.count > 1) { 15 | for i in 1...arguments.count-1 { 16 | if let n = UInt(arguments[i]) { 17 | print("Fibonacci sequence number at index \(n) is \(fib(n: n))\n") 18 | } else { 19 | print("Failed to parse argument into a number: \(arguments[i])\n") 20 | } 21 | } 22 | } else { 23 | print("Enter a non-negative number:\n") 24 | if let line = readLine() { 25 | if let n = UInt(line) { 26 | print("Fibonacci sequence number at index \(n) is \(fib(n: n))\n") 27 | } else { 28 | print("Could not convert \(line) to integer.\n") 29 | } 30 | } else { 31 | print("Could not read user input.\n") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | hello_enarx 7 | 27 | 28 | 29 |
30 |

31 |

Hello Enarx!

32 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /demos/fibonacci/go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "flag" 6 | "fmt" 7 | "log" 8 | "os" 9 | "strconv" 10 | ) 11 | 12 | func init() { 13 | log.SetFlags(0) 14 | } 15 | 16 | func fib(n uint64) uint64 { 17 | if n <= 1 { 18 | return n 19 | } 20 | return fib(n-1) + fib(n-2) 21 | } 22 | 23 | func main() { 24 | fmt.Println("Go - Fibonacci sequence example") 25 | 26 | flag.Parse() 27 | 28 | args := flag.Args() 29 | if len(args) == 0 { 30 | fmt.Println("Enter a non-negative number:") 31 | sc := bufio.NewScanner(os.Stdin) 32 | sc.Scan() 33 | b, err := sc.Bytes(), sc.Err() 34 | if err != nil { 35 | log.Fatalf("Failed to read stdin: %s", err) 36 | } 37 | args = []string{string(b)} 38 | } 39 | 40 | for _, arg := range args { 41 | n, err := strconv.ParseUint(arg, 10, 64) 42 | if err != nil { 43 | log.Fatalf("Failed to parse number: %s", err) 44 | } 45 | fmt.Printf("Fibonacci sequence number at index %d is %d\n", n, fib(n)) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /demos/fibonacci/c++/fibonacci.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | unsigned long fib(unsigned long i) { 8 | if (i <= 1) { 9 | return i; 10 | } 11 | return fib(i - 1) + fib(i - 2); 12 | } 13 | 14 | int main(int argc, char *argv[]) { 15 | cout << "C++ - Fibonacci sequence example" << endl; 16 | if (argc <= 1) { 17 | unsigned long n; 18 | cout << "Enter a non-negative number:" << endl; 19 | cin >> n; 20 | cout << "Fibonacci sequence number at index " << n << " is " << fib(n) 21 | << endl; 22 | } else { 23 | for (unsigned int i = 1; i < argc; i++) { 24 | errno = 0; 25 | unsigned long n = strtoul(argv[i], NULL, 10); 26 | if (errno != 0) { 27 | cerr << "Failed to parse argument into a number: " << strerror(errno) 28 | << endl; 29 | exit(1); 30 | } 31 | cout << "Fibonacci sequence number at index " << n << " is " << fib(n) 32 | << endl; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/README.md: -------------------------------------------------------------------------------- 1 | # wasi_tokio_http 2 | 3 | This is a modified version of the 4 | [`tinyhttp.rs`](https://github.com/tokio-rs/tokio/blob/5288e1e144d33ace0070325b16029523b1db0ffe/examples/tinyhttp.rs) 5 | example in the tokio repository. 6 | 7 | ## Prerequisites 8 | 9 | Be sure to use a stable Rust toolchain that is no older than Rust 1.60.0. You can use `cargo --version` to view the version of your default Rust toolchain. 10 | 11 | ## Running 12 | 13 | ### wasmtime 14 | 15 | ```console 16 | ❯ CARGO_TARGET_WASM32_WASI_RUNNER="wasmtime run --tcplisten 127.0.0.1:10020" cargo run --target wasm32-wasi 17 | ``` 18 | 19 | Server is running on [`http://127.0.0.1:10020`](http://127.0.0.1:10020). 20 | 21 | ### enarx 22 | 23 | after installing [enarx](https://github.com/enarx/enarx/) in `$PATH` with `cargo install` 24 | 25 | ```console 26 | ❯ CARGO_TARGET_WASM32_WASI_RUNNER="enarx run --wasmcfgfile Enarx.toml" cargo run --target wasm32-wasi 27 | ``` 28 | 29 | Server is running on [`https://127.0.0.1:10020`](https://127.0.0.1:10020). 30 | -------------------------------------------------------------------------------- /demos/fibonacci/c/fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | unsigned long fib(unsigned long i) { 7 | if (i <= 1) { 8 | return i; 9 | } 10 | return fib(i - 1) + fib(i - 2); 11 | } 12 | 13 | int main(int argc, char *argv[]) { 14 | printf("C - Fibonacci sequence example\n"); 15 | if (argc <= 1) { 16 | unsigned long n; 17 | printf("Enter a non-negative number:\n"); 18 | if (scanf("%lu", &n) != 1) { 19 | fprintf(stderr, "Failed to read number from stdin\n"); 20 | exit(1); 21 | } 22 | printf("Fibonacci sequence number at index %lu is %lu\n", n, fib(n)); 23 | } else { 24 | for (unsigned int i = 1; i < argc; i++) { 25 | errno = 0; 26 | unsigned long n = strtoul(argv[i], NULL, 10); 27 | if (errno != 0) { 28 | fprintf(stderr, "Failed to parse argument into a number: %s\n", 29 | strerror(errno)); 30 | exit(1); 31 | } 32 | printf("Fibonacci sequence number at index %lu is %lu\n", n, fib(n)); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/rust/std/tcp-client/README.md: -------------------------------------------------------------------------------- 1 | Simple TCP client for the tokio-echo-tcp server 2 | ----------------------------------------------- 3 | 4 | This demo is a TCP client which connects to tokio-echo-tcp server. 5 | 6 | # You need to lauch the server 7 | 8 | Follow README.md documentation under codex/Rust/tokio-echo-tcp and execute the server: 9 | 10 | ```sh 11 | cargo build --target wasm32-wasi --release 12 | enarx run --backend=nil --wasmcfgfile Enarx.toml target/wasm32-wasi/release/tokio-echo-tcp.wasm 13 | ``` 14 | 15 | Now when the TCP echo server is running you can build this TCP client and test it: 16 | 17 | Run release without Enarx: 18 | 19 | ```sh 20 | cargo run 21 | ``` 22 | 23 | Run inside Enarx Keep: 24 | 25 | ```sh 26 | cargo build --release --target=wasm32-wasi 27 | enarx run --backend=nil --wasmcfgfile Enarx.toml target/wasm32-wasi/release/std-tcp-client.wasm 28 | ``` 29 | 30 | Expected result following: 31 | 32 | ```sh 33 | Successfully connected to server. 34 | request_data = "GET / HTTP/1.0\r\n\r\n" 35 | "GET / HTTP/1.0\r\n\r\n" 36 | Finished. 37 | ``` 38 | -------------------------------------------------------------------------------- /demos/fibonacci/grain/fibonacci.gr: -------------------------------------------------------------------------------- 1 | import {toList} from "array" 2 | import {drop, forEach, length, map} from "list" 3 | import {parseInt} from "number" 4 | import {trim} from "string" 5 | import {fdRead, stdin} from "sys/file" 6 | import {argv} from "sys/process" 7 | import {expect} from "result" 8 | 9 | print("Grain - Fibonacci sequence example") 10 | 11 | let rec fibonacci = (i) => { 12 | if (i <= 1) { 13 | i 14 | } else { 15 | fibonacci(i - 1) + fibonacci(i - 2) 16 | } 17 | } 18 | 19 | let args = expect("failed to parse arguments", argv()) 20 | let indexes = drop(1, toList(args)) 21 | let indexes = if (length(indexes) == 0) { 22 | print("Enter a non-negative number:") 23 | let (s, _) = expect("failed to read stdin", fdRead(stdin, 19)) 24 | let i = expect("failed to parse stdin as integer number", parseInt(trim(s), 10)) 25 | [i] 26 | } else { 27 | map((arg) => { expect("failed to parse argument " ++ toString(arg) ++ " as integer number", parseInt(arg, 10)) }, indexes) 28 | } 29 | forEach((i) => { print("Fibonacci sequence number at index " ++ toString(i) ++ " is " ++ toString(fibonacci(i))) }, indexes) 30 | -------------------------------------------------------------------------------- /demos/chat-client/web-ui/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Abhishek Gupta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 Tokio Contributors 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /demos/chat-client/c++/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Enarx Chat 10 | 11 | 12 | 13 | 14 |
15 |

Enarx Chat

16 |

Click on the chat button to start

17 |

Click the stop button to stop the chat client

18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 27 | 28 |
29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /demos/README.md: -------------------------------------------------------------------------------- 1 | # Enarx Demos 2 | 3 | This directory contains full-featured applications that demonstrate the capabilities of 4 | WebAssembly running within Enarx. 5 | 6 | These apps are also featured on the [Try Enarx](try.enarx.dev) website, where they can be easily 7 | launched from your browser and run within real, secured Enarx Keeps on supported cloud platforms. 8 | 9 | Some demos have implementations in multiple programming languages. 10 | Each demo's directory is categorized by language. 11 | 12 | ## Chat Client 13 | 14 | The Chat Server app is the frontend of a simple messaging app, intended to be used with the Chat 15 | Server app. 16 | 17 | ## Chat Server 18 | 19 | The Chat Server app is the backend of a simple messaging app, intended to be used with the Chat 20 | Client app. 21 | 22 | ## Cryptle 23 | 24 | The Cryptle app is a multiplayer implementation of 25 | [Wordle](https://www.nytimes.com/games/wordle/index.html). 26 | 27 | ## Fibonacci 28 | 29 | The Fibonacci app is a simple program that demonstrates setting up file descriptors and printing 30 | to stdout. 31 | It features implementations in every language officially supported by Enarx. 32 | 33 | ## Greenhouse Monitor 34 | 35 | The Greenhouse Monitor app implements a dashboard that demonstrates features such as WebSockets 36 | and gRPC. 37 | -------------------------------------------------------------------------------- /demos/fibonacci/zig/build.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | pub fn build(b: *std.build.Builder) void { 4 | // Standard target options allows the person running `zig build` to choose 5 | // what target to build for. Here we do not override the defaults, which 6 | // means any target is allowed, and the default is native. Other options 7 | // for restricting supported target set are available. 8 | const target = b.standardTargetOptions(.{}); 9 | 10 | // Standard release options allow the person running `zig build` to select 11 | // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. 12 | const mode = b.standardReleaseOptions(); 13 | 14 | const exe = b.addExecutable("fibonacci", "src/main.zig"); 15 | exe.setTarget(target); 16 | exe.setBuildMode(mode); 17 | exe.install(); 18 | 19 | const run_cmd = exe.run(); 20 | run_cmd.step.dependOn(b.getInstallStep()); 21 | if (b.args) |args| { 22 | run_cmd.addArgs(args); 23 | } 24 | 25 | const run_step = b.step("run", "Run the app"); 26 | run_step.dependOn(&run_cmd.step); 27 | 28 | const exe_tests = b.addTest("src/main.zig"); 29 | exe_tests.setTarget(target); 30 | exe_tests.setBuildMode(mode); 31 | 32 | const test_step = b.step("test", "Run unit tests"); 33 | test_step.dependOn(&exe_tests.step); 34 | } 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Enarx Codex 2 | 3 | A collection of code examples that can be compiled to WebAssembly and run within Enarx. 4 | 5 | This repository contains git submodules. 6 | After cloning this repository, please run `git submodule update --init` to retrieve the submodules. 7 | 8 | ## Demos 9 | 10 | The `demos` directory contains full-featured applications that demonstrate the capabilities of 11 | WebAssembly running within Enarx. 12 | Look here if you're interested in seeing what complete, working Enarx applications look like. 13 | 14 | These apps are also featured on the [Try Enarx](try.enarx.dev) website, where they can be easily 15 | launched from your browser and run within real, secured Enarx Keeps on supported cloud platforms. 16 | 17 | Some demos have implementations in multiple programming languages. 18 | Each demo's directory is categorized by language. 19 | 20 | ## Examples 21 | 22 | The `examples` directory contains small, focused code examples that demonstrate how to perform 23 | specific tasks in the context of Enarx. 24 | Look here if you're writing an Enarx application and need guidance on how to perform a certain 25 | task. 26 | 27 | The examples within this directory are categorized by programming language. 28 | Within each language's directory, you will also find instructions on how to install 29 | and run the tools necessary to compile that language to a WebAssembly module. 30 | -------------------------------------------------------------------------------- /demos/fibonacci/zig/src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | 3 | fn fibonacci(i: u64) u64 { 4 | if (i <= 1) return i; 5 | return fibonacci(i - 1) + fibonacci(i - 2); 6 | } 7 | 8 | fn print_fibonacci(w: anytype, s: []const u8) !void { 9 | const i = try std.fmt.parseUnsigned(u64, s, 10); 10 | try w.print("Fibonacci sequence number at index {d} is {d}\n", .{i, fibonacci(i)}); 11 | } 12 | 13 | pub fn main() !void { 14 | const alloc: std.mem.Allocator = std.heap.page_allocator; 15 | 16 | var args = try std.process.argsAlloc(alloc); 17 | defer alloc.free(args); 18 | 19 | const stdout = std.io.getStdOut(); 20 | defer stdout.close(); 21 | 22 | const out = stdout.writer(); 23 | 24 | try out.print("Zig - Fibonacci sequence example\n", .{}); 25 | 26 | const indexes = args[1..]; 27 | if (indexes.len > 0) { 28 | for (indexes) |arg| { 29 | try print_fibonacci(out, arg); 30 | } 31 | } else { 32 | const stdin = std.io.getStdIn(); 33 | defer stdin.close(); 34 | 35 | try out.print("Enter a non-negative number:\n", .{}); 36 | var buf: [19]u8 = undefined; 37 | if (try stdin.reader().readUntilDelimiterOrEof(&buf, '\n')) |arg| { 38 | try print_fibonacci(out, arg); 39 | } else { 40 | std.debug.print("failed to read from stdin", .{}); 41 | std.process.exit(1); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demos/chat-client/web-ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Enarx Chat 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 |
18 |
19 | chat 20 |
21 |

Enarx Chat

22 |
23 | 24 |
25 |
26 | face 27 | Enarx Chat 28 |
29 |
30 | 31 | 32 |
33 | 34 | 35 |
36 | 37 |
38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io::Write; 2 | use std::os::wasi::prelude::FromRawFd; 3 | 4 | use tokio::io::{AsyncReadExt, AsyncWriteExt}; 5 | use tokio::net::{TcpListener, TcpStream}; 6 | 7 | #[tokio::main(flavor = "current_thread")] 8 | 9 | async fn main() -> std::io::Result<()> { 10 | // Set up pre-established listening socket. 11 | let standard = unsafe { std::net::TcpListener::from_raw_fd(3) }; 12 | standard.set_nonblocking(true).unwrap(); 13 | let listener = TcpListener::from_std(standard)?; 14 | 15 | loop { 16 | // Accept new sockets in a loop. 17 | let socket = match listener.accept().await { 18 | Ok(s) => s.0, 19 | Err(e) => { 20 | eprintln!("> ERROR: {}", e); 21 | continue; 22 | } 23 | }; 24 | 25 | // Spawn a background task for each new connection. 26 | tokio::spawn(async move { 27 | eprintln!("> CONNECTED"); 28 | match handle(socket).await { 29 | Ok(()) => eprintln!("> DISCONNECTED"), 30 | Err(e) => eprintln!("> ERROR: {}", e), 31 | } 32 | }); 33 | } 34 | } 35 | 36 | async fn handle(mut socket: TcpStream) -> std::io::Result<()> { 37 | loop { 38 | let mut buf = [0u8; 4096]; 39 | 40 | // Read some bytes from the socket. 41 | let read = socket.read(&mut buf).await?; 42 | 43 | // Handle a clean disconnection. 44 | if read == 0 { 45 | return Ok(()); 46 | } 47 | 48 | // Write bytes both locally and remotely. 49 | std::io::stdout().write_all(&buf[..read])?; 50 | socket.write_all(&buf[..read]).await?; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/rust/std/tcp-client/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io::{BufReader, Read, Write}; 2 | use std::net::TcpStream; 3 | 4 | // When build to wasi 5 | #[cfg(target_os = "wasi")] 6 | fn get_tcpstream() -> std::result::Result> { 7 | use std::os::wasi::io::FromRawFd; 8 | let stdstream = unsafe { std::net::TcpStream::from_raw_fd(3) }; 9 | Ok(stdstream) 10 | } 11 | 12 | // When the target of the build is not wasi 13 | #[cfg(not(target_os = "wasi"))] 14 | fn get_tcpstream() -> std::result::Result { 15 | std::net::TcpStream::connect("127.0.0.1:10010") 16 | } 17 | 18 | fn main() { 19 | // Use the TCP connection 20 | match get_tcpstream() { 21 | Ok(mut _stream) => { 22 | println!("Successfully connected to server."); 23 | 24 | // Send data over TCP 25 | let mut request_data = String::new(); 26 | request_data.push_str("GET / HTTP/1.0\r\n\r\n"); 27 | println!("request_data = {:?}", request_data); 28 | let _result = _stream.write_all(request_data.as_bytes()); 29 | 30 | // Receive data from TCP 31 | let mut reader = BufReader::new(_stream); 32 | // Echo TCP server returns our request 33 | // We read the same amount of bytes 34 | let byte_count = request_data.len(); 35 | let mut data = vec![0; byte_count]; 36 | reader.read(&mut data).unwrap(); // Read from TCP 37 | let data_str = std::str::from_utf8(&data).unwrap(); 38 | println!("{:?}", data_str); 39 | }, 40 | Err(e) => { 41 | println!("Failed to connect: {}", e); 42 | } 43 | } 44 | println!("Finished."); 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [ push, pull_request ] 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.ref }} 5 | cancel-in-progress: true 6 | jobs: 7 | check: 8 | runs-on: ubuntu-20.04 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: cachix/install-nix-action@v18 12 | - uses: cachix/cachix-action@v12 13 | continue-on-error: true 14 | with: 15 | name: enarx 16 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 17 | - run: nix flake check -L --show-trace --keep-going 18 | 19 | build: 20 | needs: [ check ] 21 | strategy: 22 | matrix: 23 | output: 24 | - chat-client-c 25 | - chat-client-cpp 26 | - chat-client-rust 27 | - chat-server-rust 28 | - cryptle-rust 29 | - fibonacci-c 30 | - fibonacci-cpp 31 | - fibonacci-go 32 | - fibonacci-rust 33 | - fibonacci-zig 34 | 35 | runs-on: ubuntu-20.04 36 | steps: 37 | - uses: actions/checkout@v3 38 | - uses: cachix/install-nix-action@v18 39 | - uses: cachix/cachix-action@v12 40 | continue-on-error: true 41 | with: 42 | name: enarx 43 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 44 | - name: Build ${{ matrix.output }} Enarx package 45 | run: nix build -L '.#${{ matrix.output }}' 46 | - run: nix run --inputs-from . 'nixpkgs#coreutils' -- --coreutils-prog=ginstall -p ./result/main.wasm ${{ matrix.output }}.wasm 47 | - uses: actions/upload-artifact@v3 48 | with: 49 | name: ${{ matrix.output }}.wasm 50 | path: ${{ matrix.output }}.wasm 51 | 52 | # TODO: Publish packages once 53 | # - https://github.com/profianinc/drawbridge/issues/148 54 | # - https://github.com/enarx/enarx/issues/2048 55 | # are done 56 | #- run: enarx package publish "examples/${{ matrix.output }}:$(nix eval --raw '.#${{ matrix.output }}.version')" ./result 57 | -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/README.md: -------------------------------------------------------------------------------- 1 | # tokio_echo 2 | 3 | This demo is a TCP Echo server for tokio. 4 | 5 | ## Prerequisites 6 | 7 | Be sure to update your rust stable toolchain to at least 1.60.0. 8 | 9 | Please ensure that you're using the standard toolchain (if using [`rustup`](https://rustup.rs/): `rustup default`). 10 | 11 | ## Running from Try Enarx 12 | 13 | First generate the Wasm file on localhost: 14 | 15 | ```sh 16 | cargo build --target wasm32-wasi 17 | ``` 18 | 19 | Access the __Try Enarx__ website: 20 | 21 | https://try.enarx.dev 22 | 23 | Select a platform. Let's try Intel SGX on Equinix. 24 | 25 | Upload the generated Wasm file from: 26 | 27 | ```sh 28 | /target/wasm32-wasi/debug/tokio-echo.wasm 29 | ``` 30 | 31 | Paste the following to the Enarx.toml text area: 32 | 33 | ```toml 34 | [[files]] 35 | kind = "stdin" 36 | 37 | [[files]] 38 | kind = "stdout" 39 | 40 | [[files]] 41 | kind = "stderr" 42 | 43 | [[files]] 44 | name = "LISTEN" 45 | kind = "listen" 46 | port = 10010 47 | prot = "tcp" 48 | ``` 49 | 50 | Click on the `Deploy` button. 51 | 52 | Now open a terminal on your machine. You are going to connect with the server using either ncat or nc (these are popular networking tools that are usually available out-of-the-box): 53 | 54 | ```sh 55 | echo hello | ncat sgx.equinix.try.enarx.dev 10010 56 | ``` 57 | 58 | In the __Try Enarx__ website, you should see the following output: 59 | 60 | ```sh 61 | hello 62 | > CONNECTED 63 | > DISCONNECTED 64 | ``` 65 | 66 | Congratulations! 67 | 68 | ## Running from localhost 69 | 70 | ### enarx 71 | 72 | After installing [enarx](https://enarx.dev/docs/Quickstart) run: 73 | 74 | ```sh 75 | CARGO_TARGET_WASM32_WASI_RUNNER="enarx run --wasmcfgfile Enarx.toml" cargo run --target wasm32-wasi 76 | ``` 77 | 78 | Open another shell and enter: 79 | 80 | ```sh 81 | echo hello | ncat 127.0.0.1 10010 82 | ``` 83 | 84 | You should see the following output from Enarx: 85 | 86 | ```sh 87 | Running enarx run --wasmcfgfile Enarx.toml target/wasm32-wasi/debug/tokio-echo.wasm 88 | > CONNECTED 89 | hello 90 | > DISCONNECTED 91 | ``` 92 | -------------------------------------------------------------------------------- /demos/chat-client/c++/assets/script.js: -------------------------------------------------------------------------------- 1 | function init() { 2 | chatArea = document.querySelector(".chat-area") 3 | chatSubmit = document.querySelector(".chat-submit") 4 | chatHeader = document.querySelector(".chat-header") 5 | chatInput = document.querySelector(".chat-input") 6 | stopButton = document.querySelector(".stop-btn") 7 | root = document.documentElement; 8 | var host = "http://localhost:50010" 9 | 10 | chatSubmit.addEventListener("click", () => { 11 | let userResponse = chatInput.value.trim(); 12 | if (userResponse !== "") { 13 | setUserResponse(); 14 | send(userResponse, host) 15 | } 16 | }) 17 | 18 | stopButton.addEventListener("click", () => { 19 | send("/04".trim(), host); 20 | chatInput.disabled = true; 21 | }) 22 | } 23 | 24 | // end of init function 25 | 26 | function userResponseBtn(e) { 27 | send(e.value); 28 | } 29 | 30 | // to submit user input when pressing enter 31 | function givenUserInput(e) { 32 | if (e.keyCode == 13) { 33 | let userResponse = chatInput.value.trim(); 34 | if (userResponse !== "") { 35 | setUserResponse() 36 | send(userResponse) 37 | } 38 | } 39 | } 40 | 41 | // to display user message on UI 42 | function setUserResponse() { 43 | let userInput = chatInput.value; 44 | if (userInput) { 45 | let temp = `
${userInput}
` 46 | chatArea.innerHTML += temp; 47 | chatInput.value = "" 48 | } else { 49 | chatInput.disabled = false; 50 | } 51 | scrollToBottomOfResults(); 52 | } 53 | 54 | 55 | 56 | function scrollToBottomOfResults() { 57 | chatArea.scrollTop = chatArea.scrollHeight; 58 | } 59 | 60 | function send(message, host) { 61 | chatInput.type = "text" 62 | passwordInput = false; 63 | chatInput.focus(); 64 | console.log("User Message:", message) 65 | $.ajax({ 66 | url: host, 67 | method: 'PUT', 68 | data: { 69 | message: message 70 | } 71 | }); 72 | chatInput.focus(); 73 | } 74 | 75 | init(); -------------------------------------------------------------------------------- /demos/chat-client/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | #[cfg(unix)] 3 | use std::os::unix::io::FromRawFd; 4 | #[cfg(target_os = "wasi")] 5 | use std::os::wasi::io::FromRawFd; 6 | use std::str::FromStr; 7 | 8 | use anyhow::{bail, Context}; 9 | use futures::StreamExt; 10 | use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; 11 | use tokio::net::TcpStream; 12 | use tokio_stream::wrappers::LinesStream; 13 | 14 | #[tokio::main(flavor = "current_thread")] 15 | async fn main() -> anyhow::Result<()> { 16 | let fd_count = env::var("FD_COUNT").context("failed to lookup `FD_COUNT`")?; 17 | let fd_count = usize::from_str(&fd_count).context("failed to parse `FD_COUNT`")?; 18 | assert_eq!( 19 | fd_count, 20 | 5, // STDIN, STDOUT, STDERR and 2 sockets 21 | "unexpected amount of file descriptors received" 22 | ); 23 | let mut stream = match env::var("FD_NAMES") 24 | .context("failed to lookup `FD_NAMES`")? 25 | .splitn(fd_count, ':') 26 | .nth(3) 27 | { 28 | None => bail!("failed to parse `FD_NAMES`"), 29 | Some("server") => { 30 | let s = unsafe { std::net::TcpStream::from_raw_fd(3) }; 31 | s.set_nonblocking(true) 32 | .context("failed to set non-blocking flag on socket")?; 33 | TcpStream::from_std(s).context("failed to initialize Tokio stream")? 34 | } 35 | Some(name) => bail!("unknown socket name `{name}`"), 36 | }; 37 | 38 | // TODO: Send and receive multiple messages concurrently once async reads from stdin are possible 39 | for line in std::io::stdin().lines() { 40 | let line = line.context("failed to read line from STDIN")?; 41 | stream 42 | .write_all(format!("{line}\n").as_bytes()) 43 | .await 44 | .context("failed to send line")?; 45 | } 46 | LinesStream::new(BufReader::new(stream).lines()) 47 | .for_each(|line| async { 48 | match line { 49 | Err(e) => eprintln!("* failed to receive line: {e}"), 50 | Ok(line) => println!("{line}"), 51 | } 52 | }) 53 | .await; 54 | Ok(()) 55 | } 56 | -------------------------------------------------------------------------------- /demos/chat-client/c/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef __wasi__ 7 | #include 8 | #include 9 | #endif 10 | 11 | int main(int argc, char const *argv[]) { 12 | #ifdef __wasi__ 13 | int fd_count = atoi(getenv("FD_COUNT")); 14 | if (fd_count != 4) { 15 | fprintf(stderr, "unexpected amount of file descriptors received:%d\n", 16 | fd_count); 17 | return -1; 18 | } 19 | 20 | char *stream_str = getenv("FD_NAMES"); 21 | char *sep_at; 22 | for (int i = 0; i < 3; i++) { 23 | sep_at = strchr(stream_str, ':'); 24 | stream_str = sep_at + 1; 25 | } 26 | if (stream_str == NULL) { 27 | fprintf(stderr, "failed to parse FD_NAMES\n"); 28 | return -1; 29 | } else if (strcmp(stream_str, "server") != 0) { 30 | fprintf(stderr, "unknown socket name `%s`\n", stream_str); 31 | return -1; 32 | } 33 | int stream = 3; 34 | #else 35 | int sock = socket(AF_INET, SOCK_STREAM, 0); 36 | struct sockaddr_in serv_addr; 37 | serv_addr.sin_family = AF_INET; 38 | serv_addr.sin_port = htons(50000); 39 | 40 | if (inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr) <= 0) { 41 | fprintf(stderr, "invalid address/address not supported\n"); 42 | return -1; 43 | } 44 | 45 | int stream = connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); 46 | if (stream < 0) { 47 | fprintf(stderr, "connection failed\n"); 48 | return -1; 49 | } 50 | #endif 51 | // TODO: Send and receive multiple messages concurrently once async reads from 52 | // stdin are possible 53 | while (1) { 54 | char line[1024]; 55 | char c = '\0'; 56 | int numBytes = 0; 57 | while (c != '\n') { 58 | c = getc(stdin); 59 | line[numBytes] = c; 60 | numBytes++; 61 | if (ferror(stdin)) { 62 | fprintf(stderr, "failed to read line from STDIN\n"); 63 | return -1; 64 | } 65 | } 66 | line[numBytes] = '\0'; 67 | printf("\nyou entered: %s\n", line); 68 | int ret = write(stream, line, numBytes); 69 | if (ret <= 0) { 70 | fprintf(stderr, "failed to send line\n"); 71 | return -1; 72 | } 73 | } 74 | close(stream); 75 | } 76 | -------------------------------------------------------------------------------- /demos/chat-client/web-ui/script.js: -------------------------------------------------------------------------------- 1 | function init() { 2 | var inactiveMessage = "Server is down" 3 | chatPopup = document.querySelector(".chat-popup") 4 | chatSubmit = document.querySelector(".chat-submit") 5 | chatHeader = document.querySelector(".chat-header") 6 | chatArea = document.querySelector(".chat-area") 7 | chatInput = document.querySelector(".chat-input") 8 | root = document.documentElement; 9 | chatPopup.style.display = "flex" 10 | var host = "http://localhost:8080" 11 | 12 | chatSubmit.addEventListener("click", () => { 13 | let userResponse = chatInput.value.trim(); 14 | if (userResponse !== "") { 15 | setUserResponse(); 16 | send(userResponse) 17 | } 18 | }) 19 | } 20 | 21 | function userResponseBtn(e) { 22 | send(e.value); 23 | } 24 | 25 | // to submit user input when he presses enter 26 | function givenUserInput(e) { 27 | if (e.keyCode == 13) { 28 | let userResponse = chatInput.value.trim(); 29 | if (userResponse !== "") { 30 | setUserResponse() 31 | send(userResponse) 32 | } 33 | } 34 | } 35 | 36 | // to display user message on UI 37 | function setUserResponse() { 38 | let userInput = chatInput.value; 39 | if (userInput) { 40 | let temp = `
${userInput}
` 41 | chatArea.innerHTML += temp; 42 | chatInput.value = "" 43 | } else { 44 | chatInput.disabled = false; 45 | } 46 | scrollToBottomOfResults(); 47 | } 48 | 49 | function scrollToBottomOfResults() { 50 | chatArea.scrollTop = chatArea.scrollHeight; 51 | } 52 | 53 | function send(message) { 54 | chatInput.type = "text" 55 | passwordInput = false; 56 | chatInput.focus(); 57 | console.log("User Message:", message) 58 | $.ajax({ 59 | url: host, 60 | method: 'PUT', 61 | data: { 62 | message: message 63 | } 64 | }); 65 | chatInput.focus(); 66 | } 67 | 68 | function createChat() { 69 | 70 | host = "http://localhost:8080"; 71 | init() 72 | const msg = document.querySelector(".msg"); 73 | msg.innerText = "Welcome to Enarx Chat! Send a message to an Enarx Keep below:"; 74 | 75 | const botTitle = document.querySelector(".bot-title"); 76 | botTitle.innerText = "Enarx Chat"; 77 | } 78 | 79 | createChat(); -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/date.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | use std::fmt::{self, Write}; 3 | use std::str; 4 | use std::time::SystemTime; 5 | 6 | use httpdate::HttpDate; 7 | 8 | pub struct Now(()); 9 | 10 | /// Returns a struct, which when formatted, renders an appropriate `Date` 11 | /// header value. 12 | pub fn now() -> Now { 13 | Now(()) 14 | } 15 | 16 | // Gee Alex, doesn't this seem like premature optimization. Well you see 17 | // there Billy, you're absolutely correct! If your server is *bottlenecked* 18 | // on rendering the `Date` header, well then boy do I have news for you, you 19 | // don't need this optimization. 20 | // 21 | // In all seriousness, though, a simple "hello world" benchmark which just 22 | // sends back literally "hello world" with standard headers actually is 23 | // bottlenecked on rendering a date into a byte buffer. Since it was at the 24 | // top of a profile, and this was done for some competitive benchmarks, this 25 | // module was written. 26 | // 27 | // Just to be clear, though, I was not intending on doing this because it 28 | // really does seem kinda absurd, but it was done by someone else [1], so I 29 | // blame them! :) 30 | // 31 | // [1]: https://github.com/rapidoid/rapidoid/blob/f1c55c0555007e986b5d069fe1086e6d09933f7b/rapidoid-commons/src/main/java/org/rapidoid/commons/Dates.java#L48-L66 32 | 33 | struct LastRenderedNow { 34 | bytes: [u8; 128], 35 | amt: usize, 36 | unix_date: u64, 37 | } 38 | 39 | thread_local!(static LAST: RefCell = RefCell::new(LastRenderedNow { 40 | bytes: [0; 128], 41 | amt: 0, 42 | unix_date: 0, 43 | })); 44 | 45 | impl fmt::Display for Now { 46 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 47 | LAST.with(|cache| { 48 | let mut cache = cache.borrow_mut(); 49 | let now = SystemTime::now(); 50 | let now_unix = now 51 | .duration_since(SystemTime::UNIX_EPOCH) 52 | .map(|since_epoch| since_epoch.as_secs()) 53 | .unwrap_or(0); 54 | if cache.unix_date != now_unix { 55 | cache.update(now, now_unix); 56 | } 57 | f.write_str(cache.buffer()) 58 | }) 59 | } 60 | } 61 | 62 | impl LastRenderedNow { 63 | fn buffer(&self) -> &str { 64 | str::from_utf8(&self.bytes[..self.amt]).unwrap() 65 | } 66 | 67 | fn update(&mut self, now: SystemTime, now_unix: u64) { 68 | self.amt = 0; 69 | self.unix_date = now_unix; 70 | write!(LocalBuffer(self), "{}", HttpDate::from(now)).unwrap(); 71 | } 72 | } 73 | 74 | struct LocalBuffer<'a>(&'a mut LastRenderedNow); 75 | 76 | impl fmt::Write for LocalBuffer<'_> { 77 | fn write_str(&mut self, s: &str) -> fmt::Result { 78 | let start = self.0.amt; 79 | let end = start + s.len(); 80 | self.0.bytes[start..end].copy_from_slice(s.as_bytes()); 81 | self.0.amt += s.len(); 82 | Ok(()) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /examples/rust/mio/echo-tcp/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "cfg-if" 7 | version = "1.0.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 10 | 11 | [[package]] 12 | name = "env_logger" 13 | version = "0.9.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" 16 | dependencies = [ 17 | "log", 18 | ] 19 | 20 | [[package]] 21 | name = "libc" 22 | version = "0.2.132" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" 25 | 26 | [[package]] 27 | name = "log" 28 | version = "0.4.17" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 31 | dependencies = [ 32 | "cfg-if", 33 | ] 34 | 35 | [[package]] 36 | name = "mio" 37 | version = "0.8.4" 38 | source = "registry+https://github.com/rust-lang/crates.io-index" 39 | checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" 40 | dependencies = [ 41 | "libc", 42 | "log", 43 | "wasi", 44 | "windows-sys", 45 | ] 46 | 47 | [[package]] 48 | name = "mio-echo-tcp" 49 | version = "0.2.0" 50 | dependencies = [ 51 | "env_logger", 52 | "mio", 53 | ] 54 | 55 | [[package]] 56 | name = "wasi" 57 | version = "0.11.0+wasi-snapshot-preview1" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 60 | 61 | [[package]] 62 | name = "windows-sys" 63 | version = "0.36.1" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" 66 | dependencies = [ 67 | "windows_aarch64_msvc", 68 | "windows_i686_gnu", 69 | "windows_i686_msvc", 70 | "windows_x86_64_gnu", 71 | "windows_x86_64_msvc", 72 | ] 73 | 74 | [[package]] 75 | name = "windows_aarch64_msvc" 76 | version = "0.36.1" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" 79 | 80 | [[package]] 81 | name = "windows_i686_gnu" 82 | version = "0.36.1" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" 85 | 86 | [[package]] 87 | name = "windows_i686_msvc" 88 | version = "0.36.1" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" 91 | 92 | [[package]] 93 | name = "windows_x86_64_gnu" 94 | version = "0.36.1" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" 97 | 98 | [[package]] 99 | name = "windows_x86_64_msvc" 100 | version = "0.36.1" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" 103 | -------------------------------------------------------------------------------- /demos/chat-client/c++/assets/style.css: -------------------------------------------------------------------------------- 1 | @import "https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css"; 2 | * { 3 | margin: 0; 4 | padding: 0; 5 | box-sizing: border-box; 6 | } 7 | 8 | :root { 9 | --chat-window-total-width: 380px; 10 | --chat-window-height: 500px; 11 | --chat-window-color-theme: #1e90ff; 12 | --chat-window-bg-color: #fff; 13 | --chat-send-button: #1e90ff; 14 | --chat-user-msg-bg: #ddd; 15 | --chat-header-bg: linear-gradient(160deg, dodgerblue 0%, #80D0C7 100%); 16 | } 17 | 18 | body { 19 | font-family: Arial, Helvetica, sans-serif; 20 | background-color: #e5e5e5; 21 | display: flex; 22 | justify-content: center; 23 | height: 100vh; 24 | width: 100%; 25 | } 26 | 27 | section { 28 | max-width: 1100px; 29 | margin: auto; 30 | text-align: center; 31 | padding: 0 1rem; 32 | } 33 | 34 | h1 { 35 | font-size: 3rem; 36 | margin-bottom: 2rem; 37 | } 38 | 39 | p { 40 | font-size: 2rem; 41 | } 42 | 43 | .icon { 44 | transform: scale(1.2); 45 | } 46 | 47 | .stop-btn { 48 | padding: 5px; 49 | margin-top: 10px; 50 | } 51 | 52 | .chat-submit:hover { 53 | opacity: 1; 54 | } 55 | 56 | .chat-area { 57 | height: 300px; 58 | width: 600px; 59 | overflow-y: auto; 60 | overflow-x: hidden; 61 | background-color: var(--chat-window-bg-color); 62 | border-radius: 30px; 63 | margin: 20px; 64 | } 65 | 66 | .msg { 67 | background-color: var(--chat-window-color-theme); 68 | color: white; 69 | padding: 0.5rem; 70 | border-radius: 5px; 71 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); 72 | } 73 | 74 | .user-msg { 75 | display: flex; 76 | align-items: center; 77 | margin-left: 10px; 78 | } 79 | 80 | .user-msg .msg { 81 | background-color: var(--chat-user-msg-bg); 82 | color: black; 83 | margin: 0.5rem; 84 | padding: 0.5rem; 85 | border-radius: 5px; 86 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); 87 | word-break: break-all; 88 | text-align: left; 89 | } 90 | 91 | .msg-image { 92 | max-width: 90%; 93 | max-height: 400px; 94 | } 95 | 96 | .chat-input-area { 97 | position: relative; 98 | display: flex; 99 | justify-content: center; 100 | } 101 | 102 | .chat-input { 103 | width: 100%; 104 | border: 1px solid #ccc; 105 | padding: 0.5rem; 106 | font-size: 1rem; 107 | border-radius: 5px; 108 | height: 2.2rem; 109 | margin-bottom: 0.5rem; 110 | margin-left: 0.5rem; 111 | outline-color: var(--chat-window-color-theme); 112 | } 113 | 114 | .chat-submit { 115 | padding: 0.25rem 0.5rem; 116 | margin-left: 0.5rem; 117 | background-color: var(--chat-send-button); 118 | color: white; 119 | display: flex; 120 | justify-content: center; 121 | align-items: center; 122 | border-radius: 5px; 123 | border: none; 124 | outline: none; 125 | cursor: pointer; 126 | margin-bottom: 0.5rem; 127 | margin-right: 0.5rem; 128 | /* opacity: 0.8; 129 | transition: opacity 0.3s; */ 130 | } 131 | 132 | .show { 133 | display: flex; 134 | } 135 | 136 | .btn-primary { 137 | /* background-color: #0096fe; */ 138 | border: 1px solid var(--chat-window-color-theme); 139 | outline: none; 140 | display: inline-block; 141 | color: var(--chat-window-color-theme); 142 | padding: 5px 15px; 143 | border-radius: 4px; 144 | cursor: pointer; 145 | margin: 5px; 146 | font-weight: bold; 147 | } 148 | 149 | .btn-primary:hover { 150 | background-color: #0096fe; 151 | color: #fff; 152 | transform: scale(1.1); 153 | } 154 | 155 | @media (max-width:500px) { 156 | .chat-popup { 157 | bottom: 120px; 158 | right: 10%; 159 | width: 80vw; 160 | height: 100%; 161 | } 162 | } -------------------------------------------------------------------------------- /examples/rust/mio/echo-tcp/README.md: -------------------------------------------------------------------------------- 1 | # MIO TCP Echo Server Example 2 | 3 | This example is an adapted version of the upstream `mio` crate `tcp_server` example. 4 | 5 | It currently depends on a modified version of `mio` with support for WASI. 6 | 7 | The added part creates the `TcpListener` from file descriptor `3`, 8 | if the `LISTEN_FDS` environment variable is set. 9 | 10 | 11 | ## How to run this example 12 | 13 | ### Install `enarx` 14 | 15 | Either from `crates.io` or from this git repository: 16 | 17 | ``` 18 | $ cd 19 | $ cargo install --path . 20 | ``` 21 | 22 | ### Build the WASM application 23 | 24 | It will need at least rust version `>= 1.60.0`. 25 | 26 | ``` 27 | $ cd 28 | $ cargo build --target wasm32-wasi -p tcp_server 29 | […] 30 | Finished dev [unoptimized + debuginfo] target(s) in 1.44s 31 | ``` 32 | 33 | ### Run it 34 | 35 | ``` 36 | $ enarx run --wasmcfgfile examples/tcp_server/Enarx.toml target/wasm32-wasi/debug/tcp_server.wasm 37 | [WARN wasmldr] 🌭DEV-ONLY BUILD, NOT FOR PRODUCTION USE🌭 38 | [DEBUG wasmldr] parsing argv 39 | [INFO wasmldr] opts: RunOptions { 40 | module: None, 41 | config: None, 42 | } 43 | [INFO wasmldr] reading module from fd 3 44 | [INFO wasmldr] reading config from fd 4 45 | [INFO wasmldr] running workload 46 | [DEBUG wasmldr::workload] configuring wasmtime engine 47 | [DEBUG wasmldr::workload] instantiating wasmtime linker 48 | [DEBUG wasmldr::workload] adding WASI to linker 49 | [DEBUG wasmldr::workload] creating WASI context 50 | [DEBUG wasmldr::workload] Processing loader config Config { 51 | files: Some( 52 | [ 53 | File { 54 | type_: "stdio", 55 | name: "stdin", 56 | addr: None, 57 | port: None, 58 | }, 59 | File { 60 | type_: "stdio", 61 | name: "stdout", 62 | addr: None, 63 | port: None, 64 | }, 65 | File { 66 | type_: "stdio", 67 | name: "stderr", 68 | addr: None, 69 | port: None, 70 | }, 71 | File { 72 | type_: "tcp_listen", 73 | name: "TEST_TCP_LISTEN", 74 | addr: None, 75 | port: Some( 76 | 9000, 77 | ), 78 | }, 79 | ], 80 | ), 81 | } 82 | [DEBUG wasmldr::workload] creating wasmtime Store 83 | [DEBUG wasmldr::workload] instantiating module from bytes 84 | [DEBUG wasmldr::workload] adding module to store 85 | [DEBUG wasmldr::workload] getting module's default function 86 | [DEBUG wasmldr::workload] calling function 87 | Using preopened socket FD 3 88 | You can connect to the server using `nc`: 89 | $ nc 90 | You'll see our welcome message and anything you type will be printed here. 91 | 92 | ``` 93 | 94 | Then from another shell: 95 | ``` 96 | $ echo ECHO | ncat 127.0.0.1 9000 97 | Hello world! 98 | ECHO 99 | ``` 100 | 101 | or, if you don't have `ncat`: 102 | ``` 103 | $ echo ECHO | netcat -q 1 127.0.0.1 9000 104 | Hello world! 105 | ECHO 106 | ``` 107 | 108 | and see the output of the Enarx keep: 109 | ``` 110 | Accepted connection from: 0.0.0.0:0 111 | Received data: ECHO 112 | Connection closed 113 | ``` 114 | 115 | To modify the port and listen address see the `Enarx.toml` file in the 116 | example directory. 117 | 118 | ### Transparent TLS 119 | 120 | Enarx automatically wraps the TCP connection in a TLS session, if you change the `proto` field in the `Enarx.toml` from `tcp` to `tls`. 121 | In this case you can connect to the echo server via `openssl` 122 | 123 | ``` 124 | $ openssl s_client -connect 127.0.0.1:9000 125 | ``` 126 | 127 | Enter your messages manually, and to end the connection enter `ctrl-d` or `Q`. 128 | -------------------------------------------------------------------------------- /demos/chat-server/rust/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::error::Error; 3 | use std::fmt::Display; 4 | #[cfg(target_os = "wasi")] 5 | use std::os::wasi::io::FromRawFd; 6 | use std::str::FromStr; 7 | 8 | use anyhow::{bail, Context}; 9 | use futures::{join, select, Stream, StreamExt, TryFutureExt}; 10 | use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; 11 | use tokio::net::{TcpListener, TcpStream}; 12 | use tokio::sync::broadcast; 13 | use tokio::sync::broadcast::Sender; 14 | use tokio_stream::wrappers::{BroadcastStream, LinesStream, TcpListenerStream}; 15 | use ulid::Ulid; 16 | 17 | /// Handles the peer TCP stream I/O. 18 | async fn handle_io( 19 | peer: &mut TcpStream, 20 | tx: &Sender, 21 | rx: impl Stream> + Unpin, 22 | id: impl Display, 23 | ) -> anyhow::Result<()> { 24 | let (input, mut output) = peer.split(); 25 | let mut input = LinesStream::new(BufReader::new(input).lines()).fuse(); 26 | let mut rx = rx.fuse(); 27 | loop { 28 | select! { 29 | line = input.next() => match line { 30 | None => return Ok(()), 31 | Some(Err(e)) => bail!("failed to receive line from {id}: {e}"), 32 | Some(Ok(line)) => if let Err(e) = tx.send(format!("{id}: {line}")) { 33 | bail!("failed to send line from {id}: {e}") 34 | }, 35 | }, 36 | line = rx.next() => match line { 37 | None => return Ok(()), 38 | Some(Err(e)) => bail!("failed to receive line for {id}: {e}"), 39 | Some(Ok(line)) => if let Err(e) = output.write_all(format!("{line}\n").as_bytes()).await { 40 | bail!("failed to send line to {id}: {e}") 41 | }, 42 | }, 43 | complete => return Ok(()), 44 | }; 45 | } 46 | } 47 | 48 | /// Handles the peer TCP stream. 49 | async fn handle(peer: &mut TcpStream, tx: &Sender) { 50 | let id = Ulid::new(); 51 | 52 | let rx = BroadcastStream::new(tx.subscribe()); 53 | if let Err(e) = tx.send(format!("{id} joined the chat")) { 54 | eprintln!("failed to send {id} join event to peers: {e}"); 55 | return; 56 | } 57 | 58 | _ = handle_io(peer, tx, rx, id) 59 | .map_err(|e| eprintln!("failed to handle {id} peer I/O: {e}")) 60 | .await; 61 | 62 | if let Err(e) = tx.send(format!("{id} left the chat")) { 63 | eprintln!("failed to send {id} leave event to peers: {e}") 64 | } 65 | } 66 | 67 | #[tokio::main(flavor = "current_thread")] 68 | async fn main() -> anyhow::Result<()> { 69 | let fd_count = env::var("FD_COUNT").context("failed to lookup `FD_COUNT`")?; 70 | let fd_count = usize::from_str(&fd_count).context("failed to parse `FD_COUNT`")?; 71 | assert_eq!( 72 | fd_count, 73 | 4, // STDIN, STDOUT, STDERR and a socket 74 | "unexpected amount of file descriptors received" 75 | ); 76 | let listener = match env::var("FD_NAMES") 77 | .context("failed to lookup `FD_NAMES`")? 78 | .splitn(fd_count, ':') 79 | .nth(3) 80 | { 81 | None => bail!("failed to parse `FD_NAMES`"), 82 | Some("ingest") => { 83 | let l = unsafe { std::net::TcpListener::from_raw_fd(3) }; 84 | l.set_nonblocking(true) 85 | .context("failed to set non-blocking flag on socket")?; 86 | TcpListener::from_std(l) 87 | .context("failed to initialize Tokio listener") 88 | .map(TcpListenerStream::new)? 89 | } 90 | Some(name) => bail!("unknown socket name `{name}`"), 91 | }; 92 | 93 | let (tx, rx) = broadcast::channel(128); 94 | join!( 95 | BroadcastStream::new(rx).for_each(|line| async { 96 | match line { 97 | Err(e) => eprintln!("failed to receive line: {e}"), 98 | Ok(line) => println!("> {line}"), 99 | } 100 | }), 101 | listener.for_each_concurrent(None, |peer| async { 102 | match peer { 103 | Err(e) => eprintln!("failed to accept connection: {e}"), 104 | Ok(mut peer) => handle(&mut peer, &tx).await, 105 | }; 106 | }) 107 | ); 108 | Ok(()) 109 | } 110 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/main.rs: -------------------------------------------------------------------------------- 1 | //! A "tiny" example of HTTP request/response handling using transports. 2 | //! 3 | //! This example is intended for *learning purposes* to see how various pieces 4 | //! hook up together and how HTTP can get up and running. Note that this example 5 | //! is written with the restriction that it *can't* use any "big" library other 6 | //! than Tokio, if you'd like a "real world" HTTP library you likely want a 7 | //! crate like Hyper. 8 | //! 9 | //! Code here is based on the `tinyhttp` example of tokio. 10 | 11 | #![warn(rust_2018_idioms)] 12 | 13 | use ::http::{Request, Response, StatusCode}; 14 | use futures::SinkExt; 15 | use http::header::{CACHE_CONTROL, CONTENT_TYPE, LAST_MODIFIED}; 16 | use protocol::Http; 17 | use std::os::wasi::io::FromRawFd; 18 | use std::{error::Error, io}; 19 | use tokio::net::{TcpListener, TcpStream}; 20 | use tokio_stream::StreamExt; 21 | use tokio_util::codec::Framed; 22 | 23 | mod date; 24 | mod protocol; 25 | 26 | fn enarx_logo() -> &'static [u8] { 27 | include_bytes!("enarx-white.svg") 28 | } 29 | 30 | fn fireworks_gif() -> &'static [u8] { 31 | include_bytes!("fireworks.gif") 32 | } 33 | 34 | fn index_page() -> &'static [u8] { 35 | include_bytes!("index.html") 36 | } 37 | 38 | const NOT_FOUND: &str = r#" 39 | 40 | 41 | 404 Not Found 42 | 43 |

Not Found

44 |

The requested URL was not found on this server.

45 | 46 | "#; 47 | 48 | #[tokio::main(flavor = "current_thread")] 49 | async fn main() -> Result<(), Box> { 50 | // Parse the arguments, bind the TCP socket we'll be listening to, spin up 51 | // our worker threads, and start shipping sockets to those worker threads. 52 | /* let addr = env::args() 53 | .nth(1) 54 | .unwrap_or_else(|| "127.0.0.1:8080".to_string()); 55 | let server = TcpListener::bind(&addr).await?; 56 | */ 57 | let listener = unsafe { std::net::TcpListener::from_raw_fd(3) }; 58 | listener.set_nonblocking(true).unwrap(); 59 | let server = TcpListener::from_std(listener).unwrap(); 60 | 61 | loop { 62 | eprintln!("Accepting connections"); 63 | let stream_res = server.accept().await; 64 | match stream_res { 65 | Err(e) => { 66 | eprintln!("failed to accept connection; error = {}", e); 67 | } 68 | Ok((stream, _)) => { 69 | tokio::spawn(async move { 70 | if let Err(e) = process(stream).await { 71 | eprintln!("failed to process connection; error = {}", e); 72 | } 73 | }); 74 | } 75 | } 76 | } 77 | } 78 | 79 | async fn process(stream: TcpStream) -> Result<(), Box> { 80 | let mut transport = Framed::new(stream, Http); 81 | 82 | while let Some(request) = transport.next().await { 83 | match request { 84 | Ok(request) => { 85 | let response = respond(request).await?; 86 | transport.send(response).await?; 87 | } 88 | Err(e) => return Err(e.into()), 89 | } 90 | } 91 | 92 | Ok(()) 93 | } 94 | 95 | async fn respond(req: Request<()>) -> Result>, Box> { 96 | let response = Response::builder(); 97 | let now_str = date::now().to_string(); 98 | let response = match req.uri().path() { 99 | "/enarx-logo.svg" => response 100 | .status(StatusCode::OK) 101 | .header(CONTENT_TYPE, "image/svg+xml") 102 | .header(LAST_MODIFIED, &now_str) 103 | .header(CACHE_CONTROL, "max-age=60, public") 104 | .body(enarx_logo().to_vec()), 105 | "/fireworks.gif" => response 106 | .status(StatusCode::OK) 107 | .header(CONTENT_TYPE, "image/gif") 108 | .header(LAST_MODIFIED, &now_str) 109 | .header(CACHE_CONTROL, "max-age=60, public") 110 | .body(fireworks_gif().to_vec()), 111 | "/" => response 112 | .status(StatusCode::OK) 113 | .header(CONTENT_TYPE, "text/html; charset=UTF-8") 114 | .header(LAST_MODIFIED, &now_str) 115 | .header(CACHE_CONTROL, "max-age=60, public") 116 | .body(index_page().to_vec()), 117 | _ => response 118 | .status(StatusCode::NOT_FOUND) 119 | .header(CONTENT_TYPE, "text/html; charset=UTF-8") 120 | .header(LAST_MODIFIED, &now_str) 121 | .header(CACHE_CONTROL, "no-store, must-revalidate") 122 | .body(NOT_FOUND.as_bytes().to_vec()), 123 | }; 124 | 125 | let response = response.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; 126 | 127 | Ok(response) 128 | } 129 | -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/protocol.rs: -------------------------------------------------------------------------------- 1 | use bytes::BytesMut; 2 | use http::{HeaderValue, Request, Response}; 3 | use std::io; 4 | use tokio_util::codec::{Decoder, Encoder}; 5 | 6 | pub struct Http; 7 | 8 | /// Implementation of encoding an HTTP response into a `BytesMut`, basically 9 | /// just writing out an HTTP/1.1 response. 10 | impl Encoder>> for Http { 11 | type Error = io::Error; 12 | 13 | fn encode(&mut self, item: Response>, dst: &mut BytesMut) -> io::Result<()> { 14 | use crate::date; 15 | use std::fmt; 16 | use std::fmt::Write; 17 | 18 | write!( 19 | BytesWrite(dst), 20 | "\ 21 | HTTP/1.1 {}\r\n\ 22 | Server: Example\r\n\ 23 | Content-Length: {}\r\n\ 24 | Date: {}\r\n\ 25 | ", 26 | item.status(), 27 | item.body().len(), 28 | date::now() 29 | ) 30 | .unwrap(); 31 | 32 | for (k, v) in item.headers() { 33 | dst.extend_from_slice(k.as_str().as_bytes()); 34 | dst.extend_from_slice(b": "); 35 | dst.extend_from_slice(v.as_bytes()); 36 | dst.extend_from_slice(b"\r\n"); 37 | } 38 | 39 | dst.extend_from_slice(b"\r\n"); 40 | dst.extend_from_slice(item.body()); 41 | 42 | return Ok(()); 43 | 44 | // Right now `write!` on `Vec` goes through io::Write and is not 45 | // super speedy, so inline a less-crufty implementation here which 46 | // doesn't go through io::Error. 47 | struct BytesWrite<'a>(&'a mut BytesMut); 48 | 49 | impl fmt::Write for BytesWrite<'_> { 50 | fn write_str(&mut self, s: &str) -> fmt::Result { 51 | self.0.extend_from_slice(s.as_bytes()); 52 | Ok(()) 53 | } 54 | 55 | fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result { 56 | fmt::write(self, args) 57 | } 58 | } 59 | } 60 | } 61 | 62 | /// Implementation of decoding an HTTP request from the bytes we've read so far. 63 | /// This leverages the `httparse` crate to do the actual parsing and then we use 64 | /// that information to construct an instance of a `http::Request` object, 65 | /// trying to avoid allocations where possible. 66 | impl Decoder for Http { 67 | type Item = Request<()>; 68 | type Error = io::Error; 69 | 70 | fn decode(&mut self, src: &mut BytesMut) -> io::Result>> { 71 | // TODO: we should grow this headers array if parsing fails and asks 72 | // for more headers 73 | let mut headers = [None; 16]; 74 | let (method, path, version, amt) = { 75 | let mut parsed_headers = [httparse::EMPTY_HEADER; 16]; 76 | let mut r = httparse::Request::new(&mut parsed_headers); 77 | let status = r.parse(src).map_err(|e| { 78 | let msg = format!("failed to parse http request: {:?}", e); 79 | io::Error::new(io::ErrorKind::Other, msg) 80 | })?; 81 | 82 | let amt = match status { 83 | httparse::Status::Complete(amt) => amt, 84 | httparse::Status::Partial => return Ok(None), 85 | }; 86 | 87 | let toslice = |a: &[u8]| { 88 | let start = a.as_ptr() as usize - src.as_ptr() as usize; 89 | assert!(start < src.len()); 90 | (start, start + a.len()) 91 | }; 92 | 93 | for (i, header) in r.headers.iter().enumerate() { 94 | let k = toslice(header.name.as_bytes()); 95 | let v = toslice(header.value); 96 | headers[i] = Some((k, v)); 97 | } 98 | 99 | ( 100 | toslice(r.method.unwrap().as_bytes()), 101 | toslice(r.path.unwrap().as_bytes()), 102 | r.version.unwrap(), 103 | amt, 104 | ) 105 | }; 106 | if version != 1 { 107 | return Err(io::Error::new( 108 | io::ErrorKind::Other, 109 | "only HTTP/1.1 accepted", 110 | )); 111 | } 112 | let data = src.split_to(amt).freeze(); 113 | let mut ret = Request::builder(); 114 | ret = ret.method(&data[method.0..method.1]); 115 | let s = data.slice(path.0..path.1); 116 | let s = unsafe { String::from_utf8_unchecked(Vec::from(s.as_ref())) }; 117 | ret = ret.uri(s); 118 | ret = ret.version(http::Version::HTTP_11); 119 | for header in headers.iter() { 120 | let (k, v) = match *header { 121 | Some((ref k, ref v)) => (k, v), 122 | None => break, 123 | }; 124 | let value = HeaderValue::from_bytes(data.slice(v.0..v.1).as_ref()) 125 | .map_err(|_| io::Error::new(io::ErrorKind::Other, "header decode error"))?; 126 | ret = ret.header(&data[k.0..k.1], value); 127 | } 128 | 129 | let req = ret 130 | .body(()) 131 | .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; 132 | Ok(Some(req)) 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /demos/chat-client/web-ui/style.css: -------------------------------------------------------------------------------- 1 | @import "https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css"; 2 | * { 3 | margin: 0; 4 | padding: 0; 5 | box-sizing: border-box; 6 | } 7 | 8 | :root { 9 | --chat-window-total-width: 85%; 10 | --chat-window-height: 80%; 11 | --chat-window-color-theme: #1e90ff; 12 | --chat-window-bg-color: #fff; 13 | --chat-send-button: #1e90ff; 14 | --chat-user-msg-bg: #ddd; 15 | --chat-header-bg: linear-gradient(160deg, dodgerblue 0%, #80D0C7 100%); 16 | } 17 | 18 | body { 19 | font-family: Arial, Helvetica, sans-serif; 20 | background-color: #e5e5e5; 21 | display: flex; 22 | justify-content: center; 23 | height: 100vh; 24 | width: 100%; 25 | } 26 | 27 | section { 28 | max-width: 1100px; 29 | margin: auto; 30 | text-align: center; 31 | padding: 0 1rem; 32 | } 33 | 34 | h1 { 35 | font-size: 3rem; 36 | margin-bottom: 2rem; 37 | } 38 | 39 | p { 40 | font-size: 2rem; 41 | } 42 | 43 | .chat-btn { 44 | position: fixed; 45 | right: 50px; 46 | bottom: 50px; 47 | border: none; 48 | outline: none; 49 | cursor: pointer; 50 | background-color: var(--chat-window-color-theme); 51 | color: white; 52 | width: 60px; 53 | height: 60px; 54 | border-radius: 50%; 55 | opacity: 0.8; 56 | transition: opacity 0.3s; 57 | box-shadow: 0 5px 5px rgba(0, 0, 0, 0.4); 58 | } 59 | 60 | .icon { 61 | transform: scale(1.2); 62 | } 63 | 64 | .chat-btn:hover, 65 | .chat-submit:hover { 66 | opacity: 1; 67 | } 68 | 69 | .chat-popup { 70 | font-family: Arial, Helvetica, sans-serif; 71 | display: none; 72 | position: fixed; 73 | bottom: 80px; 74 | right: 120px; 75 | height: var(--chat-window-height); 76 | width: var(--chat-window-total-width); 77 | background-color: var(--chat-window-bg-color); 78 | /* display: flex; */ 79 | flex-direction: column; 80 | justify-content: space-between; 81 | /* padding: 0.75rem; */ 82 | border: 1px solid #ccc; 83 | box-shadow: 5 5px 5px rgba(0, 0, 0, 0.4); 84 | border-radius: 15px; 85 | transition: all 0.5s ease-out; 86 | } 87 | 88 | .chat-header { 89 | /* background-color: dodgerblue; */ 90 | background-color: var(--chat-window-color-theme); 91 | background-image: var(--chat-header-bg); 92 | color: white; 93 | display: flex; 94 | padding: 10px; 95 | /* margin-bottom: 10px; */ 96 | align-items: center; 97 | max-height: 50px; 98 | } 99 | 100 | .chat-header .bot-title { 101 | display: flex; 102 | justify-content: flex-start; 103 | float: left; 104 | } 105 | 106 | .chat-area { 107 | height: 80%; 108 | overflow-y: auto; 109 | overflow-x: hidden; 110 | background-color: var(--chat-window-bg-color); 111 | } 112 | 113 | .bot-msg { 114 | display: flex; 115 | align-items: center; 116 | margin: 15px; 117 | } 118 | 119 | .bot-img { 120 | margin-right: 15px; 121 | } 122 | 123 | .bot-msg .msg { 124 | background-color: var(--chat-window-color-theme); 125 | color: white; 126 | padding: 0.5rem; 127 | border-radius: 5px; 128 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); 129 | } 130 | 131 | .user-msg { 132 | display: flex; 133 | justify-content: flex-end; 134 | align-items: center; 135 | margin-right: 10px; 136 | } 137 | 138 | .user-msg .msg { 139 | background-color: var(--chat-user-msg-bg); 140 | color: black; 141 | margin: 0.5rem; 142 | padding: 0.5rem; 143 | border-radius: 5px; 144 | box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4); 145 | word-break: break-all; 146 | } 147 | 148 | .msg-image { 149 | max-width: 90%; 150 | max-height: 400px; 151 | } 152 | 153 | .chat-input-area { 154 | position: relative; 155 | display: flex; 156 | justify-content: center; 157 | } 158 | 159 | .chat-input { 160 | width: 100%; 161 | border: 1px solid #ccc; 162 | padding: 0.5rem; 163 | font-size: 1rem; 164 | border-radius: 5px; 165 | height: 2.2rem; 166 | margin-bottom: 0.5rem; 167 | margin-left: 0.5rem; 168 | outline-color: var(--chat-window-color-theme); 169 | } 170 | 171 | .chat-submit { 172 | padding: 0.25rem 0.5rem; 173 | margin-left: 0.5rem; 174 | background-color: var(--chat-send-button); 175 | color: white; 176 | display: flex; 177 | justify-content: center; 178 | align-items: center; 179 | border-radius: 5px; 180 | border: none; 181 | outline: none; 182 | cursor: pointer; 183 | margin-bottom: 0.5rem; 184 | margin-right: 0.5rem; 185 | /* opacity: 0.8; 186 | transition: opacity 0.3s; */ 187 | } 188 | 189 | .show { 190 | display: flex; 191 | } 192 | 193 | .btn-primary { 194 | /* background-color: #0096fe; */ 195 | border: 1px solid var(--chat-window-color-theme); 196 | outline: none; 197 | display: inline-block; 198 | color: var(--chat-window-color-theme); 199 | padding: 5px 15px; 200 | border-radius: 4px; 201 | cursor: pointer; 202 | margin: 5px; 203 | font-weight: bold; 204 | } 205 | 206 | .btn-primary:hover { 207 | background-color: #0096fe; 208 | color: #fff; 209 | transform: scale(1.1); 210 | } 211 | 212 | @media (max-width:500px) { 213 | .chat-popup { 214 | right: 10%; 215 | width: 80vw; 216 | height: 80%; 217 | } 218 | } -------------------------------------------------------------------------------- /demos/chat-client/c++/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "assets.h" 13 | 14 | // C backend code based on https://github.com/rjzak/web_wordpuzzle 15 | 16 | const unsigned char HTTP_OK[14] = "HTTP/1.0 200\n"; 17 | const unsigned char CONTENT_TYPE_HTML[26] = "Content-Type: text/html\n\n"; 18 | const unsigned char CONTENT_TYPE_JAVASCRIPT[32] = "Content-Type: text/javascript\n\n"; 19 | const unsigned char CONTENT_TYPE_CSS[25] = "Content-Type: text/css\n\n"; 20 | const unsigned int PORT = 50010; 21 | 22 | ssize_t write_all(const int fd, unsigned char *buf, size_t n); 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | if (argc > 2) 27 | { 28 | std::cout << "Too many arguments provided" << std::endl; 29 | return 1; 30 | } 31 | 32 | bool isWebInterface = true; 33 | if (argc == 2) 34 | { 35 | if (strcmp("--nowebinterface", argv[1]) == 0) 36 | { 37 | isWebInterface = false; 38 | } 39 | } 40 | 41 | int envVarCount = atoi(std::getenv("FD_COUNT")); 42 | if (envVarCount != 5) 43 | { 44 | std::cout << "expected exactly 5 pre-opened file descriptors" << std::endl; 45 | return 1; 46 | } 47 | 48 | int serverFd, interfaceFd, newSocket; 49 | interfaceFd = envVarCount - 1; 50 | serverFd = envVarCount - 2; 51 | 52 | if (isWebInterface) 53 | { 54 | std::cout << "Running in web interface mode..." << std::endl; 55 | 56 | struct sockaddr_in addr; 57 | socklen_t addrlen = 0; 58 | 59 | addr.sin_port = htons(PORT); 60 | addr.sin_family = AF_INET; 61 | addr.sin_addr.s_addr = INADDR_ANY; 62 | 63 | char buffer[4096] = {0}; 64 | 65 | while (1) 66 | { 67 | if ((newSocket = accept(interfaceFd, (struct sockaddr *)&addr, (socklen_t *)&addrlen)) < 0) 68 | { 69 | std::cout << "Error accepting interface fd" << std::endl; 70 | break; 71 | } 72 | 73 | ssize_t bytes_read = read(newSocket, buffer, 4096); 74 | if (bytes_read < 0) 75 | { 76 | std::cout << "Error reading into buffer" << std::endl; 77 | break; 78 | } 79 | 80 | if (buffer[0] != 0x47 || buffer[1] != 0x45 || buffer[2] != 0x54) 81 | { // !GET 82 | if (buffer[0] == 0x50 && buffer[1] == 0x55 && buffer[2] == 0x54) 83 | { // PUT 84 | char *loc = strstr(buffer, "message="); 85 | loc += strlen("message="); 86 | if (write(serverFd, loc, strlen(loc)) < 0) 87 | { 88 | std::cout << "failed to write" << std::endl; 89 | } 90 | 91 | if (strcmp(loc, "%2F04") == 0) { 92 | break; 93 | } 94 | 95 | write(serverFd, "\n", 1); 96 | } 97 | } 98 | 99 | if (buffer[4] == 0x2F && buffer[5] == 0x20) 100 | { // Forward slash and space 101 | write(newSocket, HTTP_OK, sizeof(HTTP_OK) - 1); 102 | write(newSocket, CONTENT_TYPE_HTML, sizeof(CONTENT_TYPE_HTML) - 1); 103 | write_all(newSocket, index_page, sizeof(index_page)); 104 | } 105 | 106 | if (buffer[4] == 0x2F && buffer[5] == 0x73 && buffer[6] == 0x63 && buffer[7] == 0x72) 107 | { // Forward slash and scr 108 | write(newSocket, HTTP_OK, sizeof(HTTP_OK) - 1); 109 | write(newSocket, CONTENT_TYPE_JAVASCRIPT, sizeof(CONTENT_TYPE_JAVASCRIPT) - 1); 110 | write_all(newSocket, script, sizeof(script)); 111 | } 112 | 113 | if (buffer[4] == 0x2F && buffer[5] == 0x73 && buffer[6] == 0x74 && buffer[7] == 0x79) 114 | { // Forward slash and sty 115 | write(newSocket, HTTP_OK, sizeof(HTTP_OK) - 1); 116 | write(newSocket, CONTENT_TYPE_CSS, sizeof(CONTENT_TYPE_CSS) - 1); 117 | write_all(newSocket, style, sizeof(style)); 118 | } 119 | 120 | memset(buffer, 0, 4096); 121 | close(newSocket); 122 | newSocket = 0; 123 | } 124 | 125 | close(newSocket); 126 | } 127 | else 128 | { 129 | std::cout << "Running in stdin mode..." << std::endl; 130 | 131 | std::string input; 132 | while (std::cin >> input) 133 | { 134 | input += "\n"; 135 | if (write(serverFd, input.c_str(), strlen(input.c_str())) < 0) 136 | { 137 | std::cout << "Error writing input to server" << std::endl; 138 | } 139 | } 140 | } 141 | 142 | char buffer[4096] = {0}; 143 | if (read(serverFd, &buffer, 4096) < 0) 144 | { 145 | std::cout << "Error reading server message" << std::endl; 146 | } 147 | 148 | std::cout << buffer << std::endl; 149 | 150 | close(interfaceFd); 151 | close(serverFd); 152 | return 0; 153 | } 154 | 155 | ssize_t write_all(const int fd, unsigned char *buf, size_t n) 156 | { 157 | size_t total_written = 0; 158 | while (total_written < n) 159 | { 160 | size_t written = write(fd, buf + total_written, n - total_written); 161 | if (written < 0) 162 | return written; 163 | total_written += written; 164 | } 165 | return total_written; 166 | } -------------------------------------------------------------------------------- /examples/rust/tokio/http/src/enarx-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 42 | 44 | 45 | 47 | image/svg+xml 48 | 50 | 51 | 52 | 53 | 54 | 59 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /examples/rust/mio/echo-tcp/src/main.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | #![cfg(any(unix, target_os = "wasi"))] 4 | 5 | // modified version of https://github.com/tokio-rs/mio/blob/master/examples/tcp_server.rs 6 | 7 | use std::collections::HashMap; 8 | use std::io::{self, stdout, Read, Write}; 9 | #[cfg(unix)] 10 | use std::os::unix::io::FromRawFd; 11 | #[cfg(target_os = "wasi")] 12 | use std::os::wasi::io::FromRawFd; 13 | use std::str::from_utf8; 14 | 15 | use mio::event::Event; 16 | use mio::net::{TcpListener, TcpStream}; 17 | use mio::{Events, Interest, Poll, Registry, Token}; 18 | 19 | // Setup some tokens to allow us to identify which event is for which socket. 20 | const SERVER: Token = Token(0); 21 | 22 | // Some data we'll send over the connection. 23 | const DATA: &[u8] = b"Hello world!\n"; 24 | 25 | fn main() -> io::Result<()> { 26 | env_logger::init(); 27 | 28 | // Create a poll instance. 29 | let mut poll = Poll::new()?; 30 | // Create storage for events. 31 | let mut events = Events::with_capacity(128); 32 | 33 | std::env::var("FD_COUNT").map_err(|_| io::Error::from(io::ErrorKind::InvalidInput))?; 34 | 35 | // Setup the TCP server socket. 36 | let mut server = { 37 | let stdlistener = unsafe { std::net::TcpListener::from_raw_fd(3) }; 38 | stdlistener.set_nonblocking(true).unwrap(); 39 | println!("Using preopened socket FD 3"); 40 | println!("You can connect to the server using `nc`:"); 41 | match stdlistener.local_addr() { 42 | Ok(a) => println!(" $ nc {} {}", a.ip(), a.port()), 43 | Err(_) => println!(" $ nc "), 44 | } 45 | println!("You'll see our welcome message and anything you type will be printed here."); 46 | TcpListener::from_std(stdlistener) 47 | }; 48 | 49 | // Register the server with poll we can receive events for it. 50 | poll.registry() 51 | .register(&mut server, SERVER, Interest::READABLE)?; 52 | 53 | // Map of `Token` -> `TcpStream`. 54 | let mut connections = HashMap::new(); 55 | // Unique token for each incoming connection. 56 | let mut unique_token = Token(SERVER.0 + 1); 57 | 58 | loop { 59 | poll.poll(&mut events, None)?; 60 | 61 | for event in events.iter() { 62 | match event.token() { 63 | SERVER => loop { 64 | // Received an event for the TCP server socket, which 65 | // indicates we can accept an connection. 66 | let (mut connection, address) = match server.accept() { 67 | Ok((connection, address)) => (connection, address), 68 | Err(e) if e.kind() == io::ErrorKind::WouldBlock => { 69 | // If we get a `WouldBlock` error we know our 70 | // listener has no more incoming connections queued, 71 | // so we can return to polling and wait for some 72 | // more. 73 | break; 74 | } 75 | Err(e) => { 76 | // If it was any other kind of error, something went 77 | eprintln!("accept: Error {e:#?}"); 78 | break; 79 | } 80 | }; 81 | 82 | println!("Accepted connection from: {}", address); 83 | let token = next(&mut unique_token); 84 | poll.registry() 85 | .register(&mut connection, token, Interest::WRITABLE)?; 86 | 87 | connections.insert(token, connection); 88 | let _e = stdout().flush(); 89 | }, 90 | token => { 91 | // Maybe received an event for a TCP connection. 92 | let done = if let Some(connection) = connections.get_mut(&token) { 93 | match handle_connection_event(poll.registry(), connection, event) { 94 | Err(e) => { 95 | eprintln!("Error {e:#?} handling connection."); 96 | true 97 | } 98 | Ok(done) => done, 99 | } 100 | } else { 101 | // Sporadic events happen, we can safely ignore them. 102 | false 103 | }; 104 | if done { 105 | if let Some(mut connection) = connections.remove(&token) { 106 | poll.registry().deregister(&mut connection)?; 107 | } 108 | } 109 | let _e = stdout().flush(); 110 | } 111 | } 112 | } 113 | } 114 | } 115 | 116 | fn next(current: &mut Token) -> Token { 117 | let next = current.0; 118 | current.0 += 1; 119 | Token(next) 120 | } 121 | 122 | /// Returns `true` if the connection is done. 123 | fn handle_connection_event( 124 | registry: &Registry, 125 | connection: &mut TcpStream, 126 | event: &Event, 127 | ) -> io::Result { 128 | if event.is_writable() { 129 | // We can (maybe) write to the connection. 130 | match connection.write_all(DATA) { 131 | // We want to write the entire `DATA` buffer in a single go. If we 132 | // write less we'll return a short write error (same as 133 | // `io::Write::write_all` does). 134 | Ok(_) => { 135 | // After we've written something we'll reregister the connection 136 | // to only respond to readable events. 137 | registry.reregister(connection, event.token(), Interest::READABLE)? 138 | } 139 | // Would block "errors" are the OS's way of saying that the 140 | // connection is not actually ready to perform this I/O operation. 141 | Err(ref err) if would_block(err) => {} 142 | // Got interrupted (how rude!), we'll try again. 143 | Err(ref err) if interrupted(err) => { 144 | return handle_connection_event(registry, connection, event) 145 | } 146 | // Other errors we'll consider fatal. 147 | Err(err) => return Err(err), 148 | } 149 | } 150 | 151 | if event.is_readable() { 152 | let mut connection_closed = false; 153 | let mut received_data = vec![0; 4096]; 154 | let mut bytes_read = 0; 155 | // We can (maybe) read from the connection. 156 | loop { 157 | match connection.read(&mut received_data[bytes_read..]) { 158 | Ok(0) => { 159 | // Reading 0 bytes means the other side has closed the 160 | // connection or is done writing, then so are we. 161 | connection_closed = true; 162 | break; 163 | } 164 | Ok(n) => { 165 | // echo back what we received and ignore any errors while doing so 166 | let _ = connection.write_all(&received_data[bytes_read..(bytes_read + n)]); 167 | 168 | bytes_read += n; 169 | if bytes_read == received_data.len() { 170 | received_data.resize(received_data.len() + 1024, 0); 171 | } 172 | } 173 | // Would block "errors" are the OS's way of saying that the 174 | // connection is not actually ready to perform this I/O operation. 175 | Err(ref err) if would_block(err) => break, 176 | Err(ref err) if interrupted(err) => continue, 177 | // Other errors we'll consider fatal. 178 | Err(err) => return Err(err), 179 | } 180 | } 181 | 182 | if bytes_read != 0 { 183 | let received_data = &received_data[..bytes_read]; 184 | if let Ok(str_buf) = from_utf8(received_data) { 185 | println!("Received data: {}", str_buf.trim_end()); 186 | } else { 187 | println!("Received (none UTF-8) data: {:?}", received_data); 188 | } 189 | } 190 | 191 | if connection_closed { 192 | println!("Connection closed"); 193 | return Ok(true); 194 | } 195 | } 196 | 197 | Ok(false) 198 | } 199 | 200 | fn would_block(err: &io::Error) -> bool { 201 | err.kind() == io::ErrorKind::WouldBlock 202 | } 203 | 204 | fn interrupted(err: &io::Error) -> bool { 205 | err.kind() == io::ErrorKind::Interrupted 206 | } 207 | -------------------------------------------------------------------------------- /examples/rust/tokio/echo-tcp/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.1.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 10 | 11 | [[package]] 12 | name = "bytes" 13 | version = "1.2.1" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" 16 | 17 | [[package]] 18 | name = "cfg-if" 19 | version = "1.0.0" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 22 | 23 | [[package]] 24 | name = "libc" 25 | version = "0.2.153" 26 | source = "registry+https://github.com/rust-lang/crates.io-index" 27 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 28 | 29 | [[package]] 30 | name = "log" 31 | version = "0.4.17" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 34 | dependencies = [ 35 | "cfg-if", 36 | ] 37 | 38 | [[package]] 39 | name = "memchr" 40 | version = "2.5.0" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 43 | 44 | [[package]] 45 | name = "mio" 46 | version = "0.8.11" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" 49 | dependencies = [ 50 | "libc", 51 | "log", 52 | "wasi", 53 | "windows-sys 0.48.0", 54 | ] 55 | 56 | [[package]] 57 | name = "pin-project-lite" 58 | version = "0.2.9" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 61 | 62 | [[package]] 63 | name = "proc-macro2" 64 | version = "1.0.43" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" 67 | dependencies = [ 68 | "unicode-ident", 69 | ] 70 | 71 | [[package]] 72 | name = "quote" 73 | version = "1.0.21" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 76 | dependencies = [ 77 | "proc-macro2", 78 | ] 79 | 80 | [[package]] 81 | name = "socket2" 82 | version = "0.4.7" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" 85 | dependencies = [ 86 | "libc", 87 | "winapi", 88 | ] 89 | 90 | [[package]] 91 | name = "syn" 92 | version = "1.0.99" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" 95 | dependencies = [ 96 | "proc-macro2", 97 | "quote", 98 | "unicode-ident", 99 | ] 100 | 101 | [[package]] 102 | name = "tokio" 103 | version = "1.24.2" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" 106 | dependencies = [ 107 | "autocfg", 108 | "bytes", 109 | "libc", 110 | "memchr", 111 | "mio", 112 | "pin-project-lite", 113 | "socket2", 114 | "tokio-macros", 115 | "windows-sys 0.42.0", 116 | ] 117 | 118 | [[package]] 119 | name = "tokio-echo-tcp" 120 | version = "0.2.0" 121 | dependencies = [ 122 | "tokio", 123 | ] 124 | 125 | [[package]] 126 | name = "tokio-macros" 127 | version = "1.8.2" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" 130 | dependencies = [ 131 | "proc-macro2", 132 | "quote", 133 | "syn", 134 | ] 135 | 136 | [[package]] 137 | name = "unicode-ident" 138 | version = "1.0.3" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" 141 | 142 | [[package]] 143 | name = "wasi" 144 | version = "0.11.0+wasi-snapshot-preview1" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 147 | 148 | [[package]] 149 | name = "winapi" 150 | version = "0.3.9" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 153 | dependencies = [ 154 | "winapi-i686-pc-windows-gnu", 155 | "winapi-x86_64-pc-windows-gnu", 156 | ] 157 | 158 | [[package]] 159 | name = "winapi-i686-pc-windows-gnu" 160 | version = "0.4.0" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 163 | 164 | [[package]] 165 | name = "winapi-x86_64-pc-windows-gnu" 166 | version = "0.4.0" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 169 | 170 | [[package]] 171 | name = "windows-sys" 172 | version = "0.42.0" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 175 | dependencies = [ 176 | "windows_aarch64_gnullvm 0.42.1", 177 | "windows_aarch64_msvc 0.42.1", 178 | "windows_i686_gnu 0.42.1", 179 | "windows_i686_msvc 0.42.1", 180 | "windows_x86_64_gnu 0.42.1", 181 | "windows_x86_64_gnullvm 0.42.1", 182 | "windows_x86_64_msvc 0.42.1", 183 | ] 184 | 185 | [[package]] 186 | name = "windows-sys" 187 | version = "0.48.0" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 190 | dependencies = [ 191 | "windows-targets", 192 | ] 193 | 194 | [[package]] 195 | name = "windows-targets" 196 | version = "0.48.5" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 199 | dependencies = [ 200 | "windows_aarch64_gnullvm 0.48.5", 201 | "windows_aarch64_msvc 0.48.5", 202 | "windows_i686_gnu 0.48.5", 203 | "windows_i686_msvc 0.48.5", 204 | "windows_x86_64_gnu 0.48.5", 205 | "windows_x86_64_gnullvm 0.48.5", 206 | "windows_x86_64_msvc 0.48.5", 207 | ] 208 | 209 | [[package]] 210 | name = "windows_aarch64_gnullvm" 211 | version = "0.42.1" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" 214 | 215 | [[package]] 216 | name = "windows_aarch64_gnullvm" 217 | version = "0.48.5" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 220 | 221 | [[package]] 222 | name = "windows_aarch64_msvc" 223 | version = "0.42.1" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" 226 | 227 | [[package]] 228 | name = "windows_aarch64_msvc" 229 | version = "0.48.5" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 232 | 233 | [[package]] 234 | name = "windows_i686_gnu" 235 | version = "0.42.1" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" 238 | 239 | [[package]] 240 | name = "windows_i686_gnu" 241 | version = "0.48.5" 242 | source = "registry+https://github.com/rust-lang/crates.io-index" 243 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 244 | 245 | [[package]] 246 | name = "windows_i686_msvc" 247 | version = "0.42.1" 248 | source = "registry+https://github.com/rust-lang/crates.io-index" 249 | checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" 250 | 251 | [[package]] 252 | name = "windows_i686_msvc" 253 | version = "0.48.5" 254 | source = "registry+https://github.com/rust-lang/crates.io-index" 255 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 256 | 257 | [[package]] 258 | name = "windows_x86_64_gnu" 259 | version = "0.42.1" 260 | source = "registry+https://github.com/rust-lang/crates.io-index" 261 | checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" 262 | 263 | [[package]] 264 | name = "windows_x86_64_gnu" 265 | version = "0.48.5" 266 | source = "registry+https://github.com/rust-lang/crates.io-index" 267 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 268 | 269 | [[package]] 270 | name = "windows_x86_64_gnullvm" 271 | version = "0.42.1" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" 274 | 275 | [[package]] 276 | name = "windows_x86_64_gnullvm" 277 | version = "0.48.5" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 280 | 281 | [[package]] 282 | name = "windows_x86_64_msvc" 283 | version = "0.42.1" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" 286 | 287 | [[package]] 288 | name = "windows_x86_64_msvc" 289 | version = "0.48.5" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 292 | -------------------------------------------------------------------------------- /demos/fibonacci/c#/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/c++/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/c/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/go/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/java/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/ruby/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/rust/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /demos/fibonacci/zig/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------