summaryrefslogtreecommitdiff
path: root/ext/com
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2002-02-04 20:44:25 +0000
committerSVN Migration <svn@php.net>2002-02-04 20:44:25 +0000
commit7162eb219af50c180b8d15fab9009ba85af7ce44 (patch)
treef51a672d3c15b605196896952e4dc222007c464b /ext/com
parent8535164f21b6dc551a519b0e5f11cbd6bd72a2b0 (diff)
downloadphp-git-BEFORE_NEW_OBJECT_MODEL.tar.gz
This commit was manufactured by cvs2svn to create tagBEFORE_NEW_OBJECT_MODEL
'BEFORE_NEW_OBJECT_MODEL'.
Diffstat (limited to 'ext/com')
-rw-r--r--ext/com/COM.c1850
-rw-r--r--ext/com/CREDITS2
-rw-r--r--ext/com/TODO27
-rw-r--r--ext/com/VARIANT.c341
-rw-r--r--ext/com/com.h71
-rw-r--r--ext/com/conversion.c847
-rw-r--r--ext/com/conversion.h23
-rw-r--r--ext/com/php_COM.h52
-rw-r--r--ext/com/php_VARIANT.h19
-rw-r--r--ext/com/variant.h32
10 files changed, 0 insertions, 3264 deletions
diff --git a/ext/com/COM.c b/ext/com/COM.c
deleted file mode 100644
index 2e7dd0e1b7..0000000000
--- a/ext/com/COM.c
+++ /dev/null
@@ -1,1850 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2002 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- | Harald Radi <h.radi@nme.at> |
- | Alan Brown <abrown@pobox.com> |
- +----------------------------------------------------------------------+
- */
-
-/*
- * This module implements support for COM components that support the IDispatch
- * interface. Both local (COM) and remote (DCOM) components can be accessed.
- *
- * Type libraries can be loaded (in order for PHP to recognize automation constants)
- * by specifying a typelib_file in the PHP .ini file. That file should contain
- * paths to type libraries, one in every line. By default, constants are registered
- * as case-sensitive. If you want them to be defined as case-insensitive, add
- * #case_insensitive or #cis at the end of the type library path.
- *
- * This is also the first module to demonstrate Zend's OO syntax overloading
- * capabilities. CORBA coders are invited to write a CORBA module as well!
- *
- * Zeev
- */
-
-/*
- * 28.12.2000
- * unicode conversion fixed by Harald Radi <h.radi@nme.at>
- *
- * now all these strange '?'s should be disapeared
- */
-
-/*
- * 28.1.2001
- * VARIANT datatype and pass_by_reference support
- */
-
-/*
- * 03.6.2001
- * Enhanced Typelib support to include a search by name
- */
-
-#ifdef PHP_WIN32
-
-#define _WIN32_DCOM
-
-#include <iostream.h>
-#include <math.h>
-
-#include "php.h"
-#include "php_ini.h"
-
-#include "php_COM.h"
-#include "php_VARIANT.h"
-
-static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC);
-static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC);
-static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC);
-static int do_COM_propget(VARIANT *var_result, comval *obj, pval *arg_property, int cleanup TSRMLS_DC);
-static void php_register_COM_class(TSRMLS_D);
-static void php_COM_init(int module_number TSRMLS_DC);
-
-static int le_comval;
-static int codepage;
-
-#ifdef _DEBUG
-int resourcecounter = 1;
-#endif
-
-function_entry COM_functions[] = {
- PHP_FE(com_load, NULL)
- PHP_FE(com_invoke, NULL)
- PHP_FE(com_addref, NULL)
- PHP_FE(com_release, NULL)
- PHP_FE(com_propget, NULL)
- PHP_FE(com_propput, NULL)
- PHP_FE(com_load_typelib, NULL)
- PHP_FE(com_isenum, NULL)
-
- PHP_FALIAS(com_get, com_propget, NULL)
- PHP_FALIAS(com_propset, com_propput, NULL)
- PHP_FALIAS(com_set, com_propput, NULL)
-
- { NULL, NULL, NULL }
-};
-
-
-static PHP_MINFO_FUNCTION(COM)
-{
- DISPLAY_INI_ENTRIES();
-}
-
-
-PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DISPPARAMS FAR* pDispParams, VARIANT FAR* pVarResult, char **ErrString TSRMLS_DC)
-{
- HRESULT hr;
- int failed = FALSE;
- unsigned int ArgErr;
- EXCEPINFO ExceptInfo;
-
- *ErrString = NULL;
- /* @todo use DispInvoke here ? */
- if (C_ISREFD(obj)) {
- if (C_HASTLIB(obj)) {
- hr = C_TYPEINFO_VT(obj)->Invoke(C_TYPEINFO(obj), C_DISPATCH(obj), dispIdMember, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
- if (FAILED(hr)) {
- hr = C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), dispIdMember, &IID_NULL, LOCALE_SYSTEM_DEFAULT, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
- if (SUCCEEDED(hr)) {
- /*
- * ITypLib doesn't work
- * Release ITypeLib and fall back to IDispatch
- */
-
- C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
- C_HASTLIB(obj) = FALSE;
- }
- }
- } else {
- hr = C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), dispIdMember, &IID_NULL, LOCALE_SYSTEM_DEFAULT, wFlags, pDispParams, pVarResult, &ExceptInfo, &ArgErr);
- }
-
- if (FAILED(hr)) {
- switch (hr) {
- case DISP_E_EXCEPTION: {
- int srclen=0;
- char *src=estrdup("");
- int desclen=0;
- char *desc=estrdup("");
-
- if (ExceptInfo.bstrSource)
- {
- src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
- SysFreeString(ExceptInfo.bstrSource);
- }
- if (ExceptInfo.bstrDescription)
- {
- desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
- SysFreeString(ExceptInfo.bstrDescription);
- }
-
- *ErrString = pemalloc(srclen+desclen+50, 1);
- sprintf(*ErrString, "<b>Source</b>: %s <b>Description</b>: %s", src, desc);
- efree(src);
- efree(desc);
-
- if (ExceptInfo.bstrHelpFile)
- {
- SysFreeString(ExceptInfo.bstrHelpFile);
- }
- }
- case DISP_E_PARAMNOTFOUND:
- case DISP_E_TYPEMISMATCH:
- *ErrString = pemalloc(25, 1);
- sprintf(*ErrString, "<b>Argument</b>: %d", pDispParams->cArgs-ArgErr+1);
- break;
- }
- }
-
- if (pVarResult && (V_VT(pVarResult) == VT_EMPTY)) {
- V_VT(pVarResult) = VT_I4;
- V_I4(pVarResult) = hr;
- }
-
- return hr;
- } else {
- return DISP_E_UNKNOWNINTERFACE;
- }
-}
-
-
-PHPAPI HRESULT php_COM_get_ids_of_names(comval *obj, OLECHAR FAR* FAR* rgszNames, DISPID FAR* rgDispId TSRMLS_DC)
-{
- HRESULT hr;
-
- if (C_ISREFD(obj)) {
- if (C_HASTLIB(obj)) {
- hr = C_TYPEINFO_VT(obj)->GetIDsOfNames(C_TYPEINFO(obj), rgszNames, 1, rgDispId);
-
- if (FAILED(hr)) {
- hr = C_DISPATCH_VT(obj)->GetIDsOfNames(C_DISPATCH(obj), &IID_NULL, rgszNames, 1, LOCALE_SYSTEM_DEFAULT, rgDispId);
-
- if (SUCCEEDED(hr)) {
- /*
- * ITypLib doesn't work
- * Release ITypeLib and fall back to IDispatch
- */
-
- C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
- C_HASTLIB(obj) = FALSE;
- }
- }
- } else {
- hr = C_DISPATCH_VT(obj)->GetIDsOfNames(C_DISPATCH(obj), &IID_NULL, rgszNames, 1, LOCALE_SYSTEM_DEFAULT, rgDispId);
- }
-
- return hr;
- } else {
- return DISP_E_UNKNOWNINTERFACE;
- }
-}
-
-
-PHPAPI HRESULT php_COM_release(comval *obj TSRMLS_DC)
-{
- HRESULT hr;
-
- if (obj->refcount > 1) {
- C_RELEASE(obj);
- } else if (obj->refcount == 1) {
- if (C_HASTLIB(obj)) {
- C_TYPEINFO_VT(obj)->Release(C_TYPEINFO(obj));
- }
- if (C_HASENUM(obj)) {
- hr = C_ENUMVARIANT_VT(obj)->Release(C_ENUMVARIANT(obj));
- }
- hr = C_DISPATCH_VT(obj)->Release(C_DISPATCH(obj));
- C_RELEASE(obj);
- }
-
- return obj->refcount;
-}
-
-
-PHPAPI HRESULT php_COM_addref(comval *obj TSRMLS_DC)
-{
- if (C_ISREFD(obj)) {
- C_ADDREF(obj);
- }
-
- return obj->refcount;
-}
-
-
-PHPAPI HRESULT php_COM_set(comval *obj, IDispatch FAR* FAR* ppDisp, int cleanup TSRMLS_DC)
-{
- HRESULT hr = 1;
- DISPPARAMS dispparams;
- VARIANT *var_result;
- IDispatch FAR* pDisp;
-
- pDisp = *ppDisp;
- if (cleanup) {
- *ppDisp = NULL;
- }
-
- C_REFCOUNT(obj) = 1;
- C_DISPATCH(obj) = pDisp;
- C_HASTLIB(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->GetTypeInfo(C_DISPATCH(obj), 0, LANG_NEUTRAL, &C_TYPEINFO(obj)));
-
- dispparams.rgvarg = NULL;
- dispparams.rgdispidNamedArgs = NULL;
- dispparams.cArgs = 0;
- dispparams.cNamedArgs = 0;
-
- ALLOC_VARIANT(var_result);
-
- if (C_HASENUM(obj) = SUCCEEDED(C_DISPATCH_VT(obj)->Invoke(C_DISPATCH(obj), DISPID_NEWENUM, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
- DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, NULL, NULL))) {
- if (V_VT(var_result) == VT_UNKNOWN) {
- C_HASENUM(obj) = SUCCEEDED(V_UNKNOWN(var_result)->lpVtbl->QueryInterface(V_UNKNOWN(var_result), &IID_IEnumVARIANT,
- (void**)&C_ENUMVARIANT(obj)));
- } else if (V_VT(var_result) == VT_DISPATCH) {
- C_HASENUM(obj) = SUCCEEDED(V_DISPATCH(var_result)->lpVtbl->QueryInterface(V_DISPATCH(var_result), &IID_IEnumVARIANT,
- (void**)&C_ENUMVARIANT(obj)));
- }
- }
-
- FREE_VARIANT(var_result);
-
- if (!cleanup) {
- hr = C_DISPATCH_VT(obj)->AddRef(C_DISPATCH(obj));
- }
-
-#ifdef _DEBUG
- obj->resourceindex = resourcecounter++;
-#endif
-
- return hr;
-}
-
-
-PHPAPI HRESULT php_COM_clone(comval *obj, comval *clone, int cleanup TSRMLS_DC)
-{
- HRESULT hr;
-
- C_HASTLIB(obj) = C_HASTLIB(clone);
- C_HASENUM(obj) = C_HASENUM(obj);
- C_DISPATCH(obj) = C_DISPATCH(clone);
- C_TYPEINFO(obj) = C_TYPEINFO(clone);
-
- if (cleanup || !C_ISREFD(obj)) {
- obj->refcount = clone->refcount;
- clone->refcount = 0;
- } else {
- if (C_HASTLIB(obj)) {
- C_TYPEINFO_VT(obj)->AddRef(C_TYPEINFO(obj));
- }
- if (C_HASENUM(obj)) {
- C_ENUMVARIANT_VT(obj)->AddRef(C_ENUMVARIANT(obj));
- }
- hr = C_DISPATCH_VT(obj)->AddRef(C_DISPATCH(obj));
- obj->refcount = 1;
- }
-
-#ifdef _DEBUG
- obj->resourceindex = resourcecounter++;
-#endif
-
- return hr;
-}
-
-
-PHPAPI char *php_COM_error_message(HRESULT hr TSRMLS_DC)
-{
- void *pMsgBuf;
-
- if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
- hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pMsgBuf, 0, NULL)) {
- char error_string[] = "No description available";
-
- pMsgBuf = LocalAlloc(LMEM_FIXED, sizeof(error_string));
- memcpy(pMsgBuf, error_string, sizeof(error_string));
- }
-
- return pMsgBuf;
-}
-
-
-static char *php_string_from_clsid(const CLSID *clsid TSRMLS_DC)
-{
- LPOLESTR ole_clsid;
- char *clsid_str;
-
- StringFromCLSID(clsid, &ole_clsid);
- clsid_str = php_OLECHAR_to_char(ole_clsid, NULL, codepage TSRMLS_CC);
- LocalFree(ole_clsid);
-
- return clsid_str;
-}
-
-
-PHPAPI HRESULT php_COM_destruct(comval *obj TSRMLS_DC)
-{
- HRESULT hr = S_OK;
-
- if (C_ISREFD(obj)) {
- C_REFCOUNT(obj) = 1;
- hr = php_COM_release(obj TSRMLS_CC);
- }
- efree(obj);
-
- return hr;
-}
-
-
-static void php_comval_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- php_COM_destruct(rsrc->ptr TSRMLS_CC);
-}
-
-
-static PHP_INI_MH(OnTypelibFileChange)
-{
- FILE *typelib_file;
- char *typelib_name_buffer;
- char *strtok_buf = NULL;
- int interactive;
- interactive = CG(interactive);
-
- if (!new_value || (typelib_file = VCWD_FOPEN(new_value, "r"))==NULL) {
- return FAILURE;
- }
-
- if (interactive) {
- printf("Loading type libraries...");
- fflush(stdout);
- }
-
- typelib_name_buffer = (char *) emalloc(sizeof(char)*1024);
-
- while (fgets(typelib_name_buffer, 1024, typelib_file)) {
- ITypeLib *pTL;
- char *typelib_name;
- char *modifier, *ptr;
- int mode = CONST_CS | CONST_PERSISTENT; /* CONST_PERSISTENT is ok here */
-
- if (typelib_name_buffer[0]==';') {
- continue;
- }
- typelib_name = php_strtok_r(typelib_name_buffer, "\r\n", &strtok_buf); /* get rid of newlines */
- if (typelib_name == NULL) {
- continue;
- }
- typelib_name = php_strtok_r(typelib_name, "#", &strtok_buf);
- modifier = php_strtok_r(NULL, "#", &strtok_buf);
- if (modifier != NULL) {
- if (!strcmp(modifier, "cis") || !strcmp(modifier, "case_insensitive")) {
- mode &= ~CONST_CS;
- }
- }
-
- /* Remove leading/training white spaces on search_string */
- while (isspace(*typelib_name)) {/* Ends on '\0' in worst case */
- typelib_name ++;
- }
- ptr = typelib_name + strlen(typelib_name) - 1;
- while ((ptr != typelib_name) && isspace(*ptr)) {
- *ptr = '\0';
- ptr--;
- }
-
- if (interactive) {
- printf("\rLoading %-60s\r", typelib_name);
- }
-
- if ((pTL = php_COM_find_typelib(typelib_name, mode TSRMLS_CC)) != NULL) {
- php_COM_load_typelib(pTL, mode TSRMLS_CC);
- pTL->lpVtbl->Release(pTL);
- }
- }
-
- efree(typelib_name_buffer);
- fclose(typelib_file);
-
- if (interactive) {
- printf("\r%70s\r", "");
- }
-
- return SUCCESS;
-}
-
-
-PHP_INI_BEGIN()
-PHP_INI_ENTRY_EX("com.allow_dcom", "0", PHP_INI_SYSTEM, NULL, php_ini_boolean_displayer_cb)
-PHP_INI_ENTRY_EX("com.autoregister_typelib", "0", PHP_INI_SYSTEM, NULL, php_ini_boolean_displayer_cb)
-PHP_INI_ENTRY_EX("com.autoregister_verbose", "0", PHP_INI_SYSTEM, NULL, php_ini_boolean_displayer_cb)
-PHP_INI_ENTRY_EX("com.autoregister_casesensitive", "1", PHP_INI_SYSTEM, NULL, php_ini_boolean_displayer_cb)
-PHP_INI_ENTRY("com.typelib_file", "", PHP_INI_SYSTEM, OnTypelibFileChange)
-PHP_INI_END()
-
-
-/* {{{ proto int com_load(string module_name [, string remote_host [, int codepage [, string typelib]]])
- Loads a COM module */
-PHP_FUNCTION(com_load)
-{
- pval *module_name, *code_page, *typelib = NULL, *server_name = NULL, *user_name=NULL, *password=NULL, *domain=NULL;
- CLSID clsid;
- HRESULT hr;
- OLECHAR *ProgID;
- comval *obj;
- char *error_message;
- char *clsid_str;
- int mode = 0;
- ITypeLib *pTL;
- CLSCTX flags = CLSCTX_SERVER;
-
- codepage = CP_ACP;
-
- switch (ZEND_NUM_ARGS()) {
- case 1:
- zend_get_parameters(ht, 1, &module_name);
- break;
-
- case 2:
- zend_get_parameters(ht, 2, &module_name, &server_name);
- break;
-
- case 3:
- zend_get_parameters(ht, 3, &module_name, &server_name, &code_page);
-
- convert_to_long_ex(&code_page);
- codepage = Z_LVAL_P(code_page);
- break;
-
- case 4:
- zend_get_parameters(ht, 4, &module_name, &server_name, &code_page, &typelib);
-
- convert_to_string_ex(&typelib);
- convert_to_long_ex(&code_page);
- codepage = Z_LVAL_P(code_page);
-
- break;
-
- default:
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (server_name != NULL) {
- /* if a server is passed, one obviously wants to instanciate a
- * remote server
- */
- flags = CLSCTX_REMOTE_SERVER;
-
- /* What is server name? A String or an array? */
-
- if (Z_TYPE_P(server_name) == IS_ARRAY) {
- pval **tmp;
- /* DAB: 22 Sept 2001 */
- /* Aha - we have a number of possible */
- /* arguments. They are in the hash */
- /* By name: Server, Domain, Username, Password */
- /* Flags. */
- /* This has been crafted to maintian maximum backward */
- /* compatability, If the server name is specified as a */
- /* string, then the function shoule behave as before */
- /* by defaulting username and password and using the */
- /* (I believe) incorrect CLSCTX_SERVER instantiation */
- /* paramter. However if server is specified in this array */
- /* then we use either CLSCTX_REMOTE_SERVER or whatever */
- /* flags are specified in the array */
- HashTable *ht = Z_ARRVAL(*server_name);
- if (FAILURE == zend_hash_find(ht, "Server", 7, (void **) &tmp)) {
- server_name = NULL;
- } else {
- server_name = *tmp;
- convert_to_string_ex(&server_name);
- /* CLSCTX_SERVER includes INPROC and LOCAL */
- /* SERVER. This means that any local server */
- /* will be instantiated BEFORE even looking */
- /* on a remote server. Thus if we have a */
- /* server name, probably we want to access */
- /* a remote machine or we would not have */
- /* bothered specifying it. So it would be */
- /* wrong to to connect locally. Futher, */
- /* unless the name passed is a GUID, there has */
- /* to be something to map the Prog.Id to GUID */
- /* and unless that has been modified to remove */
- /* the information about local instantiation */
- /* CLSCTX_SERVER would force a local instantiation */
- /* This setting can be overridden below if the user */
- /* specifies a flags element */
- flags = CLSCTX_REMOTE_SERVER;
- }
- if (FAILURE == zend_hash_find(ht, "Username", 9, (void **) &tmp)) {
- user_name = NULL;
- } else {
- user_name = *tmp;
- convert_to_string_ex(&user_name);
- }
- if (FAILURE == zend_hash_find(ht, "Domain", 7, (void **) &tmp)) {
- domain = NULL;
- } else {
- domain = *tmp;
- convert_to_string_ex(&domain);
- }
- if (FAILURE == zend_hash_find(ht, "Password", 9, (void **) &tmp)) {
- password=NULL;
- } else {
- password = *tmp;
- convert_to_string_ex(&password);
- }
- if (SUCCESS == zend_hash_find(ht, "Flags", 6, (void **) &tmp)) {
- convert_to_long_ex(tmp);
- flags = (CLSCTX) Z_LVAL_PP(tmp);
- }
- }
- if (Z_TYPE_P(server_name) == IS_NULL) {
- server_name = NULL;
- } else {
- if (!INI_INT("com.allow_dcom")) {
- php_error(E_WARNING, "DCOM is disabled");
- RETURN_FALSE;
- } else {
- convert_to_string_ex(&server_name);
- }
- }
- }
-
- ALLOC_COM(obj);
- convert_to_string_ex(&module_name);
- ProgID = php_char_to_OLECHAR(Z_STRVAL_P(module_name), Z_STRLEN_P(module_name), codepage TSRMLS_CC);
-
- /* obtain CLSID */
- if (FAILED(CLSIDFromString(ProgID, &clsid))) {
- /* Perhaps this is a Moniker? */
- IBindCtx *pBindCtx;
- IMoniker *pMoniker;
- ULONG ulEaten;
-
- /* @todo if (server_name) */
-
- if (!server_name) {
- /* @todo shouldn't the bind context be fetched on module startup and kept as a global shared instance ?
- * all calls to BindToObject would deliver the same instance then (as desired)
- * IBindCtx::RegisterObjectBound() should be called then after mkparsedisplayname()
- *
- * @todo use mkparsedisplaynameex() ?
- */
- if (SUCCEEDED(hr = CreateBindCtx(0, &pBindCtx))) {
- if (SUCCEEDED(hr = MkParseDisplayName(pBindCtx, ProgID, &ulEaten, &pMoniker))) {
- hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL, &IID_IDispatch, (LPVOID *) &C_DISPATCH(obj));
- pMoniker->lpVtbl->Release(pMoniker);
- }
- pBindCtx->lpVtbl->Release(pBindCtx);
- }
- } else {
- hr = MK_E_SYNTAX;
- }
-
- efree(ProgID);
-
- if (FAILED(hr)) {
- php_COM_destruct(obj TSRMLS_CC);
- error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"Invalid ProgID, GUID string, or Moniker: %s", error_message);
- LocalFree(error_message);
- RETURN_FALSE;
- }
- } else {
- efree(ProgID);
- /* obtain IDispatch */
- if (!server_name) {
- hr = CoCreateInstance(&clsid, NULL, flags, &IID_IDispatch, (LPVOID *) &C_DISPATCH(obj));
- } else {
- COSERVERINFO server_info;
- MULTI_QI pResults;
- COAUTHIDENTITY authid;
- COAUTHINFO authinfo = {RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, &authid, EOAC_NONE};
-
- server_info.dwReserved1=0;
- server_info.dwReserved2=0;
- server_info.pwszName = php_char_to_OLECHAR(Z_STRVAL_P(server_name), Z_STRLEN_P(server_name), codepage TSRMLS_CC);
- if (user_name) {
- /* Z_STRVAL_P(user_name); */
- /* Parse Username into domain\username */
- authid.User = (WCHAR *) Z_STRVAL_P(user_name);
- authid.UserLength = Z_STRLEN_P(user_name);
- if (password) {
- authid.Password = (USHORT *) Z_STRVAL_P(password);
- authid.PasswordLength = Z_STRLEN_P(password);
- } else {
- authid.Password = (USHORT *) "";
- authid.PasswordLength = 0;
- }
- if (domain) {
- authid.Domain = (USHORT *) Z_STRVAL_P(domain);
- authid.DomainLength = Z_STRLEN_P(domain);
- } else {
- authid.Domain = (USHORT *) "";
- authid.DomainLength = 0;
- }
- authid.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
-
- server_info.pAuthInfo=&authinfo;
- } else {
- server_info.pAuthInfo=NULL;
- }
-
- pResults.pIID = &IID_IDispatch;
- pResults.pItf = NULL;
- pResults.hr = S_OK;
- hr=CoCreateInstanceEx(&clsid, NULL, flags, &server_info, 1, &pResults);
- if (SUCCEEDED(hr)) {
- hr = pResults.hr;
- C_DISPATCH(obj) = (IDispatch *) pResults.pItf;
- }
- efree(server_info.pwszName);
- }
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- clsid_str = php_string_from_clsid(&clsid TSRMLS_CC);
- php_error(E_WARNING,"Unable to obtain IDispatch interface for CLSID %s: %s",clsid_str,error_message);
- LocalFree(error_message);
- efree(clsid_str);
- php_COM_destruct(obj TSRMLS_CC);
- RETURN_FALSE;
- }
- }
-
- php_COM_set(obj, &C_DISPATCH(obj), TRUE TSRMLS_CC);
-
- if (INI_INT("com.autoregister_casesensitive")) {
- mode |= CONST_CS;
- }
-
- if (C_HASTLIB(obj)) {
- if (INI_INT("com.autoregister_typelib")) {
- unsigned int idx;
-
- /* @todo check if typlib isn't already loaded */
- if (C_TYPEINFO_VT(obj)->GetContainingTypeLib(C_TYPEINFO(obj), &pTL, &idx) == S_OK) {
- php_COM_load_typelib(pTL, mode TSRMLS_CC);
- pTL->lpVtbl->Release(pTL);
- }
- }
- } else {
- if (typelib != NULL) {
- ITypeLib *pTL;
-
- if ((pTL = php_COM_find_typelib(Z_STRVAL_P(typelib), mode TSRMLS_CC)) != NULL) {
- C_HASTLIB(obj) = SUCCEEDED(pTL->lpVtbl->GetTypeInfo(pTL, 0, &C_TYPEINFO(obj)));
- /* idx 0 should deliver the ITypeInfo for the IDispatch Interface */
- if (INI_INT("com.autoregister_typelib")) {
- php_COM_load_typelib(pTL, mode TSRMLS_CC);
- }
- pTL->lpVtbl->Release(pTL);
- }
- }
- }
-
- RETURN_LONG(zend_list_insert(obj, IS_COM));
-}
-/* }}} */
-
-
-int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **arguments, int arg_count TSRMLS_DC)
-{
- DISPID dispid;
- DISPPARAMS dispparams;
- HRESULT hr;
- OLECHAR *funcname;
- SAFEARRAY *pSA;
- SAFEARRAYBOUND rgsabound[1];
- VARIANT *variant_args;
- char *error_message;
- int current_arg, current_variant;
- unsigned long count;
-
- if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "next")) {
- /* Grab one argument off the stack, allocate enough
- * VARIANTs
- * Get the IEnumVariant interface and call ->Next();
- */
-
- switch (arg_count) {
- case 0:
- count = 1;
- break;
-
- case 1:
- convert_to_long_ex(&arguments[0]);
- count = Z_LVAL_P(arguments[0]);
- break;
-
- default:
- php_error(E_WARNING,"Wrong argument count to IEnumVariant::Next()");
-
- return FAILURE;
- }
-
- rgsabound[0].lLbound = 0;
- rgsabound[0].cElements = count;
-
- if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
- VariantInit(var_result);
- return FAILURE;
- } else {
- V_ARRAY(var_result) = pSA;
- V_VT(var_result) = VT_VARIANT|VT_ARRAY;
- }
-
- if (FAILED(hr = C_ENUMVARIANT_VT(obj)->Next(C_ENUMVARIANT(obj), count, pSA->pvData, &count))) {
- char *error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"IEnumVariant::Next() failed: %s", error_message);
- efree(error_message);
- VariantClear(var_result);
- return FAILURE;
- }
-
- if (count != rgsabound[0].cElements) {
- rgsabound[0].cElements = count;
- if (FAILED(SafeArrayRedim(pSA, rgsabound))) {
- char *error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"IEnumVariant::Next() failed: %s", error_message);
- efree(error_message);
- VariantClear(var_result);
- return FAILURE;
- }
- }
-
- /* return a single element if next() was called without count */
- if ((arg_count == 0) && (count == 1)) {
- long index[] = {0};
-
- SafeArrayGetElement(pSA, index, var_result);
- SafeArrayDestroy(pSA);
- }
-
- return SUCCESS;
- } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "all")) {
-#define FETCH_BLOCKSIZE 10 /* fetch blocks of 10 elements */
-
- count = FETCH_BLOCKSIZE;
-
- rgsabound[0].lLbound = 0;
- rgsabound[0].cElements = count;
-
- if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
- VariantInit(var_result);
- return FAILURE;
- } else {
- V_ARRAY(var_result) = pSA;
- V_VT(var_result) = VT_VARIANT|VT_ARRAY;
- }
-
- /* blah*/
-
-
- } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "reset")) {
- if (FAILED(hr = C_ENUMVARIANT_VT(obj)->Reset(C_ENUMVARIANT(obj)))) {
- char *error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"IEnumVariant::Next() failed: %s", error_message);
- efree(error_message);
- return FAILURE;
- }
- return SUCCESS;
- } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "skip")) {
- unsigned long count;
-
- switch (arg_count) {
- case 0:
- count = 1;
- break;
-
- case 1:
- convert_to_long_ex(&arguments[0]);
- count = Z_LVAL_P(arguments[0]);
- break;
-
- default:
- php_error(E_WARNING,"Wrong argument count to IEnumVariant::Skip()");
- return FAILURE;
- }
- if (FAILED(hr = C_ENUMVARIANT_VT(obj)->Skip(C_ENUMVARIANT(obj), count))) {
- char *error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"IEnumVariant::Next() failed: %s", error_message);
- efree(error_message);
- return FAILURE;
- }
- return SUCCESS;
-
- } else {
- char *ErrString;
-
- funcname = php_char_to_OLECHAR(Z_STRVAL_P(function_name), Z_STRLEN_P(function_name), codepage TSRMLS_CC);
-
- hr = php_COM_get_ids_of_names(obj, &funcname, &dispid TSRMLS_CC);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"Unable to lookup %s: %s", Z_STRVAL_P(function_name), error_message);
- LocalFree(error_message);
- efree(funcname);
- return FAILURE;
- }
-
- variant_args = (VARIANT *) emalloc(sizeof(VARIANT) * arg_count);
-
- for (current_arg=0; current_arg<arg_count; current_arg++) {
- current_variant = arg_count - current_arg - 1;
- php_pval_to_variant(arguments[current_arg], &variant_args[current_variant], codepage TSRMLS_CC);
- }
-
- dispparams.rgvarg = variant_args;
- dispparams.rgdispidNamedArgs = NULL;
- dispparams.cArgs = arg_count;
- dispparams.cNamedArgs = 0;
-
- hr = php_COM_invoke(obj, dispid, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
-
- efree(funcname);
- for (current_arg=0;current_arg<arg_count;current_arg++) {
- /* don't release IDispatch pointers as they are used afterwards */
- if (V_VT(&variant_args[current_arg]) != VT_DISPATCH) {
- /* @todo review this: what happens to an array of IDispatchs or a VARIANT->IDispatch */
- VariantClear(&variant_args[current_arg]);
- }
- }
- efree(variant_args);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- if (ErrString) {
- php_error(E_WARNING,"Invoke() failed: %s %s", error_message, ErrString);
- pefree(ErrString, 1);
- } else {
- php_error(E_WARNING,"Invoke() failed: %s", error_message);
- }
- LocalFree(error_message);
- return FAILURE;
- }
- }
- return SUCCESS;
-}
-
-
-/* {{{ proto mixed com_invoke(int module, string handler_name [, mixed arg [, mixed ...]])
- Invokes a COM module */
-PHP_FUNCTION(com_invoke)
-{
- pval **arguments;
- pval *object, *function_name;
- comval *obj;
- int type;
- int arg_count = ZEND_NUM_ARGS();
- VARIANT *var_result;
-
- if (arg_count<2) {
- ZEND_WRONG_PARAM_COUNT();
- }
- arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
- if (zend_get_parameters_array(ht, arg_count, arguments) == FAILURE) {
- RETURN_FALSE;
- }
-
- object = arguments[0];
- function_name = arguments[1];
-
- /* obtain IDispatch interface */
- convert_to_long(object);
- obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
- if (!obj || (type != IS_COM)) {
- php_error(E_WARNING,"%d is not a COM object handler", Z_STRVAL_P(function_name));
- RETURN_FALSE;
- }
-
- /* obtain property/method handler */
- convert_to_string_ex(&function_name);
-
- ALLOC_VARIANT(var_result);
-
- if (do_COM_invoke(obj, function_name, var_result, arguments+2, arg_count-2 TSRMLS_CC)==FAILURE) {
- FREE_VARIANT(var_result);
- efree(arguments);
-
- RETURN_FALSE;
- }
-
- RETVAL_VARIANT(var_result);
-
- efree(arguments);
-}
-/* }}} */
-
-
-/* {{{ proto mixed com_release(int module)
- Releases a COM object */
-PHP_FUNCTION(com_release)
-{
- pval *object;
- comval *obj;
- int type;
- int arg_count = ZEND_NUM_ARGS();
-
- if (arg_count != 1) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (zend_get_parameters(ht, 1, &object)==FAILURE) {
- RETURN_FALSE;
- }
-
- /* obtain IDispatch interface */
- convert_to_long_ex(&object);
- obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
- if (!obj || (type != IS_COM)) {
- php_error(E_WARNING,"%d is not a COM object handler");
- RETURN_FALSE;
- }
-
- RETURN_LONG(php_COM_release(obj TSRMLS_CC))
-}
-/* }}} */
-
-
-/* {{{ proto mixed com_addref(int module)
- Increases the reference counter on a COM object */
-PHP_FUNCTION(com_addref)
-{
- pval *object;
- comval *obj;
- int type;
- int arg_count = ZEND_NUM_ARGS();
-
- if (arg_count != 1) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- if (zend_get_parameters(ht, 1, &object)==FAILURE) {
- RETURN_FALSE;
- }
-
- /* obtain IDispatch interface */
- convert_to_long_ex(&object);
- obj = (comval *)zend_list_find(Z_LVAL_P(object), &type);
- if (!obj || (type != IS_COM))
- {
- php_error(E_WARNING,"%d is not a COM object handler");
- RETURN_FALSE;
- }
-
- RETURN_LONG(php_COM_addref(obj TSRMLS_CC));
-}
-/* }}} */
-
-
-static int do_COM_offget(VARIANT *result, comval *array, pval *property, int cleanup TSRMLS_DC)
-{
- pval function_name;
- int retval;
-
- ZVAL_STRINGL(&function_name, "Item", 4, 0);
- retval = do_COM_invoke(array, &function_name, result, &property, 1 TSRMLS_CC);
- if (cleanup) {
- php_COM_destruct(array TSRMLS_CC);
- }
-
- return retval;
-}
-
-
-static int do_COM_propget(VARIANT *var_result, comval *obj, pval *arg_property, int cleanup TSRMLS_DC)
-{
- DISPID dispid;
- HRESULT hr;
- OLECHAR *propname;
- char *error_message;
- DISPPARAMS dispparams;
- char *ErrString;
-
- /* obtain property handler */
- propname = php_char_to_OLECHAR(Z_STRVAL_P(arg_property), Z_STRLEN_P(arg_property), codepage TSRMLS_CC);
-
- hr = php_COM_get_ids_of_names(obj, &propname, &dispid TSRMLS_CC);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"Unable to lookup %s: %s", Z_STRVAL_P(arg_property), error_message);
- LocalFree(error_message);
- efree(propname);
- if (cleanup) {
- php_COM_destruct(obj TSRMLS_CC);
- }
- return FAILURE;
- }
-
- dispparams.cArgs = 0;
- dispparams.cNamedArgs = 0;
-
- hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- if (ErrString) {
- php_error(E_WARNING,"PropGet() failed: %s %s", error_message, ErrString);
- pefree(ErrString, 1);
- } else {
- php_error(E_WARNING,"PropGet() failed: %s", error_message);
- }
- LocalFree(error_message);
- efree(propname);
- if (cleanup) {
- php_COM_destruct(obj TSRMLS_CC);
- }
- return FAILURE;
- }
-
- efree(propname);
- if (cleanup) {
- php_COM_destruct(obj TSRMLS_CC);
- }
- return SUCCESS;
-}
-
-
-static void do_COM_propput(pval *return_value, comval *obj, pval *arg_property, pval *value TSRMLS_DC)
-{
- DISPID dispid;
- HRESULT hr;
- OLECHAR *propname;
- char *error_message;
- VARIANT *var_result, *new_value;
- DISPPARAMS dispparams;
- DISPID mydispid = DISPID_PROPERTYPUT;
- char *ErrString;
-
- ALLOC_VARIANT(var_result);
- ALLOC_VARIANT(new_value);
-
- /* obtain property handler */
- propname = php_char_to_OLECHAR(Z_STRVAL_P(arg_property), Z_STRLEN_P(arg_property), codepage TSRMLS_CC);
-
- hr = php_COM_get_ids_of_names(obj, &propname, &dispid TSRMLS_CC);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"Unable to lookup %s: %s", Z_STRVAL_P(arg_property), error_message);
- LocalFree(error_message);
- efree(propname);
-
- FREE_VARIANT(var_result);
- FREE_VARIANT(new_value);
-
- RETURN_FALSE;
- }
-
- php_pval_to_variant(value, new_value, codepage TSRMLS_CC);
- dispparams.rgvarg = new_value;
- dispparams.rgdispidNamedArgs = &mydispid;
- dispparams.cArgs = 1;
- dispparams.cNamedArgs = 1;
-
- hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYPUT, &dispparams, NULL, &ErrString TSRMLS_CC);
-
- if (FAILED(hr)) {
- error_message = php_COM_error_message(hr TSRMLS_CC);
- if (ErrString) {
- php_error(E_WARNING,"PropPut() failed: %s %s", error_message, ErrString);
- pefree(ErrString, 1);
- } else {
- php_error(E_WARNING,"PropPut() failed: %s", error_message);
- }
- LocalFree(error_message);
- efree(propname);
-
- FREE_VARIANT(var_result);
- FREE_VARIANT(new_value);
-
- RETURN_FALSE;
- }
-
- dispparams.cArgs = 0;
- dispparams.cNamedArgs = 0;
-
- hr = php_COM_invoke(obj, dispid, DISPATCH_PROPERTYGET, &dispparams, var_result, &ErrString TSRMLS_CC);
-
- if (SUCCEEDED(hr)) {
- php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
- } else {
- *return_value = *value;
- zval_copy_ctor(return_value);
- }
-
- if (ErrString) {
- pefree(ErrString, 1);
- }
-
- FREE_VARIANT(var_result);
- FREE_VARIANT(new_value);
-
- efree(propname);
-}
-
-
-/* {{{ proto mixed com_propget(int module, string property_name)
- Gets properties from a COM module */
-PHP_FUNCTION(com_propget)
-{
- pval *arg_comval, *arg_property;
- int type;
- comval *obj;
- VARIANT *var_result;
-
- if ((ZEND_NUM_ARGS() != 2) || (zend_get_parameters(ht, 2, &arg_comval, &arg_property) == FAILURE)) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- /* obtain IDispatch interface */
- convert_to_long(arg_comval);
- obj = (comval *)zend_list_find(Z_LVAL_P(arg_comval), &type);
- if (!obj || (type != IS_COM)) {
- php_error(E_WARNING,"%d is not a COM object handler", Z_LVAL_P(arg_comval));
- }
- convert_to_string_ex(&arg_property);
-
- ALLOC_VARIANT(var_result);
-
- if (do_COM_propget(var_result, obj, arg_property, FALSE TSRMLS_CC) == FAILURE) {
- FREE_VARIANT(var_result);
- RETURN_FALSE;
- }
-
- RETVAL_VARIANT(var_result);
-}
-/* }}} */
-
-
-/* {{{ proto bool com_propput(int module, string property_name, mixed value)
- Puts the properties for a module */
-PHP_FUNCTION(com_propput)
-{
- pval *arg_comval, *arg_property, *arg_value;
- int type;
- comval *obj;
-
- if (ZEND_NUM_ARGS()!=3 || zend_get_parameters(ht, 3, &arg_comval, &arg_property, &arg_value)==FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- /* obtain comval interface */
- convert_to_long(arg_comval);
- /* obtain comval interface */
- obj = (comval *)zend_list_find(Z_LVAL_P(arg_comval), &type);
- if (!obj || (type != IS_COM)) {
- php_error(E_WARNING,"%d is not a COM object handler", Z_LVAL_P(arg_comval));
- }
- convert_to_string_ex(&arg_property);
-
- do_COM_propput(return_value, obj, arg_property, arg_value TSRMLS_CC);
-}
-/* }}} */
-
-
-/* {{{ proto bool com_load_typelib(string typelib_name [, int case_insensitive])
- Loads a Typelib */
-PHP_FUNCTION(com_load_typelib)
-{
- pval *arg_typelib, *arg_cis;
- ITypeLib *pTL;
- int mode = CONST_CS;
-
- switch (ZEND_NUM_ARGS()) {
- case 1:
- zend_get_parameters(ht, 1, &arg_typelib);
- break;
-
- case 2:
- zend_get_parameters(ht, 2, &arg_typelib, &arg_cis);
- convert_to_boolean_ex(&arg_cis);
- if (Z_LVAL_P(arg_cis)) {
- mode &= ~CONST_CS;
- }
- break;
-
- default:
- ZEND_WRONG_PARAM_COUNT();
- }
-
- convert_to_string_ex(&arg_typelib);
- pTL = php_COM_find_typelib(Z_STRVAL_P(arg_typelib), mode TSRMLS_CC);
- if (php_COM_load_typelib(pTL, mode TSRMLS_CC) == SUCCESS) {
- pTL->lpVtbl->Release(pTL);
- RETURN_TRUE;
- } else {
- RETURN_FALSE;
- }
-}
-/* }}} */
-
-
-PHPAPI pval php_COM_get_property_handler(zend_property_reference *property_reference)
-{
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
- pval return_value;
- pval **comval_handle;
- pval *object = property_reference->object;
- int type;
- comval *obj, *obj_prop;
- VARIANT *var_result;
- TSRMLS_FETCH();
-
- INIT_ZVAL(return_value);
- ZVAL_NULL(&return_value);
-
- /* fetch the IDispatch interface */
- zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &comval_handle);
- obj = (comval *) zend_list_find(Z_LVAL_P(*comval_handle), &type);
- if (!obj || (type != IS_COM)) {
- return return_value;
- }
-
- ALLOC_COM(obj_prop);
- ALLOC_VARIANT(var_result);
-
- for (element=property_reference->elements_list->head; element; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (Z_TYPE_P(overloaded_property)) {
- case OE_IS_ARRAY:
- if (do_COM_offget(var_result, obj, &overloaded_property->element, FALSE TSRMLS_CC) == FAILURE) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return return_value;
- }
- break;
-
- case OE_IS_OBJECT:
- if (do_COM_propget(var_result, obj, &overloaded_property->element, FALSE TSRMLS_CC) == FAILURE) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return return_value;
- }
- break;
-
- case OE_IS_METHOD: {
- FREE_VARIANT(var_result);
- if (obj != obj_prop) {
- FREE_COM(obj_prop);
-
- return_value = *object;
- ZVAL_ADDREF(&return_value);
- } else {
- RETVAL_COM(obj);
- }
- return return_value;
- }
- break;
- }
-
- if (V_VT(var_result) == VT_DISPATCH) {
- if (V_DISPATCH(var_result) == NULL) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return return_value;
- }
-
- obj = obj_prop;
- php_COM_set(obj, &V_DISPATCH(var_result), TRUE TSRMLS_CC);
- } else {
- php_variant_to_pval(var_result, &return_value, codepage TSRMLS_CC);
-
- FREE_COM(obj_prop);
- obj_prop = NULL;
- }
-
- VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
- pval_destructor(&overloaded_property->element);
- }
-
- if (obj_prop != NULL) {
- RETVAL_COM(obj);
- }
-
-
- FREE_VARIANT(var_result);
-
- return return_value;
-}
-
-
-PHPAPI int php_COM_set_property_handler(zend_property_reference *property_reference, pval *value)
-{
- pval result;
- zend_overloaded_element *overloaded_property;
- zend_llist_element *element;
- pval **comval_handle;
- pval *object = property_reference->object;
- comval *obj, *obj_prop;
- int type;
- VARIANT *var_result;
- TSRMLS_FETCH();
-
- /* fetch the IDispatch interface */
- zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &comval_handle);
- obj = (comval *)zend_list_find(Z_LVAL_P(*comval_handle), &type);
- if (!obj || (type != IS_COM)) {
- return FAILURE;
- }
-
- ALLOC_COM(obj_prop);
- ALLOC_VARIANT(var_result);
-
- for (element=property_reference->elements_list->head; element != property_reference->elements_list->tail; element=element->next) {
- overloaded_property = (zend_overloaded_element *) element->data;
- switch (Z_TYPE_P(overloaded_property)) {
- case OE_IS_ARRAY:
- if (do_COM_offget(var_result, obj, &overloaded_property->element, FALSE TSRMLS_CC) == FAILURE) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return FAILURE;
- }
- break;
-
- case OE_IS_OBJECT:
- if (do_COM_propget(var_result, obj, &overloaded_property->element, FALSE TSRMLS_CC) == FAILURE) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return FAILURE;
- }
- break;
-
- case OE_IS_METHOD:
- /* this shouldn't happen */
- return FAILURE;
- break;
- }
-
- if (V_VT(var_result) == VT_DISPATCH) {
- if (V_DISPATCH(var_result) == NULL) {
- FREE_VARIANT(var_result);
- FREE_COM(obj_prop);
-
- return FAILURE;
- }
-
- obj = obj_prop;
- php_COM_set(obj, &V_DISPATCH(var_result), TRUE TSRMLS_CC);
- } else {
- FREE_COM(obj_prop);
- FREE_VARIANT(var_result);
-
- return FAILURE;
- }
-
- VariantInit(var_result); // to protect C_DISPATCH(obj) from being freed when var_result is destructed
- pval_destructor(&overloaded_property->element);
- }
- FREE_VARIANT(var_result);
-
- overloaded_property = (zend_overloaded_element *) element->data;
- do_COM_propput(&result, obj, &overloaded_property->element, value TSRMLS_CC);
- FREE_COM(obj_prop);
-
- pval_destructor(&overloaded_property->element);
-
- return SUCCESS;
-}
-
-
-PHPAPI void php_COM_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- pval property, **handle;
- pval *object = property_reference->object;
- zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
- comval *obj;
- int type;
-
- if (zend_llist_count(property_reference->elements_list)==1
- && !strcmp(Z_STRVAL(function_name->element), "com")) {
- /* constructor */
- pval *object_handle;
-
- PHP_FN(com_load)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (!zend_is_true(return_value)) {
- ZVAL_FALSE(object);
- return;
- }
- ALLOC_ZVAL(object_handle);
- *object_handle = *return_value;
- pval_copy_constructor(object_handle);
- INIT_PZVAL(object_handle);
- zend_hash_index_update(Z_OBJPROP_P(object), 0, &object_handle, sizeof(pval *), NULL);
- pval_destructor(&function_name->element);
-
- return;
- }
-
- property = php_COM_get_property_handler(property_reference);
- if (Z_TYPE(property) == IS_NULL) {
- if (property.refcount == 1) {
- pval_destructor(&property);
- }
- pval_destructor(&function_name->element);
- return;
- }
- zend_hash_index_find(Z_OBJPROP(property), 0, (void **) &handle);
- obj = (comval *)zend_list_find(Z_LVAL_PP(handle), &type);
-
- if (!obj || (type != IS_COM)) {
- pval_destructor(&property);
- pval_destructor(&function_name->element);
- return;
- }
-
- if (zend_llist_count(property_reference->elements_list)==1
- && !strcmp(Z_STRVAL_P(&function_name->element), "release")) {
- RETVAL_LONG(php_COM_release(obj TSRMLS_CC));
- } else if (zend_llist_count(property_reference->elements_list)==1
- && !strcmp(Z_STRVAL_P(&function_name->element), "addref")) {
- RETVAL_LONG(php_COM_addref(obj TSRMLS_CC));
- } else {
- pval **arguments;
- VARIANT *var_result;
- int arg_count = ZEND_NUM_ARGS();
-
- ALLOC_VARIANT(var_result);
-
- arguments = (pval **) emalloc(sizeof(pval *)*arg_count);
- zend_get_parameters_array(ht, arg_count, arguments);
-
- if (do_COM_invoke(obj , &function_name->element, var_result, arguments, arg_count TSRMLS_CC) == FAILURE) {
- RETVAL_FALSE;
- } else {
- php_variant_to_pval(var_result, return_value, codepage TSRMLS_CC);
- }
-
- FREE_VARIANT(var_result);
- efree(arguments);
- }
-
- if (property.refcount == 1) {
- pval_destructor(&property);
- }
- pval_destructor(&function_name->element);
-}
-
-
-static ITypeLib *php_COM_find_typelib(char *search_string, int mode TSRMLS_DC)
-{
- ITypeLib *TypeLib = NULL;
- char *strtok_buf, *major, *minor;
- CLSID clsid;
- OLECHAR *p;
-
- /* Type Libraries:
- * The string we have is either:
- * a) a file name
- * b) a CLSID, major, minor e.g. "{00000200-0000-0010-8000-00AA006D2EA4},2,0"
- * c) a Type Library name e.g. "Microsoft OLE DB ActiveX Data Objects 1.0 Library"
- * Searching for the name will be more expensive that the
- * other two, so we will do that when both other attempts
- * fail.
- */
-
- search_string = php_strtok_r(search_string, ",", &strtok_buf);
- major = php_strtok_r(NULL, ",", &strtok_buf);
- minor = php_strtok_r(NULL, ",", &strtok_buf);
-
- p = php_char_to_OLECHAR(search_string, strlen(search_string), codepage TSRMLS_CC);
- /* Is the string a GUID ? */
-
- if (!FAILED(CLSIDFromString(p, &clsid))) {
- HRESULT hr;
- WORD major_i = 1;
- WORD minor_i = 0;
-
- /* We have a valid GUID, check to see if a major/minor */
- /* version was specified otherwise assume 1,0 */
- if ((major != NULL) && (minor != NULL)) {
- major_i = (WORD) atoi(major);
- minor_i = (WORD) atoi(minor);
- }
-
- /* The GUID will either be a typelibrary or a CLSID */
- hr = LoadRegTypeLib((REFGUID) &clsid, major_i, minor_i, LANG_NEUTRAL, &TypeLib);
-
- /* If the LoadRegTypeLib fails, let's try to instantiate */
- /* the class itself and then QI for the TypeInfo and */
- /* retrieve the type info from that interface */
- if (FAILED(hr) && (!major || !minor)) {
- IDispatch *Dispatch;
- ITypeInfo *TypeInfo;
- int idx;
-
- if (FAILED(CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID *) &Dispatch))) {
- efree(p);
- return NULL;
- }
- if (FAILED(Dispatch->lpVtbl->GetTypeInfo(Dispatch, 0, LANG_NEUTRAL, &TypeInfo))) {
- Dispatch->lpVtbl->Release(Dispatch);
- efree(p);
- return NULL;
- }
- Dispatch->lpVtbl->Release(Dispatch);
- if (FAILED(TypeInfo->lpVtbl->GetContainingTypeLib(TypeInfo, &TypeLib, &idx))) {
- TypeInfo->lpVtbl->Release(TypeInfo);
- efree(p);
- return NULL;
- }
- TypeInfo->lpVtbl->Release(TypeInfo);
- }
- } else {
- if (FAILED(LoadTypeLib(p, &TypeLib))) {
- /* Walk HKCR/TypeLib looking for the string */
- /* If that succeeds, call ourself recursively */
- /* using the CLSID found, else give up and bail */
- HKEY hkey, hsubkey;
- DWORD SubKeys, MaxSubKeyLength;
- char *keyname;
- register unsigned int ii, jj;
- DWORD VersionCount;
- char version[20]; /* All the version keys are 1.0, 4.6, ... */
- char *libname;
- DWORD libnamelen;
-
- /* No Need for Unicode version any more */
- efree(p);
-
- /* Starting at HKEY_CLASSES_ROOT/TypeLib */
- /* Walk all subkeys (Typelib GUIDs) looking */
- /* at each version for a string match to the */
- /* supplied argument */
-
- if (ERROR_SUCCESS != RegOpenKey(HKEY_CLASSES_ROOT, "TypeLib",&hkey)) {
- /* This is pretty bad - better bail */
- return NULL;
- }
- if (ERROR_SUCCESS != RegQueryInfoKey(hkey, NULL, NULL, NULL, &SubKeys, &MaxSubKeyLength, NULL, NULL, NULL, NULL, NULL, NULL)) {
- RegCloseKey(hkey);
- return NULL;
- }
- MaxSubKeyLength++; /* \0 is not counted */
- keyname = emalloc(MaxSubKeyLength);
- libname = emalloc(strlen(search_string)+1);
- for (ii=0;ii<SubKeys;ii++) {
- if (ERROR_SUCCESS != RegEnumKey(hkey, ii, keyname, MaxSubKeyLength)) {
- /* Failed - who cares */
- continue;
- }
- if (ERROR_SUCCESS != RegOpenKey(hkey, keyname, &hsubkey)) {
- /* Failed - who cares */
- continue;
- }
- if (ERROR_SUCCESS != RegQueryInfoKey(hsubkey, NULL, NULL, NULL, &VersionCount, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) {
- /* Failed - who cares */
- RegCloseKey(hsubkey);
- continue;
- }
- for (jj=0;jj<VersionCount;jj++) {
- if (ERROR_SUCCESS != RegEnumKey(hsubkey, jj, version, sizeof(version))) {
- /* Failed - who cares */
- continue;
- }
- /* OK we just need to retrieve the default */
- /* value for this key and see if it matches */
- libnamelen = strlen(search_string)+1;
- if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
- if ((mode & CONST_CS) ? (strcmp(libname, search_string) == 0) : (stricmp(libname, search_string) == 0)) {
- char *str;
- int major, minor;
-
- /* Found it */
- RegCloseKey(hkey);
- RegCloseKey(hsubkey);
-
- efree(libname);
- /* We can either open up the "win32" key and find the DLL name */
- /* Or just parse the version string and pass that in */
- /* The version string seems like a more portable solution */
- /* Given that there is a COM on Unix */
- if (2 != sscanf(version, "%d.%d", &major, &minor)) {
- major = 1;
- minor = 0;
- }
- str = emalloc(strlen(keyname)+strlen(version)+20); /* 18 == safety, 2 == extra comma and \0 */
- sprintf(str, "%s,%d,%d", keyname, major, minor);
- efree(keyname);
- TypeLib = php_COM_find_typelib(str, mode TSRMLS_CC);
- efree(str);
- /* This is probbaly much harder to read and follow */
- /* But it is MUCH more effiecient than trying to */
- /* test for errors and leave through a single "return" */
- return TypeLib;
- }
- } else {
- /* Failed - perhaps too small abuffer */
- /* But if too small, then the name does not match */
- }
- }
- RegCloseKey(hsubkey);
- }
- efree(keyname);
- efree(libname);
- return NULL;
- }
- }
- efree(p);
- return TypeLib;
-}
-
-
-static int php_COM_load_typelib(ITypeLib *TypeLib, int mode TSRMLS_DC)
-{
- ITypeComp *TypeComp;
- int i;
- int interfaces;
-
- if (NULL == TypeLib) {
- return FAILURE;
- }
-
- interfaces = TypeLib->lpVtbl->GetTypeInfoCount(TypeLib);
-
- TypeLib->lpVtbl->GetTypeComp(TypeLib, &TypeComp);
- for (i=0; i<interfaces; i++) {
- TYPEKIND pTKind;
-
- TypeLib->lpVtbl->GetTypeInfoType(TypeLib, i, &pTKind);
- if (pTKind==TKIND_ENUM) {
- ITypeInfo *TypeInfo;
- VARDESC *pVarDesc;
- UINT NameCount;
- int j;
-#if 0
- BSTR bstr_EnumId;
- char *EnumId;
-
- TypeLib->lpVtbl->GetDocumentation(TypeLib, i, &bstr_EnumId, NULL, NULL, NULL);
- EnumId = php_OLECHAR_to_char(bstr_EnumId, NULL, codepage);
- printf("Enumeration %d - %s:\n", i, EnumId);
- efree(EnumId);
-#endif
-
- TypeLib->lpVtbl->GetTypeInfo(TypeLib, i, &TypeInfo);
-
- j=0;
- while (SUCCEEDED(TypeInfo->lpVtbl->GetVarDesc(TypeInfo, j, &pVarDesc))) {
- BSTR bstr_ids;
- zend_constant c;
- zval exists, results;
- char *const_name;
-
- TypeInfo->lpVtbl->GetNames(TypeInfo, pVarDesc->memid, &bstr_ids, 1, &NameCount);
- if (NameCount!=1) {
- j++;
- continue;
- }
- const_name = php_OLECHAR_to_char(bstr_ids, &c.name_len, codepage TSRMLS_CC);
- c.name = zend_strndup(const_name, c.name_len);
- efree(const_name);
- c.name_len++; /* length should include the NULL */
- SysFreeString(bstr_ids);
-
- /* Before registering the contsnt, let's see if we can find it */
- if (zend_get_constant(c.name, c.name_len-1, &exists TSRMLS_CC)) {
- /* Oops, it already exists. No problem if it is defined as the same value */
- /* Check to see if they are the same */
- if (!compare_function(&results, &c.value, &exists TSRMLS_CC) && INI_INT("com.autoregister_verbose")) {
- php_error(E_WARNING,"Type library value %s is already defined and has a different value", c.name);
- }
- free(c.name);
- j++;
- continue;
- }
-
- php_variant_to_pval(pVarDesc->lpvarValue, &c.value, codepage TSRMLS_CC);
- if (mode & CONST_PERSISTENT) {
- zval_persist(&c.value TSRMLS_CC);
- mode |= CONST_EFREE_PERSISTENT;
- }
- c.flags = mode;
-
- zend_register_constant(&c TSRMLS_CC);
-
- j++;
- }
- TypeInfo->lpVtbl->Release(TypeInfo);
- }
- }
-
- return SUCCESS;
-}
-
-
-/* {{{ proto bool com_isenum(object com_module)
- Grabs an IEnumVariant */
-PHP_FUNCTION(com_isenum)
-{
- pval *object;
- pval **comval_handle;
- comval *obj;
- int type;
-
- if (ZEND_NUM_ARGS() != 1) {
- ZEND_WRONG_PARAM_COUNT();
- }
-
- zend_get_parameters(ht, 1, &object);
-
- /* obtain IDispatch interface */
- zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &comval_handle);
- obj = (comval *) zend_list_find(Z_LVAL_PP(comval_handle), &type);
- if (!obj || (type != IS_COM)) {
- php_error(E_WARNING,"%s is not a COM object handler", "");
- RETURN_FALSE;
- }
-
- RETURN_BOOL(C_HASENUM(obj));
-}
-/* }}} */
-
-
-static void php_register_COM_class(TSRMLS_D)
-{
- INIT_OVERLOADED_CLASS_ENTRY(COM_class_entry, "COM", NULL,
- php_COM_call_function_handler,
- php_COM_get_property_handler,
- php_COM_set_property_handler);
-
- zend_register_internal_class(&COM_class_entry TSRMLS_CC);
-}
-
-
-static void php_COM_init(int module_number TSRMLS_DC)
-{
- le_comval = zend_register_list_destructors_ex(php_comval_destructor, NULL, "COM", module_number);
- php_register_COM_class(TSRMLS_C);
-}
-
-
-PHP_MINIT_FUNCTION(COM)
-{
- php_COM_init(module_number TSRMLS_CC);
- php_VARIANT_init(module_number TSRMLS_CC);
-
- REGISTER_LONG_CONSTANT("CLSCTX_INPROC_SERVER", CLSCTX_INPROC_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CLSCTX_INPROC_HANDLER", CLSCTX_INPROC_HANDLER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CLSCTX_LOCAL_SERVER", CLSCTX_LOCAL_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CLSCTX_REMOTE_SERVER", CLSCTX_REMOTE_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CLSCTX_SERVER", CLSCTX_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CLSCTX_ALL", CLSCTX_ALL, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_INI_ENTRIES();
-
- return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(COM)
-{
- UNREGISTER_INI_ENTRIES();
- return SUCCESS;
-}
-
-/* exports for external object creation */
-
-zend_module_entry COM_module_entry = {
- STANDARD_MODULE_HEADER,
- "com",
- COM_functions,
- PHP_MINIT(COM),
- PHP_MSHUTDOWN(COM),
- NULL,
- NULL,
- PHP_MINFO(COM),
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
-};
-
-PHPAPI int php_COM_get_le_comval()
-{
- return le_comval;
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- */
diff --git a/ext/com/CREDITS b/ext/com/CREDITS
deleted file mode 100644
index 27bb7a0b21..0000000000
--- a/ext/com/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-Win32 COM
-Zeev Suraski, Harald Radi, Alan Brown \ No newline at end of file
diff --git a/ext/com/TODO b/ext/com/TODO
deleted file mode 100644
index 6dccb556f8..0000000000
--- a/ext/com/TODO
+++ /dev/null
@@ -1,27 +0,0 @@
-1) Multi-dimenstional array support
--- done 2) IErrorInfo
--- done 13) export VARIANT through the COM module
-14) trap exceptions and errors
-3) WithEvents
-4) Documentation (internal and user) and howtos
-5) IEnumVariant::All() which would be like IEnumVariant::Next(IDispatch::Count)
-6) Look for memory leaks and AdRef/Release problems - I KNOW there are some...
-7) Test component (goes with the docs)
-8) Test suite (Needs test component)
-9) reduce the need for VARIANT()
-10) lets try if we are able to call non IDispatch - only Typelib components
--- done 11) IEnumVariant::Next() without parameter should only return an object, not an array with one element
--- done 12) VARIANT->value as lvalue
-
-
-ad 6.) check vbsample.php (new VARIANT(*, *|VT_BYREF)) GPs
-ad 4.) faq (i've collected a few questions from various lists)
- variant attributes !!
-
-to be discussed:
-
-- dcom inporc issue
-- mts support (getcontext)
-- adsi support (ads* functions)
-- winapi interface
-- try serialisation support (if component implements IPersist)
diff --git a/ext/com/VARIANT.c b/ext/com/VARIANT.c
deleted file mode 100644
index 2303481cee..0000000000
--- a/ext/com/VARIANT.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2002 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Harald Radi <h.radi@nme.at> |
- +----------------------------------------------------------------------+
- */
-
-
-/*
- * This module maps the VARIANT datastructure into PHP so that it can be used to
- * pass values to COM and DOTNET Objects by reference and not only by value.
- *
- * harald
- */
-
-#ifdef PHP_WIN32
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "php_VARIANT.h"
-
-#include <unknwn.h>
-
-static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC);
-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);
-static 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);
-static void php_register_VARIANT_class(TSRMLS_D);
-
-static int le_variant;
-static int codepage;
-static zend_class_entry VARIANT_class_entry;
-
-
-void php_VARIANT_init(int module_number TSRMLS_DC)
-{
- le_variant = zend_register_list_destructors_ex(php_VARIANT_destructor, NULL, "VARIANT", module_number);
-
- /* variant datatypes */
- REGISTER_LONG_CONSTANT("VT_NULL", VT_NULL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_EMPTY", VT_EMPTY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_UI1", VT_UI1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_I2", VT_I2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_I4", VT_I4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_R4", VT_R4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_R8", VT_R8, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_BOOL", VT_BOOL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_ERROR", VT_ERROR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_CY", VT_CY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_DATE", VT_DATE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_BSTR", VT_BSTR, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_DECIMAL", VT_DECIMAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_UNKNOWN", VT_UNKNOWN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_DISPATCH", VT_DISPATCH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_VARIANT", VT_VARIANT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_I1", VT_I1, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_UI2", VT_UI2, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_UI4", VT_UI4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_INT", VT_INT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_UINT", VT_UINT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_ARRAY", VT_ARRAY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("VT_BYREF", VT_BYREF, CONST_CS | CONST_PERSISTENT);
-
- /* codepages */
- 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_OEMCP", CP_OEMCP, 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);
-
-#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);
-}
-
-
-PHPAPI int php_VARIANT_get_le_variant()
-{
- return le_variant;
-}
-
-
-static void php_VARIANT_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference)
-{
- pval *object = property_reference->object;
- zend_overloaded_element *function_name = (zend_overloaded_element *) property_reference->elements_list->tail->data;
- VARIANT *pVar;
-
- if ((zend_llist_count(property_reference->elements_list)==1) && !strcmp(Z_STRVAL(function_name->element), "variant")) {
- /* constructor */
- pval *object_handle, *data, *type, *code_page;
-
- ALLOC_VARIANT(pVar);
- VariantInit(pVar);
-
- switch (ZEND_NUM_ARGS()) {
- case 0:
- /* nothing to do */
- break;
- case 1:
- zend_get_parameters(ht, 1, &data);
- php_pval_to_variant(data, pVar, codepage TSRMLS_CC);
- codepage = CP_ACP;
- break;
- case 2:
- zend_get_parameters(ht, 2, &data, &type);
- php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
- codepage = CP_ACP;
- break;
- case 3:
- zend_get_parameters(ht, 3, &data, &type, &code_page);
- php_pval_to_variant_ex(data, pVar, type, codepage TSRMLS_CC);
- convert_to_long(code_page);
- codepage = Z_LVAL_P(code_page);
- break;
- default:
- ZEND_WRONG_PARAM_COUNT();
- break;
- }
-
- RETVAL_LONG(zend_list_insert(pVar, IS_VARIANT));
-
- if (!zend_is_true(return_value)) {
- ZVAL_FALSE(object);
- return;
- }
-
- ALLOC_ZVAL(object_handle);
- *object_handle = *return_value;
- pval_copy_constructor(object_handle);
- INIT_PZVAL(object_handle);
- zend_hash_index_update(Z_OBJPROP_P(object), 0, &object_handle, sizeof(pval *), NULL);
- zval_dtor(&function_name->element);
- }
-}
-
-
-static pval php_VARIANT_get_property_handler(zend_property_reference *property_reference)
-{
- zend_overloaded_element *overloaded_property;
- int type;
- pval result, **var_handle, *object = property_reference->object;
- VARIANT *var_arg;
- TSRMLS_FETCH();
-
-
- /* fetch the VARIANT structure */
- zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
- var_arg = zend_list_find(Z_LVAL_PP(var_handle), &type);
-
- if (!var_arg || (type != IS_VARIANT)) {
- ZVAL_FALSE(&result);
- } else {
- overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
- switch (Z_TYPE_P(overloaded_property)) {
- case OE_IS_ARRAY:
- ZVAL_FALSE(&result);
- break;
-
- case OE_IS_OBJECT:
- if (!strcmp(Z_STRVAL(overloaded_property->element), "value")) {
- php_variant_to_pval(var_arg, &result, codepage TSRMLS_CC);
- } else if (!strcmp(Z_STRVAL(overloaded_property->element), "type")) {
- ZVAL_LONG(&result, V_VT(var_arg))
- } else {
- ZVAL_FALSE(&result);
- php_error(E_WARNING, "Unknown member.");
- }
- break;
- case OE_IS_METHOD:
- ZVAL_FALSE(&result);
- php_error(E_WARNING, "Unknown method.");
- break;
-
- zval_dtor(&overloaded_property->element);
- }
- }
-
- return result;
-}
-
-
-static int php_VARIANT_set_property_handler(zend_property_reference *property_reference, pval *value)
-{
- zend_overloaded_element *overloaded_property;
- int type;
- pval **var_handle, *object = property_reference->object;
- VARIANT *var_arg;
- TSRMLS_FETCH();
-
-
- /* fetch the VARIANT structure */
- zend_hash_index_find(Z_OBJPROP_P(object), 0, (void **) &var_handle);
- var_arg = zend_list_find(Z_LVAL_PP(var_handle), &type);
-
- if (!var_arg || (type != IS_VARIANT)) {
- return FAILURE;
- }
-
- overloaded_property = (zend_overloaded_element *) property_reference->elements_list->head->data;
- do_VARIANT_propset(var_arg, &overloaded_property->element, value TSRMLS_CC);
- zval_dtor(&overloaded_property->element);
- return SUCCESS;
-}
-
-
-static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
-{
- int type;
-
- if (!strcmp(Z_STRVAL_P(arg_property), "value")) {
- php_pval_to_variant(value, var_arg, codepage TSRMLS_CC);
-
- return SUCCESS;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "bVal")) {
- type = VT_UI1;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "iVal")) {
- type = VT_I2;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "lVal")) {
- type = VT_I4;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "fltVal")) {
- type = VT_R4;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "dblVal")) {
- type = VT_R8;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "boolVal")) {
- type = VT_BOOL;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "scode")) {
- type = VT_ERROR;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "cyVal")) {
- type = VT_CY;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "date")) {
- type = VT_DATE;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "bstrVal")) {
- type = VT_BSTR;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pdecVal")) {
- type = VT_DECIMAL|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "punkVal")) {
- type = VT_UNKNOWN;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pdispVal")) {
- type = VT_DISPATCH;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "parray")) {
- type = VT_ARRAY;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pbVal")) {
- type = VT_UI1|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "piVal")) {
- type = VT_I2|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "plVal")) {
- type = VT_I4|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pfltVal")) {
- type = VT_R4|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pdblVal")) {
- type = VT_R8|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pboolVal")) {
- type = VT_BOOL|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pscode")) {
- type = VT_ERROR|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pcyVal")) {
- type = VT_CY|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pdate")) {
- type = VT_DATE|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pbstrVal")) {
- type = VT_BSTR|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "ppunkVal")) {
- type = VT_UNKNOWN|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "ppdispVal")) {
- type = VT_DISPATCH|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pparray")) {
- type = VT_ARRAY|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pvarVal")) {
- type = VT_VARIANT|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "byref")) {
- type = VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "cVal")) {
- type = VT_I1;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "uiVal")) {
- type = VT_UI2;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "ulVal")) {
- type = VT_UI4;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "intVal")) {
- type = VT_INT;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "uintVal")) {
- type = VT_UINT|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pcVal")) {
- type = VT_I1|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "puiVal")) {
- type = VT_UI2|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pulVal")) {
- type = VT_UI4|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "pintVal")) {
- type = VT_INT|VT_BYREF;
- } else if (!strcmp(Z_STRVAL_P(arg_property), "puintVal")) {
- type = VT_UINT|VT_BYREF;
- } else {
- php_error(E_WARNING, "Unknown member.");
- return FAILURE;
- }
-
- php_pval_to_variant_ex2(value, var_arg, type, codepage TSRMLS_CC);
-
- return SUCCESS;
-}
-
-
-static void php_VARIANT_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
- FREE_VARIANT(rsrc->ptr);
-}
-
-static void php_register_VARIANT_class(TSRMLS_D)
-{
- INIT_OVERLOADED_CLASS_ENTRY(VARIANT_class_entry, "VARIANT", NULL,
- php_VARIANT_call_function_handler,
- php_VARIANT_get_property_handler,
- php_VARIANT_set_property_handler);
-
- zend_register_internal_class(&VARIANT_class_entry TSRMLS_CC);
-}
-
-#endif /* PHP_WIN32 */
diff --git a/ext/com/com.h b/ext/com/com.h
deleted file mode 100644
index 99c17782df..0000000000
--- a/ext/com/com.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef COM_H
-#define COM_H
-
-#if PHP_WIN32
-
-BEGIN_EXTERN_C()
-
-#include <oleauto.h>
-
-typedef struct comval_ {
-#ifdef _DEBUG
- int resourceindex;
-#endif
- BOOL typelib;
- BOOL enumeration;
- int refcount;
- struct {
- IDispatch *dispatch;
- ITypeInfo *typeinfo;
- IEnumVARIANT *enumvariant;
- } i;
-} comval;
-
-END_EXTERN_C()
-
-#define ZVAL_COM(z,o) { \
- zval *handle; \
- HashTable *properties; \
- \
- ALLOC_HASHTABLE(properties); \
- zend_hash_init(properties, 0, NULL, ZVAL_PTR_DTOR, 0); \
- \
- ALLOC_ZVAL(handle); \
- INIT_PZVAL(handle); \
- ZVAL_LONG(handle, zend_list_insert((o), IS_COM)); \
- \
- zval_copy_ctor(handle); \
- zend_hash_index_update(properties, 0, &handle, sizeof(zval *), NULL); \
- object_and_properties_init(z, &COM_class_entry, properties); \
- }
-
-#define RETVAL_COM(o) ZVAL_COM(&return_value, o);
-#define RETURN_COM(o) RETVAL_COM(o) \
- return;
-
-#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 C_HASTLIB(x) ((x)->typelib)
-#define C_HASENUM(x) ((x)->enumeration)
-#define C_REFCOUNT(x) ((x)->refcount)
-#define C_ISREFD(x) C_REFCOUNT(x)
-
-#define C_ADDREF(x) (++((x)->refcount))
-#define C_RELEASE(x) (--((x)->refcount))
-
-#define C_DISPATCH(x) ((x)->i.dispatch)
-#define C_TYPEINFO(x) ((x)->i.typeinfo)
-#define C_ENUMVARIANT(x) ((x)->i.enumvariant)
-
-#define C_DISPATCH_VT(x) (C_DISPATCH(x)->lpVtbl)
-#define C_TYPEINFO_VT(x) (C_TYPEINFO(x)->lpVtbl)
-#define C_ENUMVARIANT_VT(x) (C_ENUMVARIANT(x)->lpVtbl)
-
-#endif /* PHP_WIN32 */
-
-#endif /* COM_H */
diff --git a/ext/com/conversion.c b/ext/com/conversion.c
deleted file mode 100644
index 358314f132..0000000000
--- a/ext/com/conversion.c
+++ /dev/null
@@ -1,847 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 4 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2002 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Harald Radi <h.radi@nme.at> |
- | Alan Brown <abrown@pobox.com> |
- | Paul Shortis <pshortis@dataworx.com.au> |
- +----------------------------------------------------------------------+
- */
-
-/*
- * 03.6.2001
- * Added SafeArray ==> Hash support
- */
-
-/*
- * Paul Shortis June 7, 2001 <pshortis@dataworx.com.au> - Added code to support SafeArray passing
- * to COM objects. Support includes passing arrays of variants as well
- * as typed arrays.
- */
-
-#ifdef PHP_WIN32
-
-#include "php.h"
-#include "php_COM.h"
-#include "php_VARIANT.h"
-
-/* prototypes */
-
-static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
-
-/* implementations */
-PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC)
-{
- int type = VT_EMPTY; /* default variant type */
-
- switch (Z_TYPE_P(pval_arg)) {
- case IS_NULL:
- type = VT_NULL;
- break;
-
- case IS_BOOL:
- type = VT_BOOL;
- break;
-
- case IS_OBJECT:
- if (!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT")) {
- type = VT_VARIANT|VT_BYREF;
- } else if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
- type = VT_DISPATCH;
- }
- break;
-
- case IS_ARRAY:
- type = VT_ARRAY;
- break;
-
- case IS_RESOURCE:
- case IS_CONSTANT:
- case IS_CONSTANT_ARRAY:
- /* ?? */
- break;
-
- case IS_LONG:
- type = VT_I4; /* assuming 32-bit platform */
- break;
-
- case IS_DOUBLE:
- type = VT_R8; /* assuming 64-bit double precision */
- break;
-
- case IS_STRING:
- type = VT_BSTR;
- break;
- }
-
- php_pval_to_variant_ex2(pval_arg, var_arg, type, codepage TSRMLS_CC);
-}
-
-
-PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC)
-{
- php_pval_to_variant_ex2(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
-}
-
-
-PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
-{
- OLECHAR *unicode_str;
-
- VariantInit(var_arg);
- V_VT(var_arg) = type;
-
- 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
- output data type */
- HashTable *ht = Z_ARRVAL(*pval_arg);
- int numberOfElements = zend_hash_num_elements(ht);
- SAFEARRAY *safeArray;
- SAFEARRAYBOUND bounds[1];
- VARIANT *v;
- zval **entry; /* An entry in the input array */
-
- type &= ~VT_ARRAY;
-
- if (V_VT(var_arg) == (VT_ARRAY|VT_BYREF)) { /* == is intended, because VT_*|VT_BYREF|VT_ARRAY means something diffrent */
- type &= ~VT_BYREF;
- ALLOC_VARIANT(V_VARIANTREF(var_arg));
- var_arg = V_VARIANTREF(var_arg); /* put the array in that VARIANT */
- }
-
- bounds[0].lLbound = 0;
- bounds[0].cElements = numberOfElements;
- safeArray = SafeArrayCreate(VT_VARIANT, 1, bounds);
-
- if (NULL == safeArray) {
- php_error( E_WARNING,"Unable to convert php array to VARIANT array - %s", numberOfElements ? "" : "(Empty input array)");
- ZVAL_FALSE(pval_arg);
- } else {
- V_ARRAY(var_arg) = safeArray;
- V_VT(var_arg) = VT_ARRAY|VT_VARIANT; /* Now have a valid safe array allocated */
- if (SUCCEEDED(SafeArrayLock(safeArray))) {
- ulong i;
-
- zend_hash_internal_pointer_reset(ht);
- for (i = 0; i < (ulong)numberOfElements; ++i) {
- 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 */
- if (SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) { /* Pointer to output element entry retrieved successfully */
- if (type) { /* explicit type */
- php_pval_to_variant_ex2(*entry, v, type, codepage TSRMLS_CC); /* Do the required conversion */
- } else {
- php_pval_to_variant(*entry, v, codepage TSRMLS_CC); /* Do the required conversion */
- }
- } else {
- php_error( E_WARNING,"phpArrayToSafeArray() - Unable to retrieve pointer to output element number (%d)", i);
- }
- }
- zend_hash_move_forward(ht);
- }
- SafeArrayUnlock( safeArray);
- } else {
- php_error( E_WARNING,"phpArrayToSafeArray() - Unable to lock safeArray");
- }
- }
- } else {
- switch (V_VT(var_arg)) {
- case VT_UI1:
- convert_to_long_ex(&pval_arg);
- V_UI1(var_arg) = (unsigned char) Z_LVAL_P(pval_arg);
- break;
-
- case VT_I2:
- convert_to_long_ex(&pval_arg);
- V_I2(var_arg) = (short) Z_LVAL_P(pval_arg);
- break;
-
- case VT_I4:
- convert_to_long_ex(&pval_arg);
- V_I4(var_arg) = Z_LVAL_P(pval_arg);
- break;
-
- case VT_R4:
- convert_to_double_ex(&pval_arg);
- V_R4(var_arg) = (float) Z_DVAL_P(pval_arg);
- break;
-
- case VT_R8:
- convert_to_double_ex(&pval_arg);
- V_R8(var_arg) = Z_DVAL_P(pval_arg);
- break;
-
- case VT_BOOL:
- convert_to_boolean_ex(&pval_arg);
- if (Z_LVAL_P(pval_arg)) {
- V_BOOL(var_arg) = VT_TRUE;
- } else {
- V_BOOL(var_arg) = VT_FALSE;
- }
- break;
-
- case VT_ERROR:
- convert_to_long_ex(&pval_arg);
- V_ERROR(var_arg) = Z_LVAL_P(pval_arg);
- break;
-
- case VT_CY:
- convert_to_double_ex(&pval_arg);
- VarCyFromR8(Z_DVAL_P(pval_arg), &V_CY(var_arg));
- break;
-
- case VT_DATE: {
- SYSTEMTIME wintime;
- struct tm *phptime;
-
- switch (Z_TYPE_P(pval_arg)) {
- case IS_DOUBLE:
- /* already a VariantTime value */
- V_DATE(var_arg) = Z_DVAL_P(pval_arg);
- break;
-
- /** @todo
- case IS_STRING:
- /* string representation of a time value */
-
- default:
- /* a PHP time value ? */
- convert_to_long_ex(&pval_arg);
- phptime = gmtime(&(Z_LVAL_P(pval_arg)));
- memset(&wintime, 0, sizeof(wintime));
-
- wintime.wYear = phptime->tm_year + 1900;
- wintime.wMonth = phptime->tm_mon + 1;
- wintime.wDay = phptime->tm_mday;
- wintime.wHour = phptime->tm_hour;
- wintime.wMinute = phptime->tm_min;
- wintime.wSecond = phptime->tm_sec;
-
- SystemTimeToVariantTime(&wintime, &V_DATE(var_arg));
- break;
- }
- }
- break;
-
- case VT_BSTR:
- convert_to_string_ex(&pval_arg);
- unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str, Z_STRLEN_P(pval_arg) * sizeof(OLECHAR));
- efree(unicode_str);
- break;
-
- case VT_DECIMAL:
- convert_to_string_ex(&pval_arg);
- 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));
- break;
-
- case VT_DECIMAL|VT_BYREF:
- convert_to_string_ex(&pval_arg);
- 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));
- break;
-
- case VT_UNKNOWN:
- comval_to_variant(pval_arg, var_arg TSRMLS_CC);
- if (V_VT(var_arg) != VT_DISPATCH) {
- VariantInit(var_arg);
- } else {
- V_VT(var_arg) = VT_UNKNOWN;
- V_UNKNOWN(var_arg) = (IUnknown *) V_DISPATCH(var_arg);
- }
- break;
-
- case VT_DISPATCH:
- comval_to_variant(pval_arg, var_arg TSRMLS_CC);
- if (V_VT(var_arg) != VT_DISPATCH) {
- VariantInit(var_arg);
- }
- break;
-
- case VT_UI1|VT_BYREF:
- convert_to_long(pval_arg);
- V_UI1REF(var_arg) = (unsigned char FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_I2|VT_BYREF:
- convert_to_long(pval_arg);
- V_I2REF(var_arg) = (short FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_I4|VT_BYREF:
- convert_to_long(pval_arg);
- V_I4REF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_R4|VT_BYREF:
- convert_to_double(pval_arg);
- V_R4REF(var_arg) = (float FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_R8|VT_BYREF:
- convert_to_double(pval_arg);
- V_R8REF(var_arg) = (double FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_BOOL|VT_BYREF:
- convert_to_boolean(pval_arg);
- /* emalloc or malloc ? */
- V_BOOLREF(var_arg) = (short FAR*) pemalloc(sizeof(short), 1);
- if (Z_LVAL_P(pval_arg)) {
- *V_BOOLREF(var_arg) = VT_TRUE;
- } else {
- *V_BOOLREF(var_arg) = VT_TRUE;
- }
- break;
-
- case VT_ERROR|VT_BYREF:
- convert_to_long(pval_arg);
- V_ERRORREF(var_arg) = (long FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_CY|VT_BYREF:
- convert_to_double_ex(&pval_arg);
- VarCyFromR8(Z_DVAL_P(pval_arg), var_arg->pcyVal);
- break;
-
- case VT_DATE|VT_BYREF: {
- SYSTEMTIME wintime;
- struct tm *phptime;
-
- phptime = gmtime(&(Z_LVAL_P(pval_arg)));
- memset(&wintime, 0, sizeof(wintime));
-
- wintime.wYear = phptime->tm_year + 1900;
- wintime.wMonth = phptime->tm_mon + 1;
- wintime.wDay = phptime->tm_mday;
- wintime.wHour = phptime->tm_hour;
- wintime.wMinute = phptime->tm_min;
- wintime.wSecond = phptime->tm_sec;
-
- SystemTimeToVariantTime(&wintime, var_arg->pdate);
- }
- break;
-
- case VT_BSTR|VT_BYREF:
- convert_to_string(pval_arg);
- 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 TSRMLS_CC);
- *V_BSTRREF(var_arg) = SysAllocString(unicode_str);
- efree(unicode_str);
- break;
-
- case VT_UNKNOWN|VT_BYREF:
- comval_to_variant(pval_arg, var_arg TSRMLS_CC);
- if (V_VT(var_arg) != VT_DISPATCH) {
- VariantInit(var_arg);
- } else {
- V_VT(var_arg) = VT_UNKNOWN|VT_BYREF;
- V_UNKNOWNREF(var_arg) = (IUnknown **) &V_DISPATCH(var_arg);
- }
- break;
-
- case VT_DISPATCH|VT_BYREF:
- comval_to_variant(pval_arg, var_arg TSRMLS_CC);
- if (V_VT(var_arg) != VT_DISPATCH) {
- VariantInit(var_arg);
- } else {
- V_VT(var_arg) = VT_DISPATCH|VT_BYREF;
- V_DISPATCHREF(var_arg) = &V_DISPATCH(var_arg);
- }
- break;
-
- 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;
- pval **var_handle;
-
- /* fetch the VARIANT structure */
- zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &var_handle);
-
- V_VT(var_arg) = VT_VARIANT|VT_BYREF;
- V_VARIANTREF(var_arg) = (VARIANT FAR*) zend_list_find(Z_LVAL_P(*var_handle), &tp);
-
- if (!V_VARIANTREF(var_arg) && (tp != IS_VARIANT)) {
- VariantInit(var_arg);
- }
- }
- /*
- should be, but isn't :)
-
- if (V_VT(var_arg) != (VT_VARIANT|VT_BYREF))
- {
- VariantInit(var_arg);
- }
- */
- break;
-
- case VT_I1:
- convert_to_long_ex(&pval_arg);
- V_I1(var_arg) = (char)Z_LVAL_P(pval_arg);
- break;
-
- case VT_UI2:
- convert_to_long_ex(&pval_arg);
- V_UI2(var_arg) = (unsigned short)Z_LVAL_P(pval_arg);
- break;
-
- case VT_UI4:
- convert_to_long_ex(&pval_arg);
- V_UI4(var_arg) = (unsigned long)Z_LVAL_P(pval_arg);
- break;
-
- case VT_INT:
- convert_to_long_ex(&pval_arg);
- V_INT(var_arg) = (int)Z_LVAL_P(pval_arg);
- break;
-
- case VT_UINT:
- convert_to_long_ex(&pval_arg);
- V_UINT(var_arg) = (unsigned int)Z_LVAL_P(pval_arg);
- break;
-
- case VT_I1|VT_BYREF:
- convert_to_long(pval_arg);
- V_I1REF(var_arg) = (char FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_UI2|VT_BYREF:
- convert_to_long(pval_arg);
- V_UI2REF(var_arg) = (unsigned short FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_UI4|VT_BYREF:
- convert_to_long(pval_arg);
- V_UI4REF(var_arg) = (unsigned long FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_INT|VT_BYREF:
- convert_to_long(pval_arg);
- V_INTREF(var_arg) = (int FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- case VT_UINT|VT_BYREF:
- convert_to_long(pval_arg);
- V_UINTREF(var_arg) = (unsigned int FAR*) &Z_LVAL_P(pval_arg);
- break;
-
- default:
- php_error(E_WARNING, "Type not supported or not yet implemented.");
- }
- }
-}
-
-
-PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TSRMLS_DC)
-{
- /* Changed the function to return a value for recursive error testing */
- /* Existing calls will be unaffected by the change - so it */
- /* seemed like the smallest impact on unfamiliar code */
- int ret = SUCCESS;
-
- INIT_PZVAL(pval_arg);
-
- /* Add SafeArray support */
- if (V_ISARRAY(var_arg)) {
- SAFEARRAY *array = V_ARRAY(var_arg);
- LONG indices[1];
- LONG lbound=0, ubound;
- VARTYPE vartype;
- register int ii;
- UINT Dims;
- VARIANT vv;
- pval *element;
- HRESULT hr;
-
- /* TODO: Add support for multi-dimensional SafeArrays */
- /* For now just validate that the SafeArray has one dimension */
- if (1 != (Dims = SafeArrayGetDim(array))) {
- php_error(E_WARNING,"Unsupported: multi-dimensional (%d) SafeArrays", Dims);
- ZVAL_NULL(pval_arg);
- return FAILURE;
- }
- SafeArrayLock(array);
-
- /* This call has failed for everything I have tried */
- /* But best leave it to be on the safe side */
- if (FAILED(SafeArrayGetVartype(array, &vartype)) || (vartype == VT_EMPTY)) {
- /* Fall back to what we do know */
- /* Mask off the array bit and assume */
- /* what is left is the type of the array */
- /* elements */
- vartype = V_VT(var_arg) & ~VT_ARRAY;
- }
- SafeArrayGetUBound(array, 1, &ubound);
- SafeArrayGetLBound(array, 1, &lbound);
-
- /* Since COM returned an array we set up the php */
- /* return value to be an array */
- array_init(pval_arg);
-
- /* Walk the safe array */
- for (ii=lbound;ii<=ubound;ii++) {
- indices[0] = ii;
- VariantInit(&vv); /* Docs say this just set the vt field, but you never know */
- /* Set up a variant to pass to a recursive call */
- /* So that we do not need to have two copies */
- /* of the code */
- if (VT_VARIANT == vartype) {
- hr = SafeArrayGetElement(array, indices, (VOID *) &(vv));
- } else {
- V_VT(&vv) = vartype;
- hr = SafeArrayGetElement(array, indices, (VOID *) &(vv.lVal));
- }
- if (FAILED(hr)) {
- /* Failure to retieve an element probably means the array is sparse */
- /* So leave the php array sparse too */
- continue;
- }
- /* Create an element to be added to the array */
- ALLOC_ZVAL(element);
- /* Call ourself again to handle the base type conversion */
- /* If SafeArrayGetElement proclaims to allocate */
- /* memory for a BSTR, so the recursive call frees */
- /* the string correctly */
- if (FAILURE == php_variant_to_pval(&vv, element, codepage TSRMLS_CC)) {
- /* Error occurred setting up array element */
- /* Error was displayed by the recursive call */
- FREE_ZVAL(element);
- /* TODO: Do we stop here, or go on and */
- /* try to make sense of the rest of the array */
- /* Going on leads to multiple errors displayed */
- /* for the same conversion. For large arrays that */
- /* could be very annoying */
- /* And if we don't go on - what to do about */
- /* the parts of the array that are OK? */
- /* break; */
- } else {
- /* Just insert the element into our return array */
- add_index_zval(pval_arg, ii, element);
- }
- }
- SafeArrayUnlock(array);
- } else switch (var_arg->vt & ~VT_BYREF) {
- case VT_EMPTY:
- ZVAL_NULL(pval_arg);
- break;
-
- case VT_UI1:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_UI1REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_UI1(var_arg));
- }
- break;
-
- case VT_I2:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long )*V_I2REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_I2(var_arg));
- }
- break;
-
- case VT_I4:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, *V_I4REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, V_I4(var_arg));
- }
- break;
-
- case VT_R4:
- if (V_ISBYREF(var_arg)) {
- ZVAL_DOUBLE(pval_arg, (double)*V_R4REF(var_arg));
- } else {
- ZVAL_DOUBLE(pval_arg, (double)V_R4(var_arg));
- }
- break;
-
- case VT_R8:
- if (V_ISBYREF(var_arg)) {
- ZVAL_DOUBLE(pval_arg, *V_R8REF(var_arg));
- } else {
- ZVAL_DOUBLE(pval_arg, V_R8(var_arg));
- }
- break;
-
- /* 96bit uint */
- case VT_DECIMAL: {
- OLECHAR *unicode_str;
- switch (VarBstrFromDec(&V_DECIMAL(var_arg), LOCALE_SYSTEM_DEFAULT, 0, &unicode_str)) {
- case S_OK:
- Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(unicode_str, &Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- Z_TYPE_P(pval_arg) = IS_STRING;
- break;
-
- default:
- ZVAL_NULL(pval_arg);
- ret = FAILURE;
- php_error(E_WARNING, "Error converting DECIMAL value to PHP string");
- break;
- }
- }
- break;
-
- /* Currency */
- case VT_CY:
- if (V_ISBYREF(var_arg)) {
- VarR8FromCy(*V_CYREF(var_arg), &Z_DVAL_P(pval_arg));
- } else {
- VarR8FromCy(V_CY(var_arg), &Z_DVAL_P(pval_arg));
- }
- Z_TYPE_P(pval_arg) = IS_DOUBLE;
- break;
-
- case VT_BOOL:
- if (V_ISBYREF(var_arg)) {
- if (*V_BOOLREF(var_arg)) {
- ZVAL_BOOL(pval_arg, Z_TRUE);
- } else {
- ZVAL_BOOL(pval_arg, Z_FALSE);
- }
- } else {
- if (V_BOOL(var_arg)) {
- ZVAL_BOOL(pval_arg, Z_TRUE);
- } else {
- ZVAL_BOOL(pval_arg, Z_FALSE);
- }
- }
- break;
-
- case VT_NULL:
- case VT_VOID:
- ZVAL_NULL(pval_arg);
- break;
-
- case VT_VARIANT:
- php_variant_to_pval(V_VARIANTREF(var_arg), pval_arg, codepage TSRMLS_CC);
- break;
-
- case VT_BSTR:
- if (V_ISBYREF(var_arg)) {
- Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(*V_BSTRREF(var_arg), &Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- efree(V_BSTRREF(var_arg));
- } else {
- Z_STRVAL_P(pval_arg) = php_OLECHAR_to_char(V_BSTR(var_arg), &Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
- }
-
- Z_TYPE_P(pval_arg) = IS_STRING;
- break;
-
- case VT_DATE: {
- BOOL success;
- SYSTEMTIME wintime;
- struct tm phptime;
-
- if (V_ISBYREF(var_arg)) {
- success = VariantTimeToSystemTime(*V_DATEREF(var_arg), &wintime);
- } else {
- success = VariantTimeToSystemTime(V_DATE(var_arg), &wintime);
- }
-
- if (success) {
- memset(&phptime, 0, sizeof(phptime));
-
- phptime.tm_year = wintime.wYear - 1900;
- phptime.tm_mon = wintime.wMonth - 1;
- phptime.tm_mday = wintime.wDay;
- phptime.tm_hour = wintime.wHour;
- phptime.tm_min = wintime.wMinute;
- phptime.tm_sec = wintime.wSecond;
- phptime.tm_isdst = -1;
-
- tzset();
- ZVAL_LONG(pval_arg, mktime(&phptime));
- } else {
- ret = FAILURE;
- }
- }
- break;
-
- case VT_UNKNOWN:
- if (V_UNKNOWN(var_arg) == NULL) {
- V_DISPATCH(var_arg) = NULL;
- } else {
- HRESULT hr;
-
- hr = V_UNKNOWN(var_arg)->lpVtbl->QueryInterface(var_arg->punkVal, &IID_IDispatch, &V_DISPATCH(var_arg));
-
- if (FAILED(hr))
- {
- char *error_message;
-
- error_message = php_COM_error_message(hr TSRMLS_CC);
- php_error(E_WARNING,"Unable to obtain IDispatch interface: %s", error_message);
- LocalFree(error_message);
-
- V_DISPATCH(var_arg) = NULL;
- }
- }
- /* break missing intentionaly */
- case VT_DISPATCH: {
- comval *obj;
-
- if (V_DISPATCH(var_arg) == NULL) {
- ret = FAILURE;
- ZVAL_NULL(pval_arg);
- } else {
- ALLOC_COM(obj);
- php_COM_set(obj, &V_DISPATCH(var_arg), TRUE TSRMLS_CC);
-
- ZVAL_COM(pval_arg, obj);
- }
- }
- break;
-
- case VT_I1:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_I1REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_I1(var_arg));
- }
- break;
-
- case VT_UI2:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_UI2REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_UI2(var_arg));
- }
- break;
-
- case VT_UI4:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_UI4REF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_UI4(var_arg));
- }
- break;
-
- case VT_INT:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_INTREF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_INT(var_arg));
- }
- break;
-
- case VT_UINT:
- if (V_ISBYREF(var_arg)) {
- ZVAL_LONG(pval_arg, (long)*V_UINTREF(var_arg));
- } else {
- ZVAL_LONG(pval_arg, (long)V_UINT(var_arg));
- }
- break;
-
- default:
- php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", V_VT(var_arg), V_VT(var_arg));
- ZVAL_NULL(pval_arg);
- ret = FAILURE;
- break;
- }
- return ret;
-}
-
-
-PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC)
-{
- BOOL error = FALSE;
- OLECHAR *unicode_str;
-
- if (strlen == -1) {
- /* request needed buffersize */
- strlen = MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0);
- } else {
- /* \0 terminator */
- strlen++;
- }
-
- if (strlen >= 0) {
- unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen);
-
- /* convert string */
- error = !MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, strlen, unicode_str, strlen);
- } else {
- /* return a zero-length string */
- unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR));
- *unicode_str = 0;
-
- error = TRUE;
- }
-
- if (error) {
- switch (GetLastError()) {
- case ERROR_NO_UNICODE_TRANSLATION:
- php_error(E_WARNING, "No unicode translation available for the specified string");
- break;
- case ERROR_INSUFFICIENT_BUFFER:
- php_error(E_WARNING, "Internal Error: Insufficient Buffer");
- break;
- default:
- php_error(E_WARNING, "Unknown error in php_char_to_OLECHAR()");
- }
- }
-
- return unicode_str;
-}
-
-
-PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int codepage TSRMLS_DC)
-{
- char *C_str;
- uint length = 0;
-
- /* request needed buffersize */
- uint reqSize = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL);
-
- if (reqSize) {
- C_str = (char *) emalloc(sizeof(char) * reqSize);
-
- /* convert string */
- length = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1;
- } else {
- C_str = (char *) emalloc(sizeof(char));
- *C_str = 0;
-
- php_error(E_WARNING,"Error in php_OLECHAR_to_char()");
- }
-
- if (out_length) {
- *out_length = length;
- }
-
- return C_str;
-}
-
-
-static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC)
-{
- pval **comval_handle;
- comval *obj;
- int type;
-
- /* fetch the comval structure */
- zend_hash_index_find(Z_OBJPROP_P(pval_arg), 0, (void **) &comval_handle);
- obj = (comval *)zend_list_find(Z_LVAL_P(*comval_handle), &type);
- if (!obj || (type != IS_COM) || !C_ISREFD(obj)) {
- VariantInit(var_arg);
- } else {
- V_VT(var_arg) = VT_DISPATCH;
- V_DISPATCH(var_arg) = C_DISPATCH(obj);
- }
-}
-
-#endif /* PHP_WIN32 */ \ No newline at end of file
diff --git a/ext/com/conversion.h b/ext/com/conversion.h
deleted file mode 100644
index b8c534fa22..0000000000
--- a/ext/com/conversion.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef CONVERSION_H
-#define CONVERSION_H
-
-/* isn't this defined somewhere else ? */
-
-#define Z_TRUE 1
-#define Z_FALSE 0
-
-#define VT_TRUE -1
-#define VT_FALSE 0
-
-BEGIN_EXTERN_C()
-
-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 void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
-PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TSRMLS_DC);
-PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
-PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int codepage TSRMLS_DC);
-
-END_EXTERN_C()
-
-#endif \ No newline at end of file
diff --git a/ext/com/php_COM.h b/ext/com/php_COM.h
deleted file mode 100644
index 5c0155515b..0000000000
--- a/ext/com/php_COM.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef PHP_COM_H
-#define PHP_COM_H
-
-#if PHP_WIN32
-
-#include "com.h"
-
-BEGIN_EXTERN_C()
-
-PHP_MINIT_FUNCTION(COM);
-PHP_MSHUTDOWN_FUNCTION(COM);
-
-PHP_FUNCTION(com_load);
-PHP_FUNCTION(com_invoke);
-PHP_FUNCTION(com_addref);
-PHP_FUNCTION(com_release);
-PHP_FUNCTION(com_propget);
-PHP_FUNCTION(com_propput);
-PHP_FUNCTION(com_load_typelib);
-PHP_FUNCTION(com_isenum);
-
-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_class_entry COM_class_entry;
-
-#ifdef DEBUG
- extern int resourcecounter;
-#endif
-
-END_EXTERN_C()
-
-#define phpext_com_ptr &COM_module_entry
-
-#else
-
-#define phpext_com_ptr NULL
-
-#endif /* PHP_WIN32 */
-
-#endif /* PHP_COM_H */
diff --git a/ext/com/php_VARIANT.h b/ext/com/php_VARIANT.h
deleted file mode 100644
index 54347461c8..0000000000
--- a/ext/com/php_VARIANT.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef PHP_TYPEDEF_VARIANT_H
-#define PHP_TYPEDEF_VARIANT_H
-
-#if PHP_WIN32
-
-BEGIN_EXTERN_C()
-
-#include "conversion.h"
-#include "variant.h"
-
-void php_VARIANT_init(int module_number TSRMLS_DC);
-
-PHPAPI int php_VARIANT_get_le_variant();
-
-END_EXTERN_C()
-
-#endif /* PHP_WIN32 */
-
-#endif /* PHP_TYPEDEF_VARIANT_H */
diff --git a/ext/com/variant.h b/ext/com/variant.h
deleted file mode 100644
index 3fd11f32e4..0000000000
--- a/ext/com/variant.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef VARIANT_H
-#define VARIANT_H
-
-#if PHP_WIN32
-
-#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 ZVAL_VARIANT(z, v) if (V_VT(v) == VT_DISPATCH) { \
- comval *obj; \
- ALLOC_COM(obj); \
- php_COM_set(obj, &V_DISPATCH(v), TRUE TSRMLS_CC); \
- ZVAL_LONG((z), zend_list_insert(obj, IS_COM)); \
- } else { \
- php_variant_to_pval((v), (z), codepage TSRMLS_CC); \
- FREE_VARIANT(v); \
- }
-
-#define RETVAL_VARIANT(v) ZVAL_VARIANT(return_value, (v));
-#define RETURN_VARIANT(v) RETVAL_VARIANT(v) \
- return;
-
-
-#endif /* PHP_WIN32 */
-
-#endif /* VARIANT_H */