libwine: Fix a memory leak.
[wine] / dlls / mapi32 / mapi32_main.c
index 6342875..c0363fb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *             MAPI basics
  *
- * Copyright 2001 Codeweavers Inc.
+ * 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
  * 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 "mapi.h"
-#include "mapicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
 
-HRESULT WINAPI MAPIInitialize ( LPVOID lpMapiInit )
+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)
 {
-    ERR("Stub\n");
-    return MAPI_E_NOT_INITIALIZED;
+    return MAPI_ObjectCount == 0 ? S_OK : S_FALSE;
 }
 
-HRESULT WINAPI MAPIAllocateBuffer ( ULONG cvSize, LPVOID *lppBuffer )
+HRESULT WINAPI MAPIInitialize(LPVOID init)
 {
-    ERR("Stub\n");
-    *lppBuffer = NULL;
-    return MAPI_E_NOT_INITIALIZED;
+    FIXME("(%p) Stub\n", init);
+    return SUCCESS_SUCCESS;
 }
 
-ULONG WINAPI MAPILogon(ULONG ulUIParam, LPSTR lpszProfileName, LPSTR
-lpszPassword, FLAGS flFlags, ULONG ulReserver, LPLHANDLE lplhSession)
+ULONG WINAPI MAPILogon(ULONG uiparam, LPSTR profile, LPSTR password,
+    FLAGS flags, ULONG reserved, LPLHANDLE session)
 {
-    ERR("Stub\n");
-    return MAPI_E_FAILURE;
+    FIXME("(0x%08lx %s %p 0x%08lx 0x%08lx %p) Stub\n", uiparam,
+          debugstr_a(profile), password, flags, reserved, session);
+
+    if (session) *session = 1;
+    return SUCCESS_SUCCESS;
 }
 
-HRESULT WINAPI MAPILogonEx( ULONG ulUIParam, LPSTR lpszProfileName, LPSTR
-lpszPassword, FLAGS flFlags, VOID* lppSession)
+ULONG WINAPI MAPILogoff(LHANDLE session, ULONG uiparam, FLAGS flags,
+    ULONG reserved )
 {
-    ERR("Stub\n");
-    return MAPI_E_LOGON_FAILURE;
+    FIXME("(0x%08lx 0x%08lx 0x%08lx 0x%08lx) Stub\n", session,
+          uiparam, flags, reserved);
+    return SUCCESS_SUCCESS;
 }
 
-VOID WINAPI MAPIUninitialize(void)
+HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
+    LPWSTR password, ULONG flags, LPMAPISESSION *session)
 {
-    ERR("Stub\n");
+    FIXME("(0x%08lx %s %p 0x%08lx %p) Stub\n", uiparam,
+          debugstr_w(profile), password, flags, session);
+    return SUCCESS_SUCCESS;
 }
 
-VOID WINAPI DeinitMapiUtil(void)
+VOID WINAPI MAPIUninitialize(void)
 {
-    ERR("Stub\n");
+    FIXME("Stub\n");
 }