Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php/pecl-php-ffi
Foreign Function Interface
https://github.com/php/pecl-php-ffi
Last synced: 5 days ago
JSON representation
Foreign Function Interface
- Host: GitHub
- URL: https://github.com/php/pecl-php-ffi
- Owner: php
- Created: 2016-12-12T00:23:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-12T00:24:31.000Z (almost 8 years ago)
- Last Synced: 2024-04-13T21:55:17.405Z (6 months ago)
- Language: C
- Homepage: https://pecl.php.net/package/ffi
- Size: 183 KB
- Stars: 11
- Watchers: 8
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
$Id$
Usage:
First you need to declare the functions and types that you will be using:
$win32_idl <<GetTickCount();
echo $ffi->MessageBoxA(0, "The tick count is " . $count, "Ticky Ticky", 1);Structures:
===========You can declare structures in your ffi IDL using C style syntax.
Structure support is read-only for the moment. You can pass structures
to functions and return them (these two examples work on linux):Passing structs:
gettimeofday($tv, $tz) );
printf("tv_sec=%d tv_usec=%d\n", $tv->tv_sec, $tv->tv_usec);
?>Returning Structs:
gethostbyname("localhost");
printf("h_length=%d h_name=%s\n", $he->h_length, $he->h_name);
?>Tips:
For functions that expect to copy/store memory into a buffer, use
str_repeat() to "allocate" room for that buffer.vim:tw=78:et