ntdll: Use cpu_info to check for AVX availability.
[wine/zf.git] / dlls / ntprint / ntprint.c
blob6a4cb57c7f6be2266181c05b1ce914decf21e62c
1 /*
2 * Implementation of the Spooler Setup API (Printing)
4 * Copyright 2007 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "wingdi.h"
29 #include "winnls.h"
30 #include "winver.h"
31 #include "winspool.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(ntprint);
37 typedef struct {
38 LPMONITOR_INFO_2W mi2; /* Buffer for installed Monitors */
39 DWORD installed; /* Number of installed Monitors */
40 } monitorinfo_t;
42 /*****************************************************
43 * PSetupCreateMonitorInfo [NTPRINT.@]
48 HANDLE WINAPI PSetupCreateMonitorInfo(DWORD unknown1, WCHAR *server)
50 monitorinfo_t * mi=NULL;
51 DWORD needed;
52 DWORD res;
54 TRACE("(%d, %s)\n", unknown1, debugstr_w(server));
56 mi = HeapAlloc(GetProcessHeap(), 0, sizeof(monitorinfo_t));
57 if (!mi) {
58 /* FIXME: SetLastError() needed? */
59 return NULL;
62 /* Get the needed size for all Monitors */
63 res = EnumMonitorsW(server, 2, NULL, 0, &needed, &mi->installed);
64 if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
65 mi->mi2 = HeapAlloc(GetProcessHeap(), 0, needed);
66 res = EnumMonitorsW(server, 2, (LPBYTE) mi->mi2, needed, &needed, &mi->installed);
69 if (!res) {
70 HeapFree(GetProcessHeap(), 0, mi);
71 return NULL;
74 TRACE("=> %p (%u monitors installed)\n", mi, mi->installed);
75 return mi;
78 /*****************************************************
79 * PSetupDestroyMonitorInfo [NTPRINT.@]
83 VOID WINAPI PSetupDestroyMonitorInfo(HANDLE monitorinfo)
85 monitorinfo_t * mi = monitorinfo;
87 TRACE("(%p)\n", mi);
88 if (mi) {
89 if (mi->installed) HeapFree(GetProcessHeap(), 0, mi->mi2);
90 HeapFree(GetProcessHeap(), 0, mi);
94 /*****************************************************
95 * PSetupEnumMonitor [NTPRINT.@]
97 * Copy the selected Monitorname to a buffer
99 * PARAMS
100 * monitorinfo [I] HANDLE from PSetupCreateMonitorInfo
101 * index [I] Nr. of the Monitorname to copy
102 * buffer [I] Target, that receive the Monitorname
103 * psize [IO] PTR to a DWORD that hold the size of the buffer and receive
104 * the needed size, when the buffer is too small
106 * RETURNS
107 * Success: TRUE
108 * Failure: FALSE
110 * NOTES
111 * size is in Bytes on w2k and WCHAR on XP
115 BOOL WINAPI PSetupEnumMonitor(HANDLE monitorinfo, DWORD index, LPWSTR buffer, LPDWORD psize)
117 monitorinfo_t * mi = monitorinfo;
118 LPWSTR nameW;
119 DWORD len;
121 TRACE("(%p, %u, %p, %p) => %d\n", mi, index, buffer, psize, psize ? *psize : 0);
123 if (index < mi->installed) {
124 nameW = mi->mi2[index].pName;
125 len = lstrlenW(nameW) + 1;
126 if (len <= *psize) {
127 memcpy(buffer, nameW, len * sizeof(WCHAR));
128 TRACE("#%u: %s\n", index, debugstr_w(buffer));
129 return TRUE;
131 *psize = len;
132 SetLastError(ERROR_INSUFFICIENT_BUFFER);
133 return FALSE;
135 SetLastError(ERROR_NO_MORE_ITEMS);
136 return FALSE;