11// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2- // SPDX-FileCopyrightText: 2020–2024 grommunio GmbH
2+ // SPDX-FileCopyrightText: 2020–2025 grommunio GmbH
33// This file is part of Gromox.
44#ifdef HAVE_CONFIG_H
55#include " config.h"
3737
3838ZEND_BEGIN_MODULE_GLOBALS (mapi)
3939 /* this is the global hresult value, used in *every* php mapi function */
40- unsigned long hr;
40+ ec_error_t hr;
4141 /* This is a reference to the MAPI exception class */
4242 zend_class_entry *exception_ce;
4343 zend_bool exceptions_enabled;
@@ -64,7 +64,7 @@ ZEND_END_MODULE_GLOBALS(mapi)
6464 do { \
6565 MAPI_G (hr) = (rv); \
6666 if (MAPI_G (exceptions_enabled)) \
67- zend_throw_exception (MAPI_G (exception_ce), mapi_strerror (MAPI_G (hr)), MAPI_G (hr)); \
67+ zend_throw_exception (MAPI_G (exception_ce), mapi_strerror (MAPI_G (hr)), static_cast < uint32_t >( MAPI_G (hr) )); \
6868 RETVAL_FALSE; \
6969 return ; \
7070 } while (false )
@@ -299,7 +299,7 @@ static void stream_object_free(STREAM_OBJECT *pstream)
299299 efree (pstream);
300300}
301301
302- static uint32_t stream_object_commit (STREAM_OBJECT *pstream)
302+ static ec_error_t stream_object_commit (STREAM_OBJECT *pstream)
303303{
304304 if (pstream->hsession == GUID_NULL || pstream->hparent == 0 || pstream->proptag == 0 )
305305 return ecInvalidParam;
@@ -336,7 +336,7 @@ static void notif_sink_free(NOTIF_SINK *psink)
336336 efree (psink);
337337}
338338
339- static uint32_t notif_sink_timedwait (NOTIF_SINK *psink,
339+ static ec_error_t notif_sink_timedwait (NOTIF_SINK *psink,
340340 uint32_t timeval, ZNOTIFICATION_ARRAY *pnotifications)
341341{
342342 if (0 == psink->count ) {
@@ -491,7 +491,7 @@ static PHP_RINIT_FUNCTION(mapi)
491491 zstrplus str_server (zend_string_init (ZEND_STRL (" _SERVER" ), 0 ));
492492 zstrplus str_user (zend_string_init (ZEND_STRL (" REMOTE_USER" ), 0 ));
493493
494- MAPI_G (hr) = 0 ;
494+ MAPI_G (hr) = ecSuccess ;
495495 MAPI_G (exception_ce) = NULL ;
496496 MAPI_G (exceptions_enabled) = 0 ;
497497 auto server_vars = zend_hash_find (&EG (symbol_table), str_server.get ());
@@ -540,7 +540,7 @@ static ZEND_FUNCTION(mapi_load_mapidefs)
540540
541541static ZEND_FUNCTION (mapi_last_hresult)
542542{
543- RETURN_LONG (MAPI_G (hr));
543+ RETURN_LONG (static_cast < uint32_t >( MAPI_G (hr) ));
544544}
545545
546546static ZEND_FUNCTION (mapi_prop_type)
@@ -1396,7 +1396,7 @@ static ZEND_FUNCTION(mapi_msgstore_getarchiveentryid)
13961396 MAPI_G (hr) = ecNotFound;
13971397 if (MAPI_G (exceptions_enabled))
13981398 zend_throw_exception (MAPI_G (exception_ce),
1399- " MAPI error " , MAPI_G (hr));
1399+ " MAPI error " , static_cast < uint32_t >( MAPI_G (hr) ));
14001400 RETVAL_FALSE;
14011401}
14021402
@@ -1532,7 +1532,7 @@ static ZEND_FUNCTION(mapi_sink_create)
15321532 RETVAL_FALSE;
15331533 if (MAPI_G (exceptions_enabled))
15341534 zend_throw_exception (MAPI_G (exception_ce),
1535- " MAPI error " , MAPI_G (hr));
1535+ " MAPI error " , static_cast < uint32_t >( MAPI_G (hr) ));
15361536 } else {
15371537 MAPI_G (hr) = ecSuccess;
15381538 RETVAL_RG (psink, le_mapi_advisesink);
@@ -2106,15 +2106,14 @@ static ZEND_FUNCTION(mapi_stream_setsize)
21062106static ZEND_FUNCTION (mapi_stream_commit)
21072107{
21082108 ZCL_MEMORY;
2109- uint32_t result;
21102109 zval *pzresource;
21112110 STREAM_OBJECT *pstream;
21122111
21132112 if (zend_parse_parameters (ZEND_NUM_ARGS (),
21142113 " r" , &pzresource) == FAILURE || NULL == pzresource)
21152114 pthrow (ecInvalidParam);
21162115 ZEND_FETCH_RESOURCE (pstream, pzresource, le_stream);
2117- result = stream_object_commit (pstream);
2116+ auto result = stream_object_commit (pstream);
21182117 if (result != ecSuccess)
21192118 pthrow (result);
21202119 RETVAL_TRUE;
@@ -3509,7 +3508,7 @@ static ZEND_FUNCTION(mapi_importcontentschanges_importmessagemove)
35093508 MAPI_G (hr) = NotImplemented;
35103509 if (MAPI_G (exceptions_enabled))
35113510 zend_throw_exception (MAPI_G (exception_ce),
3512- " MAPI error " , MAPI_G (hr));
3511+ " MAPI error " , static_cast < uint32_t >( MAPI_G (hr) ));
35133512 RETVAL_FALSE;
35143513}
35153514
@@ -4001,7 +4000,7 @@ static ZEND_FUNCTION(kc_session_restore)
40014000 }
40024001 auto result = zclient_checksession (hsession);
40034002 if (result != ecSuccess) {
4004- RETVAL_LONG (result);
4003+ RETVAL_LONG (static_cast < uint32_t >( result) );
40054004 return ;
40064005 }
40074006 presource = st_malloc<MAPI_RESOURCE>();
@@ -4132,7 +4131,7 @@ static ZEND_FUNCTION(mapi_strerror)
41324131 RETVAL_FALSE;
41334132 return ;
41344133 }
4135- auto s = mapi_strerror (code);
4134+ auto s = mapi_strerror (static_cast < ec_error_t >( static_cast < uint32_t >( code)) );
41364135 if (s == nullptr )
41374136 RETVAL_FALSE;
41384137 else
0 commit comments