Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
75354242
Commit
75354242
authored
Jul 08, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lookup COM/LPT devices in the registry when they are used, instead of
loading everything at startup.
parent
4ef7ba72
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
87 deletions
+63
-87
comm16.c
dlls/user/comm16.c
+63
-83
user_main.c
dlls/user/user_main.c
+0
-4
No files found.
dlls/user/comm16.c
View file @
75354242
...
...
@@ -85,11 +85,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(comm);
#define MAX_PORTS 9
struct
DosDeviceStruct
{
char
*
devicename
;
/* /dev/ttyS0 */
HANDLE
handle
;
int
suspended
;
int
unget
,
xmit
;
int
baudrate
;
int
evtchar
;
/* events */
int
commerror
,
eventmask
;
...
...
@@ -128,75 +126,55 @@ static void COMM_MSRUpdate( HANDLE handle, UCHAR * pMsr )
*
pMsr
=
(
*
pMsr
&
~
MSR_MASK
)
|
tmpmsr
;
}
void
COMM_Init
(
void
)
static
BOOL
get_com_device_name
(
int
port
,
char
*
devicename
,
DWORD
size
,
int
*
baudrate
)
{
int
x
;
char
option
[
10
],
temp
[
256
],
*
btemp
;
HKEY
hkey
;
for
(
x
=
0
;
x
!=
MAX_PORTS
;
x
++
)
{
strcpy
(
option
,
"COMx"
);
option
[
3
]
=
'1'
+
x
;
option
[
4
]
=
'\0'
;
/* default value */
strcpy
(
temp
,
"*"
);
if
(
!
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
serialports"
,
&
hkey
))
{
DWORD
type
,
count
=
sizeof
(
temp
);
RegQueryValueExA
(
hkey
,
option
,
0
,
&
type
,
temp
,
&
count
);
RegCloseKey
(
hkey
);
}
if
(
!
strcmp
(
temp
,
"*"
)
||
*
temp
==
'\0'
)
COM
[
x
].
devicename
=
NULL
;
else
{
btemp
=
strchr
(
temp
,
','
);
if
(
btemp
!=
NULL
)
{
*
btemp
++
=
'\0'
;
COM
[
x
].
baudrate
=
atoi
(
btemp
);
}
else
{
COM
[
x
].
baudrate
=
-
1
;
}
if
((
COM
[
x
].
devicename
=
malloc
(
strlen
(
temp
)
+
1
))
==
NULL
)
WARN
(
"Can't malloc for device info!
\n
"
);
else
{
COM
[
x
].
handle
=
0
;
strcpy
(
COM
[
x
].
devicename
,
temp
);
TRACE
(
"%s = %s
\n
"
,
option
,
COM
[
x
].
devicename
);
}
}
strcpy
(
option
,
"LPTx"
);
option
[
3
]
=
'1'
+
x
;
option
[
4
]
=
'\0'
;
/* default value */
strcpy
(
temp
,
"*"
);
if
(
!
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
parallelports"
,
&
hkey
))
{
DWORD
type
,
count
=
sizeof
(
temp
);
RegQueryValueExA
(
hkey
,
option
,
0
,
&
type
,
temp
,
&
count
);
RegCloseKey
(
hkey
);
}
if
(
!
strcmp
(
temp
,
"*"
)
||
*
temp
==
'\0'
)
LPT
[
x
].
devicename
=
NULL
;
else
{
if
((
LPT
[
x
].
devicename
=
malloc
(
strlen
(
temp
)
+
1
))
==
NULL
)
WARN
(
"Can't malloc for device info!
\n
"
);
else
{
LPT
[
x
].
handle
=
0
;
strcpy
(
LPT
[
x
].
devicename
,
temp
);
TRACE
(
"%s = %s
\n
"
,
option
,
LPT
[
x
].
devicename
);
}
}
HKEY
hkey
;
char
temp
[
256
],
*
btemp
;
if
(
port
>=
MAX_PORTS
)
return
FALSE
;
temp
[
0
]
=
0
;
if
(
!
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
serialports"
,
&
hkey
))
{
DWORD
type
,
count
=
sizeof
(
temp
);
char
value
[
8
];
sprintf
(
value
,
"COM%d"
,
port
+
1
);
RegQueryValueExA
(
hkey
,
value
,
0
,
&
type
,
temp
,
&
count
);
RegCloseKey
(
hkey
);
}
if
(
!
temp
[
0
])
return
FALSE
;
btemp
=
strchr
(
temp
,
','
);
if
(
btemp
!=
NULL
)
{
*
btemp
++
=
'\0'
;
if
(
baudrate
)
*
baudrate
=
atoi
(
btemp
);
}
else
if
(
baudrate
)
*
baudrate
=
-
1
;
if
(
devicename
)
lstrcpynA
(
devicename
,
temp
,
size
);
return
TRUE
;
}
}
static
BOOL
get_lpt_device_name
(
int
port
,
char
*
devicename
,
DWORD
size
)
{
HKEY
hkey
;
char
temp
[
256
];
if
(
port
>=
MAX_PORTS
)
return
FALSE
;
temp
[
0
]
=
0
;
if
(
!
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Wine
\\
Wine
\\
Config
\\
parallelports"
,
&
hkey
))
{
DWORD
type
,
count
=
sizeof
(
temp
);
char
value
[
8
];
sprintf
(
value
,
"LPT%d"
,
port
+
1
);
RegQueryValueExA
(
hkey
,
value
,
0
,
&
type
,
temp
,
&
count
);
RegCloseKey
(
hkey
);
}
if
(
!
temp
[
0
])
return
FALSE
;
if
(
devicename
)
lstrcpynA
(
devicename
,
temp
,
size
);
return
TRUE
;
}
...
...
@@ -228,14 +206,14 @@ static int GetCommPort_ov(LPOVERLAPPED ov, int write)
return
-
1
;
}
static
int
ValidCOMPort
(
int
x
)
inline
static
int
ValidCOMPort
(
int
x
)
{
return
(
x
<
MAX_PORTS
?
(
int
)
COM
[
x
].
devicename
:
0
);
return
get_com_device_name
(
x
,
NULL
,
0
,
NULL
);
}
static
int
ValidLPTPort
(
int
x
)
inline
static
int
ValidLPTPort
(
int
x
)
{
return
(
x
<
MAX_PORTS
?
(
int
)
LPT
[
x
].
devicename
:
0
);
return
get_lpt_device_name
(
x
,
NULL
,
0
);
}
static
int
WinError
(
void
)
...
...
@@ -549,13 +527,16 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
if
(
port
--
==
0
)
ERR
(
"BUG ! COM0 or LPT0 don't exist !
\n
"
);
if
(
!
strncasecmp
(
device
,
"COM"
,
3
))
{
if
(
!
strncasecmp
(
device
,
"COM"
,
3
))
{
char
devicename
[
32
];
int
baudrate
;
TRACE
(
"%s = %s
\n
"
,
device
,
COM
[
port
].
devicename
);
if
(
!
ValidCOMPort
(
port
))
if
(
!
get_com_device_name
(
port
,
devicename
,
sizeof
(
devicename
),
&
baudrate
))
return
IE_BADID
;
TRACE
(
"%s = %s
\n
"
,
device
,
devicename
);
if
(
COM
[
port
].
handle
)
return
IE_OPEN
;
...
...
@@ -563,7 +544,7 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_OVERLAPPED
|
FILE_FLAG_NO_BUFFERING
,
0
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
ERR
(
"Couldn't open %s ! (%s)
\n
"
,
COM
[
port
].
devicename
,
strerror
(
errno
));
ERR
(
"Couldn't open %s ! (%s)
\n
"
,
devicename
,
strerror
(
errno
));
return
IE_HARDWARE
;
}
else
{
memset
(
COM
[
port
].
unknown
,
0
,
sizeof
(
COM
[
port
].
unknown
));
...
...
@@ -575,10 +556,10 @@ INT16 WINAPI OpenComm16(LPCSTR device,UINT16 cbInQueue,UINT16 cbOutQueue)
/* save terminal state */
GetCommState16
(
port
,
&
COM
[
port
].
dcb
);
/* set default parameters */
if
(
COM
[
port
].
baudrate
>-
1
){
if
(
baudrate
>-
1
){
DCB16
dcb
;
memcpy
(
&
dcb
,
&
COM
[
port
].
dcb
,
sizeof
(
dcb
));
dcb
.
BaudRate
=
COM
[
port
].
baudrate
;
dcb
.
BaudRate
=
baudrate
;
/* more defaults:
* databits, parity, stopbits
*/
...
...
@@ -724,13 +705,13 @@ LONG WINAPI EscapeCommFunction16(UINT16 cid,UINT16 nFunction)
switch
(
nFunction
)
{
case
GETMAXCOM
:
TRACE
(
"GETMAXCOM
\n
"
);
for
(
max
=
MAX_PORTS
;
!
COM
[
max
].
devicename
;
max
--
)
for
(
max
=
MAX_PORTS
;
!
ValidCOMPort
(
max
)
;
max
--
)
;
return
max
;
case
GETMAXLPT
:
TRACE
(
"GETMAXLPT
\n
"
);
for
(
max
=
MAX_PORTS
;
!
LPT
[
max
].
devicename
;
max
--
)
for
(
max
=
MAX_PORTS
;
!
ValidLPTPort
(
max
)
;
max
--
)
;
return
FLAG_LPT
+
max
;
...
...
@@ -1209,4 +1190,3 @@ BOOL16 WINAPI EnableCommNotification16( INT16 cid, HWND16 hwnd,
ptr
->
n_write
=
cbOutQueue
;
return
TRUE
;
}
dlls/user/user_main.c
View file @
75354242
...
...
@@ -50,7 +50,6 @@ extern UINT (WINAPI *pfnGDIRealizePalette)(HDC hdc);
static
HMODULE
graphics_driver
;
static
DWORD
exiting_thread_id
;
extern
void
COMM_Init
(
void
);
extern
void
WDML_NotifyThreadDetach
(
void
);
#define GET_USER_FUNC(name) USER_Driver.p##name = (void*)GetProcAddress( graphics_driver, #name )
...
...
@@ -265,9 +264,6 @@ static BOOL process_attach(void)
/* Initialize mouse driver */
if
(
USER_Driver
.
pInitMouse
)
USER_Driver
.
pInitMouse
(
InputKeyStateTable
);
/* Initialize 16-bit serial communications */
COMM_Init
();
return
TRUE
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment