Defining custom structs in skeleton
| From: | Yannick Warnier | Date: | Wed, 22 Sep 2004 19:38:57 +0000 |
| Subject: | Defining custom structs in skeleton | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-1373@lists.php.net to get a copy of this message | ||
Hi,
I am currently trying to get a C librabry into a PHP extension but I am
having problems when 'making' the auto-generated extension files.
I think the problem comes from the way I'm trying to use data types.
I followed the steps described in
http://talks.php.net/show/extending-php-apachecon2003
to define the
functions I'd like to use from the libssh library, create a .def file,
use ext_skel, update config.m4, configure...
Then "make" gives me plenty of errors like:
/tmp/ssh/ssh.c: In function `zif_open_session_channel':
/tmp/ssh/ssh.c:232: error: parse error before '?' token
/tmp/ssh/ssh.c:232: error: parse error before '?' token
It seems like the problem is the special data types definitions in
libssh. For example, I want to import this function:
SSH_SESSION *ssh_connect(SSH_OPTIONS *options);
Which uses SSH_SESSION and SSH_OPTIONS, both being structs defined
earlier in the libssh library.
And for this error case, I would like to use
CHANNEL *open_session_channel(SSH_SESSION *session,int window,int
maxpacket);
Which also uses SSH_SESSION.
The lines around 232 (indicated by >>>) in ssh.c are:
PHP_FUNCTION(open_session_channel)
{
int argc = ZEND_NUM_ARGS();
int session_id = -1;
long window;
long maxpacket;
zval *session = NULL;
if (zend_parse_parameters(argc TSRMLS_CC, "rll", &session, &window,
&maxpacket) == FAILURE)
return;
if (session) {
>>> ZEND_FETCH_RESOURCE(???, ???, session, session_id, "???",
???_rsrc_id); }
php_error(E_WARNING, "open_session_channel: not yet implemented");
}
I couldn't find any doc about this kind of "features" of
extension-making, so I didn't even try to declare those data types in my
definition file and have used "resource" instead of those SSH_SESSION
types.
Could someone point me out on some kind of doc or help me with this?
is in ssh.c:
Obviously I need to understand how custom data types can be defined in
my skeleton file, then maybe I will get things right in ssh.c.
Thanks,
Yannick