diff options
| author | Fuwn <[email protected]> | 2022-03-13 07:17:44 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-13 07:17:44 -0700 |
| commit | 58966d1102cc6baafd90269ab2523d3f6da98e55 (patch) | |
| tree | a48a0bef996bf2cef942a6d4a0b9ea23c668afe3 /examples/ffi.lua | |
| download | archived-senpy-ffi-58966d1102cc6baafd90269ab2523d3f6da98e55.tar.xz archived-senpy-ffi-58966d1102cc6baafd90269ab2523d3f6da98e55.zip | |
feat(senpy_ffi): 0.1.0 :star:
Diffstat (limited to 'examples/ffi.lua')
| -rw-r--r-- | examples/ffi.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/ffi.lua b/examples/ffi.lua new file mode 100644 index 0000000..b7f3a10 --- /dev/null +++ b/examples/ffi.lua @@ -0,0 +1,34 @@ +local ffi = require("ffi") + +local os = ffi.os +local extension + +if os == "Linux" then + extension = "so" +elseif os == "Windows" then + extension = "dll" +else + extension = "dylib" +end + +ffi.cdef[[ + int status(void); +]] + +local C = ffi.load("target/debug/senpy_ffi." .. extension) + +-- status +local c_status = C.status() +local status + +if c_status == 1 then + status = "up" +elseif c_status == 0 then + status = "down" +elseif c_status == -1 then + status = "not down, but unreachable" +else + status = "unknown" +end + +print("status: api.senpy.club is " .. status) |