mapi32 vendor drop
Added: vendor/wine/dlls/mapi32/
Added: vendor/wine/dlls/mapi32/current/
Added: vendor/wine/dlls/mapi32/current/Makefile.in
Added: vendor/wine/dlls/mapi32/current/imalloc.c
Added: vendor/wine/dlls/mapi32/current/mapi32.spec
Added: vendor/wine/dlls/mapi32/current/mapi32_main.c
Added: vendor/wine/dlls/mapi32/current/prop.c
Added: vendor/wine/dlls/mapi32/current/util.c

Added: vendor/wine/dlls/mapi32/current/Makefile.in
--- vendor/wine/dlls/mapi32/current/Makefile.in	2006-01-14 18:51:22 UTC (rev 20858)
+++ vendor/wine/dlls/mapi32/current/Makefile.in	2006-01-14 19:29:26 UTC (rev 20859)
@@ -0,0 +1,20 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = mapi32.dll
+IMPORTLIB = libmapi32.$(IMPLIBEXT)
+IMPORTS   = shlwapi ole32 user32 kernel32 ntdll
+EXTRALIBS = -luuid $(LIBUNICODE)
+
+C_SRCS = \
+	imalloc.c \
+	mapi32_main.c \
+	prop.c \
+	util.c
+
+SUBDIRS = tests
+
+@MAKE_DLL_RULES@
+
+### Dependencies:
Property changes on: vendor/wine/dlls/mapi32/current/Makefile.in
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: vendor/wine/dlls/mapi32/current/imalloc.c
--- vendor/wine/dlls/mapi32/current/imalloc.c	2006-01-14 18:51:22 UTC (rev 20858)
+++ vendor/wine/dlls/mapi32/current/imalloc.c	2006-01-14 19:29:26 UTC (rev 20859)
@@ -0,0 +1,182 @@
+/*
+ * MAPI Default IMalloc implementation
+ *
+ * Copyright 2004 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+
+#define COBJMACROS
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "winternl.h"
+#include "objbase.h"
+#include "shlwapi.h"
+#include "mapiutil.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mapi);
+
+static const IMallocVtbl MAPI_IMalloc_vt;
+
+typedef struct
+{
+  const IMallocVtbl *lpVtbl;
+  LONG lRef;
+} MAPI_IMALLOC;
+
+static MAPI_IMALLOC MAPI_IMalloc = { &MAPI_IMalloc_vt, 0u };
+
+extern LONG MAPI_ObjectCount; /* In mapi32_main.c */
+
+/*************************************************************************
+ * MAPIGetDefaultMalloc@0 (MAPI32.59)
+ *
+ * Get the default MAPI IMalloc interface.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  A pointer to the MAPI default allocator.
+ */
+LPMALLOC WINAPI MAPIGetDefaultMalloc(void)
+{
+    TRACE("()\n");
+
+    IMalloc_AddRef((LPMALLOC)&MAPI_IMalloc);
+    return (LPMALLOC)&MAPI_IMalloc;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_QueryInterface
+ */
+static HRESULT WINAPI IMAPIMalloc_fnQueryInterface(LPMALLOC iface, REFIID refiid,
+                                                   LPVOID *ppvObj)
+{
+    TRACE("(%s,%p)\n", debugstr_guid(refiid), ppvObj);
+
+    if (IsEqualIID(refiid, &IID_IUnknown) ||
+        IsEqualIID(refiid, &IID_IMalloc))
+    {
+        *ppvObj = (LPMALLOC) &MAPI_IMalloc;
+        TRACE("Returning IMalloc (%p)\n", *ppvObj);
+        return S_OK;
+    }
+    TRACE("Returning E_NOINTERFACE\n");
+    return E_NOINTERFACE;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_AddRef
+ */
+static ULONG WINAPI IMAPIMalloc_fnAddRef(LPMALLOC iface)
+{
+    TRACE("(%p)\n", iface);
+    InterlockedIncrement(&MAPI_ObjectCount);
+    return 1u;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_Release
+ */
+static ULONG WINAPI IMAPIMalloc_fnRelease(LPMALLOC iface)
+{
+    TRACE("(%p)\n", iface);
+    InterlockedDecrement(&MAPI_ObjectCount);
+    return 1u;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_Alloc
+ */
+static LPVOID WINAPI IMAPIMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
+{
+    TRACE("(%p)->(%ld)\n", iface, cb);
+
+    return LocalAlloc(LMEM_FIXED, cb);
+}
+
+/**************************************************************************
+ * IMAPIMalloc_Realloc
+ */
+static LPVOID WINAPI IMAPIMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
+{
+    TRACE("(%p)->(%p, %ld)\n", iface, pv, cb);
+
+    if (!pv)
+        return LocalAlloc(LMEM_FIXED, cb);
+
+    if (cb)
+        return LocalReAlloc((HANDLE) pv, cb, LMEM_MOVEABLE);
+
+    LocalFree((HANDLE) pv);
+    return NULL;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_Free
+ */
+static void WINAPI IMAPIMalloc_fnFree(LPMALLOC iface, LPVOID pv)
+{
+    TRACE("(%p)->(%p)\n", iface, pv);
+    LocalFree((HANDLE) pv);
+}
+
+/**************************************************************************
+ * IMAPIMalloc_GetSize
+ */
+static DWORD WINAPI IMAPIMalloc_fnGetSize(LPMALLOC iface, LPVOID pv)
+{
+    TRACE("(%p)->(%p)\n", iface, pv);
+    return LocalSize((HANDLE) pv);
+}
+
+/**************************************************************************
+ * IMAPIMalloc_DidAlloc
+ */
+static INT WINAPI IMAPIMalloc_fnDidAlloc(LPMALLOC iface, LPVOID pv)
+{
+    TRACE("(%p)->(%p)\n", iface, pv);
+    return -1;
+}
+
+/**************************************************************************
+ * IMAPIMalloc_HeapMinimize
+ */
+static void WINAPI IMAPIMalloc_fnHeapMinimize(LPMALLOC iface)
+{
+    TRACE("(%p)\n", iface);
+}
+
+static const IMallocVtbl MAPI_IMalloc_vt =
+{
+    IMAPIMalloc_fnQueryInterface,
+    IMAPIMalloc_fnAddRef,
+    IMAPIMalloc_fnRelease,
+    IMAPIMalloc_fnAlloc,
+    IMAPIMalloc_fnRealloc,
+    IMAPIMalloc_fnFree,
+    IMAPIMalloc_fnGetSize,
+    IMAPIMalloc_fnDidAlloc,
+    IMAPIMalloc_fnHeapMinimize
+};
Property changes on: vendor/wine/dlls/mapi32/current/imalloc.c
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: vendor/wine/dlls/mapi32/current/mapi32.spec
--- vendor/wine/dlls/mapi32/current/mapi32.spec	2006-01-14 18:51:22 UTC (rev 20858)
+++ vendor/wine/dlls/mapi32/current/mapi32.spec	2006-01-14 19:29:26 UTC (rev 20859)
@@ -0,0 +1,191 @@
+  8 stub @
+ 10 stdcall MAPILogonEx(long ptr ptr long ptr)
+ 11 stdcall MAPILogonEx@20(long ptr ptr long ptr) MAPILogonEx
+ 12 stdcall MAPIAllocateBuffer(long ptr)
+ 13 stdcall MAPIAllocateBuffer@8(long ptr) MAPIAllocateBuffer
+ 14 stdcall MAPIAllocateMore(long ptr ptr)
+ 15 stdcall MAPIAllocateMore@12(long ptr ptr) MAPIAllocateMore
+ 16 stdcall MAPIFreeBuffer(ptr)
+ 17 stdcall MAPIFreeBuffer@4(ptr) MAPIFreeBuffer
+ 18 stub MAPIAdminProfiles
+ 19 stub MAPIAdminProfiles@8
+ 20 stdcall MAPIInitialize(ptr)
+ 21 stdcall MAPIInitialize@4(ptr) MAPIInitialize
+ 22 stdcall MAPIUninitialize()
+ 23 stdcall MAPIUninitialize@0() MAPIUninitialize
+ 24 stub PRProviderInit
+ 25 stub LAUNCHWIZARD
+ 26 stub LaunchWizard@20
+ 27 stub DllGetClassObject
+ 28 stdcall -private DllCanUnloadNow()
+ 29 stub MAPIOpenFormMgr
+ 30 stub MAPIOpenFormMgr@8
+ 31 stub MAPIOpenLocalFormContainer
+ 32 stub MAPIOpenLocalFormContainer@4
+ 33 stdcall ScInitMapiUtil@4(long) ScInitMapiUtil
+ 34 stdcall DeinitMapiUtil@0() DeinitMapiUtil
+ 35 stub ScGenerateMuid@4
+ 36 stub HrAllocAdviseSink@12
+ 41 stdcall WrapProgress@20(ptr ptr ptr ptr ptr) WrapProgress
+ 42 stdcall HrThisThreadAdviseSink@8(ptr ptr) HrThisThreadAdviseSink
+ 43 stub ScBinFromHexBounded@12
+ 44 stdcall FBinFromHex@8(ptr ptr) FBinFromHex
+ 45 stdcall HexFromBin@12(ptr long ptr) HexFromBin
+ 46 stub BuildDisplayTable@40
+ 47 stdcall SwapPlong@8(ptr long) SwapPlong
+ 48 stdcall SwapPword@8(ptr long) SwapPword
+ 49 stub MAPIInitIdle@4
+ 50 stub MAPIDeinitIdle@0
+ 51 stub InstallFilterHook@4
+ 52 stub FtgRegisterIdleRoutine@20
+ 53 stub EnableIdleRoutine@8
+ 54 stub DeregisterIdleRoutine@4
+ 55 stub ChangeIdleRoutine@28
+ 59 stdcall MAPIGetDefaultMalloc@0() MAPIGetDefaultMalloc
+ 60 stdcall CreateIProp@24(ptr ptr ptr ptr ptr ptr) CreateIProp
+ 61 stub CreateTable@36
+ 62 stdcall MNLS_lstrlenW@4(wstr) MNLS_lstrlenW
+ 63 stdcall MNLS_lstrcmpW@8(wstr wstr) MNLS_lstrcmpW
+ 64 stdcall MNLS_lstrcpyW@8(ptr wstr) MNLS_lstrcpyW
+ 65 stdcall MNLS_CompareStringW@24(long wstr wstr) MNLS_CompareStringW
+ 66 stdcall MNLS_MultiByteToWideChar@24(long long str long ptr long) kernel32.MultiByteToWideChar
+ 67 stdcall MNLS_WideCharToMultiByte@32(long long wstr long ptr long ptr ptr) kernel32.WideCharToMultiByte
+ 68 stdcall MNLS_IsBadStringPtrW@8(ptr long) kernel32.IsBadStringPtrW
+ 72 stdcall FEqualNames@8(ptr ptr) FEqualNames
+ 73 stub WrapStoreEntryID@24
+ 74 stdcall IsBadBoundedStringPtr@8(ptr long) IsBadBoundedStringPtr
+ 75 stub HrQueryAllRows@24
+ 76 stdcall PropCopyMore@16(ptr ptr ptr ptr) PropCopyMore
+ 77 stdcall UlPropSize@4(ptr) UlPropSize
+ 78 stdcall FPropContainsProp@12(ptr ptr long) FPropContainsProp
+ 79 stdcall FPropCompareProp@12(ptr long ptr) FPropCompareProp
+ 80 stdcall LPropCompareProp@8(ptr ptr) LPropCompareProp
+ 81 stub HrAddColumns@16
+ 82 stub HrAddColumnsEx@20
+121 stdcall -ret64 FtAddFt@16(double double) MAPI32_FtAddFt
+122 stub FtAdcFt@20
+123 stdcall -ret64 FtSubFt@16(double double) MAPI32_FtSubFt
+124 stdcall -ret64 FtMulDw@12(long double) MAPI32_FtMulDw
+125 stdcall -ret64 FtMulDwDw@8(long long) MAPI32_FtMulDwDw
+126 stdcall -ret64 FtNegFt@8(double) MAPI32_FtNegFt
+127 stub FtDivFtBogus@20
+128 stdcall UlAddRef@4(ptr) UlAddRef
+129 stdcall UlRelease@4(ptr) UlRelease
+130 stdcall SzFindCh@8(str long) shlwapi.StrChrA
+131 stdcall SzFindLastCh@8(str str long) shlwapi.StrRChrA
+132 stdcall SzFindSz@8(str str) shlwapi.StrStrA
+133 stdcall UFromSz@4(str) UFromSz
+135 stdcall HrGetOneProp@12(ptr long ptr) HrGetOneProp
+136 stdcall HrSetOneProp@8(ptr ptr) HrSetOneProp
+137 stdcall FPropExists@8(ptr long) FPropExists
+138 stdcall PpropFindProp@12(ptr long long) PpropFindProp
+139 stdcall FreePadrlist@4(ptr) FreePadrlist
+140 stdcall FreeProws@4(ptr) FreeProws
+141 stub HrSzFromEntryID@12
+142 stub HrEntryIDFromSz@12
+143 stub HrComposeEID@28
+144 stub HrDecomposeEID@28
+145 stub HrComposeMsgID@24
+146 stub HrDecomposeMsgID@24
+147 stdcall OpenStreamOnFile@24(ptr ptr ptr ptr ptr ptr) OpenStreamOnFile
+148 stdcall OpenStreamOnFile(ptr ptr ptr ptr ptr ptr)
+149 stub OpenTnefStream@28
+150 stub OpenTnefStream
+151 stub OpenTnefStreamEx@32
+152 stub OpenTnefStreamEx
+153 stub GetTnefStreamCodepage@12
+154 stub GetTnefStreamCodepage
+155 stdcall UlFromSzHex@4(ptr) UlFromSzHex
+156 stub UNKOBJ_ScAllocate@12
+157 stub UNKOBJ_ScAllocateMore@16
+158 stub UNKOBJ_Free@8
+159 stub UNKOBJ_FreeRows@8
+160 stub UNKOBJ_ScCOAllocate@12
+161 stub UNKOBJ_ScCOReallocate@12
+162 stub UNKOBJ_COFree@8
+163 stub UNKOBJ_ScSzFromIdsAlloc@20
+164 stub ScCountNotifications@12
+165 stub ScCopyNotifications@16
+166 stub ScRelocNotifications@20
+170 stdcall ScCountProps@12(long ptr ptr) ScCountProps
+171 stdcall ScCopyProps@16(long ptr ptr ptr) ScCopyProps
+172 stdcall ScRelocProps@20(long ptr ptr ptr ptr) ScRelocProps
+173 stdcall LpValFindProp@12(long long ptr) LpValFindProp
+174 stdcall ScDupPropset@16(long ptr ptr ptr) ScDupPropset
+175 stdcall FBadRglpszA@8(ptr long) FBadRglpszA
+176 stdcall FBadRglpszW@8(ptr long) FBadRglpszW
+177 stdcall FBadRowSet@4(ptr) FBadRowSet
+178 stub FBadRglpNameID@8
+179 stdcall FBadPropTag@4(long) FBadPropTag
+180 stdcall FBadRow@4(ptr) FBadRow
+181 stdcall FBadProp@4(ptr) FBadProp
+182 stdcall FBadColumnSet@4(ptr) FBadColumnSet
+183 stub RTFSync@12
+184 stub RTFSync
+185 stub WrapCompressedRTFStream@12
+186 stub WrapCompressedRTFStream
+187 stub __ValidateParameters@8
+188 stub __CPPValidateParameters@8
+189 stub FBadSortOrderSet@4
+190 stdcall FBadEntryList@4(ptr) FBadEntryList
+191 stub FBadRestriction@4
+192 stub ScUNCFromLocalPath@12
+193 stub ScLocalPathFromUNC@12
+194 stub HrIStorageFromStream@16
+195 stub HrValidateIPMSubtree@20
+196 stub OpenIMsgSession@12
+197 stub CloseIMsgSession@4
+198 stub OpenIMsgOnIStg@44
+199 stub SetAttribIMsgOnIStg@16
+200 stub GetAttribIMsgOnIStg@12
+201 stub MapStorageSCode@4
+202 stub ScMAPIXFromCMC
+203 stub ScMAPIXFromSMAPI
+204 stub EncodeID@12
+205 stub FDecodeID@12
+206 stub CchOfEncoding@4
+207 stdcall CbOfEncoded@4(ptr) CbOfEncoded
+208 stub MAPISendDocuments
+209 stdcall MAPILogon(long ptr ptr long long ptr)
+210 stub MAPILogoff
+211 stub MAPISendMail
+212 stub MAPISaveMail
+213 stub MAPIReadMail
+214 stub MAPIFindNext
+215 stub MAPIDeleteMail
+217 stub MAPIAddress
+218 stub MAPIDetails
+219 stub MAPIResolveName
+220 stub BMAPISendMail
+221 stub BMAPISaveMail
+222 stub BMAPIReadMail
+223 stub BMAPIGetReadMail
+224 stub BMAPIFindNext
+225 stub BMAPIAddress
+226 stub BMAPIGetAddress
+227 stub BMAPIDetails
+228 stub BMAPIResolveName
+229 stub cmc_act_on
+230 stub cmc_free
+231 stub cmc_list
+232 stub cmc_logoff
+233 stub cmc_logon
+234 stub cmc_look_up
+235 stdcall cmc_query_configuration( long long ptr ptr )
+236 stub cmc_read
+237 stub cmc_send
+238 stub cmc_send_documents
+239 stub HrDispatchNotifications@4
+241 stub HrValidateParameters@8
+244 stub ScCreateConversationIndex@16
+246 stub HrGetOmiProvidersFlags
+247 stub HrGetOmiProvidersFlags@8
+248 stub HrSetOmiProvidersFlagsInvalid
+249 stub HrSetOmiProvidersFlagsInvalid@4
+250 stub GetOutlookVersion
+251 stub GetOutlookVersion@0
+252 stub FixMAPI
+253 stub FixMAPI@0
+# This entry point is sometimes used to detect if the mapi dll came from Outlook
+#254 stub FGetComponentPath
+#255 stub FGetComponentPath@20

Added: vendor/wine/dlls/mapi32/current/mapi32_main.c
--- vendor/wine/dlls/mapi32/current/mapi32_main.c	2006-01-14 18:51:22 UTC (rev 20858)
+++ vendor/wine/dlls/mapi32/current/mapi32_main.c	2006-01-14 19:29:26 UTC (rev 20859)
@@ -0,0 +1,94 @@
+/*
+ *             MAPI basics
+ *
+ * Copyright 2001 CodeWeavers Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "objbase.h"
+#include "mapix.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mapi);
+
+LONG MAPI_ObjectCount = 0;
+
+/***********************************************************************
+ *              DllMain (MAPI32.init)
+ */
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
+{
+    TRACE("(%p,%ld,%p)\n", hinstDLL, fdwReason, fImpLoad);
+
+    switch (fdwReason)
+    {
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(hinstDLL);
+        break;
+    case DLL_PROCESS_DETACH:
+	TRACE("DLL_PROCESS_DETACH: %ld objects remaining\n", MAPI_ObjectCount);
+	break;
+    }
+    return TRUE;
+}
+
+/***********************************************************************
+ * DllCanUnloadNow (MAPI32.28)
+ *
+ * Determine if this dll can be unloaded from the callers address space.
+ *
+ * PARAMS
+ *  None.
+ *
+ * RETURNS
+ *  S_OK, if the dll can be unloaded,
+ *  S_FALSE, otherwise.
+ */
+HRESULT WINAPI DllCanUnloadNow(void)
+{
+    return MAPI_ObjectCount == 0 ? S_OK : S_FALSE;
+}
+
+HRESULT WINAPI MAPIInitialize ( LPVOID lpMapiInit )
+{
+    ERR("Stub\n");
+    return MAPI_E_NOT_INITIALIZED;
+}
+
+ULONG WINAPI MAPILogon(ULONG ulUIParam, LPSTR lpszProfileName, LPSTR
+lpszPassword, FLAGS flFlags, ULONG ulReserver, LPLHANDLE lplhSession)
+{
+    ERR("Stub\n");
+    return MAPI_E_LOGON_FAILED;
+}
+
+HRESULT WINAPI MAPILogonEx(ULONG_PTR ulUIParam, LPWSTR lpszProfileName,
+                           LPWSTR lpszPassword, ULONG flFlags,
+                           LPMAPISESSION *lppSession)
+{
+    ERR("Stub\n");
+    return MAPI_E_LOGON_FAILED;
+}
+
+VOID WINAPI MAPIUninitialize(void)
+{
+    ERR("Stub\n");
+}
Property changes on: vendor/wine/dlls/mapi32/current/mapi32_main.c
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: vendor/wine/dlls/mapi32/current/prop.c
--- vendor/wine/dlls/mapi32/current/prop.c	2006-01-14 18:51:22 UTC (rev 20858)
+++ vendor/wine/dlls/mapi32/current/prop.c	2006-01-14 19:29:26 UTC (rev 20859)
@@ -0,0 +1,2549 @@
+/*
+ * Property functions
+ *
+ * Copyright 2004 Jon Griffiths
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <stdarg.h>
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winerror.h"
+#include "winternl.h"
+#include "objbase.h"
+#include "shlwapi.h"
+#include "wine/list.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "mapival.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(mapi);
+
+BOOL WINAPI FBadRglpszA(LPSTR*,ULONG);
+
+/* Internal: Check if a property value array is invalid */
+static inline ULONG PROP_BadArray(LPSPropValue lpProp, size_t elemSize)
+{
+    return IsBadReadPtr(lpProp->Value.MVi.lpi, lpProp->Value.MVi.cValues * elemSize);
+}
+
+/*************************************************************************
+ * PropCopyMore@16 (MAPI32.76)
+ *
+ * Copy a property value.
+ *
+ * PARAMS
+ *  lpDest [O] Destination for the copied value
+ *  lpSrc  [I] Property value to copy to lpDest
+ *  lpMore [I] Linked memory allocation function (pass MAPIAllocateMore())
+ *  lpOrig [I] Original allocation to which memory will be linked
+ *
+ * RETURNS
+ *  Success: S_OK. lpDest contains a deep copy of lpSrc.
+ *  Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid,
+ *           MAPI_E_NOT_ENOUGH_MEMORY, if memory allocation fails.
+ *
+ * NOTES
+ *  Any elements within the property returned should not be individually
+ *  freed, as they will be freed when lpOrig is.
+ */
+SCODE WINAPI PropCopyMore(LPSPropValue lpDest, LPSPropValue lpSrc,
+                          ALLOCATEMORE *lpMore, LPVOID lpOrig)
+{
+    ULONG ulLen, i;
+    SCODE scode = S_OK;
+
+    TRACE("(%p,%p,%p,%p)\n", lpDest, lpSrc, lpMore, lpOrig);
+
+    if (!lpDest || IsBadWritePtr(lpDest, sizeof(SPropValue)) ||
+        FBadProp(lpSrc) || !lpMore)
+        return MAPI_E_INVALID_PARAMETER;
+
+    /* Shallow copy first, this is sufficient for properties without pointers */
+    *lpDest = *lpSrc;
+
+   switch (PROP_TYPE(lpSrc->ulPropTag))
+    {
+    case PT_CLSID:
+        scode = lpMore(sizeof(GUID), lpOrig, (LPVOID*)&lpDest->Value.lpguid);
+        if (SUCCEEDED(scode))
+            memcpy(lpDest->Value.lpguid, lpSrc->Value.lpguid, sizeof(GUID));
+        break;
+    case PT_STRING8:
+        ulLen = lstrlenA(lpSrc->Value.lpszA) + 1u;
+        scode = lpMore(ulLen, lpOrig, (LPVOID*)&lpDest->Value.lpszA);
+        if (SUCCEEDED(scode))
+            memcpy(lpDest->Value.lpszA, lpSrc->Value.lpszA, ulLen);
+        break;
+    case PT_UNICODE:
+        ulLen = (strlenW(lpSrc->Value.lpszW) + 1u) * sizeof(WCHAR);
+        scode = lpMore(ulLen, lpOrig, (LPVOID*)&lpDest->Value.lpszW);
+        if (SUCCEEDED(scode))
+            memcpy(lpDest->Value.lpszW, lpSrc->Value.lpszW, ulLen);
+        break;
+    case PT_BINARY:
+        scode = lpMore(lpSrc->Value.bin.cb, lpOrig, (LPVOID*)&lpDest->Value.bin.lpb);
+        if (SUCCEEDED(scode))
+            memcpy(lpDest->Value.bin.lpb, lpSrc->Value.bin.lpb, lpSrc->Value.bin.cb);
+        break;
+    default:
+        if (lpSrc->ulPropTag & MV_FLAG)
+        {
+            ulLen = UlPropSize(lpSrc);
+
+            if (PROP_TYPE(lpSrc->ulPropTag) == PT_MV_STRING8 ||
+                PROP_TYPE(lpSrc->ulPropTag) == PT_MV_UNICODE)
+            {
+                /* UlPropSize doesn't account for the string pointers */
+                ulLen += lpSrc->Value.MVszA.cValues * sizeof(char*);
+            }
+            else if (PROP_TYPE(lpSrc->ulPropTag) == PT_MV_BINARY)
+            {
+               /* UlPropSize doesn't account for the SBinary structs */
+               ulLen += lpSrc->Value.MVbin.cValues * sizeof(SBinary);
+            }
+
+            lpDest->Value.MVi.cValues = lpSrc->Value.MVi.cValues;
+            scode = lpMore(ulLen, lpOrig, (LPVOID*)&lpDest->Value.MVi.lpi);
+            if (FAILED(scode))
+                break;
+
+            /* Note that we could allocate the memory for each value in a
+             * multi-value property seperately, however if an allocation failed
+             * we would be left with a bunch of allocated memory, which (while
+             * not really leaked) is unusable until lpOrig is freed. So for
+             * strings and binary arrays we make a single allocation for all
+             * of the data. This is consistent since individual elements can't
+             * be freed anyway.
+             */
+
+            switch (PROP_TYPE(lpSrc->ulPropTag))
+            {
+            case PT_MV_STRING8:
+            {
+                char *lpNextStr = (char*)(lpDest->Value.MVszA.lppszA +
+                                          lpDest->Value.MVszA.cValues);
+
+                for (i = 0; i < lpSrc->Value.MVszA.cValues; i++)
+                {
+                    ULONG ulStrLen = lstrlenA(lpSrc->Value.MVszA.lppszA[i]) + 1u;
+
+                    lpDest->Value.MVszA.lppszA[i] = lpNextStr;
+                    memcpy(lpNextStr, lpSrc->Value.MVszA.lppszA[i], ulStrLen);
+                    lpNextStr += ulStrLen;
+                }
+                break;
+            }
+            case PT_MV_UNICODE:
+            {
+                WCHAR *lpNextStr = (WCHAR*)(lpDest->Value.MVszW.lppszW +
+                                            lpDest->Value.MVszW.cValues);
+
+                for (i = 0; i < lpSrc->Value.MVszW.cValues; i++)
+                {
+                    ULONG ulStrLen = strlenW(lpSrc->Value.MVszW.lppszW[i]) + 1u;
+
+                    lpDest->Value.MVszW.lppszW[i] = lpNextStr;
+                    memcpy(lpNextStr, lpSrc->Value.MVszW.lppszW[i], ulStrLen * sizeof(WCHAR));
+                    lpNextStr += ulStrLen;
+                }
+                break;
+            }
+            case PT_MV_BINARY:
+            {
+                LPBYTE lpNext = (LPBYTE)(lpDest->Value.MVbin.lpbin +
+                                         lpDest->Value.MVbin.cValues);
+
+                for (i = 0; i < lpSrc->Value.MVszW.cValues; i++)
+                {
+                    lpDest->Value.MVbin.lpbin[i].cb = lpSrc->Value.MVbin.lpbin[i].cb;
+                    lpDest->Value.MVbin.lpbin[i].lpb = lpNext;
+                    memcpy(lpNext, lpSrc->Value.MVbin.lpbin[i].lpb, lpDest->Value.MVbin.lpbin[i].cb);
+                    lpNext += lpDest->Value.MVbin.lpbin[i].cb;
+                }
+                break;
+            }
+            default:
+                /* No embedded pointers, just copy the data over */
+                memcpy(lpDest->Value.MVi.lpi, lpSrc->Value.MVi.lpi, ulLen);
+                break;
+            }
+            break;
+        }
+    }
+    return scode;
+}
+
+/*************************************************************************
+ * UlPropSize@4 (MAPI32.77)
+ *
+ * Determine the size of a property in bytes.
+ *
+ * PARAMS
+ *  lpProp [I] Property to determine the size of
+ *
+ * RETURNS
+ *  Success: The size of the value in lpProp.
+ *  Failure: 0, if a multi-value (array) property is invalid or the type of lpProp
+ *           is unknown.
+ *
+ * NOTES
+ *  - The size returned does not include the size of the SPropValue struct
+ *    or the size of the array of pointers for multi-valued properties that
+ *    contain pointers (such as PT_MV_STRING8 or PT-MV_UNICODE).
+ *  - MSDN incorrectly states that this function returns MAPI_E_CALL_FAILED if
+ *    lpProp is invalid. In reality no checking is performed and this function
+ *    will crash if passed an invalid property, or return 0 if the property
+ *    type is PT_OBJECT or is unknown.
+ */
+ULONG WINAPI UlPropSize(LPSPropValue lpProp)
+{
+    ULONG ulRet = 1u, i;
+
+    TRACE("(%p)\n", lpProp);
+
+    switch (PROP_TYPE(lpProp->ulPropTag))
+    {
+    case PT_MV_I2:       ulRet = lpProp->Value.MVi.cValues;
+    case PT_BOOLEAN:
+    case PT_I2:          ulRet *= sizeof(USHORT);
+                         break;
+    case PT_MV_I4:       ulRet = lpProp->Value.MVl.cValues;
+    case PT_ERROR:
+    case PT_I4:          ulRet *= sizeof(LONG);
+                         break;
+    case PT_MV_I8:       ulRet = lpProp->Value.MVli.cValues;
+    case PT_I8:          ulRet *= sizeof(LONG64);
+                         break;
+    case PT_MV_R4:       ulRet = lpProp->Value.MVflt.cValues;
+    case PT_R4:          ulRet *= sizeof(float);
+                         break;
+    case PT_MV_APPTIME:
+    case PT_MV_R8:       ulRet = lpProp->Value.MVdbl.cValues;
+    case PT_APPTIME:
+    case PT_R8:          ulRet *= sizeof(double);
+                         break;
+    case PT_MV_CURRENCY: ulRet = lpProp->Value.MVcur.cValues;
+    case PT_CURRENCY:    ulRet *= sizeof(CY);
+                         break;
+    case PT_MV_SYSTIME:  ulRet = lpProp->Value.MVft.cValues;
+    case PT_SYSTIME:     ulRet *= sizeof(FILETIME);
+                         break;
+    case PT_MV_CLSID:    ulRet = lpProp->Value.MVguid.cValues;
+    case PT_CLSID:       ulRet *= sizeof(GUID);
+                         break;
+    case PT_MV_STRING8:  ulRet = 0u;
+                         for (i = 0; i < lpProp->Value.MVszA.cValues; i++)
+                             ulRet += (lstrlenA(lpProp->Value.MVszA.lppszA[i]) + 1u);
+                         break;
+    case PT_STRING8:     ulRet = lstrlenA(lpProp->Value.lpszA) + 1u;
+                         break;
+    case PT_MV_UNICODE:  ulRet = 0u;
+                         for (i = 0; i < lpProp->Value.MVszW.cValues; i++)
+                             ulRet += (strlenW(lpProp->Value.MVszW.lppszW[i]) + 1u);
+                         ulRet *= sizeof(WCHAR);
+                         break;
+    case PT_UNICODE:     ulRet = (lstrlenW(lpProp->Value.lpszW) + 1u) * sizeof(WCHAR);
+                         break;
+    case PT_MV_BINARY:   ulRet = 0u;
+                         for (i = 0; i < lpProp->Value.MVbin.cValues; i++)
+                             ulRet += lpProp->Value.MVbin.lpbin[i].cb;
+                         break;
+    case PT_BINARY:      ulRet = lpProp->Value.bin.cb;
+                         break;
+    case PT_OBJECT:
+    default:             ulRet = 0u;
+                         break;
+    }
+
+    return ulRet;
+}
+
+/*************************************************************************
+ * FPropContainsProp@12 (MAPI32.78)
+ *
+ * Find a property with a given property tag in a property array.
+ *
+ * PARAMS
+ *  lpHaystack [I] Property to match to
+ *  lpNeedle   [I] Property to find in lpHaystack
+ *  ulFuzzy    [I] Flags controlling match type and strictness (FL_* flags from "mapidefs.h")
+ *
+ * RETURNS
+ *  TRUE, if lpNeedle matches lpHaystack according to the criteria of ulFuzzy.
+ *
+ * NOTES
+ *  Only property types of PT_STRING8 and PT_BINARY are handled by this function.
+ */
+BOOL WINAPI FPropContainsProp(LPSPropValue lpHaystack, LPSPropValue lpNeedle, ULONG ulFuzzy)
+{
+    TRACE("(%p,%p,0x%08lx)\n", lpHaystack, lpNeedle, ulFuzzy);
+
+    if (FBadProp(lpHaystack) || FBadProp(lpNeedle) ||
+        PROP_TYPE(lpHaystack->ulPropTag) != PROP_TYPE(lpNeedle->ulPropTag))
+        return FALSE;
+
+    /* FIXME: Do later versions support Unicode as well? */
+
+    if (PROP_TYPE(lpHaystack->ulPropTag) == PT_STRING8)
+    {
+        DWORD dwFlags = 0, dwNeedleLen, dwHaystackLen;
+
+        if (ulFuzzy & FL_IGNORECASE)
+            dwFlags |= NORM_IGNORECASE;
+        if (ulFuzzy & FL_IGNORENONSPACE)
+            dwFlags |= NORM_IGNORENONSPACE;
+        if (ulFuzzy & FL_LOOSE)
+            dwFlags |= (NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS);
+
+        dwNeedleLen = lstrlenA(lpNeedle->Value.lpszA);
+        dwHaystackLen = lstrlenA(lpHaystack->Value.lpszA);
+
+        if ((ulFuzzy & (FL_SUBSTRING|FL_PREFIX)) == FL_PREFIX)
+        {
+            if (dwNeedleLen <= dwHaystackLen &&
+                CompareStringA(LOCALE_USER_DEFAULT, dwFlags,
+                               lpHaystack->Value.lpszA, dwNeedleLen,
+                               lpNeedle->Value.lpszA, dwNeedleLen) == CSTR_EQUAL)
+                return TRUE; /* needle is a prefix of haystack */
+        }
+        else if ((ulFuzzy & (FL_SUBSTRING|FL_PREFIX)) == FL_SUBSTRING)
+        {
+            LPSTR (WINAPI *pStrChrFn)(LPCSTR,WORD) = StrChrA;
+            LPSTR lpStr = lpHaystack->Value.lpszA;
+
+            if (dwFlags & NORM_IGNORECASE)
+                pStrChrFn = StrChrIA;
+
+            while ((lpStr = pStrChrFn(lpStr, *lpNeedle->Value.lpszA)) != NULL)
+            {
+                dwHaystackLen -= (lpStr - lpHaystack->Value.lpszA);
+                if (dwNeedleLen <= dwHaystackLen &&
+                    CompareStringA(LOCALE_USER_DEFAULT, dwFlags,
+                               lpStr, dwNeedleLen,
+                               lpNeedle->Value.lpszA, dwNeedleLen) == CSTR_EQUAL)
+                    return TRUE; /* needle is a substring of haystack */
+                lpStr++;
+            }
+        }
+        else if (CompareStringA(LOCALE_USER_DEFAULT, dwFlags,
+                                lpHaystack->Value.lpszA, dwHaystackLen,
+                                lpNeedle->Value.lpszA, dwNeedleLen) == CSTR_EQUAL)
+            return TRUE; /* full string match */
+    }
+    else if (PROP_TYPE(lpHaystack->ulPropTag) == PT_BINARY)
+    {
+        if ((ulFuzzy & (FL_SUBSTRING|FL_PREFIX)) == FL_PREFIX)
+        {
+            if (lpNeedle->Value.bin.cb <= lpHaystack->Value.bin.cb &&
+                !memcmp(lpNeedle->Value.bin.lpb, lpHaystack->Value.bin.lpb,
+                        lpNeedle->Value.bin.cb))
+                return TRUE; /* needle is a prefix of haystack */
+        }
+        else if ((ulFuzzy & (FL_SUBSTRING|FL_PREFIX)) == FL_SUBSTRING)
+        {
+            ULONG ulLen = lpHaystack->Value.bin.cb;
+            LPBYTE lpb = lpHaystack->Value.bin.lpb;
+
+            while ((lpb = memchr(lpb, *lpNeedle->Value.bin.lpb, ulLen)) != NULL)
+            {
+                ulLen = lpHaystack->Value.bin.cb - (lpb - lpHaystack->Value.bin.lpb);
+                if (lpNeedle->Value.bin.cb <= ulLen &&
+                    !memcmp(lpNeedle->Value.bin.lpb, lpb, lpNeedle->Value.bin.cb))
+                    return TRUE; /* needle is a substring of haystack */
+                lpb++;
+            }
+        }
+        else if (!LPropCompareProp(lpHaystack, lpNeedle))
+            return TRUE; /* needle is an exact match with haystack */
+
+    }
+    return FALSE;
+}
+
+/*************************************************************************
+ * FPropCompareProp@12 (MAPI32.79)
+ *
+ * Compare two properties.
+ *
+ * PARAMS
+ *  lpPropLeft  [I] Left hand property to compare to lpPropRight
+ *  ulOp        [I] Comparison operator (RELOP_* enum from "mapidefs.h")
+ *  lpPropRight [I] Right hand property to compare to lpPropLeft
+ *
+ * RETURNS
+ *  TRUE, if the comparison is true, FALSE otherwise.
+ */
+BOOL WINAPI FPropCompareProp(LPSPropValue lpPropLeft, ULONG ulOp, LPSPropValue lpPropRight)
+{
+    LONG iCmp;
+
+    TRACE("(%p,%ld,%p)\n", lpPropLeft, ulOp, lpPropRight);
+
+    if (ulOp > RELOP_RE || FBadProp(lpPropLeft) || FBadProp(lpPropRight))
+        return FALSE;
+
+    if (ulOp == RELOP_RE)
+    {
+        FIXME("Comparison operator RELOP_RE not yet implemented!\n");
+        return FALSE;
+    }
+
+    iCmp = LPropCompareProp(lpPropLeft, lpPropRight);
+
+    switch (ulOp)
+    {
+    case RELOP_LT: return iCmp <  0 ? TRUE : FALSE;
+    case RELOP_LE: return iCmp <= 0 ? TRUE : FALSE;
+    case RELOP_GT: return iCmp >  0 ? TRUE : FALSE;
+    case RELOP_GE: return iCmp >= 0 ? TRUE : FALSE;
+    case RELOP_EQ: return iCmp == 0 ? TRUE : FALSE;
+    case RELOP_NE: return iCmp != 0 ? TRUE : FALSE;
+    }
+    return FALSE;
+}
+
+/*************************************************************************
+ * LPropCompareProp@8 (MAPI32.80)
+ *
+ * Compare two properties.
+ *
+ * PARAMS
+ *  lpPropLeft  [I] Left hand property to compare to lpPropRight
+ *  lpPropRight [I] Right hand property to compare to lpPropLeft
+ *
+ * RETURNS
+ *  An integer less than, equal to or greater than 0, indicating that
+ *  lpszStr is less than, the same, or greater than lpszComp.
+ */
+LONG WINAPI LPropCompareProp(LPSPropValue lpPropLeft, LPSPropValue lpPropRight)
+{
+    LONG iRet;
+
+    TRACE("(%p->0x%08lx,%p->0x%08lx)\n", lpPropLeft, lpPropLeft->ulPropTag,
+          lpPropRight, lpPropRight->ulPropTag);
+
+    /* If the properties are not the same, sort by property type */
+    if (PROP_TYPE(lpPropLeft->ulPropTag) != PROP_TYPE(lpPropRight->ulPropTag))
+        return (LONG)PROP_TYPE(lpPropLeft->ulPropTag) - (LONG)PROP_TYPE(lpPropRight->ulPropTag);
+
+    switch (PROP_TYPE(lpPropLeft->ulPropTag))
+    {
+    case PT_UNSPECIFIED:
+    case PT_NULL:
+        return 0; /* NULLs are equal */
+    case PT_I2:
+        return lpPropLeft->Value.i - lpPropRight->Value.i;
+    case PT_I4:
+        return lpPropLeft->Value.l - lpPropRight->Value.l;
+    case PT_I8:
+        if (lpPropLeft->Value.li.QuadPart > lpPropRight->Value.li.QuadPart)
+            return 1;
+        if (lpPropLeft->Value.li.QuadPart == lpPropRight->Value.li.QuadPart)
+            return 0;
+        return -1;
+    case PT_R4:
+        if (lpPropLeft->Value.flt > lpPropRight->Value.flt)
+            return 1;
+        if (lpPropLeft->Value.flt == lpPropRight->Value.flt)
+            return 0;
+        return -1;
+    case PT_APPTIME:
+    case PT_R8:
+        if (lpPropLeft->Value.dbl > lpPropRight->Value.dbl)
+            return 1;
[truncated at 1000 lines; 2919 more skipped]