Changelog:
Jon Griffiths <jon_p_griffiths@yahoo.com>
+dlls/oleaut32/oleaut32.spec dlls/oleaut32/oleaut.c
Document BSTR functions, add SetOANoCache()
+dlls/ntdll/error.c dlls/shlwapi/clist.c
Documentation updates
+tools/winebuild/res16.c
msvc warning fix
+libs/port/mkstemps.c
Portability fix
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
--- wine/tools/winebuild/res16.c 2003-09-11 17:11:52.000000000 +0100
+++ wine-develop/tools/winebuild/res16.c 2003-09-23 16:02:46.000000000 +0100
@@ -98,7 +98,7 @@
}
/* get the next byte from the current resource file */
-static WORD get_byte(void)
+static unsigned char get_byte(void)
{
unsigned char ret = *file_pos++;
if (file_pos > file_end) fatal_error( "%s is a truncated/corrupted file\n", file_name );
--- wine/libs/port/mkstemps.c 2003-08-13 19:29:18.000000000 +0100
+++ wine-develop/libs/port/mkstemps.c 2003-09-21 05:50:10.000000000 +0100
@@ -17,6 +17,7 @@
Boston, MA 02111-1307, USA. */
#include "config.h"
+#include "wine/port.h"
#include <sys/types.h>
#include <stdlib.h>
@@ -30,6 +31,9 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#ifdef HAVE_PROCESS_H
+#include <process.h>
+#endif
/* We need to provide a type for gcc_uint64_t. */
#ifdef __GNUC__
diff -u wine/dlls/oleaut32/oleaut32.spec wine-develop/dlls/oleaut32/oleaut32.spec
--- wine/dlls/oleaut32/oleaut32.spec 2003-09-11 17:11:10.000000000 +0100
+++ wine-develop/dlls/oleaut32/oleaut32.spec 2003-09-21 07:09:49.000000000 +0100
@@ -316,6 +316,7 @@
321 stdcall -private DllUnregisterServer() OLEAUT32_DllUnregisterServer
322 stub GetRecordInfoFromGuids # stdcall (ptr long long long ptr ptr)
323 stub GetRecordInfoFromTypeInfo # stdcall (ptr ptr)
+327 stdcall SetOaNoCache()
330 stdcall VarDateFromUdate(ptr long ptr)
331 stdcall VarUdateFromDate(double long ptr)
332 stub GetAltMonthNames
diff -u wine/dlls/oleaut32/oleaut.c wine-develop/dlls/oleaut32/oleaut.c
--- wine/dlls/oleaut32/oleaut.c 2003-09-11 17:11:10.000000000 +0100
+++ wine-develop/dlls/oleaut32/oleaut.c 2003-09-21 07:09:03.000000000 +0100
@@ -43,13 +43,51 @@
/* IDispatch marshaler */
extern const GUID CLSID_PSDispatch;
+static BOOL BSTR_bCache = TRUE; /* Cache allocations to minimise alloc calls? */
+
+/******************************************************************************
+ * BSTR {OLEAUT32}
+ *
+ * NOTES
+ * BSTR is a simple typedef for a wide-character string used as the principle
+ * string type in ole automation. When encapsulated in a Variant type they are
+ * automatically copied and destroyed as the variant is processed.
+ *
+ * The low level BSTR Api allows manipulation of these strings and is used by
+ * higher level Api calls to manage the strings transparently to the caller.
+ *
+ * Internally the BSTR type is allocated with space for a DWORD byte count before
+ * the string data begins. This is undocumented and non-system code should not
+ * access the count directly. Use SysStringLen() or SysStringByteLen()
+ * instead. Note that the byte count does not include the terminating NUL.
+ *
+ * To create a new BSTR, use SysAllocString(), SysAllocStringLen() or
+ * SysAllocStringByteLen(). To change the size of an existing BSTR, use SysReAllocString()
+ * or SysReAllocStringLen(). Finally to destroy a string use SysFreeString().
+ *
+ * BSTR's are cached by Ole Automation by default. To override this behaviour
+ * either set the environment variable 'OANOCACHE', or call SetOaNoCache().
+ *
+ * SEE ALSO
+ * 'Inside OLE, second edition' by Kraig Brockshmidt.
+ */
+
/******************************************************************************
* SysStringLen [OLEAUT32.7]
*
- * The Windows documentation states that the length returned by this function
- * is not necessarely the same as the length returned by the _lstrlenW method.
- * It is the same number that was passed in as the "len" parameter if the
- * string was allocated with a SysAllocStringLen method call.
+ * Get the allocated length of a BSTR in wide characters.
+ *
+ * PARAMS
+ * str [I] BSTR to find the length of
+ *
+ * RETURNS
+ * The allocated length of str, or 0 if str is NULL.
+ *
+ * NOTES
+ * See BSTR.
+ * The returned length may be different from the length of the string as
+ * calculated by lstrlenW(), since it returns the length that was used to
+ * allocate the string by SysAllocStringLen().
*/
int WINAPI SysStringLen(BSTR str)
{
@@ -70,10 +108,16 @@
/******************************************************************************
* SysStringByteLen [OLEAUT32.149]
*
- * The Windows documentation states that the length returned by this function
- * is not necessarely the same as the length returned by the _lstrlenW method.
- * It is the same number that was passed in as the "len" parameter if the
- * string was allocated with a SysAllocStringLen method call.
+ * Get the allocated length of a BSTR in bytes.
+ *
+ * PARAMS
+ * str [I] BSTR to find the length of
+ *
+ * RETURNS
+ * The allocated length of str, or 0 if str is NULL.
+ *
+ * NOTES
+ * See SysStringLen(), BSTR().
*/
int WINAPI SysStringByteLen(BSTR str)
{
@@ -94,34 +138,57 @@
/******************************************************************************
* SysAllocString [OLEAUT32.2]
*
- * MSDN (October 2001) states that this returns a NULL value if the argument
- * is a zero-length string. This does not appear to be true; certainly it
- * returns a value under Win98 (Oleaut32.dll Ver 2.40.4515.0)
+ * Create a BSTR from an OLESTR.
+ *
+ * PARAMS
+ * str [I] Source to create BSTR from
+ *
+ * RETURNS
+ * Success: A BSTR allocated with SysAllocStringLen().
+ * Failure: NULL, if oleStr is NULL.
+ *
+ * NOTES
+ * See BSTR.
+ * MSDN (October 2001) incorrectly states that NULL is returned if oleStr has
+ * a length of 0. Native Win32 and this implementation both return a valid
+ * empty BSTR in this case.
*/
-BSTR WINAPI SysAllocString(LPCOLESTR in)
+BSTR WINAPI SysAllocString(LPCOLESTR str)
{
- if (!in) return 0;
+ if (!str) return 0;
/* Delegate this to the SysAllocStringLen32 method. */
- return SysAllocStringLen(in, lstrlenW(in));
+ return SysAllocStringLen(str, lstrlenW(str));
}
/******************************************************************************
* SysFreeString [OLEAUT32.6]
+ *
+ * Free a BSTR.
+ *
+ * PARAMS
+ * str [I] BSTR to free.
+ *
+ * RETURNS
+ * Nothing.
+ *
+ * NOTES
+ * See BSTR.
+ * str may be NULL, in which case this function does nothing.
*/
-void WINAPI SysFreeString(BSTR in)
+void WINAPI SysFreeString(BSTR str)
{
DWORD* bufferPointer;
/* NULL is a valid parameter */
- if(!in) return;
+ if(!str) return;
/*
* We have to be careful when we free a BSTR pointer, it points to
* the beginning of the string but it skips the byte count contained
* before the string.
*/
- bufferPointer = (DWORD*)in;
+ bufferPointer = (DWORD*)str;
bufferPointer--;
@@ -134,14 +201,20 @@
/******************************************************************************
* SysAllocStringLen [OLEAUT32.4]
*
- * In "Inside OLE, second edition" by Kraig Brockshmidt. In the Automation
- * section, he describes the DWORD value placed *before* the BSTR data type.
- * he describes it as a "DWORD count of characters". By experimenting with
- * a windows application, this count seems to be a DWORD count of bytes in
- * the string. Meaning that the count is double the number of wide
- * characters in the string.
+ * Create a BSTR from an OLESTR of a given wide character length.
+ *
+ * PARAMS
+ * str [I] Source to create BSTR from
+ * len [I] Length of oleStr in wide characters
+ *
+ * RETURNS
+ * Success: A newly allocated BSTR from SysAllocStringByteLen()
+ * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
+ *
+ * NOTES
+ * See BSTR(), SysAllocStringByteLen().
*/
-BSTR WINAPI SysAllocStringLen(const OLECHAR *in, unsigned int len)
+BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
{
DWORD bufferSize;
DWORD* newBuffer;
@@ -183,8 +256,8 @@
* Since it is valid to pass a NULL pointer here, we'll initialize the
* buffer to nul if it is the case.
*/
- if (in != 0)
- memcpy(newBuffer, in, bufferSize);
+ if (str != 0)
+ memcpy(newBuffer, str, bufferSize);
else
memset(newBuffer, 0, bufferSize);
@@ -200,8 +273,23 @@
/******************************************************************************
* SysReAllocStringLen [OLEAUT32.5]
+ *
+ * Change the length of a previously created BSTR.
+ *
+ * PARAMS
+ * old [O] BSTR to change the length of
+ * str [I] New source for pbstr
+ * len [I] Length of oleStr in wide characters
+ *
+ * RETURNS
+ * Success: 1. The size of pbstr is updated.
+ * Failure: 0, if len >= 0x80000000 or memory allocation fails.
+ *
+ * NOTES
+ * See BSTR(), SysAllocStringByteLen().
+ * *pbstr may be changed by this function.
*/
-int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* in, unsigned int len)
+int WINAPI SysReAllocStringLen(BSTR* old, const OLECHAR* str, unsigned int len)
{
/*
* Sanity check
@@ -214,12 +302,12 @@
DWORD *ptr = HeapReAlloc(GetProcessHeap(),0,((DWORD*)*old)-1,newbytelen+sizeof(WCHAR)+sizeof(DWORD));
*old = (BSTR)(ptr+1);
*ptr = newbytelen;
- if (in) {
- memcpy(*old, in, newbytelen);
+ if (str) {
+ memcpy(*old, str, newbytelen);
(*old)[len] = 0;
} else {
/* Subtle hidden feature: The old string data is still there
- * when 'in' is NULL!
+ * when 'in' is NULL!
* Some Microsoft program needs it.
*/
}
@@ -227,7 +315,7 @@
/*
* Allocate the new string
*/
- *old = SysAllocStringLen(in, len);
+ *old = SysAllocStringLen(str, len);
}
return 1;
@@ -236,8 +324,24 @@
/******************************************************************************
* SysAllocStringByteLen [OLEAUT32.150]
*
+ * Create a BSTR from an OLESTR of a given byte length.
+ *
+ * PARAMS
+ * str [I] Source to create BSTR from
+ * len [I] Length of oleStr in bytes
+ *
+ * RETURNS
+ * Success: A newly allocated BSTR
+ * Failure: NULL, if len is >= 0x80000000, or memory allocation fails.
+ *
+ * NOTES
+ * -If len is 0 or oleStr is NULL the resulting string is empty ("").
+ * -This function always NUL terminates the resulting BSTR.
+ * -oleStr may be either an LPCSTR or LPCOLESTR, since it is copied
+ * without checking for a terminating NUL.
+ * See BSTR.
*/
-BSTR WINAPI SysAllocStringByteLen(LPCSTR in, UINT len)
+BSTR WINAPI SysAllocStringByteLen(LPCSTR str, UINT len)
{
DWORD* newBuffer;
char* stringBuffer;
@@ -273,8 +377,8 @@
* Since it is valid to pass a NULL pointer here, we'll initialize the
* buffer to nul if it is the case.
*/
- if (in != 0)
- memcpy(newBuffer, in, len);
+ if (str != 0)
+ memcpy(newBuffer, str, len);
/*
* Make sure that there is a nul character at the end of the
@@ -289,8 +393,21 @@
/******************************************************************************
* SysReAllocString [OLEAUT32.3]
+ *
+ * Change the length of a previously created BSTR.
+ *
+ * PARAMS
+ * old [I/O] BSTR to change the length of
+ * str [I] New source for pbstr
+ *
+ * RETURNS
+ * Success: 1
+ * Failure: 0.
+ *
+ * NOTES
+ * See BSTR(), SysAllocStringStringLen().
*/
-INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR in)
+INT WINAPI SysReAllocString(LPBSTR old,LPCOLESTR str)
{
/*
* Sanity check
@@ -307,11 +424,30 @@
/*
* Allocate the new string
*/
- *old = SysAllocString(in);
+ *old = SysAllocString(str);
return 1;
}
+/******************************************************************************
+ * SetOaNoCache (OLEAUT32.327)
+ *
+ * Instruct Ole Automation not to cache BSTR allocations.
+ *
+ * PARAMS
+ * None.
+ *
+ * RETURNS
+ * Nothing.
+ *
+ * NOTES
+ * See BSTR.
+ */
+void WINAPI SetOaNoCache(void)
+{
+ BSTR_bCache = FALSE;
+}
+
static WCHAR _delimiter[2] = {'!',0}; /* default delimiter apparently */
static WCHAR *pdelimiter = &_delimiter[0];
--- wine/dlls/shlwapi/istream.c 2003-09-11 17:11:13.000000000 +0100
+++ wine-develop/dlls/shlwapi/istream.c 2003-09-21 07:23:40.000000000 +0100
@@ -482,7 +482,7 @@
return E_INVALIDARG;
dwAttr = GetFileAttributesW(lpszPath);
- if (dwAttr == -1u)
+ if (dwAttr == INVALID_FILE_ATTRIBUTES)
dwAttr = 0;
return SHCreateStreamOnFileEx(lpszPath, dwMode|STGM_WRITE, dwAttr,
--- wine/dlls/shlwapi/clist.c 2003-09-11 17:11:13.000000000 +0100
+++ wine-develop/dlls/shlwapi/clist.c 2003-09-21 03:48:51.000000000 +0100
@@ -1,5 +1,5 @@
/*
- * SHLWAPI Compact List functions
+ * SHLWAPI DataBlock List functions
*
* Copyright 2002 Jon Griffiths
*
@@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell);
-/* Compact list element (ordinals 17-22) */
+/* DataBlock list element (ordinals 17-22) */
typedef struct tagSHLWAPI_CLIST
{
ULONG ulSize; /* Size of this list element and its data */
@@ -45,7 +45,7 @@
/*************************************************************************
* NextItem
*
- * Internal helper: move a clist pointer to the next item.
+ * Internal helper: move a DataBlock pointer to the next item.
*/
inline static LPSHLWAPI_CLIST NextItem(LPCSHLWAPI_CLIST lpList)
{
@@ -57,7 +57,7 @@
/*************************************************************************
* @ [SHLWAPI.17]
*
- * Write a compact list to an IStream object.
+ * Write a DataBlock list to an IStream object.
*
* PARAMS
* lpStream [I] IStream object to write the list to
@@ -69,23 +69,19 @@
*
* NOTES
* Ordinals 17,18,19,20,21 and 22 are related and together provide a compact
- * list structure which may be stored and retrieved from an IStream object.
+ * list structure (a "DataBlock List"), which may be stored and retrieved from
+ * an IStream object.
*
* The exposed API consists of:
*
- * SHWriteDataBlockList - Write a compact list to a stream,
+ * - SHWriteDataBlockList() - Write a DataBlock list to a stream,
+ * - SHReadDataBlockList() - Read and create a list from a stream,
+ * - SHFreeDataBlockList() - Free a list,
+ * - SHAddDataBlock() - Insert a new item into a list,
+ * - SHRemoveDataBlock() - Remove an item from a list,
+ * - SHFindDataBlock() - Find an item in a list.
*
- * SHReadDataBlockList - Read and create a list from a stream,
- *
- * SHFreeDataBlockList - Free a list,
- *
- * SHAddDataBlock - Insert a new item into a list,
- *
- * SHRemoveDataBlock - Remove an item from a list,
- *
- * SHFindDataBlock - Find an item in a list.
- *
- * The compact list is stored packed into a memory array. Each element has a
+ * The DataBlock list is stored packed into a memory array. Each element has a
* size and an associated ID. Elements must be less than 64k if the list is
* to be subsequently read from a stream.
*
@@ -137,7 +133,7 @@
/*************************************************************************
* @ [SHLWAPI.18]
*
- * Read and create a compact list from an IStream object.
+ * Read and create a DataBlock list from an IStream object.
*
* PARAMS
* lpStream [I] Stream to read the list from
@@ -237,7 +233,7 @@
/*************************************************************************
* @ [SHLWAPI.19]
*
- * Free a compact list.
+ * Free a DataBlock list.
*
* PARAMS
* lpList [I] List to free
@@ -259,7 +255,7 @@
/*************************************************************************
* @ [SHLWAPI.20]
*
- * Insert a new item into a compact list.
+ * Insert a new item into a DataBlock list.
*
* PARAMS
* lppList [0] Pointer to the List
@@ -354,7 +350,7 @@
/*************************************************************************
* @ [SHLWAPI.21]
*
- * Remove an item from a compact list.
+ * Remove an item from a DataBlock list.
*
* PARAMS
* lppList [O] List to remove the item from
@@ -424,7 +420,7 @@
/*************************************************************************
* @ [SHLWAPI.22]
*
- * Find an item in a compact list.
+ * Find an item in a DataBlock list.
*
* PARAMS
* lpList [I] List to search
--- wine/dlls/ntdll/error.c 2003-09-11 17:11:06.000000000 +0100
+++ wine-develop/dlls/ntdll/error.c 2003-09-19 19:35:59.000000000 +0100
@@ -43,6 +43,15 @@
/**************************************************************************
* RtlNtStatusToDosError (NTDLL.@)
+ *
+ * Convert an NTSTATUS code to a Win32 error code.
+ *
+ * PARAMS
+ * status [I] Nt error code to map.
+ *
+ * RETURNS
+ * The mapped Win32 error code, or ERROR_MR_MID_NOT_FOUND if there is no
+ * mapping defined.
*/
ULONG WINAPI RtlNtStatusToDosError( NTSTATUS status )
{
--- wine/dlls/shlwapi/wsprintf.c 2003-09-11 17:11:13.000000000 +0100
+++ wine-develop/dlls/shlwapi/wsprintf.c 2003-09-21 05:25:33.000000000 +0100
@@ -276,9 +276,9 @@
* Print formatted output to a string, up to a maximum number of chars.
*
* PARAMS
- * lpOut [O] Destination for output string
- * cchLimitIn [I] Maximum number of characters to write
- * lpFmt [I] Format string
+ * buffer [O] Destination for output string
+ * maxlen [I] Maximum number of characters to write
+ * spec [I] Format string
*
* RETURNS
* Success: The number of characters written.