diff --git a/NEWS b/NEWS index 36ddefc30bf..f77b7618189 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ PHP 4.0 NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ?? 1999, Version 4.0 Beta 3 - +- Improved the Win32 COM module to support [out] parameters (Boris Wedl) - Fixed garbage returned at the end of certain Sybase-Columns (Thies) Patch submitted by: neal@wanlink.com - Added Microsoft SQL Server module for Win32 (Frank) diff --git a/ext/rpc/com/COM.c b/ext/rpc/com/COM.c index c726b700d01..5bc41c10c85 100644 --- a/ext/rpc/com/COM.c +++ b/ext/rpc/com/COM.c @@ -70,7 +70,7 @@ static PHP_MINFO_FUNCTION(COM) } -php3_module_entry COM_module_entry = { +zend_module_entry COM_module_entry = { "Win32 COM", COM_functions, PHP_MINIT(COM), PHP_MSHUTDOWN(COM), NULL, NULL, PHP_MINFO(COM), STANDARD_MODULE_PROPERTIES }; @@ -78,7 +78,7 @@ void php_register_COM_class(); static int php_COM_load_typelib(char *typelib_name, int mode); -static char *_php3_COM_error_message(HRESULT hr) +static char *php_COM_error_message(HRESULT hr) { void *pMsgBuf; @@ -126,7 +126,7 @@ char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent } -static char *_php3_string_from_clsid(CLSID *clsid) +static char *php_string_from_clsid(CLSID *clsid) { LPOLESTR ole_clsid; char *clsid_str; @@ -140,7 +140,7 @@ static char *_php3_string_from_clsid(CLSID *clsid) } -static void _php3_idispatch_destructor(IDispatch *i_dispatch) +static void php_idispatch_destructor(IDispatch *i_dispatch) { i_dispatch->lpVtbl->Release(i_dispatch); } @@ -217,7 +217,7 @@ PHP_INI_END() PHP_MINIT_FUNCTION(COM) { CoInitialize(NULL); - le_idispatch = register_list_destructors(_php3_idispatch_destructor,NULL); + le_idispatch = register_list_destructors(php_idispatch_destructor,NULL); php_register_COM_class(); REGISTER_INI_ENTRIES(); return SUCCESS; @@ -266,7 +266,7 @@ PHP_FUNCTION(COM_load) // obtain CLSID if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); + error_message = php_COM_error_message(hr); php_error(E_WARNING,"Invalid ProgID: %s\n", error_message); LocalFree(error_message); RETURN_FALSE; @@ -295,8 +295,8 @@ PHP_FUNCTION(COM_load) efree(server_info.pwszName); } if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); - clsid_str = _php3_string_from_clsid(&clsid); + error_message = php_COM_error_message(hr); + clsid_str = php_string_from_clsid(&clsid); php_error(E_WARNING,"Unable to obtain IDispatch interface for CLSID %s: %s",clsid_str,error_message); LocalFree(error_message); efree(clsid_str); @@ -309,43 +309,78 @@ PHP_FUNCTION(COM_load) static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persistent) { - switch (var_arg->vt) { + + switch (var_arg->vt & ~VT_BYREF) { case VT_EMPTY: var_uninit(pval_arg); break; case VT_UI1: - pval_arg->value.lval = (long) var_arg->bVal; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + pval_arg->value.lval = (long) var_arg->bVal; + else + pval_arg->value.lval = (long)*(var_arg->pbVal); pval_arg->type = IS_LONG; break; case VT_I2: - pval_arg->value.lval = (long) var_arg->iVal; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + pval_arg->value.lval = (long) var_arg->iVal; + else + pval_arg->value.lval = (long )*(var_arg->piVal); pval_arg->type = IS_LONG; break; case VT_I4: - pval_arg->value.lval = var_arg->lVal; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + pval_arg->value.lval = var_arg->lVal; + else + pval_arg->value.lval = *(var_arg->plVal); pval_arg->type = IS_LONG; break; case VT_R4: - pval_arg->value.dval = (double) var_arg->fltVal; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + pval_arg->value.dval = (double) var_arg->fltVal; + else + pval_arg->value.dval = (double)*(var_arg->pfltVal); + pval_arg->type = IS_DOUBLE; break; case VT_R8: - pval_arg->value.dval = var_arg->dblVal; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + pval_arg->value.dval = var_arg->dblVal; + else + pval_arg->value.dval = *(var_arg->pdblVal); pval_arg->type = IS_DOUBLE; break; case VT_BOOL: - - if (var_arg->boolVal & 0xFFFF) { - pval_arg->value.lval = 1; - } else { - - pval_arg->value.lval = 0; + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + { + if (var_arg->boolVal & 0xFFFF) { + pval_arg->value.lval = 1; + } else { + pval_arg->value.lval = 0; + } + } + else + { + if (*(var_arg->pboolVal) & 0xFFFF) { + pval_arg->value.lval = 1; + } else { + pval_arg->value.lval = 0; + } } - pval_arg->type = IS_BOOL; break; case VT_BSTR: - pval_arg->value.str.val = php_OLECHAR_to_char(var_arg->bstrVal, &pval_arg->value.str.len, persistent); + if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) + { + pval_arg->value.str.val = php_OLECHAR_to_char(var_arg->bstrVal, &pval_arg->value.str.len, persistent); + SysFreeString(var_arg->bstrVal); + } + else + { + pval_arg->value.str.val = php_OLECHAR_to_char(*(var_arg->pbstrVal), &pval_arg->value.str.len, persistent); + SysFreeString(*(var_arg->pbstrVal)); + efree(var_arg->pbstrVal); + } pval_arg->type = IS_STRING; break; case VT_UNKNOWN: @@ -362,7 +397,7 @@ static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persist } -static void _php3_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg) +static void php_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg) { OLECHAR *unicode_str; @@ -373,8 +408,16 @@ static void _php3_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg) break; case IS_LONG: case IS_BOOL: - var_arg->vt = VT_I4; // assuming 32-bit platform - var_arg->lVal = pval_arg->value.lval; + if (pval_arg->is_ref == 0) + { + var_arg->vt = VT_I4; // assuming 32-bit platform + var_arg->lVal = pval_arg->value.lval; + } + else + { + var_arg->vt = VT_I4 | VT_BYREF; // assuming 32-bit platform + var_arg->plVal = &(pval_arg->value.lval); + } break; case IS_DOUBLE: var_arg->vt = VT_R8; // assuming 64-bit double precision @@ -382,15 +425,23 @@ static void _php3_pval_to_variant(pval *pval_arg, VARIANTARG *var_arg) break; case IS_STRING: unicode_str = php_char_to_OLECHAR(pval_arg->value.str.val, pval_arg->value.str.len); - var_arg->bstrVal = SysAllocString(unicode_str); - var_arg->vt = VT_BSTR; + if (pval_arg->is_ref == 0) + { + var_arg->bstrVal = SysAllocString(unicode_str); + var_arg->vt = VT_BSTR; + } + else + { + var_arg->pbstrVal = (BSTR *)emalloc(sizeof(BSTR *)); + *(var_arg->pbstrVal) = SysAllocString(unicode_str); + var_arg->vt = VT_BSTR | VT_BYREF; + break; + } efree(unicode_str); - break; } } - int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_result, pval **arguments, int arg_count) { DISPID dispid; @@ -407,7 +458,7 @@ int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_re 1, LOCALE_SYSTEM_DEFAULT, &dispid); if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); + error_message = php_COM_error_message(hr); php_error(E_WARNING,"Unable to lookup %s: %s\n", function_name->value.str.val, error_message); LocalFree(error_message); efree(funcname); @@ -418,7 +469,7 @@ int do_COM_invoke(IDispatch *i_dispatch, pval *function_name, VARIANTARG *var_re for (current_arg=0; current_argvalue.str.val, error_message); LocalFree(error_message); efree(propname); @@ -543,7 +602,7 @@ static int do_COM_propget(VARIANTARG *var_result, IDispatch *i_dispatch, pval *a &dispparams, var_result, NULL, 0); if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); + error_message = php_COM_error_message(hr); php_error(E_WARNING,"PropGet() failed: %s\n", error_message); LocalFree(error_message); efree(propname); @@ -581,7 +640,7 @@ static void do_COM_propput(pval *return_value, IDispatch *i_dispatch, pval *arg_ 1, LOCALE_SYSTEM_DEFAULT, &dispid); if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); + error_message = php_COM_error_message(hr); php_error(E_WARNING,"Unable to lookup %s: %s\n", arg_property->value.str.val, error_message); LocalFree(error_message); efree(propname); @@ -589,7 +648,7 @@ static void do_COM_propput(pval *return_value, IDispatch *i_dispatch, pval *arg_ } - _php3_pval_to_variant(value, &new_value); + php_pval_to_variant(value, &new_value); dispparams.rgvarg = &new_value; dispparams.rgdispidNamedArgs = &mydispid; dispparams.cArgs = 1; @@ -607,7 +666,7 @@ static void do_COM_propput(pval *return_value, IDispatch *i_dispatch, pval *arg_ &dispparams, &var_result, NULL, 0); if (FAILED(hr)) { - error_message = _php3_COM_error_message(hr); + error_message = php_COM_error_message(hr); php_error(E_WARNING,"PropPut() failed: %s\n", error_message); LocalFree(error_message); efree(propname); diff --git a/ext/session/session.c b/ext/session/session.c index 73f5bb5f607..07058207ffb 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -891,7 +891,7 @@ static void php_rinit_session_globals(PSLS_D) zend_hash_init(&PS(vars), 0, NULL, NULL, 0); PS(define_sid) = 0; - PS(use_cookies) = INI_INT("session.use_cookies"); + PS(use_cookies) = INI_BOOL("session.use_cookies"); PS(save_path) = estrdup(INI_STR("session.save_path")); PS(session_name) = estrdup(INI_STR("session.name")); PS(entropy_file) = estrdup(INI_STR("session.entropy_file")); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 67297c1c481..3c960466757 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3153,7 +3153,7 @@ PHP_FUNCTION(getservbyport) convert_to_long_ex(port); convert_to_string_ex(proto); - serv = getservbyport(htons((*port)->value.lval),(*proto)->value.str.val); + serv = getservbyport(htons((unsigned short) (*port)->value.lval),(*proto)->value.str.val); if(serv == NULL) RETURN_FALSE; diff --git a/main/mergesort.c b/main/mergesort.c index 0cb10291263..d0461a58c9b 100644 --- a/main/mergesort.c +++ b/main/mergesort.c @@ -62,8 +62,8 @@ static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; #include /* Includes definition for u_char */ #endif -static void setup (u_char *, u_char *, size_t, size_t, int (*)()); -static void insertionsort (u_char *, size_t, size_t, int (*)()); +static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *)); +static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *)); #define ISIZE sizeof(int) #define PSIZE sizeof(u_char *) @@ -98,14 +98,10 @@ static void insertionsort (u_char *, size_t, size_t, int (*)()); /* * Arguments are as for qsort. */ -int -mergesort(base, nmemb, size, cmp) - void *base; - size_t nmemb; - register size_t size; - int (*cmp) (const void *, const void *); +int mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) { - register int i, sense; + register unsigned int i; + register int sense; int big, iflag; register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; u_char *list2, *list1, *p2, *p, *last, **p1; @@ -261,11 +257,7 @@ COPY: b = t; * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL * is defined. Otherwise simple pairwise merging is used.) */ -void -setup(list1, list2, n, size, cmp) - size_t n, size; - int (*cmp) (const void *, const void *); - u_char *list1, *list2; +static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *)) { int i, length, size2, tmp, sense; u_char *f1, *f2, *s, *l2, *last, *p2; @@ -335,11 +327,7 @@ setup(list1, list2, n, size, cmp) * This is to avoid out-of-bounds addresses in sorting the * last 4 elements. */ -static void -insertionsort(a, n, size, cmp) - u_char *a; - size_t n, size; - int (*cmp) (const void *, const void *); +static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *)) { u_char *ai, *s, *t, *u, tmp; int i; diff --git a/main/php_ini.h b/main/php_ini.h index 339c4aa7ace..1aa64c3da55 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -117,11 +117,12 @@ PHPAPI PHP_INI_DISP(php_ini_color_displayer_cb); #define INI_INT(name) php_ini_long((name), sizeof(name), 0) #define INI_FLT(name) php_ini_double((name), sizeof(name), 0) #define INI_STR(name) php_ini_string((name), sizeof(name), 0) - +#define INI_BOOL(name) ((zend_bool) INI_INT(name)) #define INI_ORIG_INT(name) php_ini_long((name), sizeof(name), 1) #define INI_ORIG_FLT(name) php_ini_double((name), sizeof(name), 1) #define INI_ORIG_STR(name) php_ini_string((name), sizeof(name), 1) +#define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name)) #define REGISTER_INI_ENTRIES() php_register_ini_entries(ini_entries, module_number)