Help with updating from PHP 5 to PHP 7

[email protected] (Benedikt Carda)
Newsgroups php.pecl.dev
Message-ID <[email protected]>
Hello,

I am not sure if it is o.k. to ask for help on this mailing list. 
Unfortunately at stackoverflow.com nobody who is familiar with 
php-extensions seems to be around.
I found this guide for upgrading PHP: 
https://wiki.php.net/phpng-upgrading. And I searched other packages to 
see how they did it. I managed that the package I try to update compiles 
without errors, but I get some warnings and one of those at least is 
still breaking the functionality of the package.

Here is the diff of one function I changed that now breaks. Can somebody 
tell me where I am wrong?

PHP_FUNCTION(scard_connect)
{
   DWORD dwPreferredProtocol = SCARD_PROTOCOL_T1|SCARD_PROTOCOL_T0;
   DWORD dwCurrentProtocol;
   SCARDHANDLE hCard = 0;
   LONG rc = 0;
   zval* ctx_res;
- zval* current_protocol;
+ zval current_protocol;
   SCARDCONTEXT context;
   char *strReaderName;
   int strReaderNameLen;

- MAKE_STD_ZVAL(current_protocol);
- ZVAL_LONG(current_protocol,0);
+ ZVAL_LONG(&current_protocol,0);

   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|lz", 
&ctx_res, &strReaderName, &strReaderNameLen, 
&dwPreferredProtocol,&current_protocol) == FAILURE) {
    RETURN_NULL();
   }

- 
ZEND_FETCH_RESOURCE(context,SCARDCONTEXT,&ctx_res,-1,PHP_PCSC_CTX_RES_NAME,le_pcsc_ctx_res);

+  if ((context = (SCARDCONTEXT)zend_fetch_resource(Z_RES_P(ctx_res), 
PHP_PCSC_CTX_RES_NAME, le_pcsc_ctx_res)) == NULL) {
+        RETURN_FALSE;
+  }

   rc = SCardConnect(context, strReaderName, SCARD_SHARE_SHARED, 
dwPreferredProtocol, &hCard, &dwCurrentProtocol);
   if (rc != SCARD_S_SUCCESS) {
     PCSC_G(last_errno)=rc;
     RETURN_FALSE;
   }
-  ZVAL_LONG(current_protocol,dwCurrentProtocol);
+ ZVAL_LONG(&current_protocol,dwCurrentProtocol);

- ZEND_REGISTER_RESOURCE(return_value,(void*)hCard,le_pcsc_conn_res);
+ RETURN_RES(zend_register_resource((void*)hCard,le_pcsc_conn_res));

}


Thanks in advance,
Benedikt.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.