Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
eff9c9ef
Commit
eff9c9ef
authored
Sep 10, 2007
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Sep 11, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localspl: Implement OpenPort and ClosePort.
parent
278cc8e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
2 deletions
+128
-2
localmon.c
dlls/localspl/localmon.c
+128
-2
No files found.
dlls/localspl/localmon.c
View file @
eff9c9ef
...
...
@@ -42,6 +42,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(localspl);
/*****************************************************/
static
CRITICAL_SECTION
port_handles_cs
;
static
CRITICAL_SECTION_DEBUG
port_handles_cs_debug
=
{
0
,
0
,
&
port_handles_cs
,
{
&
port_handles_cs_debug
.
ProcessLocksList
,
&
port_handles_cs_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": port_handles_cs"
)
}
};
static
CRITICAL_SECTION
port_handles_cs
=
{
&
port_handles_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
CRITICAL_SECTION
xcv_handles_cs
;
static
CRITICAL_SECTION_DEBUG
xcv_handles_cs_debug
=
{
...
...
@@ -55,10 +65,17 @@ static CRITICAL_SECTION xcv_handles_cs = { &xcv_handles_cs_debug, -1, 0, 0, 0, 0
typedef
struct
{
struct
list
entry
;
DWORD
type
;
WCHAR
nameW
[
1
];
}
port_t
;
typedef
struct
{
struct
list
entry
;
ACCESS_MASK
GrantedAccess
;
WCHAR
nameW
[
1
];
}
xcv_t
;
static
struct
list
port_handles
=
LIST_INIT
(
port_handles
);
static
struct
list
xcv_handles
=
LIST_INIT
(
xcv_handles
);
/* ############################### */
...
...
@@ -299,6 +316,45 @@ static DWORD get_type_from_name(LPCWSTR name)
return
PORT_IS_UNKNOWN
;
}
/*****************************************************
* get_type_from_local_name (internal)
*
*/
static
DWORD
get_type_from_local_name
(
LPCWSTR
nameW
)
{
LPPORT_INFO_1W
pi
;
LPWSTR
myname
=
NULL
;
DWORD
needed
=
0
;
DWORD
numentries
=
0
;
DWORD
id
=
0
;
TRACE
(
"(%s)
\n
"
,
debugstr_w
(
myname
));
needed
=
get_ports_from_reg
(
1
,
NULL
,
0
,
&
numentries
);
pi
=
spl_alloc
(
needed
);
if
(
pi
)
needed
=
get_ports_from_reg
(
1
,
(
LPBYTE
)
pi
,
needed
,
&
numentries
);
if
(
pi
&&
needed
&&
numentries
>
0
)
{
/* we got a number of valid ports. */
while
((
myname
==
NULL
)
&&
(
id
<
numentries
))
{
if
(
lstrcmpiW
(
nameW
,
pi
[
id
].
pName
)
==
0
)
{
TRACE
(
"(%u) found %s
\n
"
,
id
,
debugstr_w
(
pi
[
id
].
pName
));
myname
=
pi
[
id
].
pName
;
}
id
++
;
}
}
id
=
(
myname
)
?
get_type_from_name
(
myname
)
:
PORT_IS_UNKNOWN
;
spl_free
(
pi
);
return
id
;
}
/******************************************************************************
* localmon_AddPortExW [exported through MONITOREX]
*
...
...
@@ -357,6 +413,31 @@ static BOOL WINAPI localmon_AddPortExW(LPWSTR pName, DWORD level, LPBYTE pBuffer
}
/*****************************************************
* localmon_ClosePort [exported through MONITOREX]
*
* Close a
*
* PARAMS
* hPort [i] The Handle to close
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*
*/
static
BOOL
WINAPI
localmon_ClosePort
(
HANDLE
hPort
)
{
port_t
*
port
=
(
port_t
*
)
hPort
;
TRACE
(
"(%p)
\n
"
,
port
);
EnterCriticalSection
(
&
port_handles_cs
);
list_remove
(
&
port
->
entry
);
LeaveCriticalSection
(
&
port_handles_cs
);
spl_free
(
port
);
return
TRUE
;
}
/*****************************************************
* localmon_EnumPortsW [exported through MONITOREX]
*
* Enumerate all local Ports
...
...
@@ -416,6 +497,51 @@ cleanup:
}
/*****************************************************
* localmon_OpenPort [exported through MONITOREX]
*
* Open a Data-Channel for a Port
*
* PARAMS
* pName [i] Name of selected Object
* phPort [o] The resulting Handle is stored here
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*
*/
static
BOOL
WINAPI
localmon_OpenPortW
(
LPWSTR
pName
,
PHANDLE
phPort
)
{
port_t
*
port
;
DWORD
len
;
DWORD
type
;
TRACE
(
"%s, %p)
\n
"
,
debugstr_w
(
pName
),
phPort
);
/* an empty name is invalid */
if
(
!
pName
[
0
])
return
FALSE
;
/* does the port exist? */
type
=
get_type_from_local_name
(
pName
);
if
(
!
type
)
return
FALSE
;
len
=
(
lstrlenW
(
pName
)
+
1
)
*
sizeof
(
WCHAR
);
port
=
spl_alloc
(
sizeof
(
port_t
)
+
len
);
if
(
!
port
)
return
FALSE
;
port
->
type
=
type
;
memcpy
(
&
port
->
nameW
,
pName
,
len
);
*
phPort
=
(
HANDLE
)
port
;
EnterCriticalSection
(
&
port_handles_cs
);
list_add_tail
(
&
port_handles
,
&
port
->
entry
);
LeaveCriticalSection
(
&
port_handles_cs
);
TRACE
(
"=> %p
\n
"
,
port
);
return
TRUE
;
}
/*****************************************************
* localmon_XcvClosePort [exported through MONITOREX]
*
* Close a Communication-Channel
...
...
@@ -658,13 +784,13 @@ LPMONITOREX WINAPI InitializePrintMonitor(LPWSTR regroot)
sizeof
(
MONITOREX
)
-
sizeof
(
DWORD
),
{
localmon_EnumPortsW
,
NULL
,
/* localmon_OpenPortW */
localmon_OpenPortW
,
NULL
,
/* localmon_OpenPortExW */
NULL
,
/* localmon_StartDocPortW */
NULL
,
/* localmon_WritePortW */
NULL
,
/* localmon_ReadPortW */
NULL
,
/* localmon_EndDocPortW */
NULL
,
/* localmon_ClosePortW */
localmon_ClosePort
,
NULL
,
/* Use AddPortUI in localui.dll */
localmon_AddPortExW
,
NULL
,
/* Use ConfigurePortUI in localui.dll */
...
...
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