2001-01-25 23:22:21 +01:00
|
|
|
/*
|
Release 941122
Sun Nov 20 18:30:06 1994 Alexandre Julliard (julliard@lamisun.epfl.ch)
* [controls/scroll.c] [include/scroll.h]
Rewritten most of scroll-bar code for better Windows look & feel.
Implemented EnableScrollBar().
Preliminary keyboard support.
* [objects/bitblt.c]
Fixed BadMatch error for BitBlt() and StretchBlt() when reading
bits from outside the visible region.
* [objects/oembitmap.c] [include/bitmaps/obm_*]
Use XPM symbolic colors to load bitmaps. This allows the colors
of the bitmaps to depend on the system colors.
* [tools/make_debug]
Made the make_debug script more robust.
* [windows/dialog.c]
Fixed CheckRadioButton().
* [windows/nonclient.c]
A few changes to scroll-bar drawing and tracking.
* [windows/winpos.c]
Renamed NextWindowFromPoint() to WINPOS_NextWindowFromPoint() to
avoid confusion, and optimized it somewhat.
Nov 19, 94 Martin Ayotte (wine@trgcorp.mksinfo.qc.ca)
* [misc/audio.c]
* [misc/mcianim.c]
more coding but nothing spectacular.
* [misc/mmaux.c]
some coding to access '/dev/mixer'.
* [misc/midi.c]
some coding to read .MID files, but it's not playing yet.
Sun Nov 13 19:31:03 1994 James Youngman (mbcstjy@afs.man.ac.uk)
* [objects/dib.c]
Reimplemented DIB_SetImageBits_RLE8() so that it would cope with
bitmaps which don't end 0x00, 0x02 (previously it blew up). This
includes some bitmaps output by Paint Shop Pro. Implementation is
possibly now too lax. Please see the notes on the function about
why.
* [controls/desktop.c]
The desktop pattern should be painted if the wallpaper doesn't
cover the whole screen width OR the whole screen height.
Sun Nov 13 00:07:11 MET 1994 Erik Bos <erik@xs4all.nl>
* [objects/dib.c]
Small bug in DIB_SetImageBits() fixed, bitmaps in 16,24 bpp
now work.
* [loader/ne_resource.c] [include/resource.h]
Some cleanup.
Thu Nov 10 20:44:58 1994 Martin von Loewis (martin@cs.csufresno.edu)
* [Configure]
[rc/sysres.rc]
Primitive compile-time support for multiple languages
* [rc/sysres_De.rc]
New file
* [loader/resource.c]
LoadBitmap: Recognize end of sysresbm properly
* [rc/Imakefile]
Rules to compile resources simplified, dependencies changed
* [rc/sysresbm.rc]
Don't use sysresbm if using XPM
* [windows/dialog.c]
CreateDialogIndirectParam: Reverse Z-order of controls
* [windows/message.c]
MSG_TranslateMouseMsg: Fix HTTRANSPARENT handling
* [windows/winpos.c]
NextWindowFromPoint: New function
* [controls/button.c]
WM_NCHITTEST: Group Box is HTTRANSPARENT
BUTTON_CheckAutoRadioButton: New function
BM_SETCHECK: Added call to BUTTON_CheckAutoRadioButton
Mon Nov 7 11:20:26 1994 Paul Falstad (pf@zoof.cts.com)
* [objects/text.c]
Fix hang when using DrawText(..., DT_WORDBREAK) with a word that
is too long to break.
* [objects/font.c]
Don't assume helvetica if there is no font family; let the other
font attributes decide what font to use.
* [controls/widgets.c]
Listboxes and combo boxes need to be notified of double-clicks.
* [controls/listbox.c]
[include/listbox.h]
scrolling to bottom of list box should display last item at the
bottom, not at the top.
list boxes need to allocate a separate heap for their item data,
rather than using the user heap. Otherwise, it's very easy to run
out of memory for list box items.
removed redundant code in ListBoxAddString(). Implemented simple
version of LBS_SORT.
Don't put [.] in the list box when using DDL_DIRECTORY.
* [controls/combo.c]
Combos should pass CBS_SORT onto their list box.
* [windows/win.c]
If window creation is aborted, remove the window from the
linked lists.
* [controls/static.c]
static controls with SS_ICON were always returning 0 from
WM_NCCREATE.
Make sure static controls have text to draw before drawing it.
1994-11-22 17:31:29 +01:00
|
|
|
* DEC 93 Erik Bos <erik@xs4all.nl>
|
Release 960728
Sun Jul 28 17:57:19 1996 Alexandre Julliard <julliard@lrc.epfl.ch>
* [loader/task.c] [include/task.h]
Implemented SwitchStackTo()/SwitchStackBack().
* [include/wintypes.h] [loader/main.c]
Added __winelib variable to distinguish between emulator and
library at run-time. Later on, this should avoid some
recompilations when building Winelib.
* [windows/property.c]
Implemented Win32 functions for window properties.
Fri Jul 26 18:00:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu>
* [controls/listbox.c]
Implemented LBS_SORT style, WM_COMPAREITEM, and WM_DELETEITEM
messages.
* [controls/menu.c]
Call TranslateMessage() to enable shortcuts (on WM_CHAR).
* [include/cursoricon.h]
Moved #pragma pack(1) back to where it belongs.
* [objects/palette.c]
RealizeDefaultPalette() maps to system colors only.
Do not broadcast palette notifications when in TrueColor.
* [objects/color.c] [include/palette.h]
Miscellaneous optimizations. Had to fix several
"improvements" made to my patch for previous release.
* [objects/dib.c]
Reverse dib bits order for 24-bit SetDIBits().
* [objects/dc.c]
GetDeviceCaps() does not return RC_PALETTE when in TrueColor.
* [windows/scroll.c]
Scroll update region too.
* [windows/message.c]
Include QS_MOUSE into the event mask for nonclient mouse
message filter. Fixes problems with Word 6 freezing when
mouse hits nonclient area.
* [windows/win.c]
Allow top-level windows to be linked as HWND_TOP in CreateWindow().
* [windows/winpos.c] [windows/mdi.c]
Attempt to fix control menu duplication.
Fri Jul 26 09:49:35 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
* [files/drive.c]
GetDriveType32A(): return value for CDROM fixed.
* [files/file.c]
SearchPath* added.
* [if1632/gdi32.spec] [objects/brush.c]
SetBrushOrgEx() added.
* [loader/pe_resource.c]
If even loading the default entry fails, we just use the first
entry from the resource directory.
[loader/task.c]
SetSigHandler() stub added, Paradox 4.5 now starts up.
* [misc/comm.c] [include/windows.h] [if1632/kernel32.spec]
COMM functions updated to win32, not complete.
* [misc/lstr.c]
FormatMessageA partially implemented.
* [include/miscemu.h] [memory/selector.c]
[memory/global.c] [miscemu/dosmem.c]
DOS memory handling changed: 1MB preallocated block, real-mode
segment handling possible, SetSelectorBase into lower physical 1MB
possible.
* [miscemu/dpmi.c]
Real-mode segments changed, real-mode int 21,ax=6506 added.
AX=0x0303 added.
* [multimedia/time.c]
Fixed bug in killTimer.
* [objects/bitmap.c]
LoadImageA partially implemented.
Wed Jul 24 18:20:24 1996 Albrecht Kleine <kleine@ak.sax.de>
* [include/dde_mem.h][include/dde_proc.h]
[ipc/dde_atom.c][ipc/dde_proc.c][windows/message.c]
[ipc/generic_hash.h][library/miscstubs.c]
Changes for error free compilation using "--with-ipc":
replaced some names with *16-equivalent (e.g. MSG to MSG16),
modified prototype of function DDE_GlobalFree() .
* [objects/palette.c]
Added check for metafile-DC in GDISelectPalette(),
GDIRealizePalette(),RealizeDefaultPalette() and
IsDCCurrentPalette().
Tue Jul 23 22:46:53 1996 Andrew Lewycky <plewycky@oise.utoronto.ca>
* [controls/edit.c]
EDIT_WM_Create: Don't EDIT_EM_ReplaceSel if created with lParam = "",
fixes Winhelp.
* [windows/dialog.c]
DIALOG_CreateIndirect: Initialise dlgProc before creating children.
1996-07-28 20:50:11 +02:00
|
|
|
*
|
|
|
|
* Copyright 1996 Marcus Meissner
|
1999-03-21 16:45:41 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
Release 0.5
Sun Jan 2 12:38:53 1994 David Metcalfe <david@prism.demon.co.uk>
* [windows/class.c]
Implemented GetClassName and GetClassInfo.
* [windows/caret.c]
Various improvements to text caret code.
Fri Dec 31 15:22:22 1993 John Brezak <brezak@apollo.hp.com>
* [misc/comm.c]
Patches to work with NetBSD.
Thu Dec 30 12:11:55 1993 John Richardson <jrichard@cs.uml.edu>
* [objects/bitblt.c] Added StretchBlt().
Tue Jan 4 05:22:07 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [misc/user.c]
Added creation of system message queue.
* [objects/bitmap.c] [objects/dcvalues.c] [windows/dc.c]
Added DC size fields into DC structure.
* [objects/clipping.c]
Bug fix in CLIPPING_IntersectRect().
* [windows/class.c]
Allocate a DCE instead of a DC for CS_CLASSDC classes.
* [windows/clipping.c]
Fixed GetUpdateRect() and GetUpdateRgn() to clip to the client area.
* [windows/dce.c]
Implemented GetDCEx() and GetWindowDC().
* [windows/defwnd.c]
Implemented WM_WINDOWPOSCHANGED handling.
* [windows/event.c]
Preliminary support for Xlib event handling instead of Xt callbacks.
Changed MSG_AddMsg() calls to hardware_event() or PostMessage().
* [windows/message.c]
Preliminary support for multiple message queues.
Implemented hardware_event() to store messages into the system queue.
Implemented Get/SetTaskQueue().
Better WM_PAINT and WM_TIMER handling.
Changes to use Xlib instead of Xt for events.
* [windows/painting.c]
Use GetDCEx() to retrieve the DC, to get a correct visible region.
* [windows/timer.c]
Moved the timer procedure callback into DispatchMessage().
Changed implementation to get rid of Xt timeouts. Timer checking
is now done inside GetMessage().
* [windows/win.c]
Allocate a DCE instead of a DC for CS_OWNDC windows.
Replaced Xt calls with Xlib calls.
Moved window positioning functions into windows/winpos.c
* [windows/winpos.c] (New file)
Rewritten most of the window positioning functions.
Implemented SetWindowPos() and MapWindowPoints().
Jan 3, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [if1632/user.spec]
Bad arguments description for function SetDlgItemText.
* [objects/text.c]
Function DrawText now handle DT_CALCRECT request.
* [misc/message.c]
Message boxes now use DrawText with DT_CALCRECT.
* [windows/graphics.c]
Bug fix in function FrameRect, (it was using PEN instead of BRUSH).
* [windows/win.c]
Bug fix for flags in function ShowWindow.
More accurate WM_SIZE generated by function ShowWindow.
* [controls/listbox.c]
More code for LBS_MULTIPLESEL.
More code for LBS_MULTICOLUMN.
* [include/windows.h]
Bad define for MF_SEPARATOR.
* [controls/menu.c]
New functions: PopMenuWndProc() with 'glues',
CreatePopupMenu(), AppendMenu(), InsertMenu(), RemoveMenu(),
DeleteMenu(), ModifyMenu(), TrackPopupMenu().
Code in stubs: CreateMenu(), DestroyMenu().
Sat Jan 1 10:22:43 1994 Bob Amstadt (bob@pooh)
* loader/wine.c: Added support for relocation types 5 and 6.
Mon Dec 27 11:06:03 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/comm.c]
new functions: BuildCommDCB(), OpenComm(), CloseComm(),
SetCommBreak(), ClearCommBreak(), EscapeCommFunction(), FlushComm(),
GetCommError(), SetCommEventMask(), GetCommEventMask(),
SetCommState(), GetCommState(), TransmitCommChar(), ReadComm(),
WriteComm().
Wed Dec 22 13:00:15 1993 David Metcalfe <david@prism.demon.co.uk>
* [windows/caret.c]
Implemented text caret functions.
Tue Dec 21 06:13:58 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [loader/wine.c]
Bug fix in LoadImage().
* [objects/bitblt.c] [objects/clipping.c] [objects/text.c]
[windows/dc.c] [windows/dce.c] [windows/graphics.c]
Modified graphics calls to take into account the DC origin.
* [windows/defwnd.c]
Added preliminary WM_NCCALCSIZE handling.
* [windows/event.c]
Send WM_NCCALCSIZE message on resize event.
* [windows/win.c]
Send WM_NCCALCSIZE message in CreateWindow().
Realize widgets at creation time (should prevent problems with
unrealized widgets).
Dec 19, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/static.c]
Send mouse & keyboard message received to its parent.
* [controls/scroll.c]
Send keyboard message received to its parent.
* [controls/listbox.c]
Add Navigation keys .
ListBox now use VSCROLL & HSCROLL instead of children.
Alpha version of LBS_MULTIPLESEL.
Alpha version of LBS_MULTICOLUMN.
* [controls/combo.c]
Add Navigation keys on closed ComboBox.
Remove useless 'COMBOBOX_CreateComboBox' function.
Mon Dec 19 20:39:34 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [loader/wine.
LoadImage() modified to use FindFile().
* [misc/file.c]
SetErrorMode added
* [misc/dos_fs.c]
bug fixes.
Dec 13, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [memory/global.c]
bug fix in GlobalGetFreeSegment : good ptr in 'g_prev'.
* [sysres.dll]
preliminary version of a 'glass of wine' bitmap
* [windows/event.c]
New function 'GetCapture'.
* [controls/scroll.c]
Remove useless 'SCROLLBAR_CreateScrollBar' function.
* [controls/listbox.c]
Remove useless 'LISTBOX_CreateListBox' function.
Mon Dec 13 13:51:00 1993 David Metcalfe <david@prism.demon.co.uk>
* [objects/font.c]
Corrected bugs in GetCharWidth().
* [windows/event.c]
Modified EVENT_key to send Windows virtual key codes for
WM_KEYDOWN and WM_KEYUP messages, and a WM_CHAR message
for printable characters.
Wed Dec 08 19:20:00 1993 Karl Guenter Wuensch (hn324wu@unidui.uni-duisburg.de)
* [windows/graphics.c]
Added Polyline and Polygon
Mon Dec 13 14:51:54 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [controls/listbox.c]
ListBoxDirectory() modified to use dos_fs.c's functions to
access files&|drives.
Sat Dec 04 17:04:23 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/dos_fs.c]
Added FindFile() to search a file in a dos/unix style path.
* [misc/file.c]
New Win31 functions: OpenFile, _lcreate, _llseek, GetTempDrive,
GetTempFileName, GetWindowsDirectory, GetSystemDirectory,
GetDriveType.
* [misc/int21.c]
Modified.
Wed Dec 1 16:20:45 1993 Miguel de Icaza (miguel@roxanne.nuclecu.unam.mx)
* [misc/profile.c]
The Profile functions now return the correct values. They now
implement all the features described in the SDK.
Tue Nov 30 13:55:27 1993 Bob Amstadt (bob at amscons)
* [loader/selector.c]
Rewrote selector aliasing routines to use System V IPC
routine to alias memory segments.
Nov 28, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/listbox.c]
More consistency in functions using wIndexes
* [controls/scroll.c]
New function : ShowScrollBar().
* [loader/cursor.c] ... New file
Move cursor functions from [loader/resource.c].
New function : ClipCursor().
New function : GetClipCursor().
New function : CreateCursor().
SetCursor() now working using gloabal variable 'winHasCursor'.
*[object/palette.c]
New stub only : SelectPalette().
New stub only : RealizePalette().
*[win/event.c]
New function : EVENT_enter_notify(),
update 'winHasCursor' and send WM_SETCURSOR.
*[win/defwnd.c]
Add processing of WM_SETCURSOR message.
*[win/win.c]
New members in WND structure : hCursor, hWndVScroll & hWndHScroll.
CreateWindowEx() now create children for WM_HSCROLL & WM_VSCROLL.
New function ClientToScreen().
New function ScreenToClient().
Mon Nov 25 18:25:40 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [files.h / regfunc.h / misc/dos.c]
Removed.
* [misc/dos_fs.c]
Added support for loading dosdrive cfg from wine.ini.
* [misc/int21.c]
Modified.
Wed Nov 24 11:37:33 1993 julliard@disuns2.epfl.ch (Alexandre Julliard)
* [include/atom.h] [memory/atom.c]
Implemented atoms.
* [windows/class.c]
Modified RegisterClass() to use atoms.
Implemented CS_GLOBALCLASS style.
* [windows/message.c]
Implemented RegisterWindowMessage().
* [loader/resource.c]
Bug fix in LoadResource().
* [windows/dialog.c]
Modified CreateDialogParam() to use Find/LoadResource().
1994-01-04 21:14:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
#include "winbase.h"
|
2020-09-28 16:34:11 +02:00
|
|
|
#include "winnls.h"
|
1999-03-14 13:25:36 +01:00
|
|
|
#include "winerror.h"
|
2006-01-12 13:32:51 +01:00
|
|
|
#include "winioctl.h"
|
|
|
|
#include "ddk/ntddser.h"
|
2001-07-26 23:43:56 +02:00
|
|
|
|
|
|
|
#include "wine/server.h"
|
1999-03-14 13:25:36 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-16 11:52:17 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(comm);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2001-07-23 19:56:33 +02:00
|
|
|
/***********************************************************************
|
2003-09-12 02:26:15 +02:00
|
|
|
* COMM_Parse* (Internal)
|
2001-07-23 19:56:33 +02:00
|
|
|
*
|
2003-09-12 02:26:15 +02:00
|
|
|
* The following COMM_Parse* functions are used by the BuildCommDCB
|
|
|
|
* functions to help parse the various parts of the device control string.
|
2001-07-23 19:56:33 +02:00
|
|
|
*/
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseStart(LPCWSTR ptr)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR comW[] = {'C','O','M',0};
|
2004-01-16 03:14:50 +01:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/* The device control string may optionally start with "COMx" followed
|
|
|
|
by an optional ':' and spaces. */
|
2020-09-28 16:34:11 +02:00
|
|
|
if(!wcsnicmp(ptr, comW, 3))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
ptr += 3;
|
|
|
|
|
|
|
|
/* Allow any com port above 0 as Win 9x does (NT only allows
|
|
|
|
values for com ports which are actually present) */
|
|
|
|
if(*ptr < '1' || *ptr > '9')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Advance pointer past port number */
|
|
|
|
while(*ptr >= '0' && *ptr <= '9') ptr++;
|
|
|
|
|
|
|
|
/* The com port number must be followed by a ':' or ' ' */
|
|
|
|
if(*ptr != ':' && *ptr != ' ')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Advance pointer to beginning of next parameter */
|
|
|
|
while(*ptr == ' ') ptr++;
|
|
|
|
if(*ptr == ':')
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
while(*ptr == ' ') ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* The device control string must not start with a space. */
|
|
|
|
else if(*ptr == ' ')
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseNumber(LPCWSTR ptr, LPDWORD lpnumber)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(*ptr < '0' || *ptr > '9') return NULL;
|
2020-09-28 16:34:11 +02:00
|
|
|
*lpnumber = wcstoul(ptr, NULL, 10);
|
2003-09-12 02:26:15 +02:00
|
|
|
while(*ptr >= '0' && *ptr <= '9') ptr++;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseParity(LPCWSTR ptr, LPBYTE lpparity)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
/* Contrary to what you might expect, Windows only sets the Parity
|
|
|
|
member of DCB and not fParity even when parity is specified in the
|
|
|
|
device control string */
|
|
|
|
|
2020-04-01 10:28:01 +02:00
|
|
|
switch(*ptr++)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'e':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'E':
|
|
|
|
*lpparity = EVENPARITY;
|
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'm':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'M':
|
|
|
|
*lpparity = MARKPARITY;
|
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'n':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'N':
|
|
|
|
*lpparity = NOPARITY;
|
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'o':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'O':
|
|
|
|
*lpparity = ODDPARITY;
|
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 's':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'S':
|
|
|
|
*lpparity = SPACEPARITY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseByteSize(LPCWSTR ptr, LPBYTE lpbytesize)
|
2001-07-23 19:56:33 +02:00
|
|
|
{
|
2003-09-12 02:26:15 +02:00
|
|
|
DWORD temp;
|
|
|
|
|
|
|
|
if(!(ptr = COMM_ParseNumber(ptr, &temp)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(temp >= 5 && temp <= 8)
|
2001-07-23 19:56:33 +02:00
|
|
|
{
|
2003-09-12 02:26:15 +02:00
|
|
|
*lpbytesize = temp;
|
|
|
|
return ptr;
|
2001-07-23 19:56:33 +02:00
|
|
|
}
|
2003-09-12 02:26:15 +02:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-23 19:56:33 +02:00
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseStopBits(LPCWSTR ptr, LPBYTE lpstopbits)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
DWORD temp;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR stopbits15W[] = {'1','.','5',0};
|
2003-09-12 02:26:15 +02:00
|
|
|
|
2020-09-28 16:34:11 +02:00
|
|
|
if(!wcsncmp(stopbits15W, ptr, 3))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
ptr += 3;
|
|
|
|
*lpstopbits = ONE5STOPBITS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!(ptr = COMM_ParseNumber(ptr, &temp)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(temp == 1)
|
|
|
|
*lpstopbits = ONESTOPBIT;
|
|
|
|
else if(temp == 2)
|
|
|
|
*lpstopbits = TWOSTOPBITS;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
static LPCWSTR COMM_ParseOnOff(LPCWSTR ptr, LPDWORD lponoff)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR onW[] = {'o','n',0};
|
|
|
|
static const WCHAR offW[] = {'o','f','f',0};
|
2004-01-16 03:14:50 +01:00
|
|
|
|
2020-09-28 16:34:11 +02:00
|
|
|
if(!wcsnicmp(onW, ptr, 2))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
ptr += 2;
|
|
|
|
*lponoff = 1;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(offW, ptr, 3))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
ptr += 3;
|
|
|
|
*lponoff = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* COMM_BuildOldCommDCB (Internal)
|
|
|
|
*
|
|
|
|
* Build a DCB using the old style settings string eg: "96,n,8,1"
|
|
|
|
*/
|
2004-01-16 03:14:50 +01:00
|
|
|
static BOOL COMM_BuildOldCommDCB(LPCWSTR device, LPDCB lpdcb)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
2004-01-16 03:14:50 +01:00
|
|
|
WCHAR last = 0;
|
2003-09-12 02:26:15 +02:00
|
|
|
|
|
|
|
if(!(device = COMM_ParseNumber(device, &lpdcb->BaudRate)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch(lpdcb->BaudRate)
|
|
|
|
{
|
2001-07-23 19:56:33 +02:00
|
|
|
case 11:
|
|
|
|
case 30:
|
|
|
|
case 60:
|
2003-09-12 02:26:15 +02:00
|
|
|
lpdcb->BaudRate *= 10;
|
2001-07-23 19:56:33 +02:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
case 24:
|
|
|
|
case 48:
|
|
|
|
case 96:
|
2003-09-12 02:26:15 +02:00
|
|
|
lpdcb->BaudRate *= 100;
|
2001-07-23 19:56:33 +02:00
|
|
|
break;
|
|
|
|
case 19:
|
2003-09-12 02:26:15 +02:00
|
|
|
lpdcb->BaudRate = 19200;
|
2001-07-23 19:56:33 +02:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
while(*device == ' ') device++;
|
|
|
|
if(*device++ != ',') return FALSE;
|
|
|
|
while(*device == ' ') device++;
|
2001-07-23 19:56:33 +02:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
if(!(device = COMM_ParseParity(device, &lpdcb->Parity)))
|
|
|
|
return FALSE;
|
2001-07-23 19:56:33 +02:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
while(*device == ' ') device++;
|
|
|
|
if(*device++ != ',') return FALSE;
|
|
|
|
while(*device == ' ') device++;
|
|
|
|
|
|
|
|
if(!(device = COMM_ParseByteSize(device, &lpdcb->ByteSize)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
while(*device == ' ') device++;
|
|
|
|
if(*device++ != ',') return FALSE;
|
|
|
|
while(*device == ' ') device++;
|
|
|
|
|
|
|
|
if(!(device = COMM_ParseStopBits(device, &lpdcb->StopBits)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* The last parameter for flow control is optional. */
|
|
|
|
while(*device == ' ') device++;
|
|
|
|
if(*device == ',')
|
|
|
|
{
|
|
|
|
device++;
|
|
|
|
while(*device == ' ') device++;
|
2020-04-01 10:28:01 +02:00
|
|
|
if(*device) last = *device++;
|
2003-09-12 02:26:15 +02:00
|
|
|
while(*device == ' ') device++;
|
|
|
|
}
|
2003-09-15 22:00:54 +02:00
|
|
|
|
|
|
|
/* Win NT sets the flow control members based on (or lack of) the last
|
|
|
|
parameter. Win 9x does not set these members. */
|
2003-09-12 02:26:15 +02:00
|
|
|
switch(last)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
lpdcb->fInX = FALSE;
|
|
|
|
lpdcb->fOutX = FALSE;
|
|
|
|
lpdcb->fOutxCtsFlow = FALSE;
|
|
|
|
lpdcb->fOutxDsrFlow = FALSE;
|
|
|
|
lpdcb->fDtrControl = DTR_CONTROL_ENABLE;
|
|
|
|
lpdcb->fRtsControl = RTS_CONTROL_ENABLE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'x':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'X':
|
|
|
|
lpdcb->fInX = TRUE;
|
|
|
|
lpdcb->fOutX = TRUE;
|
|
|
|
lpdcb->fOutxCtsFlow = FALSE;
|
|
|
|
lpdcb->fOutxDsrFlow = FALSE;
|
|
|
|
lpdcb->fDtrControl = DTR_CONTROL_ENABLE;
|
|
|
|
lpdcb->fRtsControl = RTS_CONTROL_ENABLE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2020-04-01 10:28:01 +02:00
|
|
|
case 'p':
|
2003-09-12 02:26:15 +02:00
|
|
|
case 'P':
|
|
|
|
lpdcb->fInX = FALSE;
|
|
|
|
lpdcb->fOutX = FALSE;
|
|
|
|
lpdcb->fOutxCtsFlow = TRUE;
|
|
|
|
lpdcb->fOutxDsrFlow = TRUE;
|
|
|
|
lpdcb->fDtrControl = DTR_CONTROL_HANDSHAKE;
|
|
|
|
lpdcb->fRtsControl = RTS_CONTROL_HANDSHAKE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2001-07-23 19:56:33 +02:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/* This should be the end of the string. */
|
|
|
|
if(*device) return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-07-23 19:56:33 +02:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* COMM_BuildNewCommDCB (Internal)
|
|
|
|
*
|
|
|
|
* Build a DCB using the new style settings string.
|
|
|
|
* eg: "baud=9600 parity=n data=8 stop=1 xon=on to=on"
|
|
|
|
*/
|
2004-01-16 03:14:50 +01:00
|
|
|
static BOOL COMM_BuildNewCommDCB(LPCWSTR device, LPDCB lpdcb, LPCOMMTIMEOUTS lptimeouts)
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
DWORD temp;
|
|
|
|
BOOL baud = FALSE, stop = FALSE;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR baudW[] = {'b','a','u','d','=',0};
|
|
|
|
static const WCHAR parityW[] = {'p','a','r','i','t','y','=',0};
|
|
|
|
static const WCHAR dataW[] = {'d','a','t','a','=',0};
|
|
|
|
static const WCHAR stopW[] = {'s','t','o','p','=',0};
|
|
|
|
static const WCHAR toW[] = {'t','o','=',0};
|
|
|
|
static const WCHAR xonW[] = {'x','o','n','=',0};
|
|
|
|
static const WCHAR odsrW[] = {'o','d','s','r','=',0};
|
|
|
|
static const WCHAR octsW[] = {'o','c','t','s','=',0};
|
|
|
|
static const WCHAR dtrW[] = {'d','t','r','=',0};
|
|
|
|
static const WCHAR rtsW[] = {'r','t','s','=',0};
|
|
|
|
static const WCHAR idsrW[] = {'i','d','s','r','=',0};
|
2003-09-12 02:26:15 +02:00
|
|
|
|
|
|
|
while(*device)
|
|
|
|
{
|
|
|
|
while(*device == ' ') device++;
|
|
|
|
|
2020-09-28 16:34:11 +02:00
|
|
|
if(!wcsnicmp(baudW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
baud = TRUE;
|
|
|
|
|
|
|
|
if(!(device = COMM_ParseNumber(device + 5, &lpdcb->BaudRate)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(parityW, device, 7))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseParity(device + 7, &lpdcb->Parity)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(dataW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseByteSize(device + 5, &lpdcb->ByteSize)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(stopW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
stop = TRUE;
|
|
|
|
|
|
|
|
if(!(device = COMM_ParseStopBits(device + 5, &lpdcb->StopBits)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(toW, device, 3))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 3, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lptimeouts->ReadIntervalTimeout = 0;
|
|
|
|
lptimeouts->ReadTotalTimeoutMultiplier = 0;
|
|
|
|
lptimeouts->ReadTotalTimeoutConstant = 0;
|
|
|
|
lptimeouts->WriteTotalTimeoutMultiplier = 0;
|
|
|
|
lptimeouts->WriteTotalTimeoutConstant = temp ? 60000 : 0;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(xonW, device, 4))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 4, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lpdcb->fOutX = temp;
|
|
|
|
lpdcb->fInX = temp;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(odsrW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 5, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lpdcb->fOutxDsrFlow = temp;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(octsW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 5, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lpdcb->fOutxCtsFlow = temp;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(dtrW, device, 4))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 4, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lpdcb->fDtrControl = temp;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(rtsW, device, 4))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 4, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lpdcb->fRtsControl = temp;
|
|
|
|
}
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(!wcsnicmp(idsrW, device, 5))
|
2003-09-12 02:26:15 +02:00
|
|
|
{
|
|
|
|
if(!(device = COMM_ParseOnOff(device + 5, &temp)))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-09-15 22:00:54 +02:00
|
|
|
/* Win NT sets the fDsrSensitivity member based on the
|
|
|
|
idsr parameter. Win 9x sets fOutxDsrFlow instead. */
|
2003-09-12 02:26:15 +02:00
|
|
|
lpdcb->fDsrSensitivity = temp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* After the above parsing, the next character (if not the end of
|
|
|
|
the string) should be a space */
|
|
|
|
if(*device && *device != ' ')
|
|
|
|
return FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-07-23 19:56:33 +02:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/* If stop bits were not specified, a default is always supplied. */
|
|
|
|
if(!stop)
|
|
|
|
{
|
|
|
|
if(baud && lpdcb->BaudRate == 110)
|
|
|
|
lpdcb->StopBits = TWOSTOPBITS;
|
|
|
|
else
|
|
|
|
lpdcb->StopBits = ONESTOPBIT;
|
2001-07-23 19:56:33 +02:00
|
|
|
}
|
|
|
|
|
2001-10-21 17:01:20 +02:00
|
|
|
return TRUE;
|
2001-07-23 19:56:33 +02:00
|
|
|
}
|
|
|
|
|
1999-03-21 16:45:41 +01:00
|
|
|
/**************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* BuildCommDCBA (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Updates a device control block data structure with values from an
|
|
|
|
* ascii device control string. The device control string has two forms
|
|
|
|
* normal and extended, it must be exclusively in one or the other form.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
2002-02-27 22:34:54 +01:00
|
|
|
* True on success, false on a malformed control string.
|
1999-03-21 16:45:41 +01:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI BuildCommDCBA(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCSTR device, /* [in] The ascii device control string used to update the DCB. */
|
|
|
|
LPDCB lpdcb) /* [out] The device control block to be updated. */
|
1999-03-21 16:45:41 +01:00
|
|
|
{
|
|
|
|
return BuildCommDCBAndTimeoutsA(device,lpdcb,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2004-01-16 03:14:50 +01:00
|
|
|
* BuildCommDCBAndTimeoutsA (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Updates a device control block data structure with values from an
|
2002-02-27 22:34:54 +01:00
|
|
|
* ascii device control string. Taking timeout values from a timeouts
|
2000-12-20 00:33:03 +01:00
|
|
|
* struct if desired by the control string.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
2004-01-16 03:14:50 +01:00
|
|
|
* True on success, false bad handles etc.
|
1999-03-21 16:45:41 +01:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI BuildCommDCBAndTimeoutsA(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCSTR device, /* [in] The ascii device control string. */
|
|
|
|
LPDCB lpdcb, /* [out] The device control block to be updated. */
|
2003-09-12 02:26:15 +02:00
|
|
|
LPCOMMTIMEOUTS lptimeouts) /* [in] The COMMTIMEOUTS structure to be updated. */
|
2004-01-16 03:14:50 +01:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
UNICODE_STRING deviceW;
|
|
|
|
|
|
|
|
TRACE("(%s,%p,%p)\n",device,lpdcb,lptimeouts);
|
|
|
|
if(device) RtlCreateUnicodeStringFromAsciiz(&deviceW,device);
|
|
|
|
else deviceW.Buffer = NULL;
|
|
|
|
|
|
|
|
if(deviceW.Buffer) ret = BuildCommDCBAndTimeoutsW(deviceW.Buffer,lpdcb,lptimeouts);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&deviceW);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* BuildCommDCBAndTimeoutsW (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Updates a device control block data structure with values from a
|
|
|
|
* unicode device control string. Taking timeout values from a timeouts
|
|
|
|
* struct if desired by the control string.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True on success, false bad handles etc
|
|
|
|
*/
|
|
|
|
BOOL WINAPI BuildCommDCBAndTimeoutsW(
|
|
|
|
LPCWSTR devid, /* [in] The unicode device control string. */
|
|
|
|
LPDCB lpdcb, /* [out] The device control block to be updated. */
|
|
|
|
LPCOMMTIMEOUTS lptimeouts) /* [in] The COMMTIMEOUTS structure to be updated. */
|
1999-03-21 16:45:41 +01:00
|
|
|
{
|
2003-09-12 02:26:15 +02:00
|
|
|
DCB dcb;
|
|
|
|
COMMTIMEOUTS timeouts;
|
|
|
|
BOOL result;
|
2004-01-16 03:14:50 +01:00
|
|
|
LPCWSTR ptr = devid;
|
2008-03-03 23:27:46 +01:00
|
|
|
|
2004-01-16 03:14:50 +01:00
|
|
|
TRACE("(%s,%p,%p)\n",debugstr_w(devid),lpdcb,lptimeouts);
|
1999-03-21 16:45:41 +01:00
|
|
|
|
2008-03-03 23:27:46 +01:00
|
|
|
memset(&timeouts, 0, sizeof timeouts);
|
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/* Set DCBlength. (Windows NT does not do this, but 9x does) */
|
|
|
|
lpdcb->DCBlength = sizeof(DCB);
|
1999-03-21 16:45:41 +01:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
/* Make a copy of the original data structures to work with since if
|
|
|
|
if there is an error in the device control string the originals
|
|
|
|
should not be modified (except possibly DCBlength) */
|
2008-03-03 23:27:46 +01:00
|
|
|
dcb = *lpdcb;
|
|
|
|
if(lptimeouts) timeouts = *lptimeouts;
|
1999-03-21 16:45:41 +01:00
|
|
|
|
2003-09-12 02:26:15 +02:00
|
|
|
ptr = COMM_ParseStart(ptr);
|
|
|
|
|
|
|
|
if(ptr == NULL)
|
|
|
|
result = FALSE;
|
2020-09-28 16:34:11 +02:00
|
|
|
else if(wcschr(ptr, ','))
|
2003-09-12 02:26:15 +02:00
|
|
|
result = COMM_BuildOldCommDCB(ptr, &dcb);
|
|
|
|
else
|
|
|
|
result = COMM_BuildNewCommDCB(ptr, &dcb, &timeouts);
|
|
|
|
|
|
|
|
if(result)
|
|
|
|
{
|
2008-03-03 23:27:46 +01:00
|
|
|
*lpdcb = dcb;
|
|
|
|
if(lptimeouts) *lptimeouts = timeouts;
|
2003-09-12 02:26:15 +02:00
|
|
|
return TRUE;
|
1999-03-21 16:45:41 +01:00
|
|
|
}
|
2003-09-12 02:26:15 +02:00
|
|
|
else
|
|
|
|
{
|
2004-01-16 03:14:50 +01:00
|
|
|
WARN("Invalid device control string: %s\n", debugstr_w(devid));
|
2003-09-12 02:26:15 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-03-21 16:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* BuildCommDCBW (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* Updates a device control block structure with values from an
|
|
|
|
* unicode device control string. The device control string has two forms
|
|
|
|
* normal and extended, it must be exclusively in one or the other form.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
2005-03-30 19:08:31 +02:00
|
|
|
* True on success, false on a malformed control string.
|
1999-03-21 16:45:41 +01:00
|
|
|
*/
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL WINAPI BuildCommDCBW(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCWSTR devid, /* [in] The unicode device control string. */
|
|
|
|
LPDCB lpdcb) /* [out] The device control block to be updated. */
|
1999-03-21 16:45:41 +01:00
|
|
|
{
|
|
|
|
return BuildCommDCBAndTimeoutsW(devid,lpdcb,NULL);
|
|
|
|
}
|
|
|
|
|
2000-07-15 23:36:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* FIXME:
|
|
|
|
* The functionality of CommConfigDialogA, GetDefaultCommConfig and
|
|
|
|
* SetDefaultCommConfig is implemented in a DLL (usually SERIALUI.DLL).
|
|
|
|
* This is dependent on the type of COMM port, but since it is doubtful
|
|
|
|
* anybody will get around to implementing support for fancy serial
|
2002-06-01 01:06:46 +02:00
|
|
|
* ports in WINE, this is hardcoded for the time being. The name of
|
|
|
|
* this DLL should be stored in and read from the system registry in
|
2000-07-15 23:36:31 +02:00
|
|
|
* the hive HKEY_LOCAL_MACHINE, key
|
|
|
|
* System\\CurrentControlSet\\Services\\Class\\Ports\\????
|
|
|
|
* where ???? is the port number... that is determined by PNP
|
2002-06-01 01:06:46 +02:00
|
|
|
* The DLL should be loaded when the COMM port is opened, and closed
|
2000-07-15 23:36:31 +02:00
|
|
|
* when the COMM port is closed. - MJM 20 June 2000
|
|
|
|
***********************************************************************/
|
2006-01-24 14:00:32 +01:00
|
|
|
static const WCHAR lpszSerialUI[] = {
|
2004-10-26 02:16:39 +02:00
|
|
|
's','e','r','i','a','l','u','i','.','d','l','l',0 };
|
2000-07-15 23:36:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CommConfigDialogA (KERNEL32.@)
|
2000-07-15 23:36:31 +02:00
|
|
|
*
|
|
|
|
* Raises a dialog that allows the user to configure a comm port.
|
|
|
|
* Fills the COMMCONFIG struct with information specified by the user.
|
|
|
|
* This function should call a similar routine in the COMM driver...
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* TRUE on success, FALSE on failure
|
|
|
|
* If successful, the lpCommConfig structure will contain a new
|
|
|
|
* configuration for the comm port, as specified by the user.
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* The library with the CommConfigDialog code is never unloaded.
|
|
|
|
* Perhaps this should be done when the comm port is closed?
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CommConfigDialogA(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCSTR lpszDevice, /* [in] name of communications device */
|
2005-05-09 21:32:33 +02:00
|
|
|
HWND hWnd, /* [in] parent window for the dialog */
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */
|
|
|
|
{
|
2007-03-06 05:40:56 +01:00
|
|
|
LPWSTR lpDeviceW = NULL;
|
|
|
|
DWORD len;
|
|
|
|
BOOL r;
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2007-02-20 16:38:13 +01:00
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_a(lpszDevice), hWnd, lpCommConfig);
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2007-03-06 05:40:56 +01:00
|
|
|
if (lpszDevice)
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 );
|
|
|
|
lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len );
|
|
|
|
}
|
|
|
|
r = CommConfigDialogW(lpDeviceW, hWnd, lpCommConfig);
|
|
|
|
HeapFree( GetProcessHeap(), 0, lpDeviceW );
|
2000-07-15 23:36:31 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CommConfigDialogW (KERNEL32.@)
|
2000-07-15 23:36:31 +02:00
|
|
|
*
|
2005-11-08 12:01:03 +01:00
|
|
|
* See CommConfigDialogA.
|
2000-07-15 23:36:31 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI CommConfigDialogW(
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCWSTR lpszDevice, /* [in] name of communications device */
|
2005-05-09 21:32:33 +02:00
|
|
|
HWND hWnd, /* [in] parent window for the dialog */
|
2001-02-12 04:49:57 +01:00
|
|
|
LPCOMMCONFIG lpCommConfig) /* [out] pointer to struct to fill */
|
|
|
|
{
|
2009-09-09 13:12:28 +02:00
|
|
|
DWORD (WINAPI *pCommConfigDialog)(LPCWSTR, HWND, LPCOMMCONFIG);
|
2004-10-26 02:25:58 +02:00
|
|
|
HMODULE hConfigModule;
|
2007-03-06 05:40:56 +01:00
|
|
|
DWORD res = ERROR_INVALID_PARAMETER;
|
2004-10-26 02:25:58 +02:00
|
|
|
|
2007-02-20 16:38:13 +01:00
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_w(lpszDevice), hWnd, lpCommConfig);
|
2004-10-26 02:25:58 +02:00
|
|
|
hConfigModule = LoadLibraryW(lpszSerialUI);
|
|
|
|
|
2007-03-06 05:40:56 +01:00
|
|
|
if (hConfigModule) {
|
2009-09-09 13:12:28 +02:00
|
|
|
pCommConfigDialog = (void *)GetProcAddress(hConfigModule, "drvCommConfigDialogW");
|
2007-03-06 05:40:56 +01:00
|
|
|
if (pCommConfigDialog) {
|
|
|
|
res = pCommConfigDialog(lpszDevice, hWnd, lpCommConfig);
|
|
|
|
}
|
|
|
|
FreeLibrary(hConfigModule);
|
|
|
|
}
|
2004-10-26 02:25:58 +02:00
|
|
|
|
2007-03-06 05:40:56 +01:00
|
|
|
if (res) SetLastError(res);
|
|
|
|
return (res == ERROR_SUCCESS);
|
2000-07-15 23:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2007-10-26 20:15:14 +02:00
|
|
|
* SetDefaultCommConfigW (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2007-10-26 20:15:14 +02:00
|
|
|
* Initializes the default configuration for a communication device.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpszDevice [I] Name of the device targeted for configuration
|
|
|
|
* lpCommConfig [I] PTR to a buffer with the configuration for the device
|
|
|
|
* dwSize [I] Number of bytes in the buffer
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2007-10-26 20:15:14 +02:00
|
|
|
* Failure: FALSE
|
|
|
|
* Success: TRUE, and default configuration saved
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2000-07-15 23:36:31 +02:00
|
|
|
*/
|
2007-10-26 20:15:14 +02:00
|
|
|
BOOL WINAPI SetDefaultCommConfigW(LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
|
2001-02-12 04:49:57 +01:00
|
|
|
{
|
2009-09-09 13:12:28 +02:00
|
|
|
BOOL (WINAPI *lpfnSetDefaultCommConfig)(LPCWSTR, LPCOMMCONFIG, DWORD);
|
2000-07-15 23:36:31 +02:00
|
|
|
HMODULE hConfigModule;
|
2004-10-26 02:16:39 +02:00
|
|
|
BOOL r = FALSE;
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2007-02-20 16:38:13 +01:00
|
|
|
TRACE("(%s, %p, %u)\n", debugstr_w(lpszDevice), lpCommConfig, dwSize);
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2004-10-26 02:16:39 +02:00
|
|
|
hConfigModule = LoadLibraryW(lpszSerialUI);
|
2000-07-15 23:36:31 +02:00
|
|
|
if(!hConfigModule)
|
2004-10-26 02:16:39 +02:00
|
|
|
return r;
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2009-09-09 13:12:28 +02:00
|
|
|
lpfnSetDefaultCommConfig = (void *)GetProcAddress(hConfigModule, "drvSetDefaultCommConfigW");
|
2004-10-26 02:16:39 +02:00
|
|
|
if (lpfnSetDefaultCommConfig)
|
|
|
|
r = lpfnSetDefaultCommConfig(lpszDevice, lpCommConfig, dwSize);
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2004-10-26 02:16:39 +02:00
|
|
|
FreeLibrary(hConfigModule);
|
2000-07-15 23:36:31 +02:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2007-10-26 20:15:14 +02:00
|
|
|
* SetDefaultCommConfigA (KERNEL32.@)
|
2000-07-15 23:36:31 +02:00
|
|
|
*
|
2007-10-26 20:15:14 +02:00
|
|
|
* Initializes the default configuration for a communication device.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2007-10-26 20:15:14 +02:00
|
|
|
* See SetDefaultCommConfigW.
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2000-07-15 23:36:31 +02:00
|
|
|
*/
|
2007-10-26 20:15:14 +02:00
|
|
|
BOOL WINAPI SetDefaultCommConfigA(LPCSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
|
2001-02-12 04:49:57 +01:00
|
|
|
{
|
2000-07-15 23:36:31 +02:00
|
|
|
BOOL r;
|
2004-10-26 02:16:39 +02:00
|
|
|
LPWSTR lpDeviceW = NULL;
|
|
|
|
DWORD len;
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2007-02-20 16:38:13 +01:00
|
|
|
TRACE("(%s, %p, %u)\n", debugstr_a(lpszDevice), lpCommConfig, dwSize);
|
2000-07-15 23:36:31 +02:00
|
|
|
|
2004-10-26 02:16:39 +02:00
|
|
|
if (lpszDevice)
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, NULL, 0 );
|
|
|
|
lpDeviceW = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpszDevice, -1, lpDeviceW, len );
|
|
|
|
}
|
|
|
|
r = SetDefaultCommConfigW(lpDeviceW,lpCommConfig,dwSize);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, lpDeviceW );
|
2000-07-15 23:36:31 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-08 20:29:54 +02:00
|
|
|
/***********************************************************************
|
2004-01-16 03:21:01 +01:00
|
|
|
* GetDefaultCommConfigW (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2000-07-08 20:29:54 +02:00
|
|
|
*/
|
2004-01-16 03:21:01 +01:00
|
|
|
BOOL WINAPI GetDefaultCommConfigW(
|
|
|
|
LPCWSTR lpszName, /* [in] The unicode name of the device targeted for configuration. */
|
2001-02-12 04:49:57 +01:00
|
|
|
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. */
|
2000-12-20 00:33:03 +01:00
|
|
|
{
|
2009-09-09 13:12:28 +02:00
|
|
|
DWORD (WINAPI *pGetDefaultCommConfig)(LPCWSTR, LPCOMMCONFIG, LPDWORD);
|
2007-02-26 22:16:07 +01:00
|
|
|
HMODULE hConfigModule;
|
|
|
|
DWORD res = ERROR_INVALID_PARAMETER;
|
2000-07-08 20:29:54 +02:00
|
|
|
|
2007-02-26 22:16:07 +01:00
|
|
|
TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_w(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
|
|
|
|
hConfigModule = LoadLibraryW(lpszSerialUI);
|
2000-07-08 20:29:54 +02:00
|
|
|
|
2007-02-26 22:16:07 +01:00
|
|
|
if (hConfigModule) {
|
2009-09-09 13:12:28 +02:00
|
|
|
pGetDefaultCommConfig = (void *)GetProcAddress(hConfigModule, "drvGetDefaultCommConfigW");
|
2007-02-26 22:16:07 +01:00
|
|
|
if (pGetDefaultCommConfig) {
|
|
|
|
res = pGetDefaultCommConfig(lpszName, lpCC, lpdwSize);
|
|
|
|
}
|
|
|
|
FreeLibrary(hConfigModule);
|
|
|
|
}
|
2000-07-08 20:29:54 +02:00
|
|
|
|
2007-02-26 22:16:07 +01:00
|
|
|
if (res) SetLastError(res);
|
|
|
|
return (res == ERROR_SUCCESS);
|
2000-07-08 20:29:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2004-01-16 03:21:01 +01:00
|
|
|
* GetDefaultCommConfigA (KERNEL32.@)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
2004-01-16 03:21:01 +01:00
|
|
|
* Acquires the default configuration of the specified communication device. (ascii)
|
2000-12-20 00:33:03 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
* True on successful reading of the default configuration,
|
|
|
|
* if the device is not found or the buffer is too small.
|
2000-07-08 20:29:54 +02:00
|
|
|
*/
|
2004-01-16 03:21:01 +01:00
|
|
|
BOOL WINAPI GetDefaultCommConfigA(
|
|
|
|
LPCSTR lpszName, /* [in] The ascii name of the device targeted for configuration. */
|
2001-02-12 04:49:57 +01:00
|
|
|
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. */
|
|
|
|
{
|
2000-12-20 00:33:03 +01:00
|
|
|
BOOL ret = FALSE;
|
2004-01-16 03:21:01 +01:00
|
|
|
UNICODE_STRING lpszNameW;
|
2000-07-08 20:29:54 +02:00
|
|
|
|
2007-02-20 16:38:13 +01:00
|
|
|
TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_a(lpszName), lpCC, lpdwSize, lpdwSize ? *lpdwSize : 0 );
|
2004-01-16 03:21:01 +01:00
|
|
|
if(lpszName) RtlCreateUnicodeStringFromAsciiz(&lpszNameW,lpszName);
|
|
|
|
else lpszNameW.Buffer = NULL;
|
|
|
|
|
2007-02-26 22:16:07 +01:00
|
|
|
ret = GetDefaultCommConfigW(lpszNameW.Buffer,lpCC,lpdwSize);
|
2004-01-16 03:21:01 +01:00
|
|
|
|
|
|
|
RtlFreeUnicodeString(&lpszNameW);
|
2000-07-08 20:29:54 +02:00
|
|
|
return ret;
|
|
|
|
}
|