aboutsummaryrefslogtreecommitdiff
path: root/examples/ffi.php
blob: cf22c4a647304fac2b2e7e41f596c9a7c6472ddf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

$extension = (PHP_OS_FAMILY == "Darwin" ? "dylib" : "so");

$ffi = FFI::cdef(
  "int status(void);",
  "target/debug/libsenpy_ffi.$extension"
);

$c_status = $ffi->status();
$status;

if ($c_status == 1):
  $status = "up";
elseif ($c_status == 0):
  $status = "down";
elseif ($c_status == -1):
  $status = "not down, but unreachable";
else:
  $status = "unknown";
endif;

echo "status: api.senpy.club is " . $status . "\r\n";

?>