Re: [PHP4BETA] call_user_function() in PHP4
| From: | Zeev Suraski | Date: | Fri, 28 Apr 2000 17:02:36 +0000 |
| Subject: | Re: [PHP4BETA] call_user_function() in PHP4 | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-14154@lists.php.net to get a copy of this message | ||
On Fri, 28 Apr 2000, Andrei Zmievski wrote:
> On Fri, 28 Apr 2000, Steve Langasek wrote:
> > Hi all,
> > I'm hoping someone here can help me with this problem.
> >
> > I've been trying to fix up php_pam (ftp://ftp.netexpress.net/pub/pam) to work
> > with PHP4. Everything seems to work just fine, except for one section of code
> > where I'm calling a user function from within PHP:
> >
> > {
> > pval conv_retval, msg_pval, resp_pval;
> > pval *args[2];
> >
> > if (array_init(&msg_pval) == FAILURE) {
> > php3_error( E_ERROR, "Couldn't initialize pam message array" );
> > return PAM_CONV_ERR;
> > }
> > if (array_init(&resp_pval) == FAILURE) {
> > php3_error( E_ERROR, "Couldn't initialize pam response array" );
> > return PAM_CONV_ERR;
> > }
> >
> > for (count=0; count < num_msg; ++count) {
> > add_next_index_long( &msg_pval, msgm[count]->msg_style );
> > add_next_index_string( &msg_pval, msgm[count]->msg, 1 );
> > }
> >
> > args[0] = &msg_pval;
> > args[1] = &resp_pval;
> >
> > if (call_user_function( CG(function_table), NULL,
> > &php_conv_func, &conv_retval, 2, args ) != SUCCESS)
> > {
> > goto failed_conversation;
> > }
> >
> > ...
> > }
>
> Oh, in addition the args array needs to be declared as:
>
> zval **args[2]
>
> because in PHP 4 call_user_function() needs an array of pointers to
> pointers to zval's. Accordingly, the whole functions needs to be
> rewritten to respect that.
Actually that's not true, the semantics of call_user_function() hasn't
changed. call_user_function_Ex() was introduced to implement a high
performance API.
Zeev
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/