mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
merged from EXPERIMENTAL
lots of cleanup work
This commit is contained in:
parent
bb0858db34
commit
9c6b9eb76b
16 changed files with 1394 additions and 1116 deletions
504
ext/com/COM.c
504
ext/com/COM.c
File diff suppressed because it is too large
Load diff
|
@ -28,25 +28,20 @@
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
#include "variant.h"
|
|
||||||
#include "conversion.h"
|
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
|
#include "php_VARIANT.h"
|
||||||
|
|
||||||
#include <unknwn.h>
|
#include <unknwn.h>
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT);
|
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC);
|
||||||
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
static int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value);
|
||||||
|
static pval php_VARIANT_get_property_handler(zend_property_reference *property_reference);
|
||||||
int php_VARIANT_get_le_variant();
|
static void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
||||||
void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
static void php_VARIANT_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||||
pval php_VARIANT_get_property_handler(zend_property_reference *property_reference);
|
static void php_register_VARIANT_class(TSRMLS_D);
|
||||||
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value);
|
|
||||||
void php_register_VARIANT_class(TSRMLS_D);
|
|
||||||
static void php_variant_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
|
||||||
|
|
||||||
static int le_variant;
|
static int le_variant;
|
||||||
static int codepage;
|
static int codepage;
|
||||||
|
|
||||||
static zend_class_entry VARIANT_class_entry;
|
static zend_class_entry VARIANT_class_entry;
|
||||||
|
|
||||||
function_entry VARIANT_functions[] = {
|
function_entry VARIANT_functions[] = {
|
||||||
|
@ -66,7 +61,7 @@ zend_module_entry VARIANT_module_entry = {
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT)
|
PHP_MINIT_FUNCTION(VARIANT)
|
||||||
{
|
{
|
||||||
le_variant = zend_register_list_destructors_ex(php_variant_destructor, NULL, "VARIANT", module_number);
|
le_variant = zend_register_list_destructors_ex(php_VARIANT_destructor, NULL, "VARIANT", module_number);
|
||||||
|
|
||||||
/* variant datatypes */
|
/* variant datatypes */
|
||||||
REGISTER_LONG_CONSTANT("VT_NULL", VT_NULL, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("VT_NULL", VT_NULL, CONST_CS | CONST_PERSISTENT);
|
||||||
|
@ -97,10 +92,18 @@ PHP_MINIT_FUNCTION(VARIANT)
|
||||||
REGISTER_LONG_CONSTANT("CP_ACP", CP_ACP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_ACP", CP_ACP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_MACCP", CP_MACCP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_MACCP", CP_MACCP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
|
|
||||||
REGISTER_LONG_CONSTANT("CP_THREAD_ACP", CP_THREAD_ACP, CONST_CS | CONST_PERSISTENT);
|
|
||||||
REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#ifdef CP_SYMBOL
|
||||||
|
REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#else
|
||||||
|
# error "CP_SYMBOL undefined"
|
||||||
|
#endif
|
||||||
|
#ifdef CP_THREAD_ACP
|
||||||
|
REGISTER_LONG_CONSTANT("CP_THREAD_ACP", CP_THREAD_ACP, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#else
|
||||||
|
# error "CP_THREAD_ACP undefined"
|
||||||
|
#endif
|
||||||
|
|
||||||
php_register_VARIANT_class(TSRMLS_C);
|
php_register_VARIANT_class(TSRMLS_C);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@ -111,12 +114,12 @@ PHP_MSHUTDOWN_FUNCTION(VARIANT)
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int php_VARIANT_get_le_variant()
|
PHPAPI int php_VARIANT_get_le_variant()
|
||||||
{
|
{
|
||||||
return le_variant;
|
return le_variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
|
static void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
|
||||||
{
|
{
|
||||||
pval *object = property_reference->object;
|
pval *object = property_reference->object;
|
||||||
zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
|
zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
|
||||||
|
@ -137,17 +140,17 @@ void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
getParameters(ht, 1, &data);
|
getParameters(ht, 1, &data);
|
||||||
php_pval_to_variant(data, pVar, codepage);
|
php_pval_to_variant(data, pVar, codepage TSRMLS_CC);
|
||||||
codepage = CP_ACP;
|
codepage = CP_ACP;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
getParameters(ht, 2, &data, &type);
|
getParameters(ht, 2, &data, &type);
|
||||||
php_pval_to_variant_ex(data, pVar, type, codepage);
|
php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
|
||||||
codepage = CP_ACP;
|
codepage = CP_ACP;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
getParameters(ht, 3, &data, &type, &code_page);
|
getParameters(ht, 3, &data, &type, &code_page);
|
||||||
php_pval_to_variant_ex(data, pVar, type, codepage);
|
php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
|
||||||
convert_to_long(code_page);
|
convert_to_long(code_page);
|
||||||
codepage = code_page->value.lval;
|
codepage = code_page->value.lval;
|
||||||
break;
|
break;
|
||||||
|
@ -173,14 +176,14 @@ void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pval php_VARIANT_get_property_handler(zend_property_reference *property_reference)
|
||||||
pval php_VARIANT_get_property_handler(zend_property_reference *property_reference)
|
|
||||||
{
|
{
|
||||||
zend_overloaded_element *overloaded_property;
|
zend_overloaded_element *overloaded_property;
|
||||||
int type;
|
int type;
|
||||||
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
pval result, **var_handle, *object = property_reference->object;
|
pval result, **var_handle, *object = property_reference->object;
|
||||||
VARIANT *var_arg;
|
VARIANT *var_arg;
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
/* fetch the VARIANT structure */
|
/* fetch the VARIANT structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
||||||
|
@ -202,7 +205,7 @@ pval php_VARIANT_get_property_handler(zend_property_reference *property_referenc
|
||||||
case OE_IS_OBJECT:
|
case OE_IS_OBJECT:
|
||||||
if(!strcmp(overloaded_property->element.value.str.val, "value"))
|
if(!strcmp(overloaded_property->element.value.str.val, "value"))
|
||||||
{
|
{
|
||||||
php_variant_to_pval(var_arg, &result, 0, codepage);
|
php_variant_to_pval(var_arg, &result, 0, codepage TSRMLS_CC);
|
||||||
}
|
}
|
||||||
else if(!strcmp(Z_STRVAL(overloaded_property->element), "type"))
|
else if(!strcmp(Z_STRVAL(overloaded_property->element), "type"))
|
||||||
{
|
{
|
||||||
|
@ -226,13 +229,14 @@ pval php_VARIANT_get_property_handler(zend_property_reference *property_referenc
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value)
|
static int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value)
|
||||||
{
|
{
|
||||||
zend_overloaded_element *overloaded_property;
|
zend_overloaded_element *overloaded_property;
|
||||||
int type;
|
int type;
|
||||||
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
pval **var_handle, *object = property_reference->object;
|
pval **var_handle, *object = property_reference->object;
|
||||||
VARIANT *var_arg;
|
VARIANT *var_arg;
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
/* fetch the VARIANT structure */
|
/* fetch the VARIANT structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
||||||
|
@ -242,12 +246,12 @@ int php_VARIANT_set_property_handler(zend_property_reference *property_reference
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|
||||||
overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
|
overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
|
||||||
do_VARIANT_propset(var_arg, &overloaded_property->element, value);
|
do_VARIANT_propset(var_arg, &overloaded_property->element, value TSRMLS_CC);
|
||||||
zval_dtor(&overloaded_property->element);
|
zval_dtor(&overloaded_property->element);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value)
|
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
|
||||||
{
|
{
|
||||||
pval type;
|
pval type;
|
||||||
|
|
||||||
|
@ -415,17 +419,17 @@ static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value)
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_pval_to_variant_ex(value, var_arg, &type, codepage);
|
php_pval_to_variant_ex(value, var_arg, &type, codepage TSRMLS_CC);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void php_variant_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void php_VARIANT_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
{
|
{
|
||||||
efree(rsrc);
|
FREE_VARIANT(rsrc->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void php_register_VARIANT_class(TSRMLS_D)
|
static void php_register_VARIANT_class(TSRMLS_D)
|
||||||
{
|
{
|
||||||
INIT_OVERLOADED_CLASS_ENTRY(VARIANT_class_entry, "VARIANT", NULL,
|
INIT_OVERLOADED_CLASS_ENTRY(VARIANT_class_entry, "VARIANT", NULL,
|
||||||
php_VARIANT_call_function_handler,
|
php_VARIANT_call_function_handler,
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#include "oleauto.h"
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
|
#include <oleauto.h>
|
||||||
|
|
||||||
typedef struct comval_ {
|
typedef struct comval_ {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -19,6 +21,8 @@ typedef struct comval_ {
|
||||||
} i;
|
} i;
|
||||||
} comval;
|
} comval;
|
||||||
|
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
#define ZVAL_COM(z,o) { \
|
#define ZVAL_COM(z,o) { \
|
||||||
zval *handle; \
|
zval *handle; \
|
||||||
HashTable *properties; \
|
HashTable *properties; \
|
||||||
|
@ -32,14 +36,18 @@ typedef struct comval_ {
|
||||||
\
|
\
|
||||||
zval_copy_ctor(handle); \
|
zval_copy_ctor(handle); \
|
||||||
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
|
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
|
||||||
object_and_properties_init(z, &com_class_entry, properties); \
|
object_and_properties_init(z, &COM_class_entry, properties); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RETVAL_COM(o) ZVAL_COM(&return_value, o)
|
#define RETVAL_COM(o) ZVAL_COM(&return_value, o);
|
||||||
#define RETURN_COM(o) RETVAL_COM(o) \
|
#define RETURN_COM(o) RETVAL_COM(o) \
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval))
|
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval)); \
|
||||||
|
C_REFCOUNT(z) = 0;
|
||||||
|
|
||||||
|
#define FREE_COM(z) efree(z);
|
||||||
|
|
||||||
#define IS_COM php_COM_get_le_comval()
|
#define IS_COM php_COM_get_le_comval()
|
||||||
|
|
||||||
#define C_HASTLIB(x) ((x)->typelib)
|
#define C_HASTLIB(x) ((x)->typelib)
|
||||||
|
|
|
@ -37,12 +37,6 @@
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
|
|
||||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
|
|
||||||
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
|
|
||||||
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage);
|
|
||||||
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage);
|
|
||||||
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage);
|
|
||||||
|
|
||||||
static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
|
static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
|
||||||
static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
||||||
|
|
||||||
|
@ -50,7 +44,7 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
||||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
|
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
int type = VT_EMPTY; /* default variant type */
|
int type = VT_EMPTY; /* default variant type */
|
||||||
|
|
||||||
switch(Z_TYPE_P(pval_arg))
|
switch(Z_TYPE_P(pval_arg))
|
||||||
{
|
{
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
|
@ -64,7 +58,7 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
|
||||||
case IS_OBJECT:
|
case IS_OBJECT:
|
||||||
if(!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT"))
|
if(!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT"))
|
||||||
{
|
{
|
||||||
type = VT_VARIANT;
|
type = VT_VARIANT|VT_BYREF;
|
||||||
}
|
}
|
||||||
else if(!strcmp(Z_OBJCE_P(pval_arg)->name, "COM"))
|
else if(!strcmp(Z_OBJCE_P(pval_arg)->name, "COM"))
|
||||||
{
|
{
|
||||||
|
@ -93,10 +87,10 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
type = VT_BSTR;
|
type = VT_BSTR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pval_arg->is_ref) /* deprecated, implemented for downwards compatiblity */
|
if(pval_arg->is_ref) /* deprecated, implemented for downwards compatiblity */
|
||||||
{
|
{
|
||||||
type |= VT_BYREF;
|
type |= VT_BYREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,22 +110,22 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
V_VT(var_arg) = type;
|
V_VT(var_arg) = type;
|
||||||
|
|
||||||
if(V_VT(var_arg) & VT_ARRAY)
|
if(V_VT(var_arg) & VT_ARRAY)
|
||||||
{
|
{
|
||||||
/* For now we'll just handle single dimension arrays, we'll use the data type of the first element for the
|
/* For now we'll just handle single dimension arrays, we'll use the data type of the first element for the
|
||||||
output data type */
|
output data type */
|
||||||
HashTable *ht = Z_ARRVAL(*pval_arg);
|
HashTable *ht = Z_ARRVAL(*pval_arg);
|
||||||
int numberOfElements = zend_hash_num_elements(ht);
|
int numberOfElements = zend_hash_num_elements(ht);
|
||||||
SAFEARRAY *safeArray;
|
SAFEARRAY *safeArray;
|
||||||
SAFEARRAYBOUND bounds[1];
|
SAFEARRAYBOUND bounds[1];
|
||||||
VARIANT *v;
|
VARIANT *v;
|
||||||
zval **entry; /* An entry in the input array */
|
zval **entry; /* An entry in the input array */
|
||||||
|
|
||||||
type &= ~VT_ARRAY;
|
type &= ~VT_ARRAY;
|
||||||
|
|
||||||
if(V_VT(var_arg) == (VT_ARRAY|VT_BYREF)) /* == is intended, because VT_*|VT_BYREF|VT_ARRAY means something diffrent */
|
if(V_VT(var_arg) == (VT_ARRAY|VT_BYREF)) /* == is intended, because VT_*|VT_BYREF|VT_ARRAY means something diffrent */
|
||||||
{
|
{
|
||||||
type &= ~VT_BYREF;
|
type &= ~VT_BYREF;
|
||||||
ALLOC_VARIANT(V_VARIANTREF(var_arg));
|
ALLOC_VARIANT(V_VARIANTREF(var_arg));
|
||||||
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
|
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +135,7 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
|
|
||||||
if(NULL == safeArray)
|
if(NULL == safeArray)
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
|
php_error( E_WARNING,"Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
|
||||||
ZVAL_FALSE(pval_arg);
|
ZVAL_FALSE(pval_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -158,20 +152,20 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
if((zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) && (entry != NULL)) /* Get a pointer to the php array element */
|
if((zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) && (entry != NULL)) /* Get a pointer to the php array element */
|
||||||
{
|
{
|
||||||
/* Add another value to the safe array */
|
/* Add another value to the safe array */
|
||||||
if(SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v)))/* Pointer to output element entry retrieved successfully */
|
if(SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) /* Pointer to output element entry retrieved successfully */
|
||||||
{
|
{
|
||||||
if(type) /* explicit type */
|
if(type) /* explicit type */
|
||||||
{
|
{
|
||||||
pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
|
pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
|
php_error( E_WARNING,"phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zend_hash_move_forward(ht);
|
zend_hash_move_forward(ht);
|
||||||
|
@ -180,207 +174,210 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "phpArrayToSafeArray() - Unable to lock safeArray");
|
php_error( E_WARNING,"phpArrayToSafeArray() - Unable to lock safeArray");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(V_VT(var_arg))
|
switch(V_VT(var_arg))
|
||||||
{
|
{
|
||||||
case VT_UI1:
|
case VT_UI1:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI1(var_arg) = (unsigned char)Z_LVAL_P(pval_arg);
|
V_UI1(var_arg) = (unsigned char)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I2:
|
case VT_I2:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I2(var_arg) = (short)Z_LVAL_P(pval_arg);
|
V_I2(var_arg) = (short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I4:
|
case VT_I4:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I4(var_arg) = Z_LVAL_P(pval_arg);
|
V_I4(var_arg) = Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R4:
|
case VT_R4:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
V_R4(var_arg) = (float)Z_DVAL_P(pval_arg);
|
V_R4(var_arg) = (float)Z_DVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R8:
|
case VT_R8:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
V_R8(var_arg) = Z_DVAL_P(pval_arg);
|
V_R8(var_arg) = Z_DVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BOOL:
|
case VT_BOOL:
|
||||||
convert_to_boolean_ex(&pval_arg);
|
convert_to_boolean_ex(&pval_arg);
|
||||||
V_BOOL(var_arg) = (short)Z_LVAL_P(pval_arg);
|
V_BOOL(var_arg) = (short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_ERROR:
|
case VT_ERROR:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_ERROR(var_arg) = Z_LVAL_P(pval_arg);
|
V_ERROR(var_arg) = Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_CY:
|
case VT_CY:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
VarCyFromR8(Z_DVAL_P(pval_arg), &V_CY(var_arg));
|
VarCyFromR8(Z_DVAL_P(pval_arg), &V_CY(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DATE:
|
case VT_DATE:
|
||||||
{
|
{
|
||||||
SYSTEMTIME wintime;
|
SYSTEMTIME wintime;
|
||||||
struct tm *phptime;
|
struct tm *phptime;
|
||||||
|
|
||||||
phptime = gmtime(&(pval_arg->value.lval));
|
phptime = gmtime(&(pval_arg->value.lval));
|
||||||
memset(&wintime, 0, sizeof(wintime));
|
memset(&wintime, 0, sizeof(wintime));
|
||||||
|
|
||||||
wintime.wYear = phptime->tm_year + 1900;
|
wintime.wYear = phptime->tm_year + 1900;
|
||||||
wintime.wMonth = phptime->tm_mon + 1;
|
wintime.wMonth = phptime->tm_mon + 1;
|
||||||
wintime.wDay = phptime->tm_mday;
|
wintime.wDay = phptime->tm_mday;
|
||||||
wintime.wHour = phptime->tm_hour;
|
wintime.wHour = phptime->tm_hour;
|
||||||
wintime.wMinute = phptime->tm_min;
|
wintime.wMinute = phptime->tm_min;
|
||||||
wintime.wSecond = phptime->tm_sec;
|
wintime.wSecond = phptime->tm_sec;
|
||||||
|
|
||||||
SystemTimeToVariantTime(&wintime, &V_DATE(var_arg));
|
SystemTimeToVariantTime(&wintime, &V_DATE(var_arg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR:
|
case VT_BSTR:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
V_BSTR(var_arg) = SysAllocString(unicode_str);
|
V_BSTR(var_arg) = SysAllocString(unicode_str);
|
||||||
efree(unicode_str);
|
efree(unicode_str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DECIMAL:
|
case VT_DECIMAL:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, &V_DECIMAL(var_arg));
|
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, &V_DECIMAL(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DECIMAL|VT_BYREF:
|
case VT_DECIMAL|VT_BYREF:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, V_DECIMALREF(var_arg));
|
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, V_DECIMALREF(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UNKNOWN:
|
case VT_UNKNOWN:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_UNKNOWN;
|
V_VT(var_arg) = VT_UNKNOWN;
|
||||||
V_UNKNOWN(var_arg) = (IUnknown *) V_DISPATCH(var_arg);
|
V_UNKNOWN(var_arg) = (IUnknown *) V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DISPATCH:
|
case VT_DISPATCH:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI1|VT_BYREF:
|
case VT_UI1|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI1REF(var_arg) = (unsigned char FAR*) &Z_LVAL_P(pval_arg);
|
V_UI1REF(var_arg) = (unsigned char FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I2|VT_BYREF:
|
case VT_I2|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I2REF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
V_I2REF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I4|VT_BYREF:
|
case VT_I4|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I4REF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
V_I4REF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R4|VT_BYREF:
|
case VT_R4|VT_BYREF:
|
||||||
convert_to_double(pval_arg);
|
convert_to_double(pval_arg);
|
||||||
V_R4REF(var_arg) = (float FAR*) &Z_LVAL_P(pval_arg);
|
V_R4REF(var_arg) = (float FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R8|VT_BYREF:
|
case VT_R8|VT_BYREF:
|
||||||
convert_to_double(pval_arg);
|
convert_to_double(pval_arg);
|
||||||
V_R8REF(var_arg) = (double FAR*) &Z_LVAL_P(pval_arg);
|
V_R8REF(var_arg) = (double FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BOOL|VT_BYREF:
|
case VT_BOOL|VT_BYREF:
|
||||||
convert_to_boolean(pval_arg);
|
convert_to_boolean(pval_arg);
|
||||||
V_BOOLREF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
V_BOOLREF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_ERROR|VT_BYREF:
|
case VT_ERROR|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_ERRORREF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
V_ERRORREF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_CY|VT_BYREF:
|
case VT_CY|VT_BYREF:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
VarCyFromR8(pval_arg->value.dval, var_arg->pcyVal);
|
VarCyFromR8(pval_arg->value.dval, var_arg->pcyVal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DATE|VT_BYREF:
|
case VT_DATE|VT_BYREF:
|
||||||
{
|
{
|
||||||
SYSTEMTIME wintime;
|
SYSTEMTIME wintime;
|
||||||
struct tm *phptime;
|
struct tm *phptime;
|
||||||
|
|
||||||
phptime = gmtime(&(pval_arg->value.lval));
|
phptime = gmtime(&(pval_arg->value.lval));
|
||||||
memset(&wintime, 0, sizeof(wintime));
|
memset(&wintime, 0, sizeof(wintime));
|
||||||
|
|
||||||
wintime.wYear = phptime->tm_year + 1900;
|
wintime.wYear = phptime->tm_year + 1900;
|
||||||
wintime.wMonth = phptime->tm_mon + 1;
|
wintime.wMonth = phptime->tm_mon + 1;
|
||||||
wintime.wDay = phptime->tm_mday;
|
wintime.wDay = phptime->tm_mday;
|
||||||
wintime.wHour = phptime->tm_hour;
|
wintime.wHour = phptime->tm_hour;
|
||||||
wintime.wMinute = phptime->tm_min;
|
wintime.wMinute = phptime->tm_min;
|
||||||
wintime.wSecond = phptime->tm_sec;
|
wintime.wSecond = phptime->tm_sec;
|
||||||
|
|
||||||
SystemTimeToVariantTime(&wintime, var_arg->pdate);
|
SystemTimeToVariantTime(&wintime, var_arg->pdate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR|VT_BYREF:
|
case VT_BSTR|VT_BYREF:
|
||||||
convert_to_string(pval_arg);
|
convert_to_string(pval_arg);
|
||||||
V_BSTRREF(var_arg) = (BSTR FAR*) emalloc(sizeof(BSTR FAR*));
|
V_BSTRREF(var_arg) = (BSTR FAR*) emalloc(sizeof(BSTR FAR*));
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
*V_BSTRREF(var_arg) = SysAllocString(unicode_str);
|
*V_BSTRREF(var_arg) = SysAllocString(unicode_str);
|
||||||
efree(unicode_str);
|
efree(unicode_str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UNKNOWN|VT_BYREF:
|
case VT_UNKNOWN|VT_BYREF:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_UNKNOWN|VT_BYREF;
|
V_VT(var_arg) = VT_UNKNOWN|VT_BYREF;
|
||||||
V_UNKNOWNREF(var_arg) = (IUnknown **) &V_DISPATCH(var_arg);
|
V_UNKNOWNREF(var_arg) = (IUnknown **) &V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DISPATCH|VT_BYREF:
|
case VT_DISPATCH|VT_BYREF:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_DISPATCH|VT_BYREF;
|
V_VT(var_arg) = VT_DISPATCH|VT_BYREF;
|
||||||
V_DISPATCHREF(var_arg) = &V_DISPATCH(var_arg);
|
V_DISPATCHREF(var_arg) = &V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_VARIANT|VT_BYREF:
|
case VT_VARIANT:
|
||||||
|
php_error(E_WARNING,"VT_VARIANT is invalid. Use VT_VARIANT|VT_BYREF instead.");
|
||||||
|
/* break missing intentionally */
|
||||||
|
case VT_VARIANT|VT_BYREF:
|
||||||
{
|
{
|
||||||
int tp;
|
int tp;
|
||||||
pval **var_handle;
|
pval **var_handle;
|
||||||
|
@ -392,9 +389,9 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
V_VARIANTREF(var_arg) = (VARIANT FAR*) zend_list_find(Z_LVAL_P(*var_handle), &tp);
|
V_VARIANTREF(var_arg) = (VARIANT FAR*) zend_list_find(Z_LVAL_P(*var_handle), &tp);
|
||||||
|
|
||||||
if(!V_VARIANTREF(var_arg) && (tp != IS_VARIANT))
|
if(!V_VARIANTREF(var_arg) && (tp != IS_VARIANT))
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
should be, but isn't :)
|
should be, but isn't :)
|
||||||
|
@ -404,65 +401,65 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I1:
|
case VT_I1:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I1(var_arg) = (char)Z_LVAL_P(pval_arg);
|
V_I1(var_arg) = (char)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI2:
|
case VT_UI2:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI2(var_arg) = (unsigned short)Z_LVAL_P(pval_arg);
|
V_UI2(var_arg) = (unsigned short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI4:
|
case VT_UI4:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI4(var_arg) = (unsigned long)Z_LVAL_P(pval_arg);
|
V_UI4(var_arg) = (unsigned long)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_INT:
|
case VT_INT:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_INT(var_arg) = (int)Z_LVAL_P(pval_arg);
|
V_INT(var_arg) = (int)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UINT:
|
case VT_UINT:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UINT(var_arg) = (unsigned int)Z_LVAL_P(pval_arg);
|
V_UINT(var_arg) = (unsigned int)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I1|VT_BYREF:
|
case VT_I1|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I1REF(var_arg) = (char FAR*) &Z_LVAL_P(pval_arg);
|
V_I1REF(var_arg) = (char FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI2|VT_BYREF:
|
case VT_UI2|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI2REF(var_arg) = (unsigned short FAR*) &Z_LVAL_P(pval_arg);
|
V_UI2REF(var_arg) = (unsigned short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI4|VT_BYREF:
|
case VT_UI4|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI4REF(var_arg) = (unsigned long FAR*) &Z_LVAL_P(pval_arg);
|
V_UI4REF(var_arg) = (unsigned long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_INT|VT_BYREF:
|
case VT_INT|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_INTREF(var_arg) = (int FAR*) &Z_LVAL_P(pval_arg);
|
V_INTREF(var_arg) = (int FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UINT|VT_BYREF:
|
case VT_UINT|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UINTREF(var_arg) = (unsigned int FAR*) &Z_LVAL_P(pval_arg);
|
V_UINTREF(var_arg) = (unsigned int FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Type not supported or not yet implemented.");
|
php_error(E_WARNING, "Type not supported or not yet implemented.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage)
|
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
/* Changed the function to return a value for recursive error testing */
|
/* Changed the function to return a value for recursive error testing */
|
||||||
/* Existing calls will be unaffected by the change - so it */
|
/* Existing calls will be unaffected by the change - so it */
|
||||||
|
@ -488,7 +485,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
/* For now just validate that the SafeArray has one dimension */
|
/* For now just validate that the SafeArray has one dimension */
|
||||||
if (1 != (Dims = SafeArrayGetDim(array)))
|
if (1 != (Dims = SafeArrayGetDim(array)))
|
||||||
{
|
{
|
||||||
php_error(E_WARNING, "Unsupported: multi-dimensional (%d) SafeArrays", Dims);
|
php_error(E_WARNING,"Unsupported: multi-dimensional (%d) SafeArrays", Dims);
|
||||||
ZVAL_NULL(pval_arg);
|
ZVAL_NULL(pval_arg);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -529,18 +526,18 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
hr = SafeArrayGetElement(array, indices, (VOID *) &(vv.lVal));
|
hr = SafeArrayGetElement(array, indices, (VOID *) &(vv.lVal));
|
||||||
}
|
}
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
/* Failure to retieve an element probably means the array is sparse */
|
/* Failure to retieve an element probably means the array is sparse */
|
||||||
/* So leave the php array sparse too */
|
/* So leave the php array sparse too */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Create an element to be added to the array */
|
/* Create an element to be added to the array */
|
||||||
ALLOC_ZVAL(element);
|
ALLOC_ZVAL(element);
|
||||||
/* Call ourself again to handle the base type conversion */
|
/* Call ourself again to handle the base type conversion */
|
||||||
/* If SafeArrayGetElement proclaims to allocate */
|
/* If SafeArrayGetElement proclaims to allocate */
|
||||||
/* memory for a BSTR, so the recursive call frees */
|
/* memory for a BSTR, so the recursive call frees */
|
||||||
/* the string correctly */
|
/* the string correctly */
|
||||||
if (FAILURE == php_variant_to_pval(&vv, element, persistent, codepage))
|
if (FAILURE == php_variant_to_pval(&vv, element, persistent, codepage TSRMLS_CC))
|
||||||
{
|
{
|
||||||
/* Error occurred setting up array element */
|
/* Error occurred setting up array element */
|
||||||
/* Error was displayed by the recursive call */
|
/* Error was displayed by the recursive call */
|
||||||
|
@ -560,10 +557,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
add_index_zval(pval_arg, ii, element);
|
add_index_zval(pval_arg, ii, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SafeArrayUnlock(array);
|
SafeArrayUnlock(array);
|
||||||
/* Clean up the SafeArray since that is our responsibility */
|
|
||||||
SafeArrayDestroyData(array);
|
|
||||||
SafeArrayDestroyDescriptor(array);
|
|
||||||
}
|
}
|
||||||
else switch(var_arg->vt & ~VT_BYREF)
|
else switch(var_arg->vt & ~VT_BYREF)
|
||||||
{
|
{
|
||||||
|
@ -633,7 +627,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
switch(VarBstrFromDec(&V_DECIMAL(var_arg), LOCALE_SYSTEM_DEFAULT, 0, &unicode_str))
|
switch(VarBstrFromDec(&V_DECIMAL(var_arg), LOCALE_SYSTEM_DEFAULT, 0, &unicode_str))
|
||||||
{
|
{
|
||||||
case S_OK:
|
case S_OK:
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(unicode_str, &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(unicode_str, &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
Z_TYPE_P(pval_arg) = IS_STRING;
|
Z_TYPE_P(pval_arg) = IS_STRING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -676,20 +670,18 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_VARIANT:
|
case VT_VARIANT:
|
||||||
php_variant_to_pval(V_VARIANTREF(var_arg), pval_arg, persistent, codepage);
|
php_variant_to_pval(V_VARIANTREF(var_arg), pval_arg, persistent, codepage TSRMLS_CC);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR:
|
case VT_BSTR:
|
||||||
if(V_ISBYREF(var_arg))
|
if(V_ISBYREF(var_arg))
|
||||||
{
|
{
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(*V_BSTRREF(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(*V_BSTRREF(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
SysFreeString(*V_BSTRREF(var_arg));
|
|
||||||
efree(V_BSTRREF(var_arg));
|
efree(V_BSTRREF(var_arg));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(V_BSTR(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(V_BSTR(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
SysFreeString(V_BSTR(var_arg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_TYPE_P(pval_arg) = IS_STRING;
|
Z_TYPE_P(pval_arg) = IS_STRING;
|
||||||
|
@ -739,8 +731,8 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
{
|
{
|
||||||
char *error_message;
|
char *error_message;
|
||||||
|
|
||||||
error_message = php_COM_error_message(hr);
|
error_message = php_COM_error_message(hr TSRMLS_CC);
|
||||||
php_error(E_WARNING, "Unable to obtain IDispatch interface: %s", error_message);
|
php_error(E_WARNING,"Unable to obtain IDispatch interface: %s", error_message);
|
||||||
LocalFree(error_message);
|
LocalFree(error_message);
|
||||||
|
|
||||||
V_DISPATCH(var_arg) = NULL;
|
V_DISPATCH(var_arg) = NULL;
|
||||||
|
@ -758,11 +750,9 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
ALLOC_COM(obj);
|
ALLOC_COM(obj);
|
||||||
php_COM_set(obj, V_DISPATCH(var_arg), TRUE);
|
php_COM_set(obj, &V_DISPATCH(var_arg), TRUE TSRMLS_CC);
|
||||||
|
|
||||||
ZVAL_COM(pval_arg, obj);
|
ZVAL_COM(pval_arg, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -824,7 +814,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
|
php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
|
||||||
ZVAL_NULL(pval_arg);
|
ZVAL_NULL(pval_arg);
|
||||||
ret = FAILURE;
|
ret = FAILURE;
|
||||||
break;
|
break;
|
||||||
|
@ -832,7 +822,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage)
|
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
OLECHAR *unicode_str;
|
OLECHAR *unicode_str;
|
||||||
|
|
||||||
|
@ -854,17 +844,17 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage)
|
||||||
switch(GetLastError())
|
switch(GetLastError())
|
||||||
{
|
{
|
||||||
case ERROR_NO_UNICODE_TRANSLATION:
|
case ERROR_NO_UNICODE_TRANSLATION:
|
||||||
php_error(E_WARNING, "No unicode translation available for the specified string");
|
php_error(E_WARNING,"No unicode translation available for the specified string");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Error in php_char_to_OLECHAR()");
|
php_error(E_WARNING,"Error in php_char_to_OLECHAR()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return unicode_str;
|
return unicode_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage)
|
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *C_str;
|
char *C_str;
|
||||||
uint length = 0;
|
uint length = 0;
|
||||||
|
@ -884,7 +874,7 @@ PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int per
|
||||||
C_str = (char *) pemalloc(sizeof(char), persistent);
|
C_str = (char *) pemalloc(sizeof(char), persistent);
|
||||||
*C_str = 0;
|
*C_str = 0;
|
||||||
|
|
||||||
php_error(E_WARNING, "Error in php_OLECHAR_to_char()");
|
php_error(E_WARNING,"Error in php_OLECHAR_to_char()");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(out_length)
|
if(out_length)
|
||||||
|
@ -903,7 +893,7 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC)
|
||||||
|
|
||||||
/* fetch the comval structure */
|
/* fetch the comval structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &comval_handle);
|
zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &comval_handle);
|
||||||
obj = (comval *) zend_list_find(Z_LVAL_P(*comval_handle), &type);
|
obj = (comval *)zend_list_find(Z_LVAL_P(*comval_handle), &type);
|
||||||
if(!obj || (type != IS_COM) || !C_ISREFD(obj))
|
if(!obj || (type != IS_COM) || !C_ISREFD(obj))
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
|
@ -915,4 +905,4 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PHP_WIN32 */
|
#endif /* PHP_WIN32 */
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
BEGIN_EXTERN_C()
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
extern void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage);
|
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
|
||||||
extern void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage);
|
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
|
||||||
extern int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage);
|
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage TSRMLS_DC);
|
||||||
extern OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage);
|
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
|
||||||
extern char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage);
|
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage TSRMLS_DC);
|
||||||
|
|
||||||
END_EXTERN_C()
|
END_EXTERN_C()
|
||||||
|
|
||||||
|
|
|
@ -10,22 +10,30 @@ BEGIN_EXTERN_C()
|
||||||
PHP_MINIT_FUNCTION(COM);
|
PHP_MINIT_FUNCTION(COM);
|
||||||
PHP_MSHUTDOWN_FUNCTION(COM);
|
PHP_MSHUTDOWN_FUNCTION(COM);
|
||||||
|
|
||||||
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult);
|
PHP_FUNCTION(com_load);
|
||||||
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId);
|
PHP_FUNCTION(com_invoke);
|
||||||
PHPAPI HRESULT php_COM_release(comval *obj);
|
PHP_FUNCTION(com_addref);
|
||||||
PHPAPI HRESULT php_COM_addref(comval *obj);
|
PHP_FUNCTION(com_release);
|
||||||
PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* pDisp, int cleanup);
|
PHP_FUNCTION(com_propget);
|
||||||
PHPAPI HRESULT php_COM_clone(comval *obj, comval *clone, int cleanup);
|
PHP_FUNCTION(com_propput);
|
||||||
|
PHP_FUNCTION(com_load_typelib);
|
||||||
|
PHP_FUNCTION(com_isenum);
|
||||||
|
|
||||||
int php_COM_get_le_comval();
|
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, char **ErrString TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_release(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_addref(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_destruct(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* pDisp, int cleanup TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_clone(comval *obj, comval *clone, int cleanup TSRMLS_DC);
|
||||||
|
PHPAPI char *php_COM_error_message(HRESULT hr TSRMLS_DC);
|
||||||
|
PHPAPI int php_COM_get_le_comval();
|
||||||
|
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
|
||||||
|
PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_reference);
|
||||||
|
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
||||||
|
|
||||||
zend_module_entry COM_module_entry;
|
zend_module_entry COM_module_entry;
|
||||||
zend_class_entry com_class_entry;
|
zend_class_entry COM_class_entry;
|
||||||
|
|
||||||
pval php_COM_get_property_handler(zend_property_reference *property_reference);
|
|
||||||
int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
|
|
||||||
char *php_COM_error_message(HRESULT hr);
|
|
||||||
void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern int resourcecounter;
|
extern int resourcecounter;
|
||||||
|
|
|
@ -3,14 +3,19 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#include "variant.h"
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
extern int php_VARIANT_get_le_variant();
|
#include "conversion.h"
|
||||||
|
#include "variant.h"
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT);
|
PHP_MINIT_FUNCTION(VARIANT);
|
||||||
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
||||||
|
|
||||||
extern zend_module_entry VARIANT_module_entry;
|
PHPAPI int php_VARIANT_get_le_variant();
|
||||||
|
|
||||||
|
zend_module_entry VARIANT_module_entry;
|
||||||
|
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
#define VARIANT_module_ptr &VARIANT_module_entry
|
#define VARIANT_module_ptr &VARIANT_module_entry
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,13 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#define ALLOC_VARIANT(v) (v) = (VARIANT *) emalloc(sizeof(VARIANT))
|
#define ALLOC_VARIANT(v) (v) = (VARIANT *) emalloc(sizeof(VARIANT)); \
|
||||||
|
VariantInit(v);
|
||||||
|
|
||||||
|
#define FREE_VARIANT(v) VariantClear(v); \
|
||||||
|
efree(v);
|
||||||
|
|
||||||
|
|
||||||
#define IS_VARIANT php_VARIANT_get_le_variant()
|
#define IS_VARIANT php_VARIANT_get_le_variant()
|
||||||
|
|
||||||
#endif /* PHP_WIN32 */
|
#endif /* PHP_WIN32 */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#include "oleauto.h"
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
|
#include <oleauto.h>
|
||||||
|
|
||||||
typedef struct comval_ {
|
typedef struct comval_ {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -19,6 +21,8 @@ typedef struct comval_ {
|
||||||
} i;
|
} i;
|
||||||
} comval;
|
} comval;
|
||||||
|
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
#define ZVAL_COM(z,o) { \
|
#define ZVAL_COM(z,o) { \
|
||||||
zval *handle; \
|
zval *handle; \
|
||||||
HashTable *properties; \
|
HashTable *properties; \
|
||||||
|
@ -32,14 +36,18 @@ typedef struct comval_ {
|
||||||
\
|
\
|
||||||
zval_copy_ctor(handle); \
|
zval_copy_ctor(handle); \
|
||||||
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
|
zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
|
||||||
object_and_properties_init(z, &com_class_entry, properties); \
|
object_and_properties_init(z, &COM_class_entry, properties); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RETVAL_COM(o) ZVAL_COM(&return_value, o)
|
#define RETVAL_COM(o) ZVAL_COM(&return_value, o);
|
||||||
#define RETURN_COM(o) RETVAL_COM(o) \
|
#define RETURN_COM(o) RETVAL_COM(o) \
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval))
|
#define ALLOC_COM(z) (z) = (comval *) emalloc(sizeof(comval)); \
|
||||||
|
C_REFCOUNT(z) = 0;
|
||||||
|
|
||||||
|
#define FREE_COM(z) efree(z);
|
||||||
|
|
||||||
#define IS_COM php_COM_get_le_comval()
|
#define IS_COM php_COM_get_le_comval()
|
||||||
|
|
||||||
#define C_HASTLIB(x) ((x)->typelib)
|
#define C_HASTLIB(x) ((x)->typelib)
|
||||||
|
|
|
@ -37,12 +37,6 @@
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
|
|
||||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
|
|
||||||
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
|
|
||||||
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage);
|
|
||||||
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage);
|
|
||||||
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage);
|
|
||||||
|
|
||||||
static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
|
static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
|
||||||
static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
||||||
|
|
||||||
|
@ -50,7 +44,7 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
|
||||||
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
|
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
int type = VT_EMPTY; /* default variant type */
|
int type = VT_EMPTY; /* default variant type */
|
||||||
|
|
||||||
switch(Z_TYPE_P(pval_arg))
|
switch(Z_TYPE_P(pval_arg))
|
||||||
{
|
{
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
|
@ -64,7 +58,7 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
|
||||||
case IS_OBJECT:
|
case IS_OBJECT:
|
||||||
if(!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT"))
|
if(!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT"))
|
||||||
{
|
{
|
||||||
type = VT_VARIANT;
|
type = VT_VARIANT|VT_BYREF;
|
||||||
}
|
}
|
||||||
else if(!strcmp(Z_OBJCE_P(pval_arg)->name, "COM"))
|
else if(!strcmp(Z_OBJCE_P(pval_arg)->name, "COM"))
|
||||||
{
|
{
|
||||||
|
@ -93,10 +87,10 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
|
||||||
case IS_STRING:
|
case IS_STRING:
|
||||||
type = VT_BSTR;
|
type = VT_BSTR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pval_arg->is_ref) /* deprecated, implemented for downwards compatiblity */
|
if(pval_arg->is_ref) /* deprecated, implemented for downwards compatiblity */
|
||||||
{
|
{
|
||||||
type |= VT_BYREF;
|
type |= VT_BYREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,22 +110,22 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
V_VT(var_arg) = type;
|
V_VT(var_arg) = type;
|
||||||
|
|
||||||
if(V_VT(var_arg) & VT_ARRAY)
|
if(V_VT(var_arg) & VT_ARRAY)
|
||||||
{
|
{
|
||||||
/* For now we'll just handle single dimension arrays, we'll use the data type of the first element for the
|
/* For now we'll just handle single dimension arrays, we'll use the data type of the first element for the
|
||||||
output data type */
|
output data type */
|
||||||
HashTable *ht = Z_ARRVAL(*pval_arg);
|
HashTable *ht = Z_ARRVAL(*pval_arg);
|
||||||
int numberOfElements = zend_hash_num_elements(ht);
|
int numberOfElements = zend_hash_num_elements(ht);
|
||||||
SAFEARRAY *safeArray;
|
SAFEARRAY *safeArray;
|
||||||
SAFEARRAYBOUND bounds[1];
|
SAFEARRAYBOUND bounds[1];
|
||||||
VARIANT *v;
|
VARIANT *v;
|
||||||
zval **entry; /* An entry in the input array */
|
zval **entry; /* An entry in the input array */
|
||||||
|
|
||||||
type &= ~VT_ARRAY;
|
type &= ~VT_ARRAY;
|
||||||
|
|
||||||
if(V_VT(var_arg) == (VT_ARRAY|VT_BYREF)) /* == is intended, because VT_*|VT_BYREF|VT_ARRAY means something diffrent */
|
if(V_VT(var_arg) == (VT_ARRAY|VT_BYREF)) /* == is intended, because VT_*|VT_BYREF|VT_ARRAY means something diffrent */
|
||||||
{
|
{
|
||||||
type &= ~VT_BYREF;
|
type &= ~VT_BYREF;
|
||||||
ALLOC_VARIANT(V_VARIANTREF(var_arg));
|
ALLOC_VARIANT(V_VARIANTREF(var_arg));
|
||||||
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
|
var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +135,7 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
|
|
||||||
if(NULL == safeArray)
|
if(NULL == safeArray)
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
|
php_error( E_WARNING,"Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
|
||||||
ZVAL_FALSE(pval_arg);
|
ZVAL_FALSE(pval_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -158,20 +152,20 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
if((zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) && (entry != NULL)) /* Get a pointer to the php array element */
|
if((zend_hash_get_current_data(ht, (void **)&entry) == SUCCESS) && (entry != NULL)) /* Get a pointer to the php array element */
|
||||||
{
|
{
|
||||||
/* Add another value to the safe array */
|
/* Add another value to the safe array */
|
||||||
if(SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v)))/* Pointer to output element entry retrieved successfully */
|
if(SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) /* Pointer to output element entry retrieved successfully */
|
||||||
{
|
{
|
||||||
if(type) /* explicit type */
|
if(type) /* explicit type */
|
||||||
{
|
{
|
||||||
pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
|
pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
|
php_error( E_WARNING,"phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zend_hash_move_forward(ht);
|
zend_hash_move_forward(ht);
|
||||||
|
@ -180,207 +174,210 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
php_error( E_WARNING, "phpArrayToSafeArray() - Unable to lock safeArray");
|
php_error( E_WARNING,"phpArrayToSafeArray() - Unable to lock safeArray");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(V_VT(var_arg))
|
switch(V_VT(var_arg))
|
||||||
{
|
{
|
||||||
case VT_UI1:
|
case VT_UI1:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI1(var_arg) = (unsigned char)Z_LVAL_P(pval_arg);
|
V_UI1(var_arg) = (unsigned char)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I2:
|
case VT_I2:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I2(var_arg) = (short)Z_LVAL_P(pval_arg);
|
V_I2(var_arg) = (short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I4:
|
case VT_I4:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I4(var_arg) = Z_LVAL_P(pval_arg);
|
V_I4(var_arg) = Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R4:
|
case VT_R4:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
V_R4(var_arg) = (float)Z_DVAL_P(pval_arg);
|
V_R4(var_arg) = (float)Z_DVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R8:
|
case VT_R8:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
V_R8(var_arg) = Z_DVAL_P(pval_arg);
|
V_R8(var_arg) = Z_DVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BOOL:
|
case VT_BOOL:
|
||||||
convert_to_boolean_ex(&pval_arg);
|
convert_to_boolean_ex(&pval_arg);
|
||||||
V_BOOL(var_arg) = (short)Z_LVAL_P(pval_arg);
|
V_BOOL(var_arg) = (short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_ERROR:
|
case VT_ERROR:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_ERROR(var_arg) = Z_LVAL_P(pval_arg);
|
V_ERROR(var_arg) = Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_CY:
|
case VT_CY:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
VarCyFromR8(Z_DVAL_P(pval_arg), &V_CY(var_arg));
|
VarCyFromR8(Z_DVAL_P(pval_arg), &V_CY(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DATE:
|
case VT_DATE:
|
||||||
{
|
{
|
||||||
SYSTEMTIME wintime;
|
SYSTEMTIME wintime;
|
||||||
struct tm *phptime;
|
struct tm *phptime;
|
||||||
|
|
||||||
phptime = gmtime(&(pval_arg->value.lval));
|
phptime = gmtime(&(pval_arg->value.lval));
|
||||||
memset(&wintime, 0, sizeof(wintime));
|
memset(&wintime, 0, sizeof(wintime));
|
||||||
|
|
||||||
wintime.wYear = phptime->tm_year + 1900;
|
wintime.wYear = phptime->tm_year + 1900;
|
||||||
wintime.wMonth = phptime->tm_mon + 1;
|
wintime.wMonth = phptime->tm_mon + 1;
|
||||||
wintime.wDay = phptime->tm_mday;
|
wintime.wDay = phptime->tm_mday;
|
||||||
wintime.wHour = phptime->tm_hour;
|
wintime.wHour = phptime->tm_hour;
|
||||||
wintime.wMinute = phptime->tm_min;
|
wintime.wMinute = phptime->tm_min;
|
||||||
wintime.wSecond = phptime->tm_sec;
|
wintime.wSecond = phptime->tm_sec;
|
||||||
|
|
||||||
SystemTimeToVariantTime(&wintime, &V_DATE(var_arg));
|
SystemTimeToVariantTime(&wintime, &V_DATE(var_arg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR:
|
case VT_BSTR:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
V_BSTR(var_arg) = SysAllocString(unicode_str);
|
V_BSTR(var_arg) = SysAllocString(unicode_str);
|
||||||
efree(unicode_str);
|
efree(unicode_str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DECIMAL:
|
case VT_DECIMAL:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, &V_DECIMAL(var_arg));
|
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, &V_DECIMAL(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DECIMAL|VT_BYREF:
|
case VT_DECIMAL|VT_BYREF:
|
||||||
convert_to_string_ex(&pval_arg);
|
convert_to_string_ex(&pval_arg);
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, V_DECIMALREF(var_arg));
|
VarDecFromStr(unicode_str, LOCALE_SYSTEM_DEFAULT, 0, V_DECIMALREF(var_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UNKNOWN:
|
case VT_UNKNOWN:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_UNKNOWN;
|
V_VT(var_arg) = VT_UNKNOWN;
|
||||||
V_UNKNOWN(var_arg) = (IUnknown *) V_DISPATCH(var_arg);
|
V_UNKNOWN(var_arg) = (IUnknown *) V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DISPATCH:
|
case VT_DISPATCH:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI1|VT_BYREF:
|
case VT_UI1|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI1REF(var_arg) = (unsigned char FAR*) &Z_LVAL_P(pval_arg);
|
V_UI1REF(var_arg) = (unsigned char FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I2|VT_BYREF:
|
case VT_I2|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I2REF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
V_I2REF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I4|VT_BYREF:
|
case VT_I4|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I4REF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
V_I4REF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R4|VT_BYREF:
|
case VT_R4|VT_BYREF:
|
||||||
convert_to_double(pval_arg);
|
convert_to_double(pval_arg);
|
||||||
V_R4REF(var_arg) = (float FAR*) &Z_LVAL_P(pval_arg);
|
V_R4REF(var_arg) = (float FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_R8|VT_BYREF:
|
case VT_R8|VT_BYREF:
|
||||||
convert_to_double(pval_arg);
|
convert_to_double(pval_arg);
|
||||||
V_R8REF(var_arg) = (double FAR*) &Z_LVAL_P(pval_arg);
|
V_R8REF(var_arg) = (double FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BOOL|VT_BYREF:
|
case VT_BOOL|VT_BYREF:
|
||||||
convert_to_boolean(pval_arg);
|
convert_to_boolean(pval_arg);
|
||||||
V_BOOLREF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
V_BOOLREF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_ERROR|VT_BYREF:
|
case VT_ERROR|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_ERRORREF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
V_ERRORREF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_CY|VT_BYREF:
|
case VT_CY|VT_BYREF:
|
||||||
convert_to_double_ex(&pval_arg);
|
convert_to_double_ex(&pval_arg);
|
||||||
VarCyFromR8(pval_arg->value.dval, var_arg->pcyVal);
|
VarCyFromR8(pval_arg->value.dval, var_arg->pcyVal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DATE|VT_BYREF:
|
case VT_DATE|VT_BYREF:
|
||||||
{
|
{
|
||||||
SYSTEMTIME wintime;
|
SYSTEMTIME wintime;
|
||||||
struct tm *phptime;
|
struct tm *phptime;
|
||||||
|
|
||||||
phptime = gmtime(&(pval_arg->value.lval));
|
phptime = gmtime(&(pval_arg->value.lval));
|
||||||
memset(&wintime, 0, sizeof(wintime));
|
memset(&wintime, 0, sizeof(wintime));
|
||||||
|
|
||||||
wintime.wYear = phptime->tm_year + 1900;
|
wintime.wYear = phptime->tm_year + 1900;
|
||||||
wintime.wMonth = phptime->tm_mon + 1;
|
wintime.wMonth = phptime->tm_mon + 1;
|
||||||
wintime.wDay = phptime->tm_mday;
|
wintime.wDay = phptime->tm_mday;
|
||||||
wintime.wHour = phptime->tm_hour;
|
wintime.wHour = phptime->tm_hour;
|
||||||
wintime.wMinute = phptime->tm_min;
|
wintime.wMinute = phptime->tm_min;
|
||||||
wintime.wSecond = phptime->tm_sec;
|
wintime.wSecond = phptime->tm_sec;
|
||||||
|
|
||||||
SystemTimeToVariantTime(&wintime, var_arg->pdate);
|
SystemTimeToVariantTime(&wintime, var_arg->pdate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR|VT_BYREF:
|
case VT_BSTR|VT_BYREF:
|
||||||
convert_to_string(pval_arg);
|
convert_to_string(pval_arg);
|
||||||
V_BSTRREF(var_arg) = (BSTR FAR*) emalloc(sizeof(BSTR FAR*));
|
V_BSTRREF(var_arg) = (BSTR FAR*) emalloc(sizeof(BSTR FAR*));
|
||||||
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage);
|
unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
|
||||||
*V_BSTRREF(var_arg) = SysAllocString(unicode_str);
|
*V_BSTRREF(var_arg) = SysAllocString(unicode_str);
|
||||||
efree(unicode_str);
|
efree(unicode_str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UNKNOWN|VT_BYREF:
|
case VT_UNKNOWN|VT_BYREF:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_UNKNOWN|VT_BYREF;
|
V_VT(var_arg) = VT_UNKNOWN|VT_BYREF;
|
||||||
V_UNKNOWNREF(var_arg) = (IUnknown **) &V_DISPATCH(var_arg);
|
V_UNKNOWNREF(var_arg) = (IUnknown **) &V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_DISPATCH|VT_BYREF:
|
case VT_DISPATCH|VT_BYREF:
|
||||||
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
comval_to_variant(pval_arg, var_arg TSRMLS_CC);
|
||||||
if(V_VT(var_arg) != VT_DISPATCH)
|
if(V_VT(var_arg) != VT_DISPATCH)
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_VT(var_arg) = VT_DISPATCH|VT_BYREF;
|
V_VT(var_arg) = VT_DISPATCH|VT_BYREF;
|
||||||
V_DISPATCHREF(var_arg) = &V_DISPATCH(var_arg);
|
V_DISPATCHREF(var_arg) = &V_DISPATCH(var_arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_VARIANT|VT_BYREF:
|
case VT_VARIANT:
|
||||||
|
php_error(E_WARNING,"VT_VARIANT is invalid. Use VT_VARIANT|VT_BYREF instead.");
|
||||||
|
/* break missing intentionally */
|
||||||
|
case VT_VARIANT|VT_BYREF:
|
||||||
{
|
{
|
||||||
int tp;
|
int tp;
|
||||||
pval **var_handle;
|
pval **var_handle;
|
||||||
|
@ -392,9 +389,9 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
V_VARIANTREF(var_arg) = (VARIANT FAR*) zend_list_find(Z_LVAL_P(*var_handle), &tp);
|
V_VARIANTREF(var_arg) = (VARIANT FAR*) zend_list_find(Z_LVAL_P(*var_handle), &tp);
|
||||||
|
|
||||||
if(!V_VARIANTREF(var_arg) && (tp != IS_VARIANT))
|
if(!V_VARIANTREF(var_arg) && (tp != IS_VARIANT))
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
should be, but isn't :)
|
should be, but isn't :)
|
||||||
|
@ -404,65 +401,65 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I1:
|
case VT_I1:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_I1(var_arg) = (char)Z_LVAL_P(pval_arg);
|
V_I1(var_arg) = (char)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI2:
|
case VT_UI2:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI2(var_arg) = (unsigned short)Z_LVAL_P(pval_arg);
|
V_UI2(var_arg) = (unsigned short)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI4:
|
case VT_UI4:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UI4(var_arg) = (unsigned long)Z_LVAL_P(pval_arg);
|
V_UI4(var_arg) = (unsigned long)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_INT:
|
case VT_INT:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_INT(var_arg) = (int)Z_LVAL_P(pval_arg);
|
V_INT(var_arg) = (int)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UINT:
|
case VT_UINT:
|
||||||
convert_to_long_ex(&pval_arg);
|
convert_to_long_ex(&pval_arg);
|
||||||
V_UINT(var_arg) = (unsigned int)Z_LVAL_P(pval_arg);
|
V_UINT(var_arg) = (unsigned int)Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_I1|VT_BYREF:
|
case VT_I1|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_I1REF(var_arg) = (char FAR*) &Z_LVAL_P(pval_arg);
|
V_I1REF(var_arg) = (char FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI2|VT_BYREF:
|
case VT_UI2|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI2REF(var_arg) = (unsigned short FAR*) &Z_LVAL_P(pval_arg);
|
V_UI2REF(var_arg) = (unsigned short FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UI4|VT_BYREF:
|
case VT_UI4|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UI4REF(var_arg) = (unsigned long FAR*) &Z_LVAL_P(pval_arg);
|
V_UI4REF(var_arg) = (unsigned long FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_INT|VT_BYREF:
|
case VT_INT|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_INTREF(var_arg) = (int FAR*) &Z_LVAL_P(pval_arg);
|
V_INTREF(var_arg) = (int FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_UINT|VT_BYREF:
|
case VT_UINT|VT_BYREF:
|
||||||
convert_to_long(pval_arg);
|
convert_to_long(pval_arg);
|
||||||
V_UINTREF(var_arg) = (unsigned int FAR*) &Z_LVAL_P(pval_arg);
|
V_UINTREF(var_arg) = (unsigned int FAR*) &Z_LVAL_P(pval_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Type not supported or not yet implemented.");
|
php_error(E_WARNING, "Type not supported or not yet implemented.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage)
|
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
/* Changed the function to return a value for recursive error testing */
|
/* Changed the function to return a value for recursive error testing */
|
||||||
/* Existing calls will be unaffected by the change - so it */
|
/* Existing calls will be unaffected by the change - so it */
|
||||||
|
@ -488,7 +485,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
/* For now just validate that the SafeArray has one dimension */
|
/* For now just validate that the SafeArray has one dimension */
|
||||||
if (1 != (Dims = SafeArrayGetDim(array)))
|
if (1 != (Dims = SafeArrayGetDim(array)))
|
||||||
{
|
{
|
||||||
php_error(E_WARNING, "Unsupported: multi-dimensional (%d) SafeArrays", Dims);
|
php_error(E_WARNING,"Unsupported: multi-dimensional (%d) SafeArrays", Dims);
|
||||||
ZVAL_NULL(pval_arg);
|
ZVAL_NULL(pval_arg);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -529,18 +526,18 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
hr = SafeArrayGetElement(array, indices, (VOID *) &(vv.lVal));
|
hr = SafeArrayGetElement(array, indices, (VOID *) &(vv.lVal));
|
||||||
}
|
}
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
/* Failure to retieve an element probably means the array is sparse */
|
/* Failure to retieve an element probably means the array is sparse */
|
||||||
/* So leave the php array sparse too */
|
/* So leave the php array sparse too */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Create an element to be added to the array */
|
/* Create an element to be added to the array */
|
||||||
ALLOC_ZVAL(element);
|
ALLOC_ZVAL(element);
|
||||||
/* Call ourself again to handle the base type conversion */
|
/* Call ourself again to handle the base type conversion */
|
||||||
/* If SafeArrayGetElement proclaims to allocate */
|
/* If SafeArrayGetElement proclaims to allocate */
|
||||||
/* memory for a BSTR, so the recursive call frees */
|
/* memory for a BSTR, so the recursive call frees */
|
||||||
/* the string correctly */
|
/* the string correctly */
|
||||||
if (FAILURE == php_variant_to_pval(&vv, element, persistent, codepage))
|
if (FAILURE == php_variant_to_pval(&vv, element, persistent, codepage TSRMLS_CC))
|
||||||
{
|
{
|
||||||
/* Error occurred setting up array element */
|
/* Error occurred setting up array element */
|
||||||
/* Error was displayed by the recursive call */
|
/* Error was displayed by the recursive call */
|
||||||
|
@ -560,10 +557,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
add_index_zval(pval_arg, ii, element);
|
add_index_zval(pval_arg, ii, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SafeArrayUnlock(array);
|
SafeArrayUnlock(array);
|
||||||
/* Clean up the SafeArray since that is our responsibility */
|
|
||||||
SafeArrayDestroyData(array);
|
|
||||||
SafeArrayDestroyDescriptor(array);
|
|
||||||
}
|
}
|
||||||
else switch(var_arg->vt & ~VT_BYREF)
|
else switch(var_arg->vt & ~VT_BYREF)
|
||||||
{
|
{
|
||||||
|
@ -633,7 +627,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
switch(VarBstrFromDec(&V_DECIMAL(var_arg), LOCALE_SYSTEM_DEFAULT, 0, &unicode_str))
|
switch(VarBstrFromDec(&V_DECIMAL(var_arg), LOCALE_SYSTEM_DEFAULT, 0, &unicode_str))
|
||||||
{
|
{
|
||||||
case S_OK:
|
case S_OK:
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(unicode_str, &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(unicode_str, &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
Z_TYPE_P(pval_arg) = IS_STRING;
|
Z_TYPE_P(pval_arg) = IS_STRING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -676,20 +670,18 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_VARIANT:
|
case VT_VARIANT:
|
||||||
php_variant_to_pval(V_VARIANTREF(var_arg), pval_arg, persistent, codepage);
|
php_variant_to_pval(V_VARIANTREF(var_arg), pval_arg, persistent, codepage TSRMLS_CC);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VT_BSTR:
|
case VT_BSTR:
|
||||||
if(V_ISBYREF(var_arg))
|
if(V_ISBYREF(var_arg))
|
||||||
{
|
{
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(*V_BSTRREF(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(*V_BSTRREF(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
SysFreeString(*V_BSTRREF(var_arg));
|
|
||||||
efree(V_BSTRREF(var_arg));
|
efree(V_BSTRREF(var_arg));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(V_BSTR(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage);
|
Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(V_BSTR(var_arg), &Z_STRLEN_P(pval_arg), persistent, codepage TSRMLS_CC);
|
||||||
SysFreeString(V_BSTR(var_arg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_TYPE_P(pval_arg) = IS_STRING;
|
Z_TYPE_P(pval_arg) = IS_STRING;
|
||||||
|
@ -739,8 +731,8 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
{
|
{
|
||||||
char *error_message;
|
char *error_message;
|
||||||
|
|
||||||
error_message = php_COM_error_message(hr);
|
error_message = php_COM_error_message(hr TSRMLS_CC);
|
||||||
php_error(E_WARNING, "Unable to obtain IDispatch interface: %s", error_message);
|
php_error(E_WARNING,"Unable to obtain IDispatch interface: %s", error_message);
|
||||||
LocalFree(error_message);
|
LocalFree(error_message);
|
||||||
|
|
||||||
V_DISPATCH(var_arg) = NULL;
|
V_DISPATCH(var_arg) = NULL;
|
||||||
|
@ -758,11 +750,9 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
ALLOC_COM(obj);
|
ALLOC_COM(obj);
|
||||||
php_COM_set(obj, V_DISPATCH(var_arg), TRUE);
|
php_COM_set(obj, &V_DISPATCH(var_arg), TRUE TSRMLS_CC);
|
||||||
|
|
||||||
ZVAL_COM(pval_arg, obj);
|
ZVAL_COM(pval_arg, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -824,7 +814,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
|
php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
|
||||||
ZVAL_NULL(pval_arg);
|
ZVAL_NULL(pval_arg);
|
||||||
ret = FAILURE;
|
ret = FAILURE;
|
||||||
break;
|
break;
|
||||||
|
@ -832,7 +822,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage)
|
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
OLECHAR *unicode_str;
|
OLECHAR *unicode_str;
|
||||||
|
|
||||||
|
@ -854,17 +844,17 @@ PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage)
|
||||||
switch(GetLastError())
|
switch(GetLastError())
|
||||||
{
|
{
|
||||||
case ERROR_NO_UNICODE_TRANSLATION:
|
case ERROR_NO_UNICODE_TRANSLATION:
|
||||||
php_error(E_WARNING, "No unicode translation available for the specified string");
|
php_error(E_WARNING,"No unicode translation available for the specified string");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
php_error(E_WARNING, "Error in php_char_to_OLECHAR()");
|
php_error(E_WARNING,"Error in php_char_to_OLECHAR()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return unicode_str;
|
return unicode_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage)
|
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *C_str;
|
char *C_str;
|
||||||
uint length = 0;
|
uint length = 0;
|
||||||
|
@ -884,7 +874,7 @@ PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int per
|
||||||
C_str = (char *) pemalloc(sizeof(char), persistent);
|
C_str = (char *) pemalloc(sizeof(char), persistent);
|
||||||
*C_str = 0;
|
*C_str = 0;
|
||||||
|
|
||||||
php_error(E_WARNING, "Error in php_OLECHAR_to_char()");
|
php_error(E_WARNING,"Error in php_OLECHAR_to_char()");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(out_length)
|
if(out_length)
|
||||||
|
@ -903,7 +893,7 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC)
|
||||||
|
|
||||||
/* fetch the comval structure */
|
/* fetch the comval structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &comval_handle);
|
zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &comval_handle);
|
||||||
obj = (comval *) zend_list_find(Z_LVAL_P(*comval_handle), &type);
|
obj = (comval *)zend_list_find(Z_LVAL_P(*comval_handle), &type);
|
||||||
if(!obj || (type != IS_COM) || !C_ISREFD(obj))
|
if(!obj || (type != IS_COM) || !C_ISREFD(obj))
|
||||||
{
|
{
|
||||||
VariantInit(var_arg);
|
VariantInit(var_arg);
|
||||||
|
@ -915,4 +905,4 @@ static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PHP_WIN32 */
|
#endif /* PHP_WIN32 */
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
BEGIN_EXTERN_C()
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
extern void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage);
|
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
|
||||||
extern void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage);
|
PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
|
||||||
extern int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage);
|
PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int persistent, int codepage TSRMLS_DC);
|
||||||
extern OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage);
|
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
|
||||||
extern char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage);
|
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage TSRMLS_DC);
|
||||||
|
|
||||||
END_EXTERN_C()
|
END_EXTERN_C()
|
||||||
|
|
||||||
|
|
|
@ -10,22 +10,30 @@ BEGIN_EXTERN_C()
|
||||||
PHP_MINIT_FUNCTION(COM);
|
PHP_MINIT_FUNCTION(COM);
|
||||||
PHP_MSHUTDOWN_FUNCTION(COM);
|
PHP_MSHUTDOWN_FUNCTION(COM);
|
||||||
|
|
||||||
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult);
|
PHP_FUNCTION(com_load);
|
||||||
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId);
|
PHP_FUNCTION(com_invoke);
|
||||||
PHPAPI HRESULT php_COM_release(comval *obj);
|
PHP_FUNCTION(com_addref);
|
||||||
PHPAPI HRESULT php_COM_addref(comval *obj);
|
PHP_FUNCTION(com_release);
|
||||||
PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* pDisp, int cleanup);
|
PHP_FUNCTION(com_propget);
|
||||||
PHPAPI HRESULT php_COM_clone(comval *obj, comval *clone, int cleanup);
|
PHP_FUNCTION(com_propput);
|
||||||
|
PHP_FUNCTION(com_load_typelib);
|
||||||
|
PHP_FUNCTION(com_isenum);
|
||||||
|
|
||||||
int php_COM_get_le_comval();
|
PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, char **ErrString TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_release(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_addref(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_destruct(comval *obj TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* pDisp, int cleanup TSRMLS_DC);
|
||||||
|
PHPAPI HRESULT php_COM_clone(comval *obj, comval *clone, int cleanup TSRMLS_DC);
|
||||||
|
PHPAPI char *php_COM_error_message(HRESULT hr TSRMLS_DC);
|
||||||
|
PHPAPI int php_COM_get_le_comval();
|
||||||
|
PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
|
||||||
|
PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_reference);
|
||||||
|
PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
||||||
|
|
||||||
zend_module_entry COM_module_entry;
|
zend_module_entry COM_module_entry;
|
||||||
zend_class_entry com_class_entry;
|
zend_class_entry COM_class_entry;
|
||||||
|
|
||||||
pval php_COM_get_property_handler(zend_property_reference *property_reference);
|
|
||||||
int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value);
|
|
||||||
char *php_COM_error_message(HRESULT hr);
|
|
||||||
void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern int resourcecounter;
|
extern int resourcecounter;
|
||||||
|
|
|
@ -3,14 +3,19 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#include "variant.h"
|
BEGIN_EXTERN_C()
|
||||||
|
|
||||||
extern int php_VARIANT_get_le_variant();
|
#include "conversion.h"
|
||||||
|
#include "variant.h"
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT);
|
PHP_MINIT_FUNCTION(VARIANT);
|
||||||
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
||||||
|
|
||||||
extern zend_module_entry VARIANT_module_entry;
|
PHPAPI int php_VARIANT_get_le_variant();
|
||||||
|
|
||||||
|
zend_module_entry VARIANT_module_entry;
|
||||||
|
|
||||||
|
END_EXTERN_C()
|
||||||
|
|
||||||
#define VARIANT_module_ptr &VARIANT_module_entry
|
#define VARIANT_module_ptr &VARIANT_module_entry
|
||||||
|
|
||||||
|
|
|
@ -28,25 +28,20 @@
|
||||||
|
|
||||||
#include "php.h"
|
#include "php.h"
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
#include "variant.h"
|
|
||||||
#include "conversion.h"
|
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
|
#include "php_VARIANT.h"
|
||||||
|
|
||||||
#include <unknwn.h>
|
#include <unknwn.h>
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT);
|
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC);
|
||||||
PHP_MSHUTDOWN_FUNCTION(VARIANT);
|
static int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value);
|
||||||
|
static pval php_VARIANT_get_property_handler(zend_property_reference *property_reference);
|
||||||
int php_VARIANT_get_le_variant();
|
static void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
||||||
void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference);
|
static void php_VARIANT_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
||||||
pval php_VARIANT_get_property_handler(zend_property_reference *property_reference);
|
static void php_register_VARIANT_class(TSRMLS_D);
|
||||||
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value);
|
|
||||||
void php_register_VARIANT_class(TSRMLS_D);
|
|
||||||
static void php_variant_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
|
|
||||||
|
|
||||||
static int le_variant;
|
static int le_variant;
|
||||||
static int codepage;
|
static int codepage;
|
||||||
|
|
||||||
static zend_class_entry VARIANT_class_entry;
|
static zend_class_entry VARIANT_class_entry;
|
||||||
|
|
||||||
function_entry VARIANT_functions[] = {
|
function_entry VARIANT_functions[] = {
|
||||||
|
@ -66,7 +61,7 @@ zend_module_entry VARIANT_module_entry = {
|
||||||
|
|
||||||
PHP_MINIT_FUNCTION(VARIANT)
|
PHP_MINIT_FUNCTION(VARIANT)
|
||||||
{
|
{
|
||||||
le_variant = zend_register_list_destructors_ex(php_variant_destructor, NULL, "VARIANT", module_number);
|
le_variant = zend_register_list_destructors_ex(php_VARIANT_destructor, NULL, "VARIANT", module_number);
|
||||||
|
|
||||||
/* variant datatypes */
|
/* variant datatypes */
|
||||||
REGISTER_LONG_CONSTANT("VT_NULL", VT_NULL, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("VT_NULL", VT_NULL, CONST_CS | CONST_PERSISTENT);
|
||||||
|
@ -97,10 +92,18 @@ PHP_MINIT_FUNCTION(VARIANT)
|
||||||
REGISTER_LONG_CONSTANT("CP_ACP", CP_ACP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_ACP", CP_ACP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_MACCP", CP_MACCP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_MACCP", CP_MACCP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
|
|
||||||
REGISTER_LONG_CONSTANT("CP_THREAD_ACP", CP_THREAD_ACP, CONST_CS | CONST_PERSISTENT);
|
|
||||||
REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#ifdef CP_SYMBOL
|
||||||
|
REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#else
|
||||||
|
# error "CP_SYMBOL undefined"
|
||||||
|
#endif
|
||||||
|
#ifdef CP_THREAD_ACP
|
||||||
|
REGISTER_LONG_CONSTANT("CP_THREAD_ACP", CP_THREAD_ACP, CONST_CS | CONST_PERSISTENT);
|
||||||
|
#else
|
||||||
|
# error "CP_THREAD_ACP undefined"
|
||||||
|
#endif
|
||||||
|
|
||||||
php_register_VARIANT_class(TSRMLS_C);
|
php_register_VARIANT_class(TSRMLS_C);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@ -111,12 +114,12 @@ PHP_MSHUTDOWN_FUNCTION(VARIANT)
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int php_VARIANT_get_le_variant()
|
PHPAPI int php_VARIANT_get_le_variant()
|
||||||
{
|
{
|
||||||
return le_variant;
|
return le_variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
|
static void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
|
||||||
{
|
{
|
||||||
pval *object = property_reference->object;
|
pval *object = property_reference->object;
|
||||||
zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
|
zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
|
||||||
|
@ -137,17 +140,17 @@ void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
getParameters(ht, 1, &data);
|
getParameters(ht, 1, &data);
|
||||||
php_pval_to_variant(data, pVar, codepage);
|
php_pval_to_variant(data, pVar, codepage TSRMLS_CC);
|
||||||
codepage = CP_ACP;
|
codepage = CP_ACP;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
getParameters(ht, 2, &data, &type);
|
getParameters(ht, 2, &data, &type);
|
||||||
php_pval_to_variant_ex(data, pVar, type, codepage);
|
php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
|
||||||
codepage = CP_ACP;
|
codepage = CP_ACP;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
getParameters(ht, 3, &data, &type, &code_page);
|
getParameters(ht, 3, &data, &type, &code_page);
|
||||||
php_pval_to_variant_ex(data, pVar, type, codepage);
|
php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
|
||||||
convert_to_long(code_page);
|
convert_to_long(code_page);
|
||||||
codepage = code_page->value.lval;
|
codepage = code_page->value.lval;
|
||||||
break;
|
break;
|
||||||
|
@ -173,14 +176,14 @@ void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pval php_VARIANT_get_property_handler(zend_property_reference *property_reference)
|
||||||
pval php_VARIANT_get_property_handler(zend_property_reference *property_reference)
|
|
||||||
{
|
{
|
||||||
zend_overloaded_element *overloaded_property;
|
zend_overloaded_element *overloaded_property;
|
||||||
int type;
|
int type;
|
||||||
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
pval result, **var_handle, *object = property_reference->object;
|
pval result, **var_handle, *object = property_reference->object;
|
||||||
VARIANT *var_arg;
|
VARIANT *var_arg;
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
/* fetch the VARIANT structure */
|
/* fetch the VARIANT structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
||||||
|
@ -202,7 +205,7 @@ pval php_VARIANT_get_property_handler(zend_property_reference *property_referenc
|
||||||
case OE_IS_OBJECT:
|
case OE_IS_OBJECT:
|
||||||
if(!strcmp(overloaded_property->element.value.str.val, "value"))
|
if(!strcmp(overloaded_property->element.value.str.val, "value"))
|
||||||
{
|
{
|
||||||
php_variant_to_pval(var_arg, &result, 0, codepage);
|
php_variant_to_pval(var_arg, &result, 0, codepage TSRMLS_CC);
|
||||||
}
|
}
|
||||||
else if(!strcmp(Z_STRVAL(overloaded_property->element), "type"))
|
else if(!strcmp(Z_STRVAL(overloaded_property->element), "type"))
|
||||||
{
|
{
|
||||||
|
@ -226,13 +229,14 @@ pval php_VARIANT_get_property_handler(zend_property_reference *property_referenc
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value)
|
static int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value)
|
||||||
{
|
{
|
||||||
zend_overloaded_element *overloaded_property;
|
zend_overloaded_element *overloaded_property;
|
||||||
int type;
|
int type;
|
||||||
|
TSRMLS_FETCH();
|
||||||
|
|
||||||
pval **var_handle, *object = property_reference->object;
|
pval **var_handle, *object = property_reference->object;
|
||||||
VARIANT *var_arg;
|
VARIANT *var_arg;
|
||||||
TSRMLS_FETCH();
|
|
||||||
|
|
||||||
/* fetch the VARIANT structure */
|
/* fetch the VARIANT structure */
|
||||||
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
|
||||||
|
@ -242,12 +246,12 @@ int php_VARIANT_set_property_handler(zend_property_reference *property_reference
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|
||||||
overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
|
overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
|
||||||
do_VARIANT_propset(var_arg, &overloaded_property->element, value);
|
do_VARIANT_propset(var_arg, &overloaded_property->element, value TSRMLS_CC);
|
||||||
zval_dtor(&overloaded_property->element);
|
zval_dtor(&overloaded_property->element);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value)
|
static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
|
||||||
{
|
{
|
||||||
pval type;
|
pval type;
|
||||||
|
|
||||||
|
@ -415,17 +419,17 @@ static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value)
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
php_pval_to_variant_ex(value, var_arg, &type, codepage);
|
php_pval_to_variant_ex(value, var_arg, &type, codepage TSRMLS_CC);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void php_variant_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
static void php_VARIANT_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
|
||||||
{
|
{
|
||||||
efree(rsrc);
|
FREE_VARIANT(rsrc->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void php_register_VARIANT_class(TSRMLS_D)
|
static void php_register_VARIANT_class(TSRMLS_D)
|
||||||
{
|
{
|
||||||
INIT_OVERLOADED_CLASS_ENTRY(VARIANT_class_entry, "VARIANT", NULL,
|
INIT_OVERLOADED_CLASS_ENTRY(VARIANT_class_entry, "VARIANT", NULL,
|
||||||
php_VARIANT_call_function_handler,
|
php_VARIANT_call_function_handler,
|
||||||
|
|
|
@ -3,7 +3,13 @@
|
||||||
|
|
||||||
#if PHP_WIN32
|
#if PHP_WIN32
|
||||||
|
|
||||||
#define ALLOC_VARIANT(v) (v) = (VARIANT *) emalloc(sizeof(VARIANT))
|
#define ALLOC_VARIANT(v) (v) = (VARIANT *) emalloc(sizeof(VARIANT)); \
|
||||||
|
VariantInit(v);
|
||||||
|
|
||||||
|
#define FREE_VARIANT(v) VariantClear(v); \
|
||||||
|
efree(v);
|
||||||
|
|
||||||
|
|
||||||
#define IS_VARIANT php_VARIANT_get_le_variant()
|
#define IS_VARIANT php_VARIANT_get_le_variant()
|
||||||
|
|
||||||
#endif /* PHP_WIN32 */
|
#endif /* PHP_WIN32 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue