Detlef Riekenberg : localspl: Implement XcvData_AddPort.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Apr 18 06:58:45 CDT 2007
Module: wine
Branch: master
Commit: fce002c3b6d10253fe67e1b483f01bfdd67e3758
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fce002c3b6d10253fe67e1b483f01bfdd67e3758
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Tue Apr 17 23:20:34 2007 +0200
localspl: Implement XcvData_AddPort.
---
dlls/localspl/Makefile.in | 2 +-
dlls/localspl/localmon.c | 58 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/localspl/Makefile.in b/dlls/localspl/Makefile.in
index 06830de..c3691e8 100644
--- a/dlls/localspl/Makefile.in
+++ b/dlls/localspl/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = localspl.dll
-IMPORTS = user32 advapi32 kernel32
+IMPORTS = spoolss user32 advapi32 kernel32
C_SRCS = \
localmon.c \
diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c
index 7e13ace..4dd0664 100644
--- a/dlls/localspl/localmon.c
+++ b/dlls/localspl/localmon.c
@@ -65,6 +65,7 @@ static struct list xcv_handles = LIST_INIT( xcv_handles );
/* ############################### */
+static const WCHAR cmd_AddPortW[] = {'A','d','d','P','o','r','t',0};
static const WCHAR cmd_DeletePortW[] = {'D','e','l','e','t','e','P','o','r','t',0};
static const WCHAR cmd_ConfigureLPTPortCommandOKW[] = {'C','o','n','f','i','g','u','r','e',
'L','P','T','P','o','r','t',
@@ -85,6 +86,7 @@ static const WCHAR cmd_SetDefaultCommConfigW[] = {'S','e','t',
'C','o','m','m','C','o','n','f','i','g',0};
static const WCHAR dllnameuiW[] = {'l','o','c','a','l','u','i','.','d','l','l',0};
+static const WCHAR emptyW[] = {0};
static const WCHAR portname_LPT[] = {'L','P','T',0};
static const WCHAR portname_COM[] = {'C','O','M',0};
@@ -126,6 +128,44 @@ static void dlg_nothingtoconfig(HWND hWnd)
}
/******************************************************************
+ * does_port_exist (internal)
+ *
+ * returns TRUE, when the Port already exists
+ *
+ */
+static BOOL does_port_exist(LPCWSTR myname)
+{
+
+ LPPORT_INFO_1W pi;
+ DWORD needed = 0;
+ DWORD returned;
+ DWORD id;
+
+ TRACE("(%s)\n", debugstr_w(myname));
+
+ id = EnumPortsW(NULL, 1, NULL, 0, &needed, &returned);
+ pi = spl_alloc(needed);
+ returned = 0;
+ if (pi)
+ id = EnumPortsW(NULL, 1, (LPBYTE) pi, needed, &needed, &returned);
+
+ if (id && returned > 0) {
+ /* we got a number of valid names. */
+ for (id = 0; id < returned; id++)
+ {
+ if (lstrcmpiW(myname, pi[id].pName) == 0) {
+ TRACE("(%u) found %s\n", id, debugstr_w(pi[id].pName));
+ spl_free(pi);
+ return TRUE;
+ }
+ }
+ }
+
+ spl_free(pi);
+ return FALSE;
+}
+
+/******************************************************************
* enumerate the local Ports from the Registry (internal)
*
* See localmon_EnumPortsW.
@@ -459,8 +499,22 @@ DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE pInput
TRACE("(%p, %s, %p, %d, %p, %d, %p)\n", hXcv, debugstr_w(pszDataName),
pInputData, cbInputData, pOutputData, cbOutputData, pcbOutputNeeded);
- /* Native localspl.dll crashes on w2k and xp, when XcvDataPort is called
- with "AddPort" as command. We do not need to implement this */
+ if (!lstrcmpW(pszDataName, cmd_AddPortW)) {
+ TRACE("InputData (%d): %s\n", cbInputData, debugstr_w( (LPWSTR) pInputData));
+ res = RegOpenKeyW(HKEY_LOCAL_MACHINE, WinNT_CV_PortsW, &hroot);
+ if (res == ERROR_SUCCESS) {
+ if (does_port_exist((LPWSTR) pInputData)) {
+ RegCloseKey(hroot);
+ return ERROR_ALREADY_EXISTS;
+ }
+ res = RegSetValueExW(hroot, (LPWSTR) pInputData, 0, REG_SZ, (const BYTE *) emptyW, sizeof(emptyW));
+ RegCloseKey(hroot);
+ SetLastError(ERROR_SUCCESS);
+ return res;
+ }
+ return res;
+ }
+
if (!lstrcmpW(pszDataName, cmd_ConfigureLPTPortCommandOKW)) {
TRACE("InputData (%d): %s\n", cbInputData, debugstr_w( (LPWSTR) pInputData));
More information about the wine-cvs
mailing list