ReactOS 0.4.16-dev-106-g10b08aa
ports.c File Reference
#include "precomp.h"
Include dependency graph for ports.c:

Go to the source code of this file.

Functions

BOOL WINAPI AddPortExW (PWSTR pName, DWORD Level, PBYTE lpBuffer, PWSTR lpMonitorName)
 
BOOL WINAPI AddPortW (PWSTR pName, HWND hWnd, PWSTR pMonitorName)
 
BOOL WINAPI ConfigurePortW (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI DeletePortW (PWSTR pName, HWND hWnd, PWSTR pPortName)
 
BOOL WINAPI EnumPortsW (PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI SetPortW (PWSTR pName, PWSTR pPortName, DWORD dwLevel, PBYTE pPortInfo)
 

Function Documentation

◆ AddPortExW()

BOOL WINAPI AddPortExW ( PWSTR  pName,
DWORD  Level,
PBYTE  lpBuffer,
PWSTR  lpMonitorName 
)

Definition at line 11 of file ports.c.

12{
13 BOOL bReturnValue = TRUE;
14 DWORD dwErrorCode = MAXDWORD;
15 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
17
18 FIXME("AddPortEx(%S, %lu, %p, %s)\n", pName, Level, lpBuffer, debugstr_w(lpMonitorName));
19
20 // Loop through all Print Provider.
22 {
24
25 // Check if this Print Provider provides the function.
26 if (!pPrintProvider->PrintProvider.fpAddPortEx)
27 continue;
28
29 bReturnValue = pPrintProvider->PrintProvider.fpAddPortEx(pName, Level, lpBuffer, lpMonitorName);
30
31 if ( !bReturnValue )
32 {
33 dwErrorCode = GetLastError();
34 }
35
36 // dwErrorCode shall not be overwritten if a previous call already succeeded.
37 if (dwErrorCode != ERROR_SUCCESS)
38 dwErrorCode = GetLastError();
39 }
40
41 SetLastError(dwErrorCode);
42 return (dwErrorCode == ERROR_SUCCESS);
43}
#define FIXME(fmt,...)
Definition: precomp.h:53
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define debugstr_w
Definition: kernel32.h:32
static LPSTR pName
Definition: security.c:75
#define MAXDWORD
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PRINTPROVIDOR PrintProvider
Definition: precomp.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
LIST_ENTRY PrintProviderList
Definition: main.c:12
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

Referenced by _RpcAddPortEx(), and AddPortExA().

◆ AddPortW()

BOOL WINAPI AddPortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pMonitorName 
)

Definition at line 46 of file ports.c.

47{
48 BOOL bReturnValue = TRUE;
49 DWORD dwErrorCode = MAXDWORD;
50 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
52
53 FIXME("AddPort(%S, %p, %s)\n", pName, hWnd, debugstr_w(pMonitorName));
54
55 // Loop through all Print Provider.
57 {
59
60 // Check if this Print Provider provides the function.
61 if (!pPrintProvider->PrintProvider.fpAddPort)
62 continue;
63
64 bReturnValue = pPrintProvider->PrintProvider.fpAddPort(pName, hWnd, pMonitorName);
65
66 if ( !bReturnValue )
67 {
68 dwErrorCode = GetLastError();
69 }
70
71 // dwErrorCode shall not be overwritten if a previous call already succeeded.
72 if (dwErrorCode != ERROR_SUCCESS)
73 dwErrorCode = GetLastError();
74 }
75
76 SetLastError(dwErrorCode);
77 return (dwErrorCode == ERROR_SUCCESS);
78}
HWND hWnd
Definition: settings.c:17

Referenced by _RpcAddPort(), and AddPortA().

◆ ConfigurePortW()

BOOL WINAPI ConfigurePortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pPortName 
)

Definition at line 81 of file ports.c.

82{
83 BOOL bReturnValue = TRUE;
84 DWORD dwErrorCode = MAXDWORD;
85 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
87
88 // Loop through all Print Provider.
90 {
92
93 // Check if this Print Provider provides the function.
94 if (!pPrintProvider->PrintProvider.fpConfigurePort)
95 continue;
96
97 bReturnValue = pPrintProvider->PrintProvider.fpConfigurePort(pName, hWnd, pPortName);
98
99 if ( !bReturnValue )
100 {
101 dwErrorCode = GetLastError();
102 }
103
104 // dwErrorCode shall not be overwritten if a previous call already succeeded.
105 if (dwErrorCode != ERROR_SUCCESS)
106 dwErrorCode = GetLastError();
107 }
108
109 SetLastError(dwErrorCode);
110 return (dwErrorCode == ERROR_SUCCESS);
111}

Referenced by _RpcConfigurePort(), and ConfigurePortA().

◆ DeletePortW()

BOOL WINAPI DeletePortW ( PWSTR  pName,
HWND  hWnd,
PWSTR  pPortName 
)

Definition at line 114 of file ports.c.

115{
116 BOOL bReturnValue = TRUE;
117 DWORD dwErrorCode = MAXDWORD;
118 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
120
121 // Loop through all Print Provider.
123 {
125
126 // Check if this Print Provider provides the function.
127 if (!pPrintProvider->PrintProvider.fpDeletePort)
128 continue;
129
130 bReturnValue = pPrintProvider->PrintProvider.fpDeletePort(pName, hWnd, pPortName);
131
132 if ( !bReturnValue )
133 {
134 dwErrorCode = GetLastError();
135 }
136
137 // dwErrorCode shall not be overwritten if a previous call already succeeded.
138 if (dwErrorCode != ERROR_SUCCESS)
139 dwErrorCode = GetLastError();
140 }
141
142 SetLastError(dwErrorCode);
143 return (dwErrorCode == ERROR_SUCCESS);
144}

Referenced by _RpcDeletePort(), and DeletePortA().

◆ EnumPortsW()

BOOL WINAPI EnumPortsW ( PWSTR  pName,
DWORD  Level,
PBYTE  pPorts,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 147 of file ports.c.

148{
149 BOOL bReturnValue = TRUE;
150 DWORD cbCallBuffer;
151 DWORD cbNeeded;
152 DWORD dwReturned;
153 DWORD dwErrorCode = MAXDWORD;
154 PBYTE pCallBuffer;
155 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
157
158 // Sanity checks.
159 if (cbBuf && !pPorts)
160 {
162 return FALSE;
163 }
164
165 // Begin counting.
166 *pcbNeeded = 0;
167 *pcReturned = 0;
168
169 // At the beginning, we have the full buffer available.
170 cbCallBuffer = cbBuf;
171 pCallBuffer = pPorts;
172
173 // Loop through all Print Provider.
175 {
177
178 // Check if this Print Provider provides an EnumPorts function.
179 if (!pPrintProvider->PrintProvider.fpEnumPorts)
180 continue;
181
182 // Call the EnumPorts function of this Print Provider.
183 cbNeeded = 0;
184 dwReturned = 0;
185 bReturnValue = pPrintProvider->PrintProvider.fpEnumPorts(pName, Level, pCallBuffer, cbCallBuffer, &cbNeeded, &dwReturned);
186
187 if ( !bReturnValue )
188 {
189 dwErrorCode = GetLastError();
190 }
191
192 // Add the returned counts to the total values.
193 *pcbNeeded += cbNeeded;
194 *pcReturned += dwReturned;
195
196 // Reduce the available buffer size for the next call without risking an underflow.
197 if (cbNeeded < cbCallBuffer)
198 cbCallBuffer -= cbNeeded;
199 else
200 cbCallBuffer = 0;
201
202 // Advance the buffer if the caller provided it.
203 if (pCallBuffer)
204 pCallBuffer += cbNeeded;
205
206 // dwErrorCode shall not be overwritten if a previous EnumPrinters call already succeeded.
207 if (dwErrorCode != ERROR_SUCCESS)
208 dwErrorCode = GetLastError();
209 }
210
211 SetLastError(dwErrorCode);
212 return (dwErrorCode == ERROR_SUCCESS);
213}
#define FALSE
Definition: types.h:117
BYTE * PBYTE
Definition: pedump.c:66
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091

Referenced by _RpcEnumPorts(), and EnumPortsA().

◆ SetPortW()

BOOL WINAPI SetPortW ( PWSTR  pName,
PWSTR  pPortName,
DWORD  dwLevel,
PBYTE  pPortInfo 
)

Definition at line 216 of file ports.c.

217{
218 BOOL bReturnValue = TRUE;
219 DWORD dwErrorCode = MAXDWORD;
220 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
222
223 // Loop through all Print Provider.
225 {
227
228 // Check if this Print Provider provides the function.
229 if (!pPrintProvider->PrintProvider.fpSetPort)
230 continue;
231
232 bReturnValue = pPrintProvider->PrintProvider.fpSetPort(pName, pPortName, dwLevel, pPortInfo);
233
234 if ( !bReturnValue )
235 {
236 dwErrorCode = GetLastError();
237 }
238
239 // dwErrorCode shall not be overwritten if a previous call already succeeded.
240 if (dwErrorCode != ERROR_SUCCESS)
241 dwErrorCode = GetLastError();
242 }
243
244 SetLastError(dwErrorCode);
245 return (dwErrorCode == ERROR_SUCCESS);
246}

Referenced by _RpcSetPort(), and SetPortA().