Move the implementation of GetDefaultCommConfig from A to W.
Get rid of a W->A cross call at the same time.
This commit is contained in:
parent
b370abab45
commit
14263ab0c4
@ -2190,51 +2190,6 @@ BOOL WINAPI SetDefaultCommConfigW(
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GetDefaultCommConfigA (KERNEL32.@)
|
|
||||||
*
|
|
||||||
* Acquires the default configuration of the specified communication device. (unicode)
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
*
|
|
||||||
* True on successful reading of the default configuration,
|
|
||||||
* if the device is not found or the buffer is too small.
|
|
||||||
*/
|
|
||||||
BOOL WINAPI GetDefaultCommConfigA(
|
|
||||||
LPCSTR lpszName, /* [in] The ascii name of the device targeted for configuration. */
|
|
||||||
LPCOMMCONFIG lpCC, /* [out] The default configuration for the device. */
|
|
||||||
LPDWORD lpdwSize) /* [in/out] Initially the size of the default configuration buffer,
|
|
||||||
afterwards the number of bytes copied to the buffer or
|
|
||||||
the needed size of the buffer. */
|
|
||||||
{
|
|
||||||
LPDCB lpdcb = &(lpCC->dcb);
|
|
||||||
char temp[40];
|
|
||||||
|
|
||||||
if (strncasecmp(lpszName,"COM",3)) {
|
|
||||||
ERR("not implemented for <%s>\n", lpszName);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("(%s %p %ld)\n", lpszName, lpCC, *lpdwSize );
|
|
||||||
if (*lpdwSize < sizeof(COMMCONFIG)) {
|
|
||||||
*lpdwSize = sizeof(COMMCONFIG);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpdwSize = sizeof(COMMCONFIG);
|
|
||||||
|
|
||||||
lpCC->dwSize = sizeof(COMMCONFIG);
|
|
||||||
lpCC->wVersion = 1;
|
|
||||||
lpCC->dwProviderSubType = PST_RS232;
|
|
||||||
lpCC->dwProviderOffset = 0L;
|
|
||||||
lpCC->dwProviderSize = 0L;
|
|
||||||
|
|
||||||
sprintf( temp, "COM%c:38400,n,8,1", lpszName[3]);
|
|
||||||
FIXME("setting %s as default\n", temp);
|
|
||||||
|
|
||||||
return BuildCommDCBA( temp, lpdcb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* GetDefaultCommConfigW (KERNEL32.@)
|
* GetDefaultCommConfigW (KERNEL32.@)
|
||||||
*
|
*
|
||||||
* Acquires the default configuration of the specified communication device. (unicode)
|
* Acquires the default configuration of the specified communication device. (unicode)
|
||||||
@ -2251,15 +2206,62 @@ BOOL WINAPI GetDefaultCommConfigW(
|
|||||||
afterwards the number of bytes copied to the buffer or
|
afterwards the number of bytes copied to the buffer or
|
||||||
the needed size of the buffer. */
|
the needed size of the buffer. */
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
LPDCB lpdcb = &(lpCC->dcb);
|
||||||
LPSTR lpszNameA;
|
WCHAR temp[40];
|
||||||
|
const WCHAR comW[] = {'C','O','M',0};
|
||||||
|
const WCHAR formatW[] = {'C','O','M','%','c',':','3','8','4','0','0',',','n',',','8',',','1',0};
|
||||||
|
|
||||||
TRACE("(%p,%p,%ld)\n",lpszName,lpCC,*lpdwSize);
|
if (strncmpiW(lpszName,comW,3)) {
|
||||||
lpszNameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszName );
|
ERR("not implemented for <%s>\n", debugstr_w(lpszName));
|
||||||
if (lpszNameA)
|
return FALSE;
|
||||||
{
|
|
||||||
ret=GetDefaultCommConfigA(lpszNameA,lpCC,lpdwSize);
|
|
||||||
HeapFree( GetProcessHeap(), 0, lpszNameA );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE("(%s %p %ld)\n", debugstr_w(lpszName), lpCC, *lpdwSize );
|
||||||
|
if (*lpdwSize < sizeof(COMMCONFIG)) {
|
||||||
|
*lpdwSize = sizeof(COMMCONFIG);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lpdwSize = sizeof(COMMCONFIG);
|
||||||
|
|
||||||
|
lpCC->dwSize = sizeof(COMMCONFIG);
|
||||||
|
lpCC->wVersion = 1;
|
||||||
|
lpCC->dwProviderSubType = PST_RS232;
|
||||||
|
lpCC->dwProviderOffset = 0L;
|
||||||
|
lpCC->dwProviderSize = 0L;
|
||||||
|
|
||||||
|
sprintfW( temp, formatW, lpszName[3]);
|
||||||
|
FIXME("setting %s as default\n", debugstr_w(temp));
|
||||||
|
|
||||||
|
return BuildCommDCBW( temp, lpdcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* GetDefaultCommConfigA (KERNEL32.@)
|
||||||
|
*
|
||||||
|
* Acquires the default configuration of the specified communication device. (ascii)
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
*
|
||||||
|
* True on successful reading of the default configuration,
|
||||||
|
* if the device is not found or the buffer is too small.
|
||||||
|
*/
|
||||||
|
BOOL WINAPI GetDefaultCommConfigA(
|
||||||
|
LPCSTR lpszName, /* [in] The ascii name of the device targeted for configuration. */
|
||||||
|
LPCOMMCONFIG lpCC, /* [out] The default configuration for the device. */
|
||||||
|
LPDWORD lpdwSize) /* [in/out] Initially the size of the default configuration buffer,
|
||||||
|
afterwards the number of bytes copied to the buffer or
|
||||||
|
the needed size of the buffer. */
|
||||||
|
{
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
UNICODE_STRING lpszNameW;
|
||||||
|
|
||||||
|
TRACE("(%s,%p,%ld)\n",lpszName,lpCC,*lpdwSize);
|
||||||
|
if(lpszName) RtlCreateUnicodeStringFromAsciiz(&lpszNameW,lpszName);
|
||||||
|
else lpszNameW.Buffer = NULL;
|
||||||
|
|
||||||
|
if(lpszNameW.Buffer) ret = GetDefaultCommConfigW(lpszNameW.Buffer,lpCC,lpdwSize);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString(&lpszNameW);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user