dwrite: Use font data access helpers when reading metrics tables.
[wine.git] / dlls / prntvpt / main.c
blob197fb54022cbf4d68443d0c577ca37437c98fe02
1 /*
2 * Print Ticket Services Module
4 * Copyright 2014 Jactry Zeng for CodeWeavers
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 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "winspool.h"
27 #include "objbase.h"
28 #include "prntvpt.h"
29 #include "wine/heap.h"
30 #include "wine/debug.h"
32 #include "prntvpt_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(prntvpt);
36 static WCHAR *heap_strdupW(const WCHAR *src)
38 WCHAR *dst;
39 size_t len;
40 if (!src) return NULL;
41 len = (wcslen(src) + 1) * sizeof(WCHAR);
42 if ((dst = heap_alloc(len))) memcpy(dst, src, len);
43 return dst;
46 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
48 TRACE("(%p, %d, %p)\n", hinst, reason, reserved);
50 switch(reason)
52 case DLL_WINE_PREATTACH:
53 return FALSE; /* prefer native version */
54 case DLL_PROCESS_ATTACH:
55 DisableThreadLibraryCalls(hinst);
56 break;
58 return TRUE;
61 HRESULT WINAPI PTReleaseMemory(PVOID mem)
63 heap_free(mem);
64 return S_OK;
67 HRESULT WINAPI PTQuerySchemaVersionSupport(PCWSTR printer, DWORD *version)
69 FIXME("stub:%s %p\n", debugstr_w(printer), version);
70 return E_NOTIMPL;
73 HRESULT WINAPI PTCloseProvider(HPTPROVIDER provider)
75 struct prn_provider *prov = (struct prn_provider *)provider;
77 TRACE("%p\n", provider);
79 if (!is_valid_provider(provider))
80 return E_HANDLE;
82 prov->owner = 0;
83 heap_free(prov->name);
84 ClosePrinter(prov->hprn);
85 heap_free(prov);
87 return S_OK;
90 HRESULT WINAPI PTOpenProvider(PCWSTR printer, DWORD version, HPTPROVIDER *provider)
92 DWORD used_version;
94 TRACE("%s, %d, %p\n", debugstr_w(printer), version, provider);
96 if (version != 1) return E_INVALIDARG;
98 return PTOpenProviderEx(printer, 1, 1, provider, &used_version);
101 HRESULT WINAPI PTOpenProviderEx(const WCHAR *printer, DWORD max_version, DWORD pref_version, HPTPROVIDER *provider, DWORD *used_version)
103 struct prn_provider *prov;
105 TRACE("%s, %d, %d, %p, %p\n", debugstr_w(printer), max_version, pref_version, provider, used_version);
107 if (!max_version || !provider || !used_version)
108 return E_INVALIDARG;
110 prov = heap_alloc(sizeof(*prov));
111 if (!prov) return E_OUTOFMEMORY;
113 if (!OpenPrinterW((LPWSTR)printer, &prov->hprn, NULL))
115 heap_free(prov);
116 return HRESULT_FROM_WIN32(GetLastError());
119 prov->name = heap_strdupW(printer);
120 prov->owner = GetCurrentThreadId();
121 *provider = (HPTPROVIDER)prov;
122 *used_version = 1;
124 return S_OK;