Imported CRT FFI lib (#7)

* Added php7 library skeleton

* Re-worked Makefile.frag to use paths correctly

* Added gitignore for lib

* clang-format

* Remove symlinked api.h

* Copy api.h into lib/ as part of build
This commit is contained in:
Justin Boswell
2021-01-29 13:44:55 -08:00
committed by GitHub
parent c6fac2d99f
commit 3fed547551
6 changed files with 83 additions and 11 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
require_once('preload.php');
final class CRT {
private static $ffi = null;
function __construct() {
if (is_null(self::$ffi)) {
try {
self::$ffi = FFI::cdef(file_get_contents(__DIR__ . "/api.h"), __DIR__ . "/libaws-crt-ffi.so");
} catch (Exception $e) {
echo 'Exception: ', $e->getMessage(), "\n";
}
}
}
function init() {
return self::$ffi->aws_crt_init();
}
function clean_up() {
return self::$ffi->aws_crt_clean_up();
}
function last_error() {
return self::$ffi->aws_crt_last_error();
}
function error_str($error) {
return self::$ffi->aws_crt_error_str((int) $error);
}
function error_name($error) {
return self::$ffi->aws_crt_error_name((int) $error);
}
}