Re: [PHP4BETA] call_user_function() in PHP4
| From: | Andrei Zmievski | Date: | Fri, 28 Apr 2000 16:54:54 +0000 |
| Subject: | Re: [PHP4BETA] call_user_function() in PHP4 | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-14153@lists.php.net to get a copy of this message | ||
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.
-Andrei
* I don't have a solution but I admire the problem. *