Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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