mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-18 01:57:13 +00:00
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:
+35
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user