wez             Tue Feb 18 04:46:18 2003 EDT

  Modified files:              
    /php4/ext/rpc/com   com.c variant.h 
  Log:
  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.
  
Index: php4/ext/rpc/com/com.c
diff -u php4/ext/rpc/com/com.c:1.23 php4/ext/rpc/com/com.c:1.24
--- php4/ext/rpc/com/com.c:1.23 Tue Feb 18 02:36:30 2003
+++ php4/ext/rpc/com/com.c      Tue Feb 18 04:46:18 2003
@@ -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 @@
        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 = {
@@ -829,6 +831,27 @@
 
 
 /* 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)
 {
Index: php4/ext/rpc/com/variant.h
diff -u php4/ext/rpc/com/variant.h:1.8 php4/ext/rpc/com/variant.h:1.9
--- php4/ext/rpc/com/variant.h:1.8      Mon Feb 10 15:58:53 2003
+++ php4/ext/rpc/com/variant.h  Tue Feb 18 04:46:18 2003
@@ -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);                                                        
                                                         \



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to