localspl: Implement InitializePrintMonitor (updated)

Detlef Riekenberg wine.dev at web.de
Thu Oct 12 16:37:23 CDT 2006


As requested by Alexandre, a static variable is used.

Changelog:
- localspl: Implement InitializePrintMonitor

Native Windows has a seperate Heap for the 
spooler-subsystem, but we do not need that.

The Memory-Macros are from msi. Thanks Mike.




-- 
 
By by ... Detlef

-------------- next part --------------
Subject: [PATCH] localspl: Implement InitializePrintMonitor

---

 dlls/localspl/localmon.c         |   32 +++++++++++++++++---
 dlls/localspl/localspl_main.c    |    2 +
 dlls/localspl/localspl_private.h |   62 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 4 deletions(-)
 create mode 100644 dlls/localspl/localspl_private.h

f0a9e1e7951f15030f66cd34e7d028c8205cb200
diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c
index 6665585..febbd1d 100644
--- a/dlls/localspl/localmon.c
+++ b/dlls/localspl/localmon.c
@@ -36,10 +36,32 @@
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
+#include "localspl_private.h"
 
 
 WINE_DEFAULT_DEBUG_CHANNEL(localspl);
 
+
+/*****************************************************
+ *   localmon_create [internal]
+ *
+ * create and initialize all needed resources for the monitor
+ *
+ */
+LPMONITOREX localmon_create(void)
+{
+    static LPMONITOREX g_monitorex = NULL;
+
+    if (g_monitorex == NULL) {
+        g_monitorex = spl_alloc_zero(sizeof(MONITOREX));
+        if (g_monitorex) {
+            g_monitorex->dwMonitorSize = sizeof(MONITOREX) - sizeof(DWORD);
+        }
+    }
+    TRACE("=> %p\n", g_monitorex);
+    return g_monitorex;
+}
+    
 /*****************************************************
  *      InitializePrintMonitor  (LOCALSPL.@)
  *
@@ -53,18 +75,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(localspl);
  *  Failure: NULL
  *
  * NOTES
- *  Native localspl.dll fails, when the Section "Ports" is missing in "win.ini".
+ *  The fixed location "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Ports"
+ *  is used to store the Ports (IniFileMapping from "win.ini", Section "Ports").
+ *  Native localspl.dll fails, when no valid Port-Entry is present.
  *
  */
 
 LPMONITOREX WINAPI InitializePrintMonitor(LPWSTR regroot)
 {
-    FIXME("(%s) stub\n", debugstr_w(regroot));
+    TRACE("(%s)\n", debugstr_w(regroot));
+    /* Parameter "regroot" is ignored on NT4.0 (localmon.dll) */
     if (!regroot || !regroot[0]) {
         SetLastError(ERROR_INVALID_PARAMETER);
         return NULL;
     }
 
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return NULL;
+    return localmon_create();
 }
diff --git a/dlls/localspl/localspl_main.c b/dlls/localspl/localspl_main.c
index b1de446..fbc6a14 100644
--- a/dlls/localspl/localspl_main.c
+++ b/dlls/localspl/localspl_main.c
@@ -36,6 +36,7 @@
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
+#include "localspl_private.h"
 
 
 WINE_DEFAULT_DEBUG_CHANNEL(localspl);
@@ -54,6 +55,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, 
 
         case DLL_PROCESS_ATTACH:
             DisableThreadLibraryCalls( hinstDLL );
+            if (localmon_create() == NULL) return FALSE;
             break;
     }
     return TRUE;
diff --git a/dlls/localspl/localspl_private.h b/dlls/localspl/localspl_private.h
new file mode 100644
index 0000000..f939bf7
--- /dev/null
+++ b/dlls/localspl/localspl_private.h
@@ -0,0 +1,62 @@
+/*
+ * Implementation of the Local Printmonitor: internal include file
+ *
+ * Copyright 2006 Detlef Riekenberg
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_LOCALSPL_PRIVATE__
+#define __WINE_LOCALSPL_PRIVATE__
+
+
+/* ## DLL-wide Globals ## */
+
+
+
+/* Memory allocation macros */
+/* Native localspl.dll uses the the Memory-Functions from spoolss.dll,
+   but we want to be independant as much as possible */
+
+static inline void *spl_alloc( size_t len )
+{
+    return HeapAlloc( GetProcessHeap(), 0, len );
+}
+
+static inline void *spl_alloc_zero( size_t len )
+{
+    return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
+}
+
+static inline void *spl_realloc( void *mem, size_t len )
+{
+    return HeapReAlloc( GetProcessHeap(), 0, mem, len );
+}
+
+static inline void *spl_realloc_zero( void *mem, size_t len )
+{
+    return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
+}
+
+static inline BOOL spl_free( void *mem )
+{
+    return HeapFree( GetProcessHeap(), 0, mem );
+}
+
+/* ### Functions ### */
+LPMONITOREX localmon_create(void);
+
+
+#endif /* __WINE_LOCALSPL_PRIVATE__ */
-- 
1.1.3


More information about the wine-patches mailing list