Detlef Riekenberg : localspl: Implement XcvOpenPort and XcvClosePort.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 17 05:21:31 CST 2007


Module: wine
Branch: master
Commit: ece92cc4384fd15d6f5a812790b43a19f1d1c4e5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ece92cc4384fd15d6f5a812790b43a19f1d1c4e5

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Thu Jan 11 15:02:24 2007 +0100

localspl: Implement XcvOpenPort and XcvClosePort.

---

 dlls/localspl/localmon.c         |   97 +++++++++++++++++++++++++++++++++++++-
 dlls/localspl/localspl_private.h |   13 +++++
 2 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c
index 4f65417..e6dcf39 100644
--- a/dlls/localspl/localmon.c
+++ b/dlls/localspl/localmon.c
@@ -36,12 +36,35 @@
 #include "localspl_private.h"
 
 #include "wine/debug.h"
+#include "wine/list.h"
 
 
 WINE_DEFAULT_DEBUG_CHANNEL(localspl);
 
 /*****************************************************/
 
+static CRITICAL_SECTION xcv_handles_cs;
+static CRITICAL_SECTION_DEBUG xcv_handles_cs_debug =
+{
+    0, 0, &xcv_handles_cs,
+    { &xcv_handles_cs_debug.ProcessLocksList, &xcv_handles_cs_debug.ProcessLocksList },
+      0, 0, { (DWORD_PTR)(__FILE__ ": xcv_handles_cs") }
+};
+static CRITICAL_SECTION xcv_handles_cs = { &xcv_handles_cs_debug, -1, 0, 0, 0, 0 };
+
+/* ############################### */
+
+typedef struct {
+    struct list entry;
+    ACCESS_MASK GrantedAccess;
+    WCHAR       nameW[1];
+} xcv_t;
+
+static struct list xcv_handles = LIST_INIT( xcv_handles );
+
+/* ############################### */
+
+
 static const WCHAR WinNT_CV_PortsW[] = {'S','o','f','t','w','a','r','e','\\',
                                         'M','i','c','r','o','s','o','f','t','\\',
                                         'W','i','n','d','o','w','s',' ','N','T','\\',
@@ -289,6 +312,73 @@ cleanup:
 }
 
 /*****************************************************
+ * localmon_XcvClosePort [exported through MONITOREX]
+ *
+ * Close a Communication-Channel
+ *
+ * PARAMS
+ *  hXcv  [i] The Handle to close
+ *
+ * RETURNS
+ *  Success: TRUE
+ *  Failure: FALSE
+ *
+ */
+BOOL WINAPI localmon_XcvClosePort(HANDLE hXcv)
+{
+    xcv_t * xcv = (xcv_t *) hXcv;
+
+    TRACE("(%p)\n", xcv);
+    /* No checks are done in Windows */
+    EnterCriticalSection(&xcv_handles_cs);
+    list_remove(&xcv->entry);
+    LeaveCriticalSection(&xcv_handles_cs);
+    spl_free(xcv);
+    return TRUE;
+}
+
+/*****************************************************
+ * localmon_XcvOpenPort [exported through MONITOREX]
+ *
+ * Open a Communication-Channel
+ *
+ * PARAMS
+ *  pName         [i] Name of selected Object
+ *  GrantedAccess [i] Access-Rights to use
+ *  phXcv         [o] The resulting Handle is stored here
+ *
+ * RETURNS
+ *  Success: TRUE
+ *  Failure: FALSE
+ *
+ */
+BOOL WINAPI localmon_XcvOpenPort(LPCWSTR pName, ACCESS_MASK GrantedAccess, PHANDLE phXcv)
+{
+    DWORD   len;
+    xcv_t * xcv;
+
+    TRACE("%s, 0x%x, %p)\n", debugstr_w(pName), GrantedAccess, phXcv);
+    /* No checks for any field is done in Windows */
+    len = (lstrlenW(pName) + 1) * sizeof(WCHAR);
+    xcv = spl_alloc( sizeof(xcv_t) + len);
+    if (xcv) {
+        xcv->GrantedAccess = GrantedAccess;
+        memcpy(&xcv->nameW, pName, len);
+        *phXcv = (HANDLE) xcv;
+        EnterCriticalSection(&xcv_handles_cs);
+        list_add_tail(&xcv_handles, &xcv->entry);
+        LeaveCriticalSection(&xcv_handles_cs);
+        TRACE("=> %p\n", xcv);
+        return TRUE;
+    }
+    else
+    {
+        *phXcv = (HANDLE) NULL;
+        return FALSE;
+    }
+}
+
+/*****************************************************
  *      InitializePrintMonitor  (LOCALSPL.@)
  *
  * Initialize the Monitor for the Local Ports
@@ -324,7 +414,12 @@ LPMONITOREX WINAPI InitializePrintMonito
             NULL,       /* localmon_AddPortW */
             NULL,       /* localmon_AddPortExW */
             localmon_ConfigurePortW,
-            localmon_DeletePortW
+            localmon_DeletePortW,
+            NULL,       /* localmon_GetPrinterDataFromPort */
+            NULL,       /* localmon_SetPortTimeOuts */
+            localmon_XcvOpenPort,
+            NULL,        /* localmon_XcvDataPort */
+            localmon_XcvClosePort
         }
     };
 
diff --git a/dlls/localspl/localspl_private.h b/dlls/localspl/localspl_private.h
index ad396c2..7633c93 100644
--- a/dlls/localspl/localspl_private.h
+++ b/dlls/localspl/localspl_private.h
@@ -35,4 +35,17 @@ extern HINSTANCE LOCALSPL_hInstance;
 #define IDS_LOCALPORT_MAXLEN 32
 #define IDS_NOTHINGTOCONFIG_MAXLEN 80
 
+/* ## Memory allocation macros ## */
+
+static inline void *spl_alloc( size_t len )
+{
+    return HeapAlloc( GetProcessHeap(), 0, len );
+}
+
+static inline BOOL spl_free( void *mem )
+{
+    return HeapFree( GetProcessHeap(), 0, mem );
+}
+
+
 #endif /* __WINE_LOCALSPL_PRIVATE__ */




More information about the wine-cvs mailing list