localspl: (4/4) Implement PortIsValid for XcvDataPort
Detlef Riekenberg
wine.dev at web.de
Mon Jan 15 17:42:15 CST 2007
Last Patch for localspl.dll in this serie
Changelog:
- localspl: Implement PortIsValid for XcvDataPort"
I have more patches for "winspool.drv" waiting, but
they need implemented Xcv-Functions from localspl.dll
--
By by ... Detlef
-------------- next part --------------
>From d6ddfae671808307e067cc826ed2236d26eaeb88 Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Tue, 16 Jan 2007 00:31:33 +0100
Subject: [PATCH] localspl: Implement PortIsValid for XcvDataPort
---
dlls/localspl/localmon.c | 67 ++++++++++++++++++++++++++++++++++++++
dlls/localspl/localspl_private.h | 16 +++++++++
2 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c
index 27f4032..35ee33f 100644
--- a/dlls/localspl/localmon.c
+++ b/dlls/localspl/localmon.c
@@ -37,6 +37,7 @@ #include "localspl_private.h"
#include "wine/debug.h"
#include "wine/list.h"
+#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(localspl);
@@ -65,8 +66,15 @@ static struct list xcv_handles = LIST_IN
/* ############################### */
static const WCHAR cmd_MonitorUIW[] = {'M','o','n','i','t','o','r','U','I',0};
+static const WCHAR cmd_PortIsValidW[] = {'P','o','r','t','I','s','V','a','l','i','d',0};
static const WCHAR dllnameuiW[] = {'l','o','c','a','l','u','i','.','d','l','l',0};
+static const WCHAR portname_LPT[] = {'L','P','T',0};
+static const WCHAR portname_COM[] = {'C','O','M',0};
+static const WCHAR portname_FILE[] = {'F','I','L','E',':',0};
+static const WCHAR portname_CUPS[] = {'C','U','P','S',':',0};
+static const WCHAR portname_LPR[] = {'L','P','R',':',0};
+
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','\\',
@@ -198,6 +206,52 @@ getports_cleanup:
}
/*****************************************************
+ * get_type_from_name (internal)
+ *
+ */
+
+static DWORD get_type_from_name(LPCWSTR name)
+{
+ HANDLE hfile;
+
+ if (!strncmpW(name, portname_LPT, sizeof(portname_LPT) / sizeof(WCHAR) -1))
+ return PORT_IS_LPT;
+
+ if (!strncmpW(name, portname_COM, sizeof(portname_COM) / sizeof(WCHAR) -1))
+ return PORT_IS_COM;
+
+ if (!strcmpW(name, portname_FILE))
+ return PORT_IS_FILE;
+
+ if (name[0] == '/')
+ return PORT_IS_UNIXNAME;
+
+ if (name[0] == '|')
+ return PORT_IS_PIPE;
+
+ if (!strncmpW(name, portname_CUPS, sizeof(portname_CUPS) / sizeof(WCHAR) -1))
+ return PORT_IS_CUPS;
+
+ if (!strncmpW(name, portname_LPR, sizeof(portname_LPR) / sizeof(WCHAR) -1))
+ return PORT_IS_LPR;
+
+ /* Must be a File or a Directory. Does the file exists ? */
+ hfile = CreateFileW(name, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ TRACE("%p for OPEN_EXISTING on %s\n", hfile, debugstr_w(name));
+ if (hfile == INVALID_HANDLE_VALUE) {
+ /* Can we create the File? */
+ hfile = CreateFileW(name, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
+ TRACE("%p for OPEN_ALWAYS\n", hfile);
+ }
+ if (hfile != INVALID_HANDLE_VALUE) {
+ CloseHandle(hfile);
+ return PORT_IS_FILENAME;
+ }
+ /* We can't use the name. use GetLastError() for the reason */
+ return PORT_IS_UNKNOWN;
+}
+
+/*****************************************************
* localmon_ConfigurePortW [exported through MONITOREX]
*
* Display the Configuration-Dialog for a specific Port
@@ -370,6 +424,7 @@ BOOL WINAPI localmon_XcvClosePort(HANDLE
DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData,
PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
{
+ DWORD res;
TRACE("(%p, %s, %p, %d, %p, %d, %p)\n", hXcv, debugstr_w(pszDataName),
pInputData, cbInputData, pOutputData, cbOutputData, pcbOutputNeeded);
@@ -383,6 +438,18 @@ DWORD WINAPI localmon_XcvDataPort(HANDLE
}
return ERROR_INSUFFICIENT_BUFFER;
}
+
+ if (!lstrcmpW(pszDataName, cmd_PortIsValidW)) {
+ TRACE("InputData (%d): %s\n", cbInputData, debugstr_w( (LPWSTR) pInputData));
+ res = get_type_from_name((LPCWSTR) pInputData);
+ TRACE("detected as %u\n", res);
+ /* names, that we have recogniced, are valid */
+ if (res) return ERROR_SUCCESS;
+
+ /* ERROR_ACCESS_DENIED, ERROR_PATH_NOT_FOUND ore something else */
+ return GetLastError();
+ }
+
FIXME("command not supported: %s\n", debugstr_w(pszDataName));
return ERROR_INVALID_PARAMETER;
}
diff --git a/dlls/localspl/localspl_private.h b/dlls/localspl/localspl_private.h
index 4b82e69..a1a73ca 100644
--- a/dlls/localspl/localspl_private.h
+++ b/dlls/localspl/localspl_private.h
@@ -35,6 +35,22 @@ #define IDS_LOCALMONITOR_MAXLEN 64
#define IDS_LOCALPORT_MAXLEN 32
#define IDS_NOTHINGTOCONFIG_MAXLEN 80
+/* ## Type of Ports ## */
+/* windows types */
+#define PORT_IS_UNKNOWN 0
+#define PORT_IS_LPT 1
+#define PORT_IS_COM 2
+#define PORT_IS_FILE 3
+#define PORT_IS_FILENAME 4
+
+/* wine extensions */
+#define PORT_IS_WINE 5
+#define PORT_IS_UNIXNAME 5
+#define PORT_IS_PIPE 6
+#define PORT_IS_CUPS 7
+#define PORT_IS_LPR 8
+
+
/* ## Memory allocation macros ## */
/* Native localspl.dll uses the the Memory-Functions from spoolss.dll */
--
1.4.1
More information about the wine-patches
mailing list