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
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
)
40 if (!src
) return NULL
;
41 len
= (wcslen(src
) + 1) * sizeof(WCHAR
);
42 if ((dst
= heap_alloc(len
))) memcpy(dst
, src
, len
);
46 HRESULT WINAPI
PTReleaseMemory(PVOID mem
)
52 HRESULT WINAPI
PTQuerySchemaVersionSupport(PCWSTR printer
, DWORD
*version
)
54 FIXME("stub:%s %p\n", debugstr_w(printer
), version
);
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
))
68 heap_free(prov
->name
);
69 ClosePrinter(prov
->hprn
);
75 HRESULT WINAPI
PTOpenProvider(PCWSTR printer
, DWORD version
, HPTPROVIDER
*provider
)
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
)
95 prov
= heap_alloc(sizeof(*prov
));
96 if (!prov
) return E_OUTOFMEMORY
;
98 if (!OpenPrinterW((LPWSTR
)printer
, &prov
->hprn
, NULL
))
101 return HRESULT_FROM_WIN32(GetLastError());
104 prov
->name
= heap_strdupW(printer
);
105 prov
->owner
= GetCurrentThreadId();
106 *provider
= (HPTPROVIDER
)prov
;