2 * PROJECT: ReactOS Spooler Router
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Functions related to Ports of the Print Monitors
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
11 EnumPortsW(PWSTR pName
, DWORD Level
, PBYTE pPorts
, DWORD cbBuf
, PDWORD pcbNeeded
, PDWORD pcReturned
)
18 PSPOOLSS_PRINT_PROVIDER pPrintProvider
;
22 if ((cbBuf
&& !pPorts
) || !pcbNeeded
|| !pcReturned
)
24 SetLastError(ERROR_INVALID_PARAMETER
);
32 // At the beginning, we have the full buffer available.
36 // Loop through all Print Provider.
37 for (pEntry
= PrintProviderList
.Flink
; pEntry
!= &PrintProviderList
; pEntry
= pEntry
->Flink
)
39 pPrintProvider
= CONTAINING_RECORD(pEntry
, SPOOLSS_PRINT_PROVIDER
, Entry
);
41 // Call the EnumPorts function of this Print Provider.
42 bReturnValue
= pPrintProvider
->PrintProvider
.fpEnumPorts(pName
, Level
, pCallBuffer
, cbCallBuffer
, &cbNeeded
, &dwReturned
);
44 // Add the returned counts to the total values.
45 *pcbNeeded
+= cbNeeded
;
46 *pcReturned
+= dwReturned
;
48 // Reduce the available buffer size for the next call without risking an underflow.
49 if (cbNeeded
< cbCallBuffer
)
50 cbCallBuffer
-= cbNeeded
;
54 // Advance the buffer if the caller provided it.
56 pCallBuffer
+= cbNeeded
;
58 // Check if we shall not ask other Print Providers.
59 if (bReturnValue
== ROUTER_STOP_ROUTING
)