kernel32: [2/2] Remove duplicate code (use serialui instead)

Detlef Riekenberg wine.dev at web.de
Mon Feb 26 15:16:07 CST 2007


Changelog:
kernel32: Remove duplicate code (use serialui instead)


-- 
 
By by ... Detlef

-------------- next part --------------
>From 1094f9b97f1669bb95307b6a2dac52c9caf88304 Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Mon, 26 Feb 2007 21:53:38 +0100
Subject: [PATCH] kernel32: Remove duplicate code (use serialui instead)
---
 dlls/kernel32/comm.c |   42 +++++++++++++++---------------------------
 1 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/dlls/kernel32/comm.c b/dlls/kernel32/comm.c
index 07caa83..8fc1033 100644
--- a/dlls/kernel32/comm.c
+++ b/dlls/kernel32/comm.c
@@ -1388,35 +1388,23 @@ BOOL WINAPI GetDefaultCommConfigW(
                               afterwards the number of bytes copied to the buffer or
                               the needed size of the buffer. */
 {
-     LPDCB lpdcb = &(lpCC->dcb);
-     WCHAR temp[40];
-     static const WCHAR comW[] = {'C','O','M',0};
-     static const WCHAR formatW[] = {'C','O','M','%','c',':','3','8','4','0','0',',','n',',','8',',','1',0};
-
-     TRACE("(%s, %p, %p)  *lpdwSize: %u\n", debugstr_w(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
-
-     if (strncmpiW(lpszName,comW,3)) {
-        ERR("not implemented for <%s>\n", debugstr_w(lpszName));
-        return FALSE;
-     }
-
-     if (*lpdwSize < sizeof(COMMCONFIG)) {
-         *lpdwSize = sizeof(COMMCONFIG);
-         return FALSE;
-       }
-
-     *lpdwSize = sizeof(COMMCONFIG);
+    FARPROC pGetDefaultCommConfig;
+    HMODULE hConfigModule;
+    DWORD   res = ERROR_INVALID_PARAMETER;
 
-     lpCC->dwSize = sizeof(COMMCONFIG);
-     lpCC->wVersion = 1;
-     lpCC->dwProviderSubType = PST_RS232;
-     lpCC->dwProviderOffset = 0L;
-     lpCC->dwProviderSize = 0L;
+    TRACE("(%s, %p, %p)  *lpdwSize: %u\n", debugstr_w(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
+    hConfigModule = LoadLibraryW(lpszSerialUI);
 
-     sprintfW( temp, formatW, lpszName[3]);
-     FIXME("setting %s as default\n", debugstr_w(temp));
+    if (hConfigModule) {
+        pGetDefaultCommConfig = GetProcAddress(hConfigModule, "drvGetDefaultCommConfigW");
+        if (pGetDefaultCommConfig) {
+            res = pGetDefaultCommConfig(lpszName, lpCC, lpdwSize);
+        }
+        FreeLibrary(hConfigModule);
+    }
 
-     return BuildCommDCBW( temp, lpdcb);
+    if (res) SetLastError(res);
+    return (res == ERROR_SUCCESS);
 }
 
 /**************************************************************************
@@ -1443,7 +1431,7 @@ BOOL WINAPI GetDefaultCommConfigA(
 	if(lpszName) RtlCreateUnicodeStringFromAsciiz(&lpszNameW,lpszName);
 	else lpszNameW.Buffer = NULL;
 
-	if(lpszNameW.Buffer) ret = GetDefaultCommConfigW(lpszNameW.Buffer,lpCC,lpdwSize);
+	ret = GetDefaultCommConfigW(lpszNameW.Buffer,lpCC,lpdwSize);
 
 	RtlFreeUnicodeString(&lpszNameW);
 	return ret;
-- 
1.4.1



More information about the wine-patches mailing list