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 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
48 TRACE("(%p, %d, %p)\n", hinst
, reason
, reserved
);
52 case DLL_WINE_PREATTACH
:
53 return FALSE
; /* prefer native version */
54 case DLL_PROCESS_ATTACH
:
55 DisableThreadLibraryCalls(hinst
);
61 HRESULT WINAPI
PTReleaseMemory(PVOID mem
)
67 HRESULT WINAPI
PTQuerySchemaVersionSupport(PCWSTR printer
, DWORD
*version
)
69 FIXME("stub:%s %p\n", debugstr_w(printer
), version
);
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
))
83 heap_free(prov
->name
);
84 ClosePrinter(prov
->hprn
);
90 HRESULT WINAPI
PTOpenProvider(PCWSTR printer
, DWORD version
, HPTPROVIDER
*provider
)
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
)
110 prov
= heap_alloc(sizeof(*prov
));
111 if (!prov
) return E_OUTOFMEMORY
;
113 if (!OpenPrinterW((LPWSTR
)printer
, &prov
->hprn
, NULL
))
116 return HRESULT_FROM_WIN32(GetLastError());
119 prov
->name
= heap_strdupW(printer
);
120 prov
->owner
= GetCurrentThreadId();
121 *provider
= (HPTPROVIDER
)prov
;