From aad491817c36a3d4e189415d0f764bcc374817c5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 18 Feb 2003 09:46:19 +0000 Subject: [PATCH] Implement com_create_guid(). Add a special case for RETVAL_VARIANT when a variant is of type VT_DISPATCH but has a NULL dispatch pointer. This kind of variant is returned by the WindowsInstaller automation interface. --- ext/rpc/com/com.c | 23 +++++++++++++++++++++++ ext/rpc/com/variant.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/ext/rpc/com/com.c b/ext/rpc/com/com.c index 47efe7231f..9a8e40587b 100644 --- a/ext/rpc/com/com.c +++ b/ext/rpc/com/com.c @@ -34,6 +34,7 @@ static ZEND_FUNCTION(com_indexed_prop_set); +static ZEND_FUNCTION(com_create_guid); /* protos */ static int com_hash(rpc_string, rpc_string *, void *, int, char *, int); @@ -96,6 +97,7 @@ RPC_FUNCTION_ENTRY_BEGIN(com) ZEND_FE(com_load_typelib, NULL) ZEND_FE(com_print_typeinfo, NULL) ZEND_FE(com_indexed_prop_set, NULL) + ZEND_FE(com_create_guid, NULL) RPC_FUNCTION_ENTRY_END() zend_module_entry com_module_entry = { @@ -830,6 +832,27 @@ static int com_get_properties(HashTable **properties, void *data) /* custom functions */ +static ZEND_FUNCTION(com_create_guid) +{ + GUID retval; + OLECHAR *guid_string; + + if (ZEND_NUM_ARGS() != 0) { + ZEND_WRONG_PARAM_COUNT(); + } + + if (CoCreateGuid(&retval) && StringFromCLSID(&retval, &guid_string)) { + Z_TYPE_P(return_value) = IS_STRING; + Z_STRVAL_P(return_value) = php_OLECHAR_to_char(guid_string, &Z_STRLEN_P(return_value), CP_ACP, 0); + + CoTaskMemFree(guid_string); + } else { + RETURN_FALSE; + } +} + + + static ZEND_FUNCTION(com_indexed_prop_set) { zval *object; diff --git a/ext/rpc/com/variant.h b/ext/rpc/com/variant.h index 8d7a9bc6d6..e8c3539572 100644 --- a/ext/rpc/com/variant.h +++ b/ext/rpc/com/variant.h @@ -32,6 +32,9 @@ efree((v)); #define ZVAL_VARIANT(z, v, cp) \ + if (V_VT(v) == VT_DISPATCH && V_DISPATCH(v) == NULL) { \ + V_VT(v) = VT_NULL; \ + } \ if (V_VT(v) == VT_DISPATCH) { \ comval *obj; \ ALLOC_COM(obj); \ -- 2.50.1