mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / prntvpt / main.c
blobd6ad0cff46a546b83d5bc49d6363107da2f75110
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 HRESULT WINAPI PTReleaseMemory(PVOID mem)
48 heap_free(mem);
49 return S_OK;
52 HRESULT WINAPI PTQuerySchemaVersionSupport(PCWSTR printer, DWORD *version)
54 FIXME("stub:%s %p\n", debugstr_w(printer), version);
55 return E_NOTIMPL;
58 HRESULT WINAPI PTCloseProvider(HPTPROVIDER provider)
60 struct prn_provider *prov = (struct prn_provider *)provider;
62 TRACE("%p\n", provider);
64 if (!is_valid_provider(provider))
65 return E_HANDLE;
67 prov->owner = 0;
68 heap_free(prov->name);
69 ClosePrinter(prov->hprn);
70 heap_free(prov);
72 return S_OK;
75 HRESULT WINAPI PTOpenProvider(PCWSTR printer, DWORD version, HPTPROVIDER *provider)
77 DWORD used_version;
79 TRACE("%s, %d, %p\n", debugstr_w(printer), version, provider);
81 if (version != 1) return E_INVALIDARG;
83 return PTOpenProviderEx(printer, 1, 1, provider, &used_version);
86 HRESULT WINAPI PTOpenProviderEx(const WCHAR *printer, DWORD max_version, DWORD pref_version, HPTPROVIDER *provider, DWORD *used_version)
88 struct prn_provider *prov;
90 TRACE("%s, %d, %d, %p, %p\n", debugstr_w(printer), max_version, pref_version, provider, used_version);
92 if (!max_version || !provider || !used_version)
93 return E_INVALIDARG;
95 prov = heap_alloc(sizeof(*prov));
96 if (!prov) return E_OUTOFMEMORY;
98 if (!OpenPrinterW((LPWSTR)printer, &prov->hprn, NULL))
100 heap_free(prov);
101 return HRESULT_FROM_WIN32(GetLastError());
104 prov->name = heap_strdupW(printer);
105 prov->owner = GetCurrentThreadId();
106 *provider = (HPTPROVIDER)prov;
107 *used_version = 1;
109 return S_OK;