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 Print Monitors
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
11 EnumMonitorsW(PWSTR pName
, DWORD Level
, PBYTE pMonitors
, DWORD cbBuf
, PDWORD pcbNeeded
, PDWORD pcReturned
)
18 PSPOOLSS_PRINT_PROVIDER pPrintProvider
;
22 if ((cbBuf
&& !pMonitors
) || !pcbNeeded
|| !pcReturned
)
24 SetLastError(ERROR_INVALID_PARAMETER
);
32 // At the beginning, we have the full buffer available.
34 pCallBuffer
= pMonitors
;
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 // Check if this Print Provider provides an EnumMonitors function.
42 if (!pPrintProvider
->PrintProvider
.fpEnumMonitors
)
45 // Call the EnumMonitors function of this Print Provider.
46 bReturnValue
= pPrintProvider
->PrintProvider
.fpEnumMonitors(pName
, Level
, pCallBuffer
, cbCallBuffer
, &cbNeeded
, &dwReturned
);
48 // Add the returned counts to the total values.
49 *pcbNeeded
+= cbNeeded
;
50 *pcReturned
+= dwReturned
;
52 // Reduce the available buffer size for the next call without risking an underflow.
53 if (cbNeeded
< cbCallBuffer
)
54 cbCallBuffer
-= cbNeeded
;
58 // Advance the buffer if the caller provided it.
60 pCallBuffer
+= cbNeeded
;
62 // Check if we shall not ask other Print Providers.
63 if (bReturnValue
== ROUTER_STOP_ROUTING
)