2002-06-01 01:06:46 +02:00
|
|
|
/*
|
1999-05-17 18:20:51 +02:00
|
|
|
* WINSPOOL functions
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
* Copyright 1996 John Harvey
|
|
|
|
* Copyright 1998 Andreas Mohr
|
2000-05-26 01:02:46 +02:00
|
|
|
* Copyright 1999 Klaas van Gend
|
|
|
|
* Copyright 1999, 2000 Huw D M Davies
|
2001-04-27 20:02:46 +02:00
|
|
|
* Copyright 2001 Marcus Meissner
|
2010-08-12 14:37:36 +02:00
|
|
|
* Copyright 2005-2010 Detlef Riekenberg
|
2010-09-20 16:26:49 +02:00
|
|
|
* Copyright 2010 Vitaly Perov
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
|
2001-04-27 20:02:46 +02:00
|
|
|
#include "config.h"
|
2002-11-12 03:22:24 +01:00
|
|
|
#include "wine/port.h"
|
2001-04-27 20:02:46 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-11-29 19:38:24 +01:00
|
|
|
#include <stdio.h>
|
1999-05-17 18:20:51 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2000-05-26 01:02:46 +02:00
|
|
|
#include <stddef.h>
|
2011-12-02 15:29:23 +01:00
|
|
|
#include <errno.h>
|
2011-11-30 23:49:14 +01:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
2005-07-22 11:04:08 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2005-07-20 19:48:53 +02:00
|
|
|
#include <signal.h>
|
2002-11-12 03:22:24 +01:00
|
|
|
#ifdef HAVE_CUPS_CUPS_H
|
2001-04-27 20:02:46 +02:00
|
|
|
# include <cups/cups.h>
|
|
|
|
#endif
|
2003-01-07 21:36:20 +01:00
|
|
|
|
2012-06-21 13:59:03 +02:00
|
|
|
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
|
|
|
#define GetCurrentProcess GetCurrentProcess_Mac
|
|
|
|
#define GetCurrentThread GetCurrentThread_Mac
|
|
|
|
#define LoadResource LoadResource_Mac
|
|
|
|
#define AnimatePalette AnimatePalette_Mac
|
|
|
|
#define EqualRgn EqualRgn_Mac
|
|
|
|
#define FillRgn FillRgn_Mac
|
|
|
|
#define FrameRgn FrameRgn_Mac
|
|
|
|
#define GetPixel GetPixel_Mac
|
|
|
|
#define InvertRgn InvertRgn_Mac
|
|
|
|
#define LineTo LineTo_Mac
|
|
|
|
#define OffsetRgn OffsetRgn_Mac
|
|
|
|
#define PaintRgn PaintRgn_Mac
|
|
|
|
#define Polygon Polygon_Mac
|
|
|
|
#define ResizePalette ResizePalette_Mac
|
|
|
|
#define SetRectRgn SetRectRgn_Mac
|
|
|
|
#define EqualRect EqualRect_Mac
|
|
|
|
#define FillRect FillRect_Mac
|
|
|
|
#define FrameRect FrameRect_Mac
|
|
|
|
#define GetCursor GetCursor_Mac
|
|
|
|
#define InvertRect InvertRect_Mac
|
|
|
|
#define OffsetRect OffsetRect_Mac
|
|
|
|
#define PtInRect PtInRect_Mac
|
|
|
|
#define SetCursor SetCursor_Mac
|
|
|
|
#define SetRect SetRect_Mac
|
|
|
|
#define ShowCursor ShowCursor_Mac
|
|
|
|
#define UnionRect UnionRect_Mac
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
#undef GetCurrentProcess
|
|
|
|
#undef GetCurrentThread
|
|
|
|
#undef LoadResource
|
|
|
|
#undef AnimatePalette
|
|
|
|
#undef EqualRgn
|
|
|
|
#undef FillRgn
|
|
|
|
#undef FrameRgn
|
|
|
|
#undef GetPixel
|
|
|
|
#undef InvertRgn
|
|
|
|
#undef LineTo
|
|
|
|
#undef OffsetRgn
|
|
|
|
#undef PaintRgn
|
|
|
|
#undef Polygon
|
|
|
|
#undef ResizePalette
|
|
|
|
#undef SetRectRgn
|
|
|
|
#undef EqualRect
|
|
|
|
#undef FillRect
|
|
|
|
#undef FrameRect
|
|
|
|
#undef GetCursor
|
|
|
|
#undef InvertRect
|
|
|
|
#undef OffsetRect
|
|
|
|
#undef PtInRect
|
|
|
|
#undef SetCursor
|
|
|
|
#undef SetRect
|
|
|
|
#undef ShowCursor
|
|
|
|
#undef UnionRect
|
|
|
|
#undef DPRINTF
|
|
|
|
#endif
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#include "wine/library.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-05-17 18:20:51 +02:00
|
|
|
#include "winbase.h"
|
2003-05-20 01:19:21 +02:00
|
|
|
#include "winuser.h"
|
1999-05-17 18:20:51 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
2003-01-08 00:09:22 +01:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winspool.h"
|
2003-01-03 04:04:46 +01:00
|
|
|
#include "winternl.h"
|
2000-09-27 00:20:14 +02:00
|
|
|
#include "wine/windef16.h"
|
2000-08-14 16:41:19 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2005-07-06 17:44:15 +02:00
|
|
|
#include "wine/list.h"
|
2000-05-26 01:02:46 +02:00
|
|
|
#include "winnls.h"
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-09-02 22:50:32 +02:00
|
|
|
#include "ddk/winsplp.h"
|
2005-07-12 19:01:44 +02:00
|
|
|
#include "wspool.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winspool);
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-09-02 22:55:25 +02:00
|
|
|
/* ############################### */
|
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
static CRITICAL_SECTION printer_handles_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG printer_handles_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &printer_handles_cs,
|
|
|
|
{ &printer_handles_cs_debug.ProcessLocksList, &printer_handles_cs_debug.ProcessLocksList },
|
2005-09-09 12:19:44 +02:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": printer_handles_cs") }
|
2005-07-05 13:00:09 +02:00
|
|
|
};
|
|
|
|
static CRITICAL_SECTION printer_handles_cs = { &printer_handles_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
2006-09-02 22:50:32 +02:00
|
|
|
/* ############################### */
|
|
|
|
|
2005-07-08 16:19:18 +02:00
|
|
|
typedef struct {
|
|
|
|
DWORD job_id;
|
|
|
|
HANDLE hf;
|
|
|
|
} started_doc_t;
|
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
typedef struct {
|
2005-07-06 17:44:15 +02:00
|
|
|
struct list jobs;
|
2005-07-19 21:12:13 +02:00
|
|
|
LONG ref;
|
2005-10-24 17:03:02 +02:00
|
|
|
} jobqueue_t;
|
2005-07-19 21:12:13 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
LPWSTR name;
|
2007-01-05 01:09:02 +01:00
|
|
|
LPWSTR printername;
|
2009-05-05 05:24:34 +02:00
|
|
|
HANDLE backend_printer;
|
2005-10-24 17:03:02 +02:00
|
|
|
jobqueue_t *queue;
|
2005-07-08 16:19:18 +02:00
|
|
|
started_doc_t *doc;
|
2012-03-30 15:39:42 +02:00
|
|
|
DEVMODEW *devmode;
|
2005-07-05 13:00:09 +02:00
|
|
|
} opened_printer_t;
|
|
|
|
|
2005-07-06 17:44:15 +02:00
|
|
|
typedef struct {
|
|
|
|
struct list entry;
|
|
|
|
DWORD job_id;
|
|
|
|
WCHAR *filename;
|
2010-08-12 14:37:36 +02:00
|
|
|
WCHAR *portname;
|
2005-07-13 16:14:37 +02:00
|
|
|
WCHAR *document_title;
|
2010-09-13 17:28:56 +02:00
|
|
|
WCHAR *printer_name;
|
2010-09-20 16:26:49 +02:00
|
|
|
LPDEVMODEW devmode;
|
2005-07-06 17:44:15 +02:00
|
|
|
} job_t;
|
|
|
|
|
2006-01-18 12:26:32 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
LPCWSTR envname;
|
|
|
|
LPCWSTR subdir;
|
2006-05-11 23:59:17 +02:00
|
|
|
DWORD driverversion;
|
|
|
|
LPCWSTR versionregpath;
|
|
|
|
LPCWSTR versionsubdir;
|
2006-01-18 12:26:32 +01:00
|
|
|
} printenv_t;
|
|
|
|
|
|
|
|
/* ############################### */
|
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
static opened_printer_t **printer_handles;
|
2007-11-04 17:57:54 +01:00
|
|
|
static UINT nb_printer_handles;
|
2005-09-29 15:34:34 +02:00
|
|
|
static LONG next_job_id = 1;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2002-02-02 19:42:11 +01:00
|
|
|
static DWORD (WINAPI *GDI_CallDeviceCapabilities16)( LPCSTR lpszDevice, LPCSTR lpszPort,
|
2000-11-29 19:38:24 +01:00
|
|
|
WORD fwCapability, LPSTR lpszOutput,
|
|
|
|
LPDEVMODEA lpdm );
|
2002-02-02 19:42:11 +01:00
|
|
|
static INT (WINAPI *GDI_CallExtDeviceMode16)( HWND hwnd, LPDEVMODEA lpdmOutput,
|
2000-11-29 19:38:24 +01:00
|
|
|
LPSTR lpszDevice, LPSTR lpszPort,
|
|
|
|
LPDEVMODEA lpdmInput, LPSTR lpszProfile,
|
|
|
|
DWORD fwMode );
|
|
|
|
|
2005-03-29 15:10:35 +02:00
|
|
|
static const WCHAR DriversW[] = { 'S','y','s','t','e','m','\\',
|
|
|
|
'C','u', 'r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'c','o','n','t','r','o','l','\\',
|
|
|
|
'P','r','i','n','t','\\',
|
|
|
|
'E','n','v','i','r','o','n','m','e','n','t','s','\\',
|
2006-05-11 23:59:17 +02:00
|
|
|
'%','s','\\','D','r','i','v','e','r','s','%','s',0 };
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-05-12 16:14:59 +02:00
|
|
|
static const WCHAR PrintersW[] = {'S','y','s','t','e','m','\\',
|
|
|
|
'C','u', 'r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'C','o','n','t','r','o','l','\\',
|
|
|
|
'P','r','i','n','t','\\',
|
|
|
|
'P','r','i','n','t','e','r','s',0};
|
|
|
|
|
2005-03-31 12:06:46 +02:00
|
|
|
static const WCHAR user_default_reg_key[] = { 'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'W','i','n','d','o','w','s',0};
|
|
|
|
|
|
|
|
static const WCHAR user_printers_reg_key[] = { 'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'D','e','v','i','c','e','s',0};
|
|
|
|
|
2008-05-06 20:26:05 +02:00
|
|
|
static const WCHAR WinNT_CV_PrinterPortsW[] = { 'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'P','r','i','n','t','e','r','P','o','r','t','s',0};
|
|
|
|
|
2010-10-18 17:49:18 +02:00
|
|
|
static WCHAR envname_win40W[] = {'W','i','n','d','o','w','s',' ','4','.','0',0};
|
2009-02-04 23:25:36 +01:00
|
|
|
static const WCHAR envname_x64W[] = {'W','i','n','d','o','w','s',' ','x','6','4',0};
|
2010-10-18 17:49:18 +02:00
|
|
|
static WCHAR envname_x86W[] = {'W','i','n','d','o','w','s',' ','N','T',' ','x','8','6',0};
|
2006-01-18 12:26:32 +01:00
|
|
|
static const WCHAR subdir_win40W[] = {'w','i','n','4','0',0};
|
2009-02-04 23:25:36 +01:00
|
|
|
static const WCHAR subdir_x64W[] = {'x','6','4',0};
|
2006-01-18 12:26:32 +01:00
|
|
|
static const WCHAR subdir_x86W[] = {'w','3','2','x','8','6',0};
|
2007-07-26 22:54:14 +02:00
|
|
|
static const WCHAR Version0_RegPathW[] = {'\\','V','e','r','s','i','o','n','-','0',0};
|
|
|
|
static const WCHAR Version0_SubdirW[] = {'\\','0',0};
|
2006-05-11 23:59:17 +02:00
|
|
|
static const WCHAR Version3_RegPathW[] = {'\\','V','e','r','s','i','o','n','-','3',0};
|
|
|
|
static const WCHAR Version3_SubdirW[] = {'\\','3',0};
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2012-05-22 17:36:25 +02:00
|
|
|
static const WCHAR AttributesW[] = {'A','t','t','r','i','b','u','t','e','s',0};
|
2007-07-26 23:05:27 +02:00
|
|
|
static const WCHAR backslashW[] = {'\\',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR Configuration_FileW[] = {'C','o','n','f','i','g','u','r','a','t',
|
2000-05-26 01:02:46 +02:00
|
|
|
'i','o','n',' ','F','i','l','e',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR DatatypeW[] = {'D','a','t','a','t','y','p','e',0};
|
|
|
|
static const WCHAR Data_FileW[] = {'D','a','t','a',' ','F','i','l','e',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR Default_DevModeW[] = {'D','e','f','a','u','l','t',' ','D','e','v','M','o','d','e',0};
|
2012-05-22 17:36:25 +02:00
|
|
|
static const WCHAR Default_PriorityW[] = {'D','e','f','a','u','l','t',' ','P','r','i','o','r','i','t','y',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR Dependent_FilesW[] = {'D','e','p','e','n','d','e','n','t',' ','F','i','l','e','s',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR DescriptionW[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
|
2012-05-31 14:57:39 +02:00
|
|
|
static const WCHAR dnsTimeoutW[] = {'d','n','s','T','i','m','e','o','u','t',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR DriverW[] = {'D','r','i','v','e','r',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR HardwareIDW[] = {'H','a','r','d','w','a','r','e','I','D',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR Help_FileW[] = {'H','e','l','p',' ','F','i','l','e',0};
|
|
|
|
static const WCHAR LocationW[] = {'L','o','c','a','t','i','o','n',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR ManufacturerW[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR MonitorW[] = {'M','o','n','i','t','o','r',0};
|
|
|
|
static const WCHAR NameW[] = {'N','a','m','e',0};
|
2008-02-26 23:09:55 +01:00
|
|
|
static const WCHAR ObjectGUIDW[] = {'O','b','j','e','c','t','G','U','I','D',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR OEM_UrlW[] = {'O','E','M',' ','U','r','l',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR ParametersW[] = {'P','a','r','a','m','e','t','e','r','s',0};
|
|
|
|
static const WCHAR PortW[] = {'P','o','r','t',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR Previous_NamesW[] = {'P','r','e','v','i','o','u','s',' ','N','a','m','e','s',0};
|
|
|
|
static const WCHAR Print_ProcessorW[] = {'P','r','i','n','t',' ','P','r','o','c','e','s','s','o','r',0};
|
|
|
|
static const WCHAR Printer_DriverW[] = {'P','r','i','n','t','e','r',' ','D','r','i','v','e','r',0};
|
|
|
|
static const WCHAR PrinterDriverDataW[] = {'P','r','i','n','t','e','r','D','r','i','v','e','r','D','a','t','a',0};
|
2008-05-06 20:26:05 +02:00
|
|
|
static const WCHAR PrinterPortsW[] = {'P','r','i','n','t','e','r','P','o','r','t','s',0};
|
2012-05-22 17:36:25 +02:00
|
|
|
static const WCHAR PriorityW[] = {'P','r','i','o','r','i','t','y',0};
|
2007-07-26 23:37:22 +02:00
|
|
|
static const WCHAR ProviderW[] = {'P','r','o','v','i','d','e','r',0};
|
|
|
|
static const WCHAR Separator_FileW[] = {'S','e','p','a','r','a','t','o','r',' ','F','i','l','e',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR Share_NameW[] = {'S','h','a','r','e',' ','N','a','m','e',0};
|
2012-05-22 17:36:25 +02:00
|
|
|
static const WCHAR StartTimeW[] = {'S','t','a','r','t','T','i','m','e',0};
|
|
|
|
static const WCHAR StatusW[] = {'S','t','a','t','u','s',0};
|
2012-05-31 14:57:39 +02:00
|
|
|
static const WCHAR txTimeoutW[] = {'t','x','T','i','m','e','o','u','t',0};
|
2012-05-22 17:36:25 +02:00
|
|
|
static const WCHAR UntilTimeW[] = {'U','n','t','i','l','T','i','m','e',0};
|
2010-10-18 17:49:19 +02:00
|
|
|
static WCHAR WinPrintW[] = {'W','i','n','P','r','i','n','t',0};
|
2004-03-07 04:46:54 +01:00
|
|
|
static const WCHAR deviceW[] = {'d','e','v','i','c','e',0};
|
2003-11-11 21:38:51 +01:00
|
|
|
static const WCHAR devicesW[] = {'d','e','v','i','c','e','s',0};
|
2004-03-07 04:46:54 +01:00
|
|
|
static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
|
2010-10-18 17:49:18 +02:00
|
|
|
static WCHAR rawW[] = {'R','A','W',0};
|
|
|
|
static WCHAR driver_9x[] = {'w','i','n','e','p','s','1','6','.','d','r','v',0};
|
|
|
|
static WCHAR driver_nt[] = {'w','i','n','e','p','s','.','d','r','v',0};
|
2010-10-18 17:49:17 +02:00
|
|
|
static const WCHAR timeout_15_45[] = {',','1','5',',','4','5',0};
|
|
|
|
static const WCHAR commaW[] = {',',0};
|
2010-10-18 17:49:19 +02:00
|
|
|
static WCHAR emptyStringW[] = {0};
|
2003-11-05 01:36:47 +01:00
|
|
|
|
|
|
|
static const WCHAR May_Delete_Value[] = {'W','i','n','e','M','a','y','D','e','l','e','t','e','M','e',0};
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2005-07-10 19:39:01 +02:00
|
|
|
static const WCHAR CUPS_Port[] = {'C','U','P','S',':',0};
|
|
|
|
static const WCHAR FILE_Port[] = {'F','I','L','E',':',0};
|
|
|
|
static const WCHAR LPR_Port[] = {'L','P','R',':',0};
|
|
|
|
|
2005-07-15 11:55:23 +02:00
|
|
|
static const WCHAR default_doc_title[] = {'L','o','c','a','l',' ','D','o','w','n','l','e','v','e','l',' ',
|
|
|
|
'D','o','c','u','m','e','n','t',0};
|
|
|
|
|
2012-06-21 13:59:03 +02:00
|
|
|
static const WCHAR PPD_Overrides[] = {'P','P','D',' ','O','v','e','r','r','i','d','e','s',0};
|
|
|
|
static const WCHAR DefaultPageSize[] = {'D','e','f','a','u','l','t','P','a','g','e','S','i','z','e',0};
|
|
|
|
|
2007-07-26 23:14:55 +02:00
|
|
|
static const DWORD di_sizeof[] = {0, sizeof(DRIVER_INFO_1W), sizeof(DRIVER_INFO_2W),
|
|
|
|
sizeof(DRIVER_INFO_3W), sizeof(DRIVER_INFO_4W),
|
|
|
|
sizeof(DRIVER_INFO_5W), sizeof(DRIVER_INFO_6W),
|
|
|
|
0, sizeof(DRIVER_INFO_8W)};
|
2007-01-17 17:18:54 +01:00
|
|
|
|
2008-03-22 19:28:50 +01:00
|
|
|
|
|
|
|
static const DWORD pi_sizeof[] = {0, sizeof(PRINTER_INFO_1W), sizeof(PRINTER_INFO_2W),
|
|
|
|
sizeof(PRINTER_INFO_3), sizeof(PRINTER_INFO_4W),
|
|
|
|
sizeof(PRINTER_INFO_5W), sizeof(PRINTER_INFO_6),
|
|
|
|
sizeof(PRINTER_INFO_7W), sizeof(PRINTER_INFO_8W),
|
|
|
|
sizeof(PRINTER_INFO_9W)};
|
|
|
|
|
2009-03-24 10:27:01 +01:00
|
|
|
static const printenv_t env_x64 = {envname_x64W, subdir_x64W, 3, Version3_RegPathW, Version3_SubdirW};
|
|
|
|
static const printenv_t env_x86 = {envname_x86W, subdir_x86W, 3, Version3_RegPathW, Version3_SubdirW};
|
|
|
|
static const printenv_t env_win40 = {envname_win40W, subdir_win40W, 0, Version0_RegPathW, Version0_SubdirW};
|
|
|
|
|
|
|
|
static const printenv_t * const all_printenv[] = {&env_x86, &env_x64, &env_win40};
|
|
|
|
|
2006-01-18 12:26:32 +01:00
|
|
|
/******************************************************************
|
|
|
|
* validate the user-supplied printing-environment [internal]
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* env [I] PTR to Environment-String or NULL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Failure: NULL
|
|
|
|
* Success: PTR to printenv_t
|
|
|
|
*
|
|
|
|
* NOTES
|
2006-02-01 12:32:10 +01:00
|
|
|
* An empty string is handled the same way as NULL.
|
2015-12-02 01:42:31 +01:00
|
|
|
* SetLastError(ERROR_INVALID_ENVIRONMENT) is called on Failure
|
2006-01-18 12:26:32 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const printenv_t * validate_envW(LPCWSTR env)
|
|
|
|
{
|
|
|
|
const printenv_t *result = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("testing %s\n", debugstr_w(env));
|
2006-02-01 12:32:10 +01:00
|
|
|
if (env && env[0])
|
2006-01-18 12:26:32 +01:00
|
|
|
{
|
|
|
|
for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++)
|
|
|
|
{
|
|
|
|
if (lstrcmpiW(env, all_printenv[i]->envname) == 0)
|
|
|
|
{
|
|
|
|
result = all_printenv[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == NULL) {
|
|
|
|
FIXME("unsupported Environment: %s\n", debugstr_w(env));
|
|
|
|
SetLastError(ERROR_INVALID_ENVIRONMENT);
|
|
|
|
}
|
|
|
|
/* on win9x, only "Windows 4.0" is allowed, but we ignore this */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = (GetVersion() & 0x80000000) ? &env_win40 : &env_x86;
|
|
|
|
}
|
|
|
|
TRACE("using %p: %s\n", result, debugstr_w(result ? result->envname : NULL));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
/* RtlCreateUnicodeStringFromAsciiz will return an empty string in the buffer
|
|
|
|
if passed a NULL string. This returns NULLs to the result.
|
|
|
|
*/
|
|
|
|
static inline PWSTR asciitounicode( UNICODE_STRING * usBufferPtr, LPCSTR src )
|
|
|
|
{
|
|
|
|
if ( (src) )
|
|
|
|
{
|
|
|
|
RtlCreateUnicodeStringFromAsciiz(usBufferPtr, src);
|
|
|
|
return usBufferPtr->Buffer;
|
|
|
|
}
|
|
|
|
usBufferPtr->Buffer = NULL; /* so that RtlFreeUnicodeString won't barf */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-07-15 11:55:23 +02:00
|
|
|
static LPWSTR strdupW(LPCWSTR p)
|
2005-07-13 16:14:37 +02:00
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if(!p) return NULL;
|
|
|
|
len = (strlenW(p) + 1) * sizeof(WCHAR);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
memcpy(ret, p, len);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-11-17 15:29:40 +01:00
|
|
|
static LPSTR strdupWtoA( LPCWSTR str )
|
|
|
|
{
|
|
|
|
LPSTR ret;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
if (!str) return NULL;
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-03-30 15:39:40 +02:00
|
|
|
static DEVMODEW *dup_devmode( const DEVMODEW *dm )
|
|
|
|
{
|
|
|
|
DEVMODEW *ret;
|
|
|
|
|
|
|
|
if (!dm) return NULL;
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, dm->dmSize + dm->dmDriverExtra );
|
|
|
|
if (ret) memcpy( ret, dm, dm->dmSize + dm->dmDriverExtra );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-05 14:25:50 +02:00
|
|
|
/***********************************************************
|
|
|
|
* DEVMODEdupWtoA
|
|
|
|
* Creates an ansi copy of supplied devmode
|
|
|
|
*/
|
|
|
|
static DEVMODEA *DEVMODEdupWtoA( const DEVMODEW *dmW )
|
|
|
|
{
|
|
|
|
LPDEVMODEA dmA;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (!dmW) return NULL;
|
|
|
|
size = dmW->dmSize - CCHDEVICENAME -
|
|
|
|
((dmW->dmSize > FIELD_OFFSET( DEVMODEW, dmFormName )) ? CCHFORMNAME : 0);
|
|
|
|
|
|
|
|
dmA = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size + dmW->dmDriverExtra );
|
|
|
|
if (!dmA) return NULL;
|
|
|
|
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, dmW->dmDeviceName, -1,
|
|
|
|
(LPSTR)dmA->dmDeviceName, CCHDEVICENAME, NULL, NULL );
|
|
|
|
|
|
|
|
if (FIELD_OFFSET( DEVMODEW, dmFormName ) >= dmW->dmSize)
|
|
|
|
{
|
|
|
|
memcpy( &dmA->dmSpecVersion, &dmW->dmSpecVersion,
|
|
|
|
dmW->dmSize - FIELD_OFFSET( DEVMODEW, dmSpecVersion ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy( &dmA->dmSpecVersion, &dmW->dmSpecVersion,
|
|
|
|
FIELD_OFFSET( DEVMODEW, dmFormName ) - FIELD_OFFSET( DEVMODEW, dmSpecVersion ) );
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, dmW->dmFormName, -1,
|
|
|
|
(LPSTR)dmA->dmFormName, CCHFORMNAME, NULL, NULL );
|
|
|
|
|
|
|
|
memcpy( &dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize - FIELD_OFFSET( DEVMODEW, dmLogPixels ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
dmA->dmSize = size;
|
|
|
|
memcpy( (char *)dmA + dmA->dmSize, (const char *)dmW + dmW->dmSize, dmW->dmDriverExtra );
|
|
|
|
return dmA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-12 14:37:36 +02:00
|
|
|
/******************************************************************
|
|
|
|
* verify, that the filename is a local file
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static inline BOOL is_local_file(LPWSTR name)
|
|
|
|
{
|
|
|
|
return (name[0] && (name[1] == ':') && (name[2] == '\\'));
|
|
|
|
}
|
|
|
|
|
2007-08-15 23:30:59 +02:00
|
|
|
/* ################################ */
|
|
|
|
|
2006-11-07 18:16:29 +01:00
|
|
|
static int multi_sz_lenA(const char *str)
|
|
|
|
{
|
|
|
|
const char *ptr = str;
|
|
|
|
if(!str) return 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ptr += lstrlenA(ptr) + 1;
|
|
|
|
} while(*ptr);
|
|
|
|
|
|
|
|
return ptr - str + 1;
|
|
|
|
}
|
|
|
|
|
2012-06-12 10:42:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* get_dword_from_reg
|
|
|
|
*
|
|
|
|
* Return DWORD associated with name from hkey.
|
|
|
|
*/
|
|
|
|
static DWORD get_dword_from_reg( HKEY hkey, const WCHAR *name )
|
|
|
|
{
|
|
|
|
DWORD sz = sizeof(DWORD), type, value = 0;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
ret = RegQueryValueExW( hkey, name, 0, &type, (LPBYTE)&value, &sz );
|
|
|
|
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN( "Got ret = %d on name %s\n", ret, debugstr_w(name) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (type != REG_DWORD)
|
|
|
|
{
|
|
|
|
ERR( "Got type %d\n", type );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD set_reg_DWORD( HKEY hkey, const WCHAR *keyname, const DWORD value )
|
|
|
|
{
|
|
|
|
return RegSetValueExW( hkey, keyname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value) );
|
|
|
|
}
|
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
/******************************************************************
|
|
|
|
* get_opened_printer
|
|
|
|
* Get the pointer to the opened printer referred by the handle
|
|
|
|
*/
|
|
|
|
static opened_printer_t *get_opened_printer(HANDLE hprn)
|
|
|
|
{
|
|
|
|
UINT_PTR idx = (UINT_PTR)hprn;
|
|
|
|
opened_printer_t *ret = NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
|
|
|
|
if ((idx > 0) && (idx <= nb_printer_handles)) {
|
|
|
|
ret = printer_handles[idx - 1];
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* get_opened_printer_name
|
|
|
|
* Get the pointer to the opened printer name referred by the handle
|
|
|
|
*/
|
|
|
|
static LPCWSTR get_opened_printer_name(HANDLE hprn)
|
|
|
|
{
|
|
|
|
opened_printer_t *printer = get_opened_printer(hprn);
|
|
|
|
if(!printer) return NULL;
|
|
|
|
return printer->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD open_printer_reg_key( const WCHAR *name, HKEY *key )
|
|
|
|
{
|
|
|
|
HKEY printers;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
*key = NULL;
|
|
|
|
err = RegCreateKeyW( HKEY_LOCAL_MACHINE, PrintersW, &printers );
|
|
|
|
if (err) return err;
|
|
|
|
|
|
|
|
err = RegOpenKeyW( printers, name, key );
|
|
|
|
if (err) err = ERROR_INVALID_PRINTER_NAME;
|
|
|
|
RegCloseKey( printers );
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* WINSPOOL_GetOpenedPrinterRegKey
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static DWORD WINSPOOL_GetOpenedPrinterRegKey(HANDLE hPrinter, HKEY *phkey)
|
|
|
|
{
|
|
|
|
LPCWSTR name = get_opened_printer_name(hPrinter);
|
|
|
|
|
|
|
|
if(!name) return ERROR_INVALID_HANDLE;
|
|
|
|
return open_printer_reg_key( name, phkey );
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2007-02-18 11:51:09 +01:00
|
|
|
WINSPOOL_SetDefaultPrinter(const char *devname, const char *name, BOOL force) {
|
2001-05-18 22:57:36 +02:00
|
|
|
char qbuf[200];
|
|
|
|
|
|
|
|
/* If forcing, or no profile string entry for device yet, set the entry
|
|
|
|
*
|
|
|
|
* The always change entry if not WINEPS yet is discussable.
|
|
|
|
*/
|
|
|
|
if (force ||
|
|
|
|
!GetProfileStringA("windows","device","*",qbuf,sizeof(qbuf)) ||
|
|
|
|
!strcmp(qbuf,"*") ||
|
2005-05-06 22:04:27 +02:00
|
|
|
!strstr(qbuf,"WINEPS.DRV")
|
2001-05-18 22:57:36 +02:00
|
|
|
) {
|
2005-05-06 22:04:27 +02:00
|
|
|
char *buf = HeapAlloc(GetProcessHeap(),0,strlen(name)+strlen(devname)+strlen(",WINEPS.DRV,LPR:")+1);
|
2005-03-31 12:06:46 +02:00
|
|
|
HKEY hkey;
|
2001-05-18 22:57:36 +02:00
|
|
|
|
2005-05-06 22:04:27 +02:00
|
|
|
sprintf(buf,"%s,WINEPS.DRV,LPR:%s",devname,name);
|
2001-05-18 22:57:36 +02:00
|
|
|
WriteProfileStringA("windows","device",buf);
|
2005-03-31 12:06:46 +02:00
|
|
|
if(RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hkey) == ERROR_SUCCESS) {
|
2005-08-03 13:03:44 +02:00
|
|
|
RegSetValueExA(hkey, "Device", 0, REG_SZ, (LPBYTE)buf, strlen(buf) + 1);
|
2005-03-31 12:06:46 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2001-05-18 22:57:36 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,buf);
|
|
|
|
}
|
|
|
|
}
|
2001-04-27 20:02:46 +02:00
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
static BOOL add_printer_driver(const WCHAR *name, WCHAR *ppd)
|
2006-11-07 18:19:06 +01:00
|
|
|
{
|
2010-10-18 17:49:18 +02:00
|
|
|
DRIVER_INFO_3W di3;
|
|
|
|
|
|
|
|
ZeroMemory(&di3, sizeof(DRIVER_INFO_3W));
|
|
|
|
di3.cVersion = 3;
|
2012-06-12 10:42:49 +02:00
|
|
|
di3.pName = (WCHAR*)name;
|
2010-10-18 17:49:18 +02:00
|
|
|
di3.pEnvironment = envname_x86W;
|
|
|
|
di3.pDriverPath = driver_nt;
|
2012-06-12 10:42:47 +02:00
|
|
|
di3.pDataFile = ppd;
|
2010-10-18 17:49:18 +02:00
|
|
|
di3.pConfigFile = driver_nt;
|
|
|
|
di3.pDefaultDataType = rawW;
|
|
|
|
|
2012-06-12 10:42:47 +02:00
|
|
|
if (AddPrinterDriverExW( NULL, 3, (LPBYTE)&di3, APD_COPY_NEW_FILES | APD_COPY_FROM_DIRECTORY ) ||
|
2007-11-05 22:48:07 +01:00
|
|
|
(GetLastError() == ERROR_PRINTER_DRIVER_ALREADY_INSTALLED ))
|
2006-11-07 18:19:06 +01:00
|
|
|
{
|
2010-10-18 17:49:18 +02:00
|
|
|
di3.cVersion = 0;
|
|
|
|
di3.pEnvironment = envname_win40W;
|
|
|
|
di3.pDriverPath = driver_9x;
|
|
|
|
di3.pConfigFile = driver_9x;
|
2012-06-12 10:42:47 +02:00
|
|
|
if (AddPrinterDriverExW( NULL, 3, (LPBYTE)&di3, APD_COPY_NEW_FILES | APD_COPY_FROM_DIRECTORY ) ||
|
2007-11-05 22:48:07 +01:00
|
|
|
(GetLastError() == ERROR_PRINTER_DRIVER_ALREADY_INSTALLED ))
|
2007-08-22 20:24:35 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-11-07 18:19:06 +01:00
|
|
|
}
|
2010-10-18 17:49:18 +02:00
|
|
|
ERR("failed with %u for %s (%s)\n", GetLastError(), debugstr_w(di3.pDriverPath), debugstr_w(di3.pEnvironment));
|
2007-08-22 20:24:35 +02:00
|
|
|
return FALSE;
|
2006-11-07 18:19:06 +01:00
|
|
|
}
|
|
|
|
|
2012-06-12 10:42:47 +02:00
|
|
|
static inline char *expand_env_string( char *str, DWORD type )
|
|
|
|
{
|
|
|
|
if (type == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
DWORD needed = ExpandEnvironmentStringsA( str, NULL, 0 );
|
|
|
|
tmp = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsA( str, tmp, needed );
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *get_fallback_ppd_name( const char *printer_name )
|
|
|
|
{
|
|
|
|
static const WCHAR ppds_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
|
|
|
|
'P','r','i','n','t','i','n','g','\\','P','P','D',' ','F','i','l','e','s',0};
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD needed, type;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
if (RegOpenKeyW( HKEY_CURRENT_USER, ppds_key, &hkey ) == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
const char *value_name = NULL;
|
|
|
|
|
|
|
|
if (RegQueryValueExA( hkey, printer_name, 0, NULL, NULL, &needed ) == ERROR_SUCCESS)
|
|
|
|
value_name = printer_name;
|
|
|
|
else if (RegQueryValueExA( hkey, "generic", 0, NULL, NULL, &needed ) == ERROR_SUCCESS)
|
|
|
|
value_name = "generic";
|
|
|
|
|
|
|
|
if (value_name)
|
|
|
|
{
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
if (!ret) return NULL;
|
|
|
|
RegQueryValueExA( hkey, value_name, 0, &type, (BYTE *)ret, &needed );
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
if (ret) return expand_env_string( ret, type );
|
|
|
|
}
|
2013-10-05 12:54:38 +02:00
|
|
|
return NULL;
|
2012-06-12 10:42:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL copy_file( const char *src, const char *dst )
|
|
|
|
{
|
|
|
|
int fds[2] = {-1, -1}, num;
|
|
|
|
char buf[1024];
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
fds[0] = open( src, O_RDONLY );
|
|
|
|
fds[1] = open( dst, O_CREAT | O_TRUNC | O_WRONLY, 0666 );
|
|
|
|
if (fds[0] == -1 || fds[1] == -1) goto fail;
|
|
|
|
|
|
|
|
while ((num = read( fds[0], buf, sizeof(buf) )) != 0)
|
|
|
|
{
|
|
|
|
if (num == -1) goto fail;
|
|
|
|
if (write( fds[1], buf, num ) != num) goto fail;
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (fds[1] != -1) close( fds[1] );
|
|
|
|
if (fds[0] != -1) close( fds[0] );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-05 12:54:38 +02:00
|
|
|
static BOOL get_internal_fallback_ppd( const WCHAR *ppd )
|
|
|
|
{
|
|
|
|
static const WCHAR typeW[] = {'P','P','D','F','I','L','E',0};
|
|
|
|
|
|
|
|
char *ptr, *end;
|
|
|
|
DWORD size, written;
|
|
|
|
HANDLE file;
|
|
|
|
BOOL ret;
|
|
|
|
HRSRC res = FindResourceW( WINSPOOL_hInstance, MAKEINTRESOURCEW(1), typeW );
|
|
|
|
|
|
|
|
if (!res || !(ptr = LoadResource( WINSPOOL_hInstance, res ))) return FALSE;
|
|
|
|
size = SizeofResource( WINSPOOL_hInstance, res );
|
|
|
|
end = memchr( ptr, 0, size ); /* resource file may contain additional nulls */
|
|
|
|
if (end) size = end - ptr;
|
|
|
|
file = CreateFileW( ppd, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, 0 );
|
|
|
|
if (file == INVALID_HANDLE_VALUE) return FALSE;
|
|
|
|
ret = WriteFile( file, ptr, size, &written, NULL ) && written == size;
|
|
|
|
CloseHandle( file );
|
|
|
|
if (ret) TRACE( "using internal fallback for %s\n", debugstr_w( ppd ));
|
|
|
|
else DeleteFileW( ppd );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-12 10:42:47 +02:00
|
|
|
static BOOL get_fallback_ppd( const char *printer_name, const WCHAR *ppd )
|
|
|
|
{
|
2013-10-05 12:54:38 +02:00
|
|
|
char *dst, *src = get_fallback_ppd_name( printer_name );
|
2012-06-12 10:42:47 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2013-10-05 12:54:38 +02:00
|
|
|
if (!src) return get_internal_fallback_ppd( ppd );
|
|
|
|
|
2012-06-12 10:42:47 +02:00
|
|
|
TRACE( "(%s %s) found %s\n", debugstr_a(printer_name), debugstr_w(ppd), debugstr_a(src) );
|
|
|
|
|
2013-10-05 12:54:38 +02:00
|
|
|
if (!(dst = wine_get_unix_file_name( ppd ))) goto fail;
|
2012-06-12 10:42:47 +02:00
|
|
|
|
|
|
|
if (symlink( src, dst ) == -1)
|
|
|
|
if (errno != ENOSYS || !copy_file( src, dst ))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
fail:
|
|
|
|
HeapFree( GetProcessHeap(), 0, dst );
|
|
|
|
HeapFree( GetProcessHeap(), 0, src );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
|
|
|
|
{
|
|
|
|
static const WCHAR dot_ppd[] = {'.','p','p','d',0};
|
|
|
|
int len = (strlenW( dir ) + strlenW( file_name )) * sizeof(WCHAR) + sizeof(dot_ppd);
|
|
|
|
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
|
|
|
|
if (!ppd) return NULL;
|
|
|
|
strcpyW( ppd, dir );
|
|
|
|
strcatW( ppd, file_name );
|
|
|
|
strcatW( ppd, dot_ppd );
|
|
|
|
|
|
|
|
return ppd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *get_ppd_dir( void )
|
|
|
|
{
|
|
|
|
static const WCHAR wine_ppds[] = {'w','i','n','e','_','p','p','d','s','\\',0};
|
|
|
|
DWORD len;
|
|
|
|
WCHAR *dir, tmp_path[MAX_PATH];
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
len = GetTempPathW( sizeof(tmp_path) / sizeof(tmp_path[0]), tmp_path );
|
|
|
|
if (!len) return NULL;
|
|
|
|
dir = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) + sizeof(wine_ppds) ) ;
|
|
|
|
if (!dir) return NULL;
|
|
|
|
|
|
|
|
memcpy( dir, tmp_path, len * sizeof(WCHAR) );
|
|
|
|
memcpy( dir + len, wine_ppds, sizeof(wine_ppds) );
|
|
|
|
res = CreateDirectoryW( dir, NULL );
|
|
|
|
if (!res && GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, dir );
|
|
|
|
dir = NULL;
|
|
|
|
}
|
|
|
|
TRACE( "ppd temporary dir: %s\n", debugstr_w(dir) );
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void unlink_ppd( const WCHAR *ppd )
|
|
|
|
{
|
|
|
|
char *unix_name = wine_get_unix_file_name( ppd );
|
|
|
|
unlink( unix_name );
|
|
|
|
HeapFree( GetProcessHeap(), 0, unix_name );
|
|
|
|
}
|
|
|
|
|
2007-07-02 17:30:44 +02:00
|
|
|
#ifdef SONAME_LIBCUPS
|
2012-04-16 14:18:41 +02:00
|
|
|
|
2005-07-11 15:21:48 +02:00
|
|
|
static void *cupshandle;
|
|
|
|
|
2012-04-16 14:18:41 +02:00
|
|
|
#define CUPS_FUNCS \
|
2013-11-01 11:43:16 +01:00
|
|
|
DO_FUNC(cupsAddOption); \
|
2012-04-16 14:18:41 +02:00
|
|
|
DO_FUNC(cupsFreeDests); \
|
2012-04-16 14:18:42 +02:00
|
|
|
DO_FUNC(cupsFreeOptions); \
|
2012-04-16 14:18:41 +02:00
|
|
|
DO_FUNC(cupsGetDests); \
|
2012-06-15 13:53:54 +02:00
|
|
|
DO_FUNC(cupsGetOption); \
|
2012-04-16 14:18:41 +02:00
|
|
|
DO_FUNC(cupsGetPPD); \
|
2012-04-16 14:18:42 +02:00
|
|
|
DO_FUNC(cupsParseOptions); \
|
2012-12-01 17:38:02 +01:00
|
|
|
DO_FUNC(cupsPrintFile)
|
2012-06-12 10:42:47 +02:00
|
|
|
#define CUPS_OPT_FUNCS \
|
2013-11-01 11:43:16 +01:00
|
|
|
DO_FUNC(cupsGetNamedDest); \
|
2016-01-28 17:30:55 +01:00
|
|
|
DO_FUNC(cupsGetPPD3); \
|
|
|
|
DO_FUNC(cupsLastErrorString)
|
2012-04-16 14:18:41 +02:00
|
|
|
|
|
|
|
#define DO_FUNC(f) static typeof(f) *p##f
|
|
|
|
CUPS_FUNCS;
|
|
|
|
#undef DO_FUNC
|
2013-11-01 11:43:16 +01:00
|
|
|
static cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *);
|
|
|
|
static http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t);
|
2016-01-28 17:30:55 +01:00
|
|
|
static const char * (*pcupsLastErrorString)(void);
|
2012-06-12 10:42:47 +02:00
|
|
|
|
|
|
|
static http_status_t cupsGetPPD3_wrapper( http_t *http, const char *name,
|
|
|
|
time_t *modtime, char *buffer,
|
|
|
|
size_t bufsize )
|
|
|
|
{
|
|
|
|
const char *ppd;
|
|
|
|
|
|
|
|
if (pcupsGetPPD3) return pcupsGetPPD3( http, name, modtime, buffer, bufsize );
|
|
|
|
|
2012-07-09 14:28:32 +02:00
|
|
|
if (!pcupsGetPPD) return HTTP_NOT_FOUND;
|
|
|
|
|
2012-06-12 10:42:47 +02:00
|
|
|
TRACE( "No cupsGetPPD3 implementation, so calling cupsGetPPD\n" );
|
|
|
|
|
|
|
|
*modtime = 0;
|
|
|
|
ppd = pcupsGetPPD( name );
|
|
|
|
|
|
|
|
TRACE( "cupsGetPPD returns %s\n", debugstr_a(ppd) );
|
|
|
|
|
|
|
|
if (!ppd) return HTTP_NOT_FOUND;
|
|
|
|
|
|
|
|
if (rename( ppd, buffer ) == -1)
|
|
|
|
{
|
|
|
|
BOOL res = copy_file( ppd, buffer );
|
|
|
|
unlink( ppd );
|
|
|
|
if (!res) return HTTP_NOT_FOUND;
|
|
|
|
}
|
|
|
|
return HTTP_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_cups_ppd( const char *printer_name, const WCHAR *ppd )
|
|
|
|
{
|
|
|
|
time_t modtime = 0;
|
|
|
|
http_status_t http_status;
|
|
|
|
char *unix_name = wine_get_unix_file_name( ppd );
|
|
|
|
|
|
|
|
TRACE( "(%s, %s)\n", debugstr_a(printer_name), debugstr_w(ppd) );
|
|
|
|
|
|
|
|
if (!unix_name) return FALSE;
|
|
|
|
|
|
|
|
http_status = cupsGetPPD3_wrapper( 0, printer_name, &modtime,
|
|
|
|
unix_name, strlen( unix_name ) + 1 );
|
2012-11-16 10:53:14 +01:00
|
|
|
|
|
|
|
if (http_status != HTTP_OK) unlink( unix_name );
|
2012-06-12 10:42:47 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, unix_name );
|
|
|
|
|
|
|
|
if (http_status == HTTP_OK) return TRUE;
|
|
|
|
|
2012-11-16 10:53:14 +01:00
|
|
|
TRACE( "failed to get ppd for printer %s from cups (status %d), calling fallback\n",
|
|
|
|
debugstr_a(printer_name), http_status );
|
2012-06-12 10:42:47 +02:00
|
|
|
return get_fallback_ppd( printer_name, ppd );
|
|
|
|
}
|
|
|
|
|
2012-06-15 13:53:54 +02:00
|
|
|
static WCHAR *get_cups_option( const char *name, int num_options, cups_option_t *options )
|
|
|
|
{
|
|
|
|
const char *value;
|
|
|
|
WCHAR *ret;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
value = pcupsGetOption( name, num_options, options );
|
|
|
|
if (!value) return NULL;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_UNIXCP, 0, value, -1, NULL, 0 );
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
if (ret) MultiByteToWideChar( CP_UNIXCP, 0, value, -1, ret, len );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2012-04-16 14:18:41 +02:00
|
|
|
|
2012-09-14 14:40:10 +02:00
|
|
|
static cups_ptype_t get_cups_printer_type( const cups_dest_t *dest )
|
|
|
|
{
|
|
|
|
WCHAR *type = get_cups_option( "printer-type", dest->num_options, dest->options ), *end;
|
|
|
|
cups_ptype_t ret = 0;
|
|
|
|
|
|
|
|
if (type && *type)
|
|
|
|
{
|
|
|
|
ret = (cups_ptype_t)strtoulW( type, &end, 10 );
|
|
|
|
if (*end) ret = 0;
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, type );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-01 05:49:22 +02:00
|
|
|
static void load_cups(void)
|
|
|
|
{
|
|
|
|
cupshandle = wine_dlopen( SONAME_LIBCUPS, RTLD_NOW, NULL, 0 );
|
|
|
|
if (!cupshandle) return;
|
|
|
|
|
|
|
|
TRACE("%p: %s loaded\n", cupshandle, SONAME_LIBCUPS);
|
|
|
|
|
|
|
|
#define DO_FUNC(x) \
|
|
|
|
p##x = wine_dlsym( cupshandle, #x, NULL, 0 ); \
|
|
|
|
if (!p##x) \
|
|
|
|
{ \
|
|
|
|
ERR("failed to load symbol %s\n", #x); \
|
|
|
|
cupshandle = NULL; \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
CUPS_FUNCS;
|
|
|
|
#undef DO_FUNC
|
|
|
|
#define DO_FUNC(x) p##x = wine_dlsym( cupshandle, #x, NULL, 0 )
|
|
|
|
CUPS_OPT_FUNCS;
|
|
|
|
#undef DO_FUNC
|
|
|
|
}
|
|
|
|
|
2003-11-05 01:36:47 +01:00
|
|
|
static BOOL CUPS_LoadPrinters(void)
|
|
|
|
{
|
2003-06-23 21:52:55 +02:00
|
|
|
int i, nrofdests;
|
2007-07-05 01:22:15 +02:00
|
|
|
BOOL hadprinter = FALSE, haddefault = FALSE;
|
2003-06-23 21:52:55 +02:00
|
|
|
cups_dest_t *dests;
|
2010-10-18 17:49:19 +02:00
|
|
|
PRINTER_INFO_2W pi2;
|
2012-06-12 10:42:47 +02:00
|
|
|
WCHAR *port, *ppd_dir = NULL, *ppd;
|
2010-10-18 17:49:17 +02:00
|
|
|
HKEY hkeyPrinter, hkeyPrinters;
|
2010-10-18 17:49:18 +02:00
|
|
|
WCHAR nameW[MAX_PATH];
|
2012-04-24 13:55:48 +02:00
|
|
|
HANDLE added_printer;
|
2012-09-14 14:40:10 +02:00
|
|
|
cups_ptype_t printer_type;
|
2001-04-27 20:02:46 +02:00
|
|
|
|
2013-04-01 05:49:22 +02:00
|
|
|
if (!cupshandle) return FALSE;
|
2002-11-12 03:22:24 +01:00
|
|
|
|
2006-05-21 14:35:29 +02:00
|
|
|
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
|
2003-11-05 01:36:47 +01:00
|
|
|
ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Printers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-09-12 02:52:59 +02:00
|
|
|
|
2003-06-23 21:52:55 +02:00
|
|
|
nrofdests = pcupsGetDests(&dests);
|
|
|
|
TRACE("Found %d CUPS %s:\n", nrofdests, (nrofdests == 1) ? "printer" : "printers");
|
2001-04-27 20:02:46 +02:00
|
|
|
for (i=0;i<nrofdests;i++) {
|
2010-10-18 17:49:19 +02:00
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, dests[i].name, -1, nameW, sizeof(nameW) / sizeof(WCHAR));
|
2012-09-14 14:40:10 +02:00
|
|
|
printer_type = get_cups_printer_type( dests + i );
|
|
|
|
|
|
|
|
TRACE( "Printer %d: %s. printer_type %x\n", i, debugstr_w(nameW), printer_type );
|
|
|
|
|
|
|
|
if (printer_type & 0x2000000 /* CUPS_PRINTER_SCANNER */)
|
|
|
|
{
|
|
|
|
TRACE( "skipping scanner-only device\n" );
|
|
|
|
continue;
|
|
|
|
}
|
2010-10-18 17:49:18 +02:00
|
|
|
|
2010-10-18 17:49:19 +02:00
|
|
|
port = HeapAlloc(GetProcessHeap(), 0, sizeof(CUPS_Port) + lstrlenW(nameW) * sizeof(WCHAR));
|
|
|
|
lstrcpyW(port, CUPS_Port);
|
|
|
|
lstrcatW(port, nameW);
|
2001-04-27 20:02:46 +02:00
|
|
|
|
2010-10-18 17:49:19 +02:00
|
|
|
if(RegOpenKeyW(hkeyPrinters, nameW, &hkeyPrinter) == ERROR_SUCCESS) {
|
2012-06-12 10:42:48 +02:00
|
|
|
DWORD status = get_dword_from_reg( hkeyPrinter, StatusW );
|
2003-11-05 01:36:47 +01:00
|
|
|
/* Printer already in registry, delete the tag added in WINSPOOL_LoadSystemPrinters
|
|
|
|
and continue */
|
|
|
|
TRACE("Printer already exists\n");
|
2010-10-18 17:49:19 +02:00
|
|
|
/* overwrite old LPR:* port */
|
|
|
|
RegSetValueExW(hkeyPrinter, PortW, 0, REG_SZ, (LPBYTE)port, (lstrlenW(port) + 1) * sizeof(WCHAR));
|
2003-11-05 01:36:47 +01:00
|
|
|
RegDeleteValueW(hkeyPrinter, May_Delete_Value);
|
2012-06-12 10:42:48 +02:00
|
|
|
/* flag that the PPD file should be checked for an update */
|
|
|
|
set_reg_DWORD( hkeyPrinter, StatusW, status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
|
2003-11-05 01:36:47 +01:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
} else {
|
2012-06-12 10:42:47 +02:00
|
|
|
BOOL added_driver = FALSE;
|
2006-08-19 15:22:39 +02:00
|
|
|
|
2014-12-17 17:10:50 +01:00
|
|
|
if (!ppd_dir && !(ppd_dir = get_ppd_dir()))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, port );
|
|
|
|
break;
|
|
|
|
}
|
2012-06-12 10:42:47 +02:00
|
|
|
ppd = get_ppd_filename( ppd_dir, nameW );
|
|
|
|
if (get_cups_ppd( dests[i].name, ppd ))
|
|
|
|
{
|
|
|
|
added_driver = add_printer_driver( nameW, ppd );
|
|
|
|
unlink_ppd( ppd );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd );
|
2012-11-01 16:08:29 +01:00
|
|
|
if (!added_driver)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, port );
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-07 18:19:06 +01:00
|
|
|
|
2010-10-18 17:49:19 +02:00
|
|
|
memset(&pi2, 0, sizeof(PRINTER_INFO_2W));
|
|
|
|
pi2.pPrinterName = nameW;
|
|
|
|
pi2.pDatatype = rawW;
|
|
|
|
pi2.pPrintProcessor = WinPrintW;
|
|
|
|
pi2.pDriverName = nameW;
|
2012-06-15 13:53:54 +02:00
|
|
|
pi2.pComment = get_cups_option( "printer-info", dests[i].num_options, dests[i].options );
|
2012-06-15 13:53:55 +02:00
|
|
|
pi2.pLocation = get_cups_option( "printer-location", dests[i].num_options, dests[i].options );
|
2010-10-18 17:49:19 +02:00
|
|
|
pi2.pPortName = port;
|
|
|
|
pi2.pParameters = emptyStringW;
|
|
|
|
pi2.pShareName = emptyStringW;
|
|
|
|
pi2.pSepFile = emptyStringW;
|
|
|
|
|
2012-04-24 13:55:48 +02:00
|
|
|
added_printer = AddPrinterW( NULL, 2, (LPBYTE)&pi2 );
|
|
|
|
if (added_printer) ClosePrinter( added_printer );
|
|
|
|
else if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS)
|
|
|
|
ERR( "printer '%s' not added by AddPrinter (error %d)\n", debugstr_w(nameW), GetLastError() );
|
2012-06-15 13:53:54 +02:00
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, pi2.pComment );
|
2012-06-15 13:53:55 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, pi2.pLocation );
|
2003-11-05 01:36:47 +01:00
|
|
|
}
|
2012-06-15 13:53:54 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, port );
|
2003-06-23 21:52:55 +02:00
|
|
|
|
|
|
|
hadprinter = TRUE;
|
2007-07-05 01:22:15 +02:00
|
|
|
if (dests[i].is_default) {
|
2010-10-18 17:49:19 +02:00
|
|
|
SetDefaultPrinterW(nameW);
|
2007-07-05 01:22:15 +02:00
|
|
|
haddefault = TRUE;
|
|
|
|
}
|
2001-04-27 20:02:46 +02:00
|
|
|
}
|
2012-06-12 10:42:47 +02:00
|
|
|
|
|
|
|
if (ppd_dir)
|
|
|
|
{
|
|
|
|
RemoveDirectoryW( ppd_dir );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd_dir );
|
|
|
|
}
|
|
|
|
|
2011-08-27 18:42:48 +02:00
|
|
|
if (hadprinter && !haddefault) {
|
2010-10-18 17:49:19 +02:00
|
|
|
MultiByteToWideChar(CP_UNIXCP, 0, dests[0].name, -1, nameW, sizeof(nameW) / sizeof(WCHAR));
|
|
|
|
SetDefaultPrinterW(nameW);
|
|
|
|
}
|
2009-02-19 18:21:07 +01:00
|
|
|
pcupsFreeDests(nrofdests, dests);
|
2003-11-05 01:36:47 +01:00
|
|
|
RegCloseKey(hkeyPrinters);
|
2012-04-20 12:19:29 +02:00
|
|
|
return TRUE;
|
2001-04-27 20:02:46 +02:00
|
|
|
}
|
2012-06-12 10:42:49 +02:00
|
|
|
|
2012-06-13 16:41:38 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static char *get_queue_name( HANDLE printer, BOOL *cups )
|
2012-06-12 10:42:49 +02:00
|
|
|
{
|
2012-06-13 16:41:38 +02:00
|
|
|
WCHAR *port, *name = NULL;
|
2012-06-12 10:42:49 +02:00
|
|
|
DWORD err, needed, type;
|
|
|
|
char *ret = NULL;
|
|
|
|
HKEY key;
|
|
|
|
|
2012-06-13 16:41:38 +02:00
|
|
|
*cups = FALSE;
|
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
err = WINSPOOL_GetOpenedPrinterRegKey( printer, &key );
|
|
|
|
if (err) return NULL;
|
|
|
|
err = RegQueryValueExW( key, PortW, 0, &type, NULL, &needed );
|
2012-06-13 16:41:38 +02:00
|
|
|
if (err) goto end;
|
2012-06-12 10:42:49 +02:00
|
|
|
port = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
if (!port) goto end;
|
|
|
|
RegQueryValueExW( key, PortW, 0, &type, (BYTE*)port, &needed );
|
2012-06-13 16:41:38 +02:00
|
|
|
|
|
|
|
if (!strncmpW( port, CUPS_Port, sizeof(CUPS_Port) / sizeof(WCHAR) -1 ))
|
|
|
|
{
|
|
|
|
name = port + sizeof(CUPS_Port) / sizeof(WCHAR) - 1;
|
|
|
|
*cups = TRUE;
|
|
|
|
}
|
|
|
|
else if (!strncmpW( port, LPR_Port, sizeof(LPR_Port) / sizeof(WCHAR) -1 ))
|
|
|
|
name = port + sizeof(LPR_Port) / sizeof(WCHAR) - 1;
|
|
|
|
if (name)
|
2012-06-12 10:42:49 +02:00
|
|
|
{
|
|
|
|
needed = WideCharToMultiByte( CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL );
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
if(ret) WideCharToMultiByte( CP_UNIXCP, 0, name, -1, ret, needed, NULL, NULL );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, port );
|
|
|
|
end:
|
|
|
|
RegCloseKey( key );
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-13 16:41:38 +02:00
|
|
|
|
2001-04-27 20:02:46 +02:00
|
|
|
|
2012-06-21 13:59:03 +02:00
|
|
|
static void set_ppd_overrides( HANDLE printer )
|
|
|
|
{
|
|
|
|
WCHAR *wstr = NULL;
|
|
|
|
int size = 0;
|
|
|
|
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
|
|
|
|
OSStatus status;
|
|
|
|
PMPrintSession session = NULL;
|
|
|
|
PMPageFormat format = NULL;
|
|
|
|
PMPaper paper;
|
|
|
|
CFStringRef paper_name;
|
|
|
|
CFRange range;
|
|
|
|
|
|
|
|
status = PMCreateSession( &session );
|
|
|
|
if (status) goto end;
|
|
|
|
|
|
|
|
status = PMCreatePageFormat( &format );
|
|
|
|
if (status) goto end;
|
|
|
|
|
|
|
|
status = PMSessionDefaultPageFormat( session, format );
|
|
|
|
if (status) goto end;
|
|
|
|
|
|
|
|
status = PMGetPageFormatPaper( format, &paper );
|
|
|
|
if (status) goto end;
|
|
|
|
|
|
|
|
status = PMPaperGetPPDPaperName( paper, &paper_name );
|
|
|
|
if (status) goto end;
|
|
|
|
|
|
|
|
range.location = 0;
|
|
|
|
range.length = CFStringGetLength( paper_name );
|
|
|
|
size = (range.length + 1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
wstr = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
CFStringGetCharacters( paper_name, range, (UniChar*)wstr );
|
|
|
|
wstr[range.length] = 0;
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (format) PMRelease( format );
|
|
|
|
if (session) PMRelease( session );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)wstr, size );
|
|
|
|
HeapFree( GetProcessHeap(), 0, wstr );
|
|
|
|
}
|
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
static BOOL update_driver( HANDLE printer )
|
|
|
|
{
|
2012-06-13 16:41:38 +02:00
|
|
|
BOOL ret, is_cups;
|
2012-06-12 10:42:49 +02:00
|
|
|
const WCHAR *name = get_opened_printer_name( printer );
|
|
|
|
WCHAR *ppd_dir, *ppd;
|
2012-06-13 16:41:38 +02:00
|
|
|
char *queue_name;
|
2012-06-12 10:42:49 +02:00
|
|
|
|
|
|
|
if (!name) return FALSE;
|
2012-06-13 16:41:38 +02:00
|
|
|
queue_name = get_queue_name( printer, &is_cups );
|
|
|
|
if (!queue_name) return FALSE;
|
2012-06-12 10:42:49 +02:00
|
|
|
|
2014-12-17 17:10:50 +01:00
|
|
|
if (!(ppd_dir = get_ppd_dir()))
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, queue_name );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-06-12 10:42:49 +02:00
|
|
|
ppd = get_ppd_filename( ppd_dir, name );
|
2012-06-13 16:41:38 +02:00
|
|
|
|
|
|
|
#ifdef SONAME_LIBCUPS
|
|
|
|
if (is_cups)
|
|
|
|
ret = get_cups_ppd( queue_name, ppd );
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ret = get_fallback_ppd( queue_name, ppd );
|
|
|
|
|
|
|
|
if (ret)
|
2012-06-12 10:42:49 +02:00
|
|
|
{
|
|
|
|
TRACE( "updating driver %s\n", debugstr_w( name ) );
|
|
|
|
ret = add_printer_driver( name, ppd );
|
|
|
|
unlink_ppd( ppd );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd_dir );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd );
|
2012-06-13 16:41:38 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, queue_name );
|
2012-06-21 13:59:02 +02:00
|
|
|
|
2012-06-21 13:59:03 +02:00
|
|
|
set_ppd_overrides( printer );
|
|
|
|
|
2012-06-21 13:59:02 +02:00
|
|
|
/* call into the driver to update the devmode */
|
|
|
|
DocumentPropertiesW( 0, printer, NULL, NULL, NULL, 0 );
|
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-04-24 13:55:48 +02:00
|
|
|
static BOOL PRINTCAP_ParseEntry( const char *pent, BOOL isfirst )
|
|
|
|
{
|
2001-05-09 19:10:41 +02:00
|
|
|
PRINTER_INFO_2A pinfo2a;
|
2011-09-13 00:18:01 +02:00
|
|
|
const char *r;
|
|
|
|
size_t name_len;
|
2003-11-11 01:42:35 +01:00
|
|
|
char *e,*s,*name,*prettyname,*devname;
|
|
|
|
BOOL ret = FALSE, set_default = FALSE;
|
2010-10-18 17:49:17 +02:00
|
|
|
char *port = NULL, *env_default;
|
2012-06-12 10:42:47 +02:00
|
|
|
HKEY hkeyPrinter, hkeyPrinters = NULL;
|
|
|
|
WCHAR devnameW[MAX_PATH], *ppd_dir = NULL, *ppd;
|
2012-04-24 13:55:48 +02:00
|
|
|
HANDLE added_printer;
|
2001-05-09 19:10:41 +02:00
|
|
|
|
2002-05-17 02:10:15 +02:00
|
|
|
while (isspace(*pent)) pent++;
|
2011-09-13 00:18:01 +02:00
|
|
|
r = strchr(pent,':');
|
|
|
|
if (r)
|
|
|
|
name_len = r - pent;
|
|
|
|
else
|
|
|
|
name_len = strlen(pent);
|
|
|
|
name = HeapAlloc(GetProcessHeap(), 0, name_len + 1);
|
|
|
|
memcpy(name, pent, name_len);
|
|
|
|
name[name_len] = '\0';
|
|
|
|
if (r)
|
|
|
|
pent = r;
|
|
|
|
else
|
2003-11-11 01:42:35 +01:00
|
|
|
pent = "";
|
|
|
|
|
|
|
|
TRACE("name=%s entry=%s\n",name, pent);
|
|
|
|
|
|
|
|
if(ispunct(*name)) { /* a tc entry, not a real printer */
|
|
|
|
TRACE("skipping tc entry\n");
|
|
|
|
goto end;
|
2001-05-09 19:10:41 +02:00
|
|
|
}
|
2003-11-11 01:42:35 +01:00
|
|
|
|
|
|
|
if(strstr(pent,":server")) { /* server only version so skip */
|
|
|
|
TRACE("skipping server entry\n");
|
|
|
|
goto end;
|
2001-05-09 19:10:41 +02:00
|
|
|
}
|
|
|
|
|
2003-11-11 01:42:35 +01:00
|
|
|
/* Determine whether this is a postscript printer. */
|
2001-05-09 19:10:41 +02:00
|
|
|
|
2003-11-11 01:42:35 +01:00
|
|
|
ret = TRUE;
|
|
|
|
env_default = getenv("PRINTER");
|
2001-05-09 19:10:41 +02:00
|
|
|
prettyname = name;
|
|
|
|
/* Get longest name, usually the one at the right for later display. */
|
2003-11-11 01:42:35 +01:00
|
|
|
while((s=strchr(prettyname,'|'))) {
|
|
|
|
*s = '\0';
|
|
|
|
e = s;
|
|
|
|
while(isspace(*--e)) *e = '\0';
|
|
|
|
TRACE("\t%s\n", debugstr_a(prettyname));
|
|
|
|
if(env_default && !strcasecmp(prettyname, env_default)) set_default = TRUE;
|
|
|
|
for(prettyname = s+1; isspace(*prettyname); prettyname++)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
e = prettyname + strlen(prettyname);
|
|
|
|
while(isspace(*--e)) *e = '\0';
|
|
|
|
TRACE("\t%s\n", debugstr_a(prettyname));
|
|
|
|
if(env_default && !strcasecmp(prettyname, env_default)) set_default = TRUE;
|
2001-05-09 19:10:41 +02:00
|
|
|
|
|
|
|
/* prettyname must fit into the dmDeviceName member of DEVMODE struct,
|
|
|
|
* if it is too long, we use it as comment below. */
|
|
|
|
devname = prettyname;
|
|
|
|
if (strlen(devname)>=CCHDEVICENAME-1)
|
|
|
|
devname = name;
|
2003-11-11 01:42:35 +01:00
|
|
|
if (strlen(devname)>=CCHDEVICENAME-1) {
|
|
|
|
ret = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
2001-05-18 22:57:36 +02:00
|
|
|
|
2001-05-09 19:10:41 +02:00
|
|
|
port = HeapAlloc(GetProcessHeap(),0,strlen("LPR:")+strlen(name)+1);
|
|
|
|
sprintf(port,"LPR:%s",name);
|
|
|
|
|
2006-05-21 14:35:29 +02:00
|
|
|
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
|
2003-11-11 01:42:35 +01:00
|
|
|
ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Printers key\n");
|
|
|
|
ret = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
2010-10-18 17:49:18 +02:00
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, devname, -1, devnameW, sizeof(devnameW) / sizeof(WCHAR));
|
|
|
|
|
2003-11-11 01:42:35 +01:00
|
|
|
if(RegOpenKeyA(hkeyPrinters, devname, &hkeyPrinter) == ERROR_SUCCESS) {
|
2012-06-13 16:41:38 +02:00
|
|
|
DWORD status = get_dword_from_reg( hkeyPrinter, StatusW );
|
2003-11-11 01:42:35 +01:00
|
|
|
/* Printer already in registry, delete the tag added in WINSPOOL_LoadSystemPrinters
|
|
|
|
and continue */
|
|
|
|
TRACE("Printer already exists\n");
|
|
|
|
RegDeleteValueW(hkeyPrinter, May_Delete_Value);
|
2012-06-13 16:41:38 +02:00
|
|
|
/* flag that the PPD file should be checked for an update */
|
|
|
|
set_reg_DWORD( hkeyPrinter, StatusW, status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
|
2003-11-11 01:42:35 +01:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
} else {
|
2006-08-19 15:22:39 +02:00
|
|
|
static CHAR data_type[] = "RAW",
|
|
|
|
print_proc[] = "WinPrint",
|
|
|
|
comment[] = "WINEPS Printer using LPR",
|
|
|
|
params[] = "<parameters?>",
|
|
|
|
share_name[] = "<share name?>",
|
|
|
|
sep_file[] = "<sep file?>";
|
2012-06-12 10:42:47 +02:00
|
|
|
BOOL added_driver = FALSE;
|
2006-08-19 15:22:39 +02:00
|
|
|
|
2014-12-17 17:10:50 +01:00
|
|
|
if (!ppd_dir && !(ppd_dir = get_ppd_dir())) goto end;
|
2012-06-12 10:42:47 +02:00
|
|
|
ppd = get_ppd_filename( ppd_dir, devnameW );
|
|
|
|
if (get_fallback_ppd( devname, ppd ))
|
|
|
|
{
|
|
|
|
added_driver = add_printer_driver( devnameW, ppd );
|
|
|
|
unlink_ppd( ppd );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd );
|
|
|
|
if (!added_driver) goto end;
|
2006-11-07 18:19:06 +01:00
|
|
|
|
2003-11-11 01:42:35 +01:00
|
|
|
memset(&pinfo2a,0,sizeof(pinfo2a));
|
2006-08-19 15:22:39 +02:00
|
|
|
pinfo2a.pPrinterName = devname;
|
|
|
|
pinfo2a.pDatatype = data_type;
|
|
|
|
pinfo2a.pPrintProcessor = print_proc;
|
2006-11-07 18:19:06 +01:00
|
|
|
pinfo2a.pDriverName = devname;
|
2006-08-19 15:22:39 +02:00
|
|
|
pinfo2a.pComment = comment;
|
|
|
|
pinfo2a.pLocation = prettyname;
|
|
|
|
pinfo2a.pPortName = port;
|
|
|
|
pinfo2a.pParameters = params;
|
|
|
|
pinfo2a.pShareName = share_name;
|
|
|
|
pinfo2a.pSepFile = sep_file;
|
2003-11-11 01:42:35 +01:00
|
|
|
|
2012-04-24 13:55:48 +02:00
|
|
|
added_printer = AddPrinterA( NULL, 2, (LPBYTE)&pinfo2a );
|
|
|
|
if (added_printer) ClosePrinter( added_printer );
|
|
|
|
else if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS)
|
|
|
|
ERR( "printer '%s' not added by AddPrinter (error %d)\n", debugstr_a(name), GetLastError() );
|
2001-05-09 19:10:41 +02:00
|
|
|
}
|
2003-11-11 01:42:35 +01:00
|
|
|
|
|
|
|
if (isfirst || set_default)
|
|
|
|
WINSPOOL_SetDefaultPrinter(devname,name,TRUE);
|
|
|
|
|
|
|
|
end:
|
2012-06-12 10:42:47 +02:00
|
|
|
if (hkeyPrinters) RegCloseKey( hkeyPrinters );
|
|
|
|
if (ppd_dir)
|
|
|
|
{
|
|
|
|
RemoveDirectoryW( ppd_dir );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ppd_dir );
|
|
|
|
}
|
2007-12-14 14:56:57 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, port);
|
2003-11-11 01:42:35 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
return ret;
|
2001-05-09 19:10:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
PRINTCAP_LoadPrinters(void) {
|
2003-11-11 01:42:35 +01:00
|
|
|
BOOL hadprinter = FALSE;
|
2001-05-09 19:10:41 +02:00
|
|
|
char buf[200];
|
|
|
|
FILE *f;
|
2003-11-11 01:42:35 +01:00
|
|
|
char *pent = NULL;
|
|
|
|
BOOL had_bash = FALSE;
|
2001-05-09 19:10:41 +02:00
|
|
|
|
|
|
|
f = fopen("/etc/printcap","r");
|
|
|
|
if (!f)
|
|
|
|
return FALSE;
|
|
|
|
|
2003-11-11 01:42:35 +01:00
|
|
|
while(fgets(buf,sizeof(buf),f)) {
|
|
|
|
char *start, *end;
|
|
|
|
|
|
|
|
end=strchr(buf,'\n');
|
|
|
|
if (end) *end='\0';
|
|
|
|
|
|
|
|
start = buf;
|
|
|
|
while(isspace(*start)) start++;
|
|
|
|
if(*start == '#' || *start == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(pent && !had_bash && *start != ':' && *start != '|') { /* start of new entry, parse the previous one */
|
|
|
|
hadprinter |= PRINTCAP_ParseEntry(pent,!hadprinter);
|
|
|
|
HeapFree(GetProcessHeap(),0,pent);
|
|
|
|
pent = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end && *--end == '\\') {
|
|
|
|
*end = '\0';
|
|
|
|
had_bash = TRUE;
|
|
|
|
} else
|
|
|
|
had_bash = FALSE;
|
|
|
|
|
|
|
|
if (pent) {
|
|
|
|
pent=HeapReAlloc(GetProcessHeap(),0,pent,strlen(pent)+strlen(start)+1);
|
|
|
|
strcat(pent,start);
|
|
|
|
} else {
|
|
|
|
pent=HeapAlloc(GetProcessHeap(),0,strlen(start)+1);
|
|
|
|
strcpy(pent,start);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if(pent) {
|
|
|
|
hadprinter |= PRINTCAP_ParseEntry(pent,!hadprinter);
|
|
|
|
HeapFree(GetProcessHeap(),0,pent);
|
2001-05-09 19:10:41 +02:00
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
return hadprinter;
|
|
|
|
}
|
|
|
|
|
2003-11-11 21:38:51 +01:00
|
|
|
static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *value)
|
2001-10-28 22:16:38 +01:00
|
|
|
{
|
2003-06-23 21:52:55 +02:00
|
|
|
if (value)
|
2004-11-30 22:38:57 +01:00
|
|
|
return RegSetValueExW(hkey, keyname, 0, REG_SZ, (const BYTE*)value,
|
2006-11-07 18:16:29 +01:00
|
|
|
(lstrlenW(value) + 1) * sizeof(WCHAR));
|
2003-06-23 21:52:55 +02:00
|
|
|
else
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
2001-10-28 22:16:38 +01:00
|
|
|
}
|
|
|
|
|
2012-04-05 14:25:50 +02:00
|
|
|
static inline DWORD set_reg_devmode( HKEY key, const WCHAR *name, const DEVMODEW *dm )
|
|
|
|
{
|
|
|
|
DEVMODEA *dmA = DEVMODEdupWtoA( dm );
|
|
|
|
DWORD ret = ERROR_FILE_NOT_FOUND;
|
|
|
|
|
|
|
|
/* FIXME: Write DEVMODEA not DEVMODEW into reg. This is what win9x does
|
|
|
|
and we support these drivers. NT writes DEVMODEW so somehow
|
|
|
|
we'll need to distinguish between these when we support NT
|
|
|
|
drivers */
|
|
|
|
|
|
|
|
if (dmA)
|
|
|
|
{
|
|
|
|
ret = RegSetValueExW( key, name, 0, REG_BINARY,
|
|
|
|
(LPBYTE)dmA, dmA->dmSize + dmA->dmDriverExtra );
|
|
|
|
HeapFree( GetProcessHeap(), 0, dmA );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-01-05 01:09:02 +01:00
|
|
|
/******************************************************************
|
|
|
|
* get_servername_from_name (internal)
|
|
|
|
*
|
|
|
|
* for an external server, a copy of the serverpart from the full name is returned
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LPWSTR get_servername_from_name(LPCWSTR name)
|
|
|
|
{
|
|
|
|
LPWSTR server;
|
|
|
|
LPWSTR ptr;
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (name == NULL) return NULL;
|
|
|
|
if ((name[0] != '\\') || (name[1] != '\\')) return NULL;
|
|
|
|
|
|
|
|
server = strdupW(&name[2]); /* skip over both backslash */
|
|
|
|
if (server == NULL) return NULL;
|
|
|
|
|
|
|
|
/* strip '\' and the printername */
|
|
|
|
ptr = strchrW(server, '\\');
|
|
|
|
if (ptr) ptr[0] = '\0';
|
|
|
|
|
|
|
|
TRACE("found %s\n", debugstr_w(server));
|
|
|
|
|
|
|
|
len = sizeof(buffer)/sizeof(buffer[0]);
|
|
|
|
if (GetComputerNameW(buffer, &len)) {
|
|
|
|
if (lstrcmpW(buffer, server) == 0) {
|
|
|
|
/* The requested Servername is our computername */
|
|
|
|
HeapFree(GetProcessHeap(), 0, server);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* get_basename_from_name (internal)
|
|
|
|
*
|
|
|
|
* skip over the serverpart from the full name
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LPCWSTR get_basename_from_name(LPCWSTR name)
|
|
|
|
{
|
|
|
|
if (name == NULL) return NULL;
|
|
|
|
if ((name[0] == '\\') && (name[1] == '\\')) {
|
|
|
|
/* skip over the servername and search for the following '\' */
|
|
|
|
name = strchrW(&name[2], '\\');
|
|
|
|
if ((name) && (name[1])) {
|
2007-01-18 11:35:50 +01:00
|
|
|
/* found a separator ('\') followed by a name:
|
|
|
|
skip over the separator and return the rest */
|
2007-01-05 01:09:02 +01:00
|
|
|
name++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* no basename present (we found only a servername) */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2012-03-30 15:39:41 +02:00
|
|
|
static void free_printer_entry( opened_printer_t *printer )
|
|
|
|
{
|
|
|
|
/* the queue is shared, so don't free that here */
|
|
|
|
HeapFree( GetProcessHeap(), 0, printer->printername );
|
|
|
|
HeapFree( GetProcessHeap(), 0, printer->name );
|
2012-03-30 15:39:42 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, printer->devmode );
|
2012-03-30 15:39:41 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, printer );
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/******************************************************************
|
2005-07-05 13:00:09 +02:00
|
|
|
* get_opened_printer_entry
|
1999-05-17 18:20:51 +02:00
|
|
|
* Get the first place empty in the opened printer table
|
2006-05-12 16:14:59 +02:00
|
|
|
*
|
|
|
|
* ToDo:
|
|
|
|
* - pDefault is ignored
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2009-05-05 05:24:34 +02:00
|
|
|
static HANDLE get_opened_printer_entry(LPWSTR name, LPPRINTER_DEFAULTSW pDefault)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2005-09-29 15:34:34 +02:00
|
|
|
UINT_PTR handle = nb_printer_handles, i;
|
2005-10-24 17:03:02 +02:00
|
|
|
jobqueue_t *queue = NULL;
|
2006-05-12 16:14:59 +02:00
|
|
|
opened_printer_t *printer = NULL;
|
2007-01-05 01:09:02 +01:00
|
|
|
LPWSTR servername;
|
|
|
|
LPCWSTR printername;
|
|
|
|
|
2009-05-05 05:24:34 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return NULL;
|
|
|
|
|
2007-01-05 01:09:02 +01:00
|
|
|
servername = get_servername_from_name(name);
|
|
|
|
if (servername) {
|
|
|
|
FIXME("server %s not supported\n", debugstr_w(servername));
|
|
|
|
HeapFree(GetProcessHeap(), 0, servername);
|
|
|
|
SetLastError(ERROR_INVALID_PRINTER_NAME);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
printername = get_basename_from_name(name);
|
|
|
|
if (name != printername) TRACE("converted %s to %s\n", debugstr_w(name), debugstr_w(printername));
|
|
|
|
|
|
|
|
/* an empty printername is invalid */
|
|
|
|
if (printername && (!printername[0])) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-08-15 18:34:22 +02:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
1999-08-15 18:34:22 +02:00
|
|
|
|
2005-07-19 21:12:13 +02:00
|
|
|
for (i = 0; i < nb_printer_handles; i++)
|
|
|
|
{
|
|
|
|
if (!printer_handles[i])
|
|
|
|
{
|
|
|
|
if(handle == nb_printer_handles)
|
|
|
|
handle = i;
|
|
|
|
}
|
2006-05-12 16:14:59 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!queue && (name) && !lstrcmpW(name, printer_handles[i]->name))
|
|
|
|
queue = printer_handles[i]->queue;
|
|
|
|
}
|
2005-07-19 21:12:13 +02:00
|
|
|
}
|
2003-10-15 23:01:05 +02:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
if (handle >= nb_printer_handles)
|
|
|
|
{
|
|
|
|
opened_printer_t **new_array;
|
|
|
|
if (printer_handles)
|
|
|
|
new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, printer_handles,
|
|
|
|
(nb_printer_handles + 16) * sizeof(*new_array) );
|
2005-07-06 17:44:15 +02:00
|
|
|
else
|
2005-07-05 13:00:09 +02:00
|
|
|
new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
(nb_printer_handles + 16) * sizeof(*new_array) );
|
|
|
|
|
|
|
|
if (!new_array)
|
|
|
|
{
|
|
|
|
handle = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
printer_handles = new_array;
|
|
|
|
nb_printer_handles += 16;
|
1999-08-15 18:34:22 +02:00
|
|
|
}
|
|
|
|
|
2006-05-12 16:14:59 +02:00
|
|
|
if (!(printer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*printer))))
|
1999-08-15 18:34:22 +02:00
|
|
|
{
|
2005-07-05 13:00:09 +02:00
|
|
|
handle = 0;
|
|
|
|
goto end;
|
1999-08-15 18:34:22 +02:00
|
|
|
}
|
2005-07-05 13:00:09 +02:00
|
|
|
|
2009-05-05 05:24:34 +02:00
|
|
|
/* get a printer handle from the backend */
|
|
|
|
if (! backend->fpOpenPrinter(name, &printer->backend_printer, pDefault)) {
|
|
|
|
handle = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
2007-01-05 01:09:02 +01:00
|
|
|
|
|
|
|
/* clone the base name. This is NULL for the printserver */
|
|
|
|
printer->printername = strdupW(printername);
|
|
|
|
|
|
|
|
/* clone the full name */
|
|
|
|
printer->name = strdupW(name);
|
|
|
|
if (name && (!printer->name)) {
|
|
|
|
handle = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2012-03-30 15:39:42 +02:00
|
|
|
if (pDefault && pDefault->pDevMode)
|
|
|
|
printer->devmode = dup_devmode( pDefault->pDevMode );
|
|
|
|
|
2005-07-19 21:12:13 +02:00
|
|
|
if(queue)
|
|
|
|
printer->queue = queue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printer->queue = HeapAlloc(GetProcessHeap(), 0, sizeof(*queue));
|
2006-05-12 16:14:59 +02:00
|
|
|
if (!printer->queue) {
|
|
|
|
handle = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
2005-07-19 21:12:13 +02:00
|
|
|
list_init(&printer->queue->jobs);
|
|
|
|
printer->queue->ref = 0;
|
|
|
|
}
|
|
|
|
InterlockedIncrement(&printer->queue->ref);
|
2005-07-05 13:00:09 +02:00
|
|
|
|
2005-07-06 17:44:15 +02:00
|
|
|
printer_handles[handle] = printer;
|
2005-07-05 13:00:09 +02:00
|
|
|
handle++;
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
2006-05-12 16:14:59 +02:00
|
|
|
if (!handle && printer) {
|
|
|
|
if (!queue) HeapFree(GetProcessHeap(), 0, printer->queue);
|
2012-03-30 15:39:41 +02:00
|
|
|
free_printer_entry( printer );
|
2006-05-12 16:14:59 +02:00
|
|
|
}
|
2005-07-05 13:00:09 +02:00
|
|
|
|
|
|
|
return (HANDLE)handle;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:43:25 +02:00
|
|
|
static void old_printer_check( BOOL delete_phase )
|
|
|
|
{
|
|
|
|
PRINTER_INFO_5W* pi;
|
|
|
|
DWORD needed, type, num, delete, i, size;
|
|
|
|
const DWORD one = 1;
|
|
|
|
HKEY key;
|
|
|
|
HANDLE hprn;
|
|
|
|
|
|
|
|
EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &needed, &num );
|
|
|
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return;
|
|
|
|
|
|
|
|
pi = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 5, (LPBYTE)pi, needed, &needed, &num );
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
if (strncmpW( pi[i].pPortName, CUPS_Port, strlenW(CUPS_Port) ) &&
|
|
|
|
strncmpW( pi[i].pPortName, LPR_Port, strlenW(LPR_Port) ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (open_printer_reg_key( pi[i].pPrinterName, &key )) continue;
|
|
|
|
|
|
|
|
if (!delete_phase)
|
|
|
|
{
|
|
|
|
RegSetValueExW( key, May_Delete_Value, 0, REG_DWORD, (LPBYTE)&one, sizeof(one) );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete = 0;
|
|
|
|
size = sizeof( delete );
|
|
|
|
RegQueryValueExW( key, May_Delete_Value, NULL, &type, (LPBYTE)&delete, &size );
|
|
|
|
RegCloseKey( key );
|
|
|
|
if (delete)
|
|
|
|
{
|
|
|
|
TRACE( "Deleting old printer %s\n", debugstr_w(pi[i].pPrinterName) );
|
|
|
|
if (OpenPrinterW( pi[i].pPrinterName, &hprn, NULL ))
|
|
|
|
{
|
|
|
|
DeletePrinter( hprn );
|
|
|
|
ClosePrinter( hprn );
|
|
|
|
}
|
|
|
|
DeletePrinterDriverExW( NULL, NULL, pi[i].pPrinterName, 0, 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi);
|
|
|
|
}
|
|
|
|
|
2012-05-18 14:43:56 +02:00
|
|
|
static const WCHAR winspool_mutex_name[] = {'_','_','W','I','N','E','_','W','I','N','S','P','O','O','L','_',
|
|
|
|
'M','U','T','E','X','_','_','\0'};
|
2012-06-12 10:42:49 +02:00
|
|
|
static HANDLE init_mutex;
|
2012-05-18 14:43:56 +02:00
|
|
|
|
2007-01-17 17:18:54 +01:00
|
|
|
void WINSPOOL_LoadSystemPrinters(void)
|
|
|
|
{
|
|
|
|
HKEY hkey, hkeyPrinters;
|
|
|
|
DWORD needed, num, i;
|
|
|
|
WCHAR PrinterName[256];
|
|
|
|
BOOL done = FALSE;
|
2012-05-18 14:43:56 +02:00
|
|
|
|
2013-04-01 05:49:22 +02:00
|
|
|
#ifdef SONAME_LIBCUPS
|
|
|
|
load_cups();
|
|
|
|
#endif
|
|
|
|
|
2012-05-18 14:43:56 +02:00
|
|
|
/* FIXME: The init code should be moved to spoolsv.exe */
|
2012-06-12 10:42:49 +02:00
|
|
|
init_mutex = CreateMutexW( NULL, TRUE, winspool_mutex_name );
|
|
|
|
if (!init_mutex)
|
2012-05-18 14:43:56 +02:00
|
|
|
{
|
|
|
|
ERR( "Failed to create mutex\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
2012-06-12 10:42:49 +02:00
|
|
|
WaitForSingleObject( init_mutex, INFINITE );
|
|
|
|
ReleaseMutex( init_mutex );
|
2012-05-18 14:43:56 +02:00
|
|
|
TRACE( "Init already done\n" );
|
|
|
|
return;
|
|
|
|
}
|
2007-01-17 17:18:54 +01:00
|
|
|
|
|
|
|
/* This ensures that all printer entries have a valid Name value. If causes
|
|
|
|
problems later if they don't. If one is found to be missed we create one
|
|
|
|
and set it equal to the name of the key */
|
|
|
|
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) == ERROR_SUCCESS) {
|
2012-04-19 14:43:25 +02:00
|
|
|
if(RegQueryInfoKeyW(hkeyPrinters, NULL, NULL, NULL, &num, NULL, NULL,
|
2007-01-17 17:18:54 +01:00
|
|
|
NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
|
|
|
|
for(i = 0; i < num; i++) {
|
2007-12-01 17:43:37 +01:00
|
|
|
if(RegEnumKeyW(hkeyPrinters, i, PrinterName, sizeof(PrinterName)/sizeof(PrinterName[0])) == ERROR_SUCCESS) {
|
2007-01-17 17:18:54 +01:00
|
|
|
if(RegOpenKeyW(hkeyPrinters, PrinterName, &hkey) == ERROR_SUCCESS) {
|
|
|
|
if(RegQueryValueExW(hkey, NameW, 0, 0, 0, &needed) == ERROR_FILE_NOT_FOUND) {
|
|
|
|
set_reg_szW(hkey, NameW, PrinterName);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:43:25 +02:00
|
|
|
old_printer_check( FALSE );
|
2007-01-17 17:18:54 +01:00
|
|
|
|
2007-07-02 17:30:44 +02:00
|
|
|
#ifdef SONAME_LIBCUPS
|
2007-01-17 17:18:54 +01:00
|
|
|
done = CUPS_LoadPrinters();
|
|
|
|
#endif
|
|
|
|
|
2007-01-30 22:27:11 +01:00
|
|
|
if(!done) /* If we have any CUPS based printers, skip looking for printcap printers */
|
|
|
|
PRINTCAP_LoadPrinters();
|
2007-01-17 17:18:54 +01:00
|
|
|
|
2012-04-19 14:43:25 +02:00
|
|
|
old_printer_check( TRUE );
|
2007-01-17 17:18:54 +01:00
|
|
|
|
2012-06-12 10:42:49 +02:00
|
|
|
ReleaseMutex( init_mutex );
|
2007-01-17 17:18:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-07-13 16:14:37 +02:00
|
|
|
/******************************************************************
|
|
|
|
* get_job
|
|
|
|
*
|
|
|
|
* Get the pointer to the specified job.
|
|
|
|
* Should hold the printer_handles_cs before calling.
|
|
|
|
*/
|
|
|
|
static job_t *get_job(HANDLE hprn, DWORD JobId)
|
|
|
|
{
|
|
|
|
opened_printer_t *printer = get_opened_printer(hprn);
|
|
|
|
job_t *job;
|
|
|
|
|
|
|
|
if(!printer) return NULL;
|
2005-07-19 21:12:13 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(job, &printer->queue->jobs, job_t, entry)
|
2005-07-13 16:14:37 +02:00
|
|
|
{
|
|
|
|
if(job->job_id == JobId)
|
|
|
|
return job;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/***********************************************************
|
|
|
|
* DEVMODEcpyAtoW
|
|
|
|
*/
|
|
|
|
static LPDEVMODEW DEVMODEcpyAtoW(DEVMODEW *dmW, const DEVMODEA *dmA)
|
|
|
|
{
|
|
|
|
BOOL Formname;
|
2004-11-30 22:38:57 +01:00
|
|
|
ptrdiff_t off_formname = (const char *)dmA->dmFormName - (const char *)dmA;
|
2000-05-26 01:02:46 +02:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
Formname = (dmA->dmSize > off_formname);
|
|
|
|
size = dmA->dmSize + CCHDEVICENAME + (Formname ? CCHFORMNAME : 0);
|
2005-08-19 12:04:03 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dmA->dmDeviceName, -1,
|
|
|
|
dmW->dmDeviceName, CCHDEVICENAME);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(!Formname) {
|
|
|
|
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion,
|
|
|
|
dmA->dmSize - CCHDEVICENAME);
|
|
|
|
} else {
|
|
|
|
memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion,
|
|
|
|
off_formname - CCHDEVICENAME);
|
2005-08-19 12:04:03 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)dmA->dmFormName, -1,
|
|
|
|
dmW->dmFormName, CCHFORMNAME);
|
2000-05-26 01:02:46 +02:00
|
|
|
memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA->dmSize -
|
|
|
|
(off_formname + CCHFORMNAME));
|
|
|
|
}
|
|
|
|
dmW->dmSize = size;
|
2004-11-30 22:38:57 +01:00
|
|
|
memcpy((char *)dmW + dmW->dmSize, (const char *)dmA + dmA->dmSize,
|
2000-05-26 01:02:46 +02:00
|
|
|
dmA->dmDriverExtra);
|
|
|
|
return dmW;
|
|
|
|
}
|
|
|
|
|
2008-03-22 19:28:50 +01:00
|
|
|
/******************************************************************
|
|
|
|
* convert_printerinfo_W_to_A [internal]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void convert_printerinfo_W_to_A(LPBYTE out, LPBYTE pPrintersW,
|
|
|
|
DWORD level, DWORD outlen, DWORD numentries)
|
|
|
|
{
|
|
|
|
DWORD id = 0;
|
|
|
|
LPSTR ptr;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %d, %u, %u)\n", out, pPrintersW, level, outlen, numentries);
|
|
|
|
|
|
|
|
len = pi_sizeof[level] * numentries;
|
|
|
|
ptr = (LPSTR) out + len;
|
|
|
|
outlen -= len;
|
|
|
|
|
|
|
|
/* copy the numbers of all PRINTER_INFO_* first */
|
|
|
|
memcpy(out, pPrintersW, len);
|
|
|
|
|
|
|
|
while (id < numentries) {
|
|
|
|
switch (level) {
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_1W * piW = (PRINTER_INFO_1W *) pPrintersW;
|
|
|
|
PRINTER_INFO_1A * piA = (PRINTER_INFO_1A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(piW->pName));
|
|
|
|
if (piW->pDescription) {
|
|
|
|
piA->pDescription = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pDescription, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pName) {
|
|
|
|
piA->pName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pComment) {
|
|
|
|
piA->pComment = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pComment, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_2W * piW = (PRINTER_INFO_2W *) pPrintersW;
|
|
|
|
PRINTER_INFO_2A * piA = (PRINTER_INFO_2A *) out;
|
|
|
|
LPDEVMODEA dmA;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(piW->pPrinterName));
|
|
|
|
if (piW->pServerName) {
|
|
|
|
piA->pServerName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pServerName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pPrinterName) {
|
|
|
|
piA->pPrinterName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPrinterName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pShareName) {
|
|
|
|
piA->pShareName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pShareName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pPortName) {
|
|
|
|
piA->pPortName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPortName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pDriverName) {
|
|
|
|
piA->pDriverName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pDriverName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pComment) {
|
|
|
|
piA->pComment = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pComment, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pLocation) {
|
|
|
|
piA->pLocation = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pLocation, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
dmA = DEVMODEdupWtoA(piW->pDevMode);
|
|
|
|
if (dmA) {
|
|
|
|
/* align DEVMODEA to a DWORD boundary */
|
|
|
|
len = (4 - ( (DWORD_PTR) ptr & 3)) & 3;
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
|
|
|
|
piA->pDevMode = (LPDEVMODEA) ptr;
|
|
|
|
len = dmA->dmSize + dmA->dmDriverExtra;
|
|
|
|
memcpy(ptr, dmA, len);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dmA);
|
|
|
|
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (piW->pSepFile) {
|
|
|
|
piA->pSepFile = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pSepFile, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pPrintProcessor) {
|
|
|
|
piA->pPrintProcessor = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPrintProcessor, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pDatatype) {
|
|
|
|
piA->pDatatype = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pDatatype, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pParameters) {
|
|
|
|
piA->pParameters = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pParameters, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pSecurityDescriptor) {
|
|
|
|
piA->pSecurityDescriptor = NULL;
|
|
|
|
FIXME("pSecurityDescriptor ignored: %s\n", debugstr_w(piW->pPrinterName));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_4W * piW = (PRINTER_INFO_4W *) pPrintersW;
|
|
|
|
PRINTER_INFO_4A * piA = (PRINTER_INFO_4A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(piW->pPrinterName));
|
|
|
|
|
|
|
|
if (piW->pPrinterName) {
|
|
|
|
piA->pPrinterName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPrinterName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pServerName) {
|
|
|
|
piA->pServerName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pServerName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_5W * piW = (PRINTER_INFO_5W *) pPrintersW;
|
|
|
|
PRINTER_INFO_5A * piA = (PRINTER_INFO_5A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(piW->pPrinterName));
|
|
|
|
|
|
|
|
if (piW->pPrinterName) {
|
|
|
|
piA->pPrinterName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPrinterName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
if (piW->pPortName) {
|
|
|
|
piA->pPortName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pPortName, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-01 00:04:35 +01:00
|
|
|
case 6: /* 6A and 6W are the same structure */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_7W * piW = (PRINTER_INFO_7W *) pPrintersW;
|
|
|
|
PRINTER_INFO_7A * piA = (PRINTER_INFO_7A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u\n", level, id);
|
|
|
|
if (piW->pszObjectGUID) {
|
|
|
|
piA->pszObjectGUID = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, piW->pszObjectGUID, -1,
|
|
|
|
ptr, outlen, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-05-03 22:40:09 +02:00
|
|
|
case 8:
|
2009-12-01 00:04:35 +01:00
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_9W * piW = (PRINTER_INFO_9W *) pPrintersW;
|
|
|
|
PRINTER_INFO_9A * piA = (PRINTER_INFO_9A *) out;
|
|
|
|
LPDEVMODEA dmA;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u\n", level, id);
|
|
|
|
dmA = DEVMODEdupWtoA(piW->pDevMode);
|
|
|
|
if (dmA) {
|
|
|
|
/* align DEVMODEA to a DWORD boundary */
|
|
|
|
len = (4 - ( (DWORD_PTR) ptr & 3)) & 3;
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
|
|
|
|
piA->pDevMode = (LPDEVMODEA) ptr;
|
|
|
|
len = dmA->dmSize + dmA->dmDriverExtra;
|
|
|
|
memcpy(ptr, dmA, len);
|
|
|
|
HeapFree(GetProcessHeap(), 0, dmA);
|
|
|
|
|
|
|
|
ptr += len;
|
|
|
|
outlen -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-22 19:28:50 +01:00
|
|
|
default:
|
|
|
|
FIXME("for level %u\n", level);
|
|
|
|
}
|
|
|
|
pPrintersW += pi_sizeof[level];
|
|
|
|
out += pi_sizeof[level];
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 00:05:15 +01:00
|
|
|
/******************************************************************
|
|
|
|
* convert_driverinfo_W_to_A [internal]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void convert_driverinfo_W_to_A(LPBYTE out, LPBYTE pDriversW,
|
|
|
|
DWORD level, DWORD outlen, DWORD numentries)
|
|
|
|
{
|
|
|
|
DWORD id = 0;
|
|
|
|
LPSTR ptr;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %d, %u, %u)\n", out, pDriversW, level, outlen, numentries);
|
|
|
|
|
|
|
|
len = di_sizeof[level] * numentries;
|
|
|
|
ptr = (LPSTR) out + len;
|
|
|
|
outlen -= len;
|
|
|
|
|
|
|
|
/* copy the numbers of all PRINTER_INFO_* first */
|
|
|
|
memcpy(out, pDriversW, len);
|
|
|
|
|
|
|
|
#define COPY_STRING(fld) \
|
|
|
|
{ if (diW->fld){ \
|
|
|
|
diA->fld = ptr; \
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, diW->fld, -1, ptr, outlen, NULL, NULL);\
|
|
|
|
ptr += len; outlen -= len;\
|
|
|
|
}}
|
|
|
|
#define COPY_MULTIZ_STRING(fld) \
|
|
|
|
{ LPWSTR p = diW->fld; if (p){ \
|
|
|
|
diA->fld = ptr; \
|
|
|
|
do {\
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, p, -1, ptr, outlen, NULL, NULL);\
|
|
|
|
ptr += len; outlen -= len; p += len;\
|
|
|
|
}\
|
|
|
|
while(len > 1 && outlen > 0); \
|
|
|
|
}}
|
|
|
|
|
|
|
|
while (id < numentries)
|
|
|
|
{
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_1W * diW = (DRIVER_INFO_1W *) pDriversW;
|
|
|
|
DRIVER_INFO_1A * diA = (DRIVER_INFO_1A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_2W * diW = (DRIVER_INFO_2W *) pDriversW;
|
|
|
|
DRIVER_INFO_2A * diA = (DRIVER_INFO_2A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_3W * diW = (DRIVER_INFO_3W *) pDriversW;
|
|
|
|
DRIVER_INFO_3A * diA = (DRIVER_INFO_3A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
COPY_STRING(pHelpFile);
|
|
|
|
COPY_MULTIZ_STRING(pDependentFiles);
|
|
|
|
COPY_STRING(pMonitorName);
|
|
|
|
COPY_STRING(pDefaultDataType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_4W * diW = (DRIVER_INFO_4W *) pDriversW;
|
|
|
|
DRIVER_INFO_4A * diA = (DRIVER_INFO_4A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
COPY_STRING(pHelpFile);
|
|
|
|
COPY_MULTIZ_STRING(pDependentFiles);
|
|
|
|
COPY_STRING(pMonitorName);
|
|
|
|
COPY_STRING(pDefaultDataType);
|
|
|
|
COPY_MULTIZ_STRING(pszzPreviousNames);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_5W * diW = (DRIVER_INFO_5W *) pDriversW;
|
|
|
|
DRIVER_INFO_5A * diA = (DRIVER_INFO_5A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_6W * diW = (DRIVER_INFO_6W *) pDriversW;
|
|
|
|
DRIVER_INFO_6A * diA = (DRIVER_INFO_6A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
COPY_STRING(pHelpFile);
|
|
|
|
COPY_MULTIZ_STRING(pDependentFiles);
|
|
|
|
COPY_STRING(pMonitorName);
|
|
|
|
COPY_STRING(pDefaultDataType);
|
|
|
|
COPY_MULTIZ_STRING(pszzPreviousNames);
|
|
|
|
COPY_STRING(pszMfgName);
|
|
|
|
COPY_STRING(pszOEMUrl);
|
|
|
|
COPY_STRING(pszHardwareID);
|
|
|
|
COPY_STRING(pszProvider);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
DRIVER_INFO_8W * diW = (DRIVER_INFO_8W *) pDriversW;
|
|
|
|
DRIVER_INFO_8A * diA = (DRIVER_INFO_8A *) out;
|
|
|
|
|
|
|
|
TRACE("(%u) #%u: %s\n", level, id, debugstr_w(diW->pName));
|
|
|
|
|
|
|
|
COPY_STRING(pName);
|
|
|
|
COPY_STRING(pEnvironment);
|
|
|
|
COPY_STRING(pDriverPath);
|
|
|
|
COPY_STRING(pDataFile);
|
|
|
|
COPY_STRING(pConfigFile);
|
|
|
|
COPY_STRING(pHelpFile);
|
|
|
|
COPY_MULTIZ_STRING(pDependentFiles);
|
|
|
|
COPY_STRING(pMonitorName);
|
|
|
|
COPY_STRING(pDefaultDataType);
|
|
|
|
COPY_MULTIZ_STRING(pszzPreviousNames);
|
|
|
|
COPY_STRING(pszMfgName);
|
|
|
|
COPY_STRING(pszOEMUrl);
|
|
|
|
COPY_STRING(pszHardwareID);
|
|
|
|
COPY_STRING(pszProvider);
|
|
|
|
COPY_STRING(pszPrintProcessor);
|
|
|
|
COPY_STRING(pszVendorSetup);
|
|
|
|
COPY_MULTIZ_STRING(pszzColorProfiles);
|
|
|
|
COPY_STRING(pszInfPath);
|
|
|
|
COPY_MULTIZ_STRING(pszzCoreDriverDependencies);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("for level %u\n", level);
|
|
|
|
}
|
|
|
|
|
|
|
|
pDriversW += di_sizeof[level];
|
|
|
|
out += di_sizeof[level];
|
|
|
|
id++;
|
|
|
|
|
|
|
|
}
|
|
|
|
#undef COPY_STRING
|
|
|
|
#undef COPY_MULTIZ_STRING
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/***********************************************************
|
2012-04-05 14:25:48 +02:00
|
|
|
* printer_info_AtoW
|
2000-05-26 01:02:46 +02:00
|
|
|
*/
|
2012-04-05 14:25:48 +02:00
|
|
|
static void *printer_info_AtoW( const void *data, DWORD level )
|
2000-05-26 01:02:46 +02:00
|
|
|
{
|
2012-04-05 14:25:48 +02:00
|
|
|
void *ret;
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING usBuffer;
|
|
|
|
|
2012-04-05 14:25:48 +02:00
|
|
|
if (!data) return NULL;
|
|
|
|
|
|
|
|
if (level < 1 || level > 9) return NULL;
|
|
|
|
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, pi_sizeof[level] );
|
|
|
|
if (!ret) return NULL;
|
|
|
|
|
|
|
|
memcpy( ret, data, pi_sizeof[level] ); /* copy everything first */
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
const PRINTER_INFO_2A *piA = (const PRINTER_INFO_2A *)data;
|
|
|
|
PRINTER_INFO_2W *piW = (PRINTER_INFO_2W *)ret;
|
|
|
|
|
|
|
|
piW->pServerName = asciitounicode( &usBuffer, piA->pServerName );
|
|
|
|
piW->pPrinterName = asciitounicode( &usBuffer, piA->pPrinterName );
|
|
|
|
piW->pShareName = asciitounicode( &usBuffer, piA->pShareName );
|
|
|
|
piW->pPortName = asciitounicode( &usBuffer, piA->pPortName );
|
|
|
|
piW->pDriverName = asciitounicode( &usBuffer, piA->pDriverName );
|
|
|
|
piW->pComment = asciitounicode( &usBuffer, piA->pComment );
|
|
|
|
piW->pLocation = asciitounicode( &usBuffer, piA->pLocation );
|
|
|
|
piW->pDevMode = piA->pDevMode ? GdiConvertToDevmodeW( piA->pDevMode ) : NULL;
|
|
|
|
piW->pSepFile = asciitounicode( &usBuffer, piA->pSepFile );
|
|
|
|
piW->pPrintProcessor = asciitounicode( &usBuffer, piA->pPrintProcessor );
|
|
|
|
piW->pDatatype = asciitounicode( &usBuffer, piA->pDatatype );
|
|
|
|
piW->pParameters = asciitounicode( &usBuffer, piA->pParameters );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
const PRINTER_INFO_9A *piA = (const PRINTER_INFO_9A *)data;
|
|
|
|
PRINTER_INFO_9W *piW = (PRINTER_INFO_9W *)ret;
|
|
|
|
|
|
|
|
piW->pDevMode = piA->pDevMode ? GdiConvertToDevmodeW( piA->pDevMode ) : NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unhandled level %d\n", level );
|
|
|
|
HeapFree( GetProcessHeap(), 0, ret );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************
|
2012-04-05 14:25:48 +02:00
|
|
|
* free_printer_info
|
2000-05-26 01:02:46 +02:00
|
|
|
*/
|
2012-04-05 14:25:48 +02:00
|
|
|
static void free_printer_info( void *data, DWORD level )
|
2000-05-26 01:02:46 +02:00
|
|
|
{
|
2012-04-05 14:25:48 +02:00
|
|
|
if (!data) return;
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_2W *piW = (PRINTER_INFO_2W *)data;
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pServerName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pPrinterName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pShareName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pPortName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pDriverName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pComment );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pLocation );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pDevMode );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pSepFile );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pPrintProcessor );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pDatatype );
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pParameters );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_9W *piW = (PRINTER_INFO_9W *)data;
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, piW->pDevMode );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unhandled level %d\n", level );
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
2000-05-26 01:02:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/******************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* DeviceCapabilities [WINSPOOL.@]
|
|
|
|
* DeviceCapabilitiesA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
|
|
|
*/
|
2000-07-16 17:44:22 +02:00
|
|
|
INT WINAPI DeviceCapabilitiesA(LPCSTR pDevice,LPCSTR pPort, WORD cap,
|
1999-05-17 18:20:51 +02:00
|
|
|
LPSTR pOutput, LPDEVMODEA lpdm)
|
|
|
|
{
|
1999-09-10 16:37:29 +02:00
|
|
|
INT ret;
|
2000-11-29 19:38:24 +01:00
|
|
|
|
2012-12-17 10:40:38 +01:00
|
|
|
TRACE("%s,%s,%u,%p,%p\n", debugstr_a(pDevice), debugstr_a(pPort), cap, pOutput, lpdm);
|
|
|
|
|
2000-11-29 19:38:24 +01:00
|
|
|
if (!GDI_CallDeviceCapabilities16)
|
|
|
|
{
|
|
|
|
GDI_CallDeviceCapabilities16 = (void*)GetProcAddress( GetModuleHandleA("gdi32"),
|
|
|
|
(LPCSTR)104 );
|
|
|
|
if (!GDI_CallDeviceCapabilities16) return -1;
|
|
|
|
}
|
2000-07-16 17:44:22 +02:00
|
|
|
ret = GDI_CallDeviceCapabilities16(pDevice, pPort, cap, pOutput, lpdm);
|
1999-09-10 16:37:29 +02:00
|
|
|
|
|
|
|
/* If DC_PAPERSIZE map POINT16s to POINTs */
|
|
|
|
if(ret != -1 && cap == DC_PAPERSIZE && pOutput) {
|
|
|
|
POINT16 *tmp = HeapAlloc( GetProcessHeap(), 0, ret * sizeof(POINT16) );
|
2000-12-13 21:03:53 +01:00
|
|
|
POINT *pt = (POINT *)pOutput;
|
1999-09-10 16:37:29 +02:00
|
|
|
INT i;
|
|
|
|
memcpy(tmp, pOutput, ret * sizeof(POINT16));
|
2000-12-13 21:03:53 +01:00
|
|
|
for(i = 0; i < ret; i++, pt++)
|
|
|
|
{
|
|
|
|
pt->x = tmp[i].x;
|
|
|
|
pt->y = tmp[i].y;
|
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, tmp );
|
|
|
|
}
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeviceCapabilitiesW [WINSPOOL.@]
|
2000-05-26 01:02:46 +02:00
|
|
|
*
|
|
|
|
* Call DeviceCapabilitiesA since we later call 16bit stuff anyway
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort,
|
|
|
|
WORD fwCapability, LPWSTR pOutput,
|
|
|
|
const DEVMODEW *pDevMode)
|
|
|
|
{
|
2008-03-09 00:38:49 +01:00
|
|
|
LPDEVMODEA dmA = DEVMODEdupWtoA(pDevMode);
|
2006-11-17 15:29:40 +01:00
|
|
|
LPSTR pDeviceA = strdupWtoA(pDevice);
|
|
|
|
LPSTR pPortA = strdupWtoA(pPort);
|
2000-05-26 01:02:46 +02:00
|
|
|
INT ret;
|
|
|
|
|
2012-12-17 10:40:38 +01:00
|
|
|
TRACE("%s,%s,%u,%p,%p\n", debugstr_w(pDevice), debugstr_w(pPort), fwCapability, pOutput, pDevMode);
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pOutput && (fwCapability == DC_BINNAMES ||
|
|
|
|
fwCapability == DC_FILEDEPENDENCIES ||
|
|
|
|
fwCapability == DC_PAPERNAMES)) {
|
|
|
|
/* These need A -> W translation */
|
|
|
|
INT size = 0, i;
|
|
|
|
LPSTR pOutputA;
|
|
|
|
ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability, NULL,
|
|
|
|
dmA);
|
|
|
|
if(ret == -1)
|
|
|
|
return ret;
|
|
|
|
switch(fwCapability) {
|
|
|
|
case DC_BINNAMES:
|
|
|
|
size = 24;
|
|
|
|
break;
|
|
|
|
case DC_PAPERNAMES:
|
|
|
|
case DC_FILEDEPENDENCIES:
|
|
|
|
size = 64;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pOutputA = HeapAlloc(GetProcessHeap(), 0, size * ret);
|
|
|
|
ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability, pOutputA,
|
|
|
|
dmA);
|
|
|
|
for(i = 0; i < ret; i++)
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pOutputA + (i * size), -1,
|
|
|
|
pOutput + (i * size), size);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pOutputA);
|
|
|
|
} else {
|
|
|
|
ret = DeviceCapabilitiesA(pDeviceA, pPortA, fwCapability,
|
|
|
|
(LPSTR)pOutput, dmA);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(),0,pPortA);
|
|
|
|
HeapFree(GetProcessHeap(),0,pDeviceA);
|
|
|
|
HeapFree(GetProcessHeap(),0,dmA);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DocumentPropertiesA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
2003-08-12 22:42:18 +02:00
|
|
|
* FIXME: implement DocumentPropertiesA via DocumentPropertiesW, not vice versa
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
|
|
|
|
LPSTR pDeviceName, LPDEVMODEA pDevModeOutput,
|
|
|
|
LPDEVMODEA pDevModeInput,DWORD fMode )
|
|
|
|
{
|
2014-07-08 02:12:25 +02:00
|
|
|
LPSTR lpName = pDeviceName, dupname = NULL;
|
2006-08-16 22:00:14 +02:00
|
|
|
static CHAR port[] = "LPT1:";
|
2000-05-26 01:02:46 +02:00
|
|
|
LONG ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p,%p,%s,%p,%p,%d)\n",
|
1999-05-17 18:20:51 +02:00
|
|
|
hWnd,hPrinter,pDeviceName,pDevModeOutput,pDevModeInput,fMode
|
|
|
|
);
|
|
|
|
|
2013-04-05 09:41:29 +02:00
|
|
|
if(!pDeviceName || !*pDeviceName) {
|
2005-07-05 13:00:09 +02:00
|
|
|
LPCWSTR lpNameW = get_opened_printer_name(hPrinter);
|
2001-04-27 20:02:46 +02:00
|
|
|
if(!lpNameW) {
|
|
|
|
ERR("no name from hPrinter?\n");
|
2005-07-05 13:00:09 +02:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2001-04-27 20:02:46 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2014-07-08 02:12:25 +02:00
|
|
|
lpName = dupname = strdupWtoA(lpNameW);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2000-11-29 19:38:24 +01:00
|
|
|
if (!GDI_CallExtDeviceMode16)
|
|
|
|
{
|
|
|
|
GDI_CallExtDeviceMode16 = (void*)GetProcAddress( GetModuleHandleA("gdi32"),
|
|
|
|
(LPCSTR)102 );
|
2001-04-27 20:02:46 +02:00
|
|
|
if (!GDI_CallExtDeviceMode16) {
|
|
|
|
ERR("No CallExtDeviceMode16?\n");
|
2014-07-08 02:12:25 +02:00
|
|
|
ret = -1;
|
|
|
|
goto end;
|
2001-04-27 20:02:46 +02:00
|
|
|
}
|
2000-11-29 19:38:24 +01:00
|
|
|
}
|
2006-08-16 22:00:14 +02:00
|
|
|
ret = GDI_CallExtDeviceMode16(hWnd, pDevModeOutput, lpName, port,
|
2000-05-26 01:02:46 +02:00
|
|
|
pDevModeInput, NULL, fMode);
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2014-07-08 02:12:25 +02:00
|
|
|
end:
|
|
|
|
HeapFree(GetProcessHeap(), 0, dupname);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* DocumentPropertiesW (WINSPOOL.@)
|
2003-08-12 22:42:18 +02:00
|
|
|
*
|
|
|
|
* FIXME: implement DocumentPropertiesA via DocumentPropertiesW, not vice versa
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter,
|
2000-05-26 01:02:46 +02:00
|
|
|
LPWSTR pDeviceName,
|
|
|
|
LPDEVMODEW pDevModeOutput,
|
|
|
|
LPDEVMODEW pDevModeInput, DWORD fMode)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2006-11-17 15:29:40 +01:00
|
|
|
LPSTR pDeviceNameA = strdupWtoA(pDeviceName);
|
2012-11-01 16:08:29 +01:00
|
|
|
LPDEVMODEA pDevModeInputA;
|
2000-05-26 01:02:46 +02:00
|
|
|
LPDEVMODEA pDevModeOutputA = NULL;
|
|
|
|
LONG ret;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p,%p,%s,%p,%p,%d)\n",
|
1999-05-17 18:20:51 +02:00
|
|
|
hWnd,hPrinter,debugstr_w(pDeviceName),pDevModeOutput,pDevModeInput,
|
|
|
|
fMode);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pDevModeOutput) {
|
|
|
|
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, NULL, NULL, 0);
|
|
|
|
if(ret < 0) return ret;
|
|
|
|
pDevModeOutputA = HeapAlloc(GetProcessHeap(), 0, ret);
|
|
|
|
}
|
2013-06-14 05:18:49 +02:00
|
|
|
pDevModeInputA = (fMode & DM_IN_BUFFER) ? DEVMODEdupWtoA(pDevModeInput) : NULL;
|
2000-05-26 01:02:46 +02:00
|
|
|
ret = DocumentPropertiesA(hWnd, hPrinter, pDeviceNameA, pDevModeOutputA,
|
|
|
|
pDevModeInputA, fMode);
|
|
|
|
if(pDevModeOutput) {
|
|
|
|
DEVMODEcpyAtoW(pDevModeOutput, pDevModeOutputA);
|
|
|
|
HeapFree(GetProcessHeap(),0,pDevModeOutputA);
|
|
|
|
}
|
|
|
|
if(fMode == 0 && ret > 0)
|
|
|
|
ret += (CCHDEVICENAME + CCHFORMNAME);
|
|
|
|
HeapFree(GetProcessHeap(),0,pDevModeInputA);
|
2002-06-01 01:06:46 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,pDeviceNameA);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2011-05-09 08:27:09 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IsValidDevmodeA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
* Validate a DEVMODE structure and fix errors if possible.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsValidDevmodeA(PDEVMODEA *pDevMode, SIZE_T size)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%ld): stub\n", pDevMode, size);
|
|
|
|
|
|
|
|
if(!pDevMode)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IsValidDevmodeW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
* Validate a DEVMODE structure and fix errors if possible.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsValidDevmodeW(PDEVMODEW *pDevMode, SIZE_T size)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%ld): stub\n", pDevMode, size);
|
|
|
|
|
|
|
|
if(!pDevMode)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenPrinterA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
2005-12-12 12:10:13 +01:00
|
|
|
* See OpenPrinterW.
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
|
2000-05-26 01:02:46 +02:00
|
|
|
LPPRINTER_DEFAULTSA pDefault)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING lpPrinterNameW;
|
|
|
|
UNICODE_STRING usBuffer;
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_DEFAULTSW DefaultW, *pDefaultW = NULL;
|
2003-02-12 02:19:25 +01:00
|
|
|
PWSTR pwstrPrinterNameW;
|
2000-05-26 01:02:46 +02:00
|
|
|
BOOL ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2012-12-17 10:40:38 +01:00
|
|
|
TRACE("%s,%p,%p\n", debugstr_a(lpPrinterName), phPrinter, pDefault);
|
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
pwstrPrinterNameW = asciitounicode(&lpPrinterNameW,lpPrinterName);
|
2003-01-24 00:07:38 +01:00
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pDefault) {
|
2003-02-12 02:19:25 +01:00
|
|
|
DefaultW.pDatatype = asciitounicode(&usBuffer,pDefault->pDatatype);
|
2003-08-13 01:46:34 +02:00
|
|
|
DefaultW.pDevMode = pDefault->pDevMode ? GdiConvertToDevmodeW(pDefault->pDevMode) : NULL;
|
2000-05-26 01:02:46 +02:00
|
|
|
DefaultW.DesiredAccess = pDefault->DesiredAccess;
|
|
|
|
pDefaultW = &DefaultW;
|
|
|
|
}
|
2003-02-12 02:19:25 +01:00
|
|
|
ret = OpenPrinterW(pwstrPrinterNameW, phPrinter, pDefaultW);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pDefault) {
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlFreeUnicodeString(&usBuffer);
|
2000-05-26 01:02:46 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, DefaultW.pDevMode);
|
|
|
|
}
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlFreeUnicodeString(&lpPrinterNameW);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenPrinterW [WINSPOOL.@]
|
2000-05-26 01:02:46 +02:00
|
|
|
*
|
2005-12-12 12:10:13 +01:00
|
|
|
* Open a Printer / Printserver or a Printer-Object
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpPrinterName [I] Name of Printserver, Printer, or Printer-Object
|
|
|
|
* phPrinter [O] The resulting Handle is stored here
|
|
|
|
* pDefault [I] PTR to Default Printer Settings or NULL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* lpPrinterName is one of:
|
|
|
|
*| Printserver (NT only): "Servername" or NULL for the local Printserver
|
|
|
|
*| Printer: "PrinterName"
|
|
|
|
*| Printer-Object: "PrinterName,Job xxx"
|
|
|
|
*| XcvMonitor: "Servername,XcvMonitor MonitorName"
|
|
|
|
*| XcvPort: "Servername,XcvPort PortName"
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
*| Printer-Object not supported
|
2006-05-12 16:14:59 +02:00
|
|
|
*| pDefaults is ignored
|
2005-12-12 12:10:13 +01:00
|
|
|
*
|
2000-05-26 01:02:46 +02:00
|
|
|
*/
|
2006-05-12 16:14:59 +02:00
|
|
|
BOOL WINAPI OpenPrinterW(LPWSTR lpPrinterName,HANDLE *phPrinter, LPPRINTER_DEFAULTSW pDefault)
|
2000-05-26 01:02:46 +02:00
|
|
|
{
|
2014-05-30 03:04:56 +02:00
|
|
|
HKEY key;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-05-12 16:14:59 +02:00
|
|
|
TRACE("(%s, %p, %p)\n", debugstr_w(lpPrinterName), phPrinter, pDefault);
|
2000-02-25 22:38:17 +01:00
|
|
|
|
2006-05-12 16:14:59 +02:00
|
|
|
if(!phPrinter) {
|
|
|
|
/* NT: FALSE with ERROR_INVALID_PARAMETER, 9x: TRUE */
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
1999-09-10 16:37:29 +02:00
|
|
|
}
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-05-12 16:14:59 +02:00
|
|
|
/* Get the unique handle of the printer or Printserver */
|
|
|
|
*phPrinter = get_opened_printer_entry(lpPrinterName, pDefault);
|
2012-06-12 10:42:49 +02:00
|
|
|
|
2014-05-30 03:04:56 +02:00
|
|
|
if (*phPrinter && WINSPOOL_GetOpenedPrinterRegKey( *phPrinter, &key ) == ERROR_SUCCESS)
|
2012-06-12 10:42:49 +02:00
|
|
|
{
|
|
|
|
DWORD deleting = 0, size = sizeof( deleting ), type;
|
|
|
|
DWORD status;
|
|
|
|
RegQueryValueExW( key, May_Delete_Value, NULL, &type, (LPBYTE)&deleting, &size );
|
2012-06-21 13:59:02 +02:00
|
|
|
WaitForSingleObject( init_mutex, INFINITE );
|
2012-06-12 10:42:49 +02:00
|
|
|
status = get_dword_from_reg( key, StatusW );
|
2012-06-21 13:59:02 +02:00
|
|
|
set_reg_DWORD( key, StatusW, status & ~PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
|
|
|
|
ReleaseMutex( init_mutex );
|
2012-06-12 10:42:49 +02:00
|
|
|
if (!deleting && (status & PRINTER_STATUS_DRIVER_UPDATE_NEEDED))
|
|
|
|
update_driver( *phPrinter );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
|
2007-01-18 11:37:51 +01:00
|
|
|
TRACE("returning %d with %u and %p\n", *phPrinter != NULL, GetLastError(), *phPrinter);
|
2006-05-12 16:14:59 +02:00
|
|
|
return (*phPrinter != 0);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddMonitorA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
2005-12-06 11:33:52 +01:00
|
|
|
* See AddMonitorW.
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
1999-09-04 16:30:33 +02:00
|
|
|
BOOL WINAPI AddMonitorA(LPSTR pName, DWORD Level, LPBYTE pMonitors)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2006-04-11 20:42:18 +02:00
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
INT len;
|
|
|
|
BOOL res;
|
|
|
|
LPMONITOR_INFO_2A mi2a;
|
|
|
|
MONITOR_INFO_2W mi2w;
|
|
|
|
|
|
|
|
mi2a = (LPMONITOR_INFO_2A) pMonitors;
|
2008-06-23 17:10:04 +02:00
|
|
|
TRACE("(%s, %d, %p) : %s %s %s\n", debugstr_a(pName), Level, pMonitors,
|
|
|
|
debugstr_a(mi2a ? mi2a->pName : NULL),
|
|
|
|
debugstr_a(mi2a ? mi2a->pEnvironment : NULL),
|
|
|
|
debugstr_a(mi2a ? mi2a->pDLLName : NULL));
|
2006-04-11 20:42:18 +02:00
|
|
|
|
|
|
|
if (Level != 2) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XP: unchanged, win9x: ERROR_INVALID_ENVIRONMENT */
|
|
|
|
if (mi2a == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&mi2w, 0, sizeof(MONITOR_INFO_2W));
|
|
|
|
if (mi2a->pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, mi2a->pName, -1, NULL, 0);
|
|
|
|
mi2w.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi2a->pName, -1, mi2w.pName, len);
|
|
|
|
}
|
|
|
|
if (mi2a->pEnvironment) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, mi2a->pEnvironment, -1, NULL, 0);
|
|
|
|
mi2w.pEnvironment = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi2a->pEnvironment, -1, mi2w.pEnvironment, len);
|
|
|
|
}
|
|
|
|
if (mi2a->pDLLName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, mi2a->pDLLName, -1, NULL, 0);
|
|
|
|
mi2w.pDLLName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi2a->pDLLName, -1, mi2w.pDLLName, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = AddMonitorW(nameW, Level, (LPBYTE) &mi2w);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, mi2w.pName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, mi2w.pEnvironment);
|
|
|
|
HeapFree(GetProcessHeap(), 0, mi2w.pDLLName);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
return (res);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddMonitorW [WINSPOOL.@]
|
2005-12-06 11:33:52 +01:00
|
|
|
*
|
|
|
|
* Install a Printmonitor
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* Level [I] Structure-Level (Must be 2)
|
|
|
|
* pMonitors [I] PTR to MONITOR_INFO_2
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* All Files for the Monitor must already be copied to %winsysdir% ("%SystemRoot%\system32")
|
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AddMonitorW(LPWSTR pName, DWORD Level, LPBYTE pMonitors)
|
|
|
|
{
|
2006-04-11 20:42:18 +02:00
|
|
|
LPMONITOR_INFO_2W mi2w;
|
|
|
|
|
|
|
|
mi2w = (LPMONITOR_INFO_2W) pMonitors;
|
2008-06-23 17:10:04 +02:00
|
|
|
TRACE("(%s, %d, %p) : %s %s %s\n", debugstr_w(pName), Level, pMonitors,
|
|
|
|
debugstr_w(mi2w ? mi2w->pName : NULL),
|
|
|
|
debugstr_w(mi2w ? mi2w->pEnvironment : NULL),
|
|
|
|
debugstr_w(mi2w ? mi2w->pDLLName : NULL));
|
2006-04-11 20:42:18 +02:00
|
|
|
|
2008-09-18 22:40:09 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
|
|
|
|
2006-04-11 20:42:18 +02:00
|
|
|
if (Level != 2) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XP: unchanged, win9x: ERROR_INVALID_ENVIRONMENT */
|
|
|
|
if (mi2w == NULL) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-09-18 22:40:09 +02:00
|
|
|
return backend->fpAddMonitor(pName, Level, pMonitors);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeletePrinterDriverA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
|
|
|
*/
|
2006-11-07 12:57:39 +01:00
|
|
|
BOOL WINAPI DeletePrinterDriverA (LPSTR pName, LPSTR pEnvironment, LPSTR pDriverName)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2006-11-07 12:57:39 +01:00
|
|
|
return DeletePrinterDriverExA(pName, pEnvironment, pDriverName, 0, 0);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************
|
|
|
|
* DeletePrinterDriverW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
2006-11-07 12:57:39 +01:00
|
|
|
BOOL WINAPI DeletePrinterDriverW (LPWSTR pName, LPWSTR pEnvironment, LPWSTR pDriverName)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2006-11-07 12:57:39 +01:00
|
|
|
return DeletePrinterDriverExW(pName, pEnvironment, pDriverName, 0, 0);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
1999-05-17 18:20:51 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeleteMonitorA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
2005-12-06 11:33:52 +01:00
|
|
|
* See DeleteMonitorW.
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2006-04-16 02:56:27 +02:00
|
|
|
BOOL WINAPI DeleteMonitorA (LPSTR pName, LPSTR pEnvironment, LPSTR pMonitorName)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2006-04-16 02:56:27 +02:00
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR EnvironmentW = NULL;
|
|
|
|
LPWSTR MonitorNameW = NULL;
|
|
|
|
BOOL res;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pEnvironment) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pEnvironment, -1, NULL, 0);
|
|
|
|
EnvironmentW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pEnvironment, -1, EnvironmentW, len);
|
|
|
|
}
|
|
|
|
if (pMonitorName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, NULL, 0);
|
|
|
|
MonitorNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, MonitorNameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = DeleteMonitorW(nameW, EnvironmentW, MonitorNameW);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, MonitorNameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, EnvironmentW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
return (res);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************
|
|
|
|
* DeleteMonitorW [WINSPOOL.@]
|
|
|
|
*
|
2005-12-06 11:33:52 +01:00
|
|
|
* Delete a specific Printmonitor from a Printing-Environment
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* pEnvironment [I] Printing-Environment of the Monitor or NULL (Default)
|
|
|
|
* pMonitorName [I] Name of the Monitor, that should be deleted
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
2006-04-16 02:56:27 +02:00
|
|
|
* NOTES
|
|
|
|
* pEnvironment is ignored in Windows for the local Computer.
|
2005-12-06 11:33:52 +01:00
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
2008-07-10 23:59:37 +02:00
|
|
|
BOOL WINAPI DeleteMonitorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMonitorName)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2006-04-16 02:56:27 +02:00
|
|
|
|
|
|
|
TRACE("(%s, %s, %s)\n",debugstr_w(pName),debugstr_w(pEnvironment),
|
|
|
|
debugstr_w(pMonitorName));
|
|
|
|
|
2008-07-10 23:59:37 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-04-16 02:56:27 +02:00
|
|
|
|
2008-07-10 23:59:37 +02:00
|
|
|
return backend->fpDeleteMonitor(pName, pEnvironment, pMonitorName);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2008-07-10 23:59:37 +02:00
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeletePortA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
2005-12-06 10:57:01 +01:00
|
|
|
* See DeletePortW.
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2006-11-28 00:47:08 +01:00
|
|
|
BOOL WINAPI DeletePortA (LPSTR pName, HWND hWnd, LPSTR pPortName)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2006-11-28 00:47:08 +01:00
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR portW = NULL;
|
|
|
|
INT len;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %s)\n", debugstr_a(pName), hWnd, debugstr_a(pPortName));
|
|
|
|
|
|
|
|
/* convert servername to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert portname to unicode */
|
|
|
|
if (pPortName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pPortName, -1, NULL, 0);
|
|
|
|
portW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPortName, -1, portW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = DeletePortW(nameW, hWnd, portW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, portW);
|
|
|
|
return res;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************
|
|
|
|
* DeletePortW [WINSPOOL.@]
|
|
|
|
*
|
2005-12-06 10:57:01 +01:00
|
|
|
* Delete a specific Port
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* hWnd [I] Handle to parent Window for the Dialog-Box
|
|
|
|
* pPortName [I] Name of the Port, that should be deleted
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
2006-11-28 00:46:28 +01:00
|
|
|
BOOL WINAPI DeletePortW (LPWSTR pName, HWND hWnd, LPWSTR pPortName)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2006-11-28 00:46:28 +01:00
|
|
|
TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
|
|
|
|
|
2009-09-28 13:32:07 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-11-28 00:46:28 +01:00
|
|
|
|
|
|
|
if (!pPortName) {
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-28 13:32:07 +02:00
|
|
|
return backend->fpDeletePort(pName, hWnd, pPortName);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/******************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* WritePrinter [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2005-07-08 16:19:18 +02:00
|
|
|
BOOL WINAPI WritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten)
|
|
|
|
{
|
|
|
|
opened_printer_t *printer;
|
|
|
|
BOOL ret = FALSE;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %p, %d, %p)\n", hPrinter, pBuf, cbBuf, pcWritten);
|
2005-07-08 16:19:18 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!printer->doc)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_SPL_NO_STARTDOC);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = WriteFile(printer->doc->hf, pBuf, cbBuf, pcWritten, NULL);
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddFormA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AddFormA(HANDLE hPrinter, DWORD Level, LPBYTE pForm)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%d,%p): stub\n", hPrinter, Level, pForm);
|
2014-01-27 22:26:48 +01:00
|
|
|
return TRUE;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddFormW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AddFormW(HANDLE hPrinter, DWORD Level, LPBYTE pForm)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%d,%p): stub\n", hPrinter, Level, pForm);
|
2014-01-27 22:26:48 +01:00
|
|
|
return TRUE;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddJobA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2005-07-06 17:44:15 +02:00
|
|
|
BOOL WINAPI AddJobA(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2005-07-06 17:44:15 +02:00
|
|
|
BOOL ret;
|
|
|
|
BYTE buf[MAX_PATH * sizeof(WCHAR) + sizeof(ADDJOB_INFO_1W)];
|
|
|
|
DWORD needed;
|
|
|
|
|
|
|
|
if(Level != 1) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = AddJobW(hPrinter, Level, buf, sizeof(buf), &needed);
|
|
|
|
|
|
|
|
if(ret) {
|
|
|
|
ADDJOB_INFO_1W *addjobW = (ADDJOB_INFO_1W*)buf;
|
|
|
|
DWORD len = WideCharToMultiByte(CP_ACP, 0, addjobW->Path, -1, NULL, 0, NULL, NULL);
|
|
|
|
*pcbNeeded = len + sizeof(ADDJOB_INFO_1A);
|
|
|
|
if(*pcbNeeded > cbBuf) {
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
ret = FALSE;
|
|
|
|
} else {
|
|
|
|
ADDJOB_INFO_1A *addjobA = (ADDJOB_INFO_1A*)pData;
|
|
|
|
addjobA->JobId = addjobW->JobId;
|
|
|
|
addjobA->Path = (char *)(addjobA + 1);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, addjobW->Path, -1, addjobA->Path, len, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddJobW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2005-07-06 17:44:15 +02:00
|
|
|
BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2005-07-06 17:44:15 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
job_t *job;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
static const WCHAR spool_path[] = {'s','p','o','o','l','\\','P','R','I','N','T','E','R','S','\\',0};
|
|
|
|
static const WCHAR fmtW[] = {'%','s','%','0','5','d','.','S','P','L',0};
|
|
|
|
WCHAR path[MAX_PATH], filename[MAX_PATH];
|
|
|
|
DWORD len;
|
|
|
|
ADDJOB_INFO_1W *addjob;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p,%d,%p,%d,%p)\n", hPrinter, Level, pData, cbBuf, pcbNeeded);
|
2005-07-06 17:44:15 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
|
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
|
|
|
|
if(!printer) {
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(Level != 1) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
job = HeapAlloc(GetProcessHeap(), 0, sizeof(*job));
|
|
|
|
if(!job)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
job->job_id = InterlockedIncrement(&next_job_id);
|
|
|
|
|
|
|
|
len = GetSystemDirectoryW(path, sizeof(path) / sizeof(WCHAR));
|
|
|
|
if(path[len - 1] != '\\')
|
|
|
|
path[len++] = '\\';
|
|
|
|
memcpy(path + len, spool_path, sizeof(spool_path));
|
|
|
|
sprintfW(filename, fmtW, path, job->job_id);
|
|
|
|
|
|
|
|
len = strlenW(filename);
|
|
|
|
job->filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
|
|
|
memcpy(job->filename, filename, (len + 1) * sizeof(WCHAR));
|
2012-04-03 12:43:38 +02:00
|
|
|
job->portname = NULL;
|
2005-07-15 11:55:23 +02:00
|
|
|
job->document_title = strdupW(default_doc_title);
|
2010-09-13 17:28:56 +02:00
|
|
|
job->printer_name = strdupW(printer->name);
|
2012-04-02 12:42:36 +02:00
|
|
|
job->devmode = dup_devmode( printer->devmode );
|
2005-07-19 21:12:13 +02:00
|
|
|
list_add_tail(&printer->queue->jobs, &job->entry);
|
2005-07-06 17:44:15 +02:00
|
|
|
|
|
|
|
*pcbNeeded = (len + 1) * sizeof(WCHAR) + sizeof(*addjob);
|
|
|
|
if(*pcbNeeded <= cbBuf) {
|
|
|
|
addjob = (ADDJOB_INFO_1W*)pData;
|
|
|
|
addjob->JobId = job->job_id;
|
|
|
|
addjob->Path = (WCHAR *)(addjob + 1);
|
|
|
|
memcpy(addjob->Path, filename, (len + 1) * sizeof(WCHAR));
|
|
|
|
ret = TRUE;
|
|
|
|
} else
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2003-04-27 22:35:08 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* GetPrintProcessorDirectoryA [WINSPOOL.@]
|
2006-05-27 00:30:58 +02:00
|
|
|
*
|
|
|
|
* Return the PATH for the Print-Processors
|
|
|
|
*
|
|
|
|
* See GetPrintProcessorDirectoryW.
|
|
|
|
*
|
|
|
|
*
|
2003-04-27 22:35:08 +02:00
|
|
|
*/
|
2003-11-27 01:59:36 +01:00
|
|
|
BOOL WINAPI GetPrintProcessorDirectoryA(LPSTR server, LPSTR env,
|
2003-04-27 22:35:08 +02:00
|
|
|
DWORD level, LPBYTE Info,
|
2006-06-09 13:06:41 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
2003-04-27 22:35:08 +02:00
|
|
|
{
|
2006-06-09 13:06:41 +02:00
|
|
|
LPWSTR serverW = NULL;
|
|
|
|
LPWSTR envW = NULL;
|
|
|
|
BOOL ret;
|
|
|
|
INT len;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_a(server),
|
2006-06-09 13:06:41 +02:00
|
|
|
debugstr_a(env), level, Info, cbBuf, pcbNeeded);
|
|
|
|
|
|
|
|
|
|
|
|
if (server) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, server, -1, NULL, 0);
|
|
|
|
serverW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, server, -1, serverW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, env, -1, NULL, 0);
|
|
|
|
envW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, env, -1, envW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NT requires the buffersize from GetPrintProcessorDirectoryW also
|
|
|
|
for GetPrintProcessorDirectoryA and WC2MB is done in-place.
|
|
|
|
*/
|
|
|
|
ret = GetPrintProcessorDirectoryW(serverW, envW, level, Info,
|
|
|
|
cbBuf, pcbNeeded);
|
|
|
|
|
|
|
|
if (ret) ret = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)Info, -1, (LPSTR)Info,
|
|
|
|
cbBuf, NULL, NULL) > 0;
|
|
|
|
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE(" required: 0x%x/%d\n", pcbNeeded ? *pcbNeeded : 0, pcbNeeded ? *pcbNeeded : 0);
|
2006-06-09 13:06:41 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, envW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, serverW);
|
|
|
|
return ret;
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GetPrintProcessorDirectoryW [WINSPOOL.@]
|
2006-05-27 00:30:58 +02:00
|
|
|
*
|
|
|
|
* Return the PATH for the Print-Processors
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* server [I] Servername (NT only) or NULL (local Computer)
|
|
|
|
* env [I] Printing-Environment (see below) or NULL (Default)
|
|
|
|
* level [I] Structure-Level (must be 1)
|
|
|
|
* Info [O] PTR to Buffer that receives the Result
|
|
|
|
* cbBuf [I] Size of Buffer at "Info"
|
2006-05-28 21:56:52 +02:00
|
|
|
* pcbNeeded [O] PTR to DWORD that receives the size in Bytes used /
|
2006-05-27 00:30:58 +02:00
|
|
|
* required for the Buffer at "Info"
|
|
|
|
*
|
|
|
|
* RETURNS
|
2006-05-28 21:56:52 +02:00
|
|
|
* Success: TRUE and in pcbNeeded the Bytes used in Info
|
|
|
|
* Failure: FALSE and in pcbNeeded the Bytes required for Info,
|
2006-05-27 00:30:58 +02:00
|
|
|
* if cbBuf is too small
|
|
|
|
*
|
2006-05-28 21:56:52 +02:00
|
|
|
* Native Values returned in Info on Success:
|
2006-05-27 00:30:58 +02:00
|
|
|
*| NT(Windows NT x86): "%winsysdir%\\spool\\PRTPROCS\\w32x86"
|
|
|
|
*| NT(Windows 4.0): "%winsysdir%\\spool\\PRTPROCS\\win40"
|
|
|
|
*| win9x(Windows 4.0): "%winsysdir%"
|
|
|
|
*
|
|
|
|
* "%winsysdir%" is the Value from GetSystemDirectoryW()
|
|
|
|
*
|
|
|
|
* BUGS
|
2006-05-28 21:56:52 +02:00
|
|
|
* Only NULL or "" is supported for server
|
2006-05-27 00:30:58 +02:00
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env,
|
|
|
|
DWORD level, LPBYTE Info,
|
2006-05-28 21:56:52 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2006-05-28 21:56:52 +02:00
|
|
|
|
2009-10-16 14:56:34 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(server), debugstr_w(env), level,
|
|
|
|
Info, cbBuf, pcbNeeded);
|
2006-05-28 21:56:52 +02:00
|
|
|
|
2009-10-16 14:56:34 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-05-28 21:56:52 +02:00
|
|
|
|
2009-10-16 14:56:34 +02:00
|
|
|
if (level != 1) {
|
|
|
|
/* (Level != 1) is ignored in win9x */
|
2006-05-28 21:56:52 +02:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-10-16 14:56:34 +02:00
|
|
|
if (pcbNeeded == NULL) {
|
|
|
|
/* (pcbNeeded == NULL) is ignored in win9x */
|
2006-05-28 21:56:52 +02:00
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-16 14:56:34 +02:00
|
|
|
|
|
|
|
return backend->fpGetPrintProcessorDirectory(server, env, level, Info, cbBuf, pcbNeeded);
|
2003-04-27 22:35:08 +02:00
|
|
|
}
|
|
|
|
|
2000-11-06 06:26:00 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* WINSPOOL_OpenDriverReg [internal]
|
|
|
|
*
|
|
|
|
* opens the registry for the printer drivers depending on the given input
|
|
|
|
* variable pEnvironment
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* the opened hkey on success
|
2002-06-01 01:06:46 +02:00
|
|
|
* NULL on error
|
2000-11-06 06:26:00 +01:00
|
|
|
*/
|
2009-12-01 00:03:58 +01:00
|
|
|
static HKEY WINSPOOL_OpenDriverReg( LPCVOID pEnvironment)
|
2005-03-29 15:10:35 +02:00
|
|
|
{
|
2006-05-11 23:59:17 +02:00
|
|
|
HKEY retval = NULL;
|
|
|
|
LPWSTR buffer;
|
|
|
|
const printenv_t * env;
|
2000-11-06 06:26:00 +01:00
|
|
|
|
2009-12-01 00:03:58 +01:00
|
|
|
TRACE("(%s)\n", debugstr_w(pEnvironment));
|
2000-11-06 06:26:00 +01:00
|
|
|
|
2009-12-01 00:03:58 +01:00
|
|
|
env = validate_envW(pEnvironment);
|
2006-05-11 23:59:17 +02:00
|
|
|
if (!env) return NULL;
|
|
|
|
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
(strlenW(DriversW) + strlenW(env->envname) +
|
|
|
|
strlenW(env->versionregpath) + 1) * sizeof(WCHAR));
|
|
|
|
if(buffer) {
|
|
|
|
wsprintfW(buffer, DriversW, env->envname, env->versionregpath);
|
|
|
|
RegCreateKeyW(HKEY_LOCAL_MACHINE, buffer, &retval);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
2000-11-06 06:26:00 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-10-18 17:49:17 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* set_devices_and_printerports [internal]
|
|
|
|
*
|
|
|
|
* set the [Devices] and [PrinterPorts] entries for a printer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
|
|
|
|
{
|
|
|
|
DWORD portlen = lstrlenW(pi->pPortName) * sizeof(WCHAR);
|
|
|
|
WCHAR *devline;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
TRACE("(%p) %s\n", pi, debugstr_w(pi->pPrinterName));
|
|
|
|
|
|
|
|
/* FIXME: the driver must change to "winspool" */
|
|
|
|
devline = HeapAlloc(GetProcessHeap(), 0, sizeof(driver_nt) + portlen + sizeof(timeout_15_45));
|
|
|
|
if (devline) {
|
|
|
|
lstrcpyW(devline, driver_nt);
|
|
|
|
lstrcatW(devline, commaW);
|
|
|
|
lstrcatW(devline, pi->pPortName);
|
|
|
|
|
|
|
|
TRACE("using %s\n", debugstr_w(devline));
|
|
|
|
WriteProfileStringW(devicesW, pi->pPrinterName, devline);
|
|
|
|
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey)) {
|
|
|
|
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
|
|
|
|
(lstrlenW(devline) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcatW(devline, timeout_15_45);
|
|
|
|
WriteProfileStringW(PrinterPortsW, pi->pPrinterName, devline);
|
|
|
|
if (!RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey)) {
|
|
|
|
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
|
|
|
|
(lstrlenW(devline) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, devline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddPrinterW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_INFO_2W *pi = (PRINTER_INFO_2W *) pPrinter;
|
2012-04-05 14:25:50 +02:00
|
|
|
LPDEVMODEW dm;
|
1999-05-22 20:53:56 +02:00
|
|
|
HANDLE retval;
|
|
|
|
HKEY hkeyPrinter, hkeyPrinters, hkeyDriver, hkeyDrivers;
|
2000-05-26 01:02:46 +02:00
|
|
|
LONG size;
|
1999-05-22 20:53:56 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s,%d,%p)\n", debugstr_w(pName), Level, pPrinter);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2015-07-29 11:39:01 +02:00
|
|
|
if(pName && *pName) {
|
2001-04-27 20:02:46 +02:00
|
|
|
ERR("pName = %s - unsupported\n", debugstr_w(pName));
|
1999-05-22 20:53:56 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(Level != 2) {
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR("Level = %d, unsupported!\n", Level);
|
1999-05-22 20:53:56 +02:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(!pPrinter) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-05-21 14:35:29 +02:00
|
|
|
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
|
1999-05-22 20:53:56 +02:00
|
|
|
ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Printers key\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-09 19:10:41 +02:00
|
|
|
if(!RegOpenKeyW(hkeyPrinters, pi->pPrinterName, &hkeyPrinter)) {
|
2012-05-22 17:36:25 +02:00
|
|
|
if (!RegQueryValueW(hkeyPrinter, AttributesW, NULL, NULL)) {
|
2001-05-09 19:10:41 +02:00
|
|
|
SetLastError(ERROR_PRINTER_ALREADY_EXISTS);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-05-22 20:53:56 +02:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
}
|
2009-12-01 00:03:58 +01:00
|
|
|
hkeyDrivers = WINSPOOL_OpenDriverReg(NULL);
|
2000-11-06 06:26:00 +01:00
|
|
|
if(!hkeyDrivers) {
|
1999-05-22 20:53:56 +02:00
|
|
|
ERR("Can't create Drivers key\n");
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if(RegOpenKeyW(hkeyDrivers, pi->pDriverName, &hkeyDriver) !=
|
1999-05-22 20:53:56 +02:00
|
|
|
ERROR_SUCCESS) {
|
2000-05-26 01:02:46 +02:00
|
|
|
WARN("Can't find driver %s\n", debugstr_w(pi->pDriverName));
|
1999-05-22 20:53:56 +02:00
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
RegCloseKey(hkeyDrivers);
|
2000-05-26 01:02:46 +02:00
|
|
|
|
|
|
|
if(lstrcmpiW(pi->pPrintProcessor, WinPrintW)) { /* FIXME */
|
2001-04-27 20:02:46 +02:00
|
|
|
FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor));
|
1999-05-22 20:53:56 +02:00
|
|
|
SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return 0;
|
|
|
|
}
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2001-05-09 19:10:41 +02:00
|
|
|
if(RegCreateKeyW(hkeyPrinters, pi->pPrinterName, &hkeyPrinter) !=
|
|
|
|
ERROR_SUCCESS) {
|
|
|
|
FIXME("Can't create printer %s\n", debugstr_w(pi->pPrinterName));
|
|
|
|
SetLastError(ERROR_INVALID_PRINTER_NAME);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-10-18 17:49:17 +02:00
|
|
|
|
|
|
|
set_devices_and_printerports(pi);
|
2012-06-15 13:53:52 +02:00
|
|
|
|
2012-06-13 16:41:39 +02:00
|
|
|
set_reg_DWORD(hkeyPrinter, AttributesW, pi->Attributes);
|
2001-10-28 22:16:38 +01:00
|
|
|
set_reg_szW(hkeyPrinter, DatatypeW, pi->pDatatype);
|
2012-06-15 13:53:53 +02:00
|
|
|
set_reg_DWORD(hkeyPrinter, Default_PriorityW, pi->DefaultPriority);
|
2012-06-15 13:53:52 +02:00
|
|
|
set_reg_szW(hkeyPrinter, DescriptionW, pi->pComment);
|
|
|
|
set_reg_DWORD(hkeyPrinter, dnsTimeoutW, 0);
|
|
|
|
set_reg_szW(hkeyPrinter, LocationW, pi->pLocation);
|
|
|
|
set_reg_szW(hkeyPrinter, NameW, pi->pPrinterName);
|
|
|
|
set_reg_szW(hkeyPrinter, ParametersW, pi->pParameters);
|
|
|
|
set_reg_szW(hkeyPrinter, PortW, pi->pPortName);
|
|
|
|
set_reg_szW(hkeyPrinter, Print_ProcessorW, pi->pPrintProcessor);
|
|
|
|
set_reg_szW(hkeyPrinter, Printer_DriverW, pi->pDriverName);
|
|
|
|
set_reg_DWORD(hkeyPrinter, PriorityW, pi->Priority);
|
|
|
|
set_reg_szW(hkeyPrinter, Separator_FileW, pi->pSepFile);
|
|
|
|
set_reg_szW(hkeyPrinter, Share_NameW, pi->pShareName);
|
|
|
|
set_reg_DWORD(hkeyPrinter, StartTimeW, pi->StartTime);
|
|
|
|
set_reg_DWORD(hkeyPrinter, StatusW, pi->Status);
|
|
|
|
set_reg_DWORD(hkeyPrinter, txTimeoutW, 0);
|
|
|
|
set_reg_DWORD(hkeyPrinter, UntilTimeW, pi->UntilTime);
|
2001-05-09 19:10:41 +02:00
|
|
|
|
2002-10-04 02:27:10 +02:00
|
|
|
size = DocumentPropertiesW(0, 0, pi->pPrinterName, NULL, NULL, 0);
|
2003-06-23 21:52:55 +02:00
|
|
|
|
2012-06-15 13:53:52 +02:00
|
|
|
if (size < 0)
|
|
|
|
{
|
2007-01-18 11:37:51 +01:00
|
|
|
FIXME("DocumentPropertiesW on printer %s fails\n", debugstr_w(pi->pPrinterName));
|
2012-06-15 13:53:52 +02:00
|
|
|
size = sizeof(DEVMODEW);
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
2001-05-09 19:10:41 +02:00
|
|
|
if(pi->pDevMode)
|
2012-04-05 14:25:50 +02:00
|
|
|
dm = pi->pDevMode;
|
2007-04-25 00:57:55 +02:00
|
|
|
else
|
2003-06-23 21:52:55 +02:00
|
|
|
{
|
2012-04-05 14:25:50 +02:00
|
|
|
dm = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
|
|
|
|
dm->dmSize = size;
|
|
|
|
if (DocumentPropertiesW(0, 0, pi->pPrinterName, dm, NULL, DM_OUT_BUFFER) < 0)
|
2003-06-23 21:52:55 +02:00
|
|
|
{
|
2007-01-18 11:37:51 +01:00
|
|
|
WARN("DocumentPropertiesW on printer %s failed!\n", debugstr_w(pi->pPrinterName));
|
2012-04-05 14:25:50 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, dm );
|
|
|
|
dm = NULL;
|
2006-06-15 12:36:00 +02:00
|
|
|
}
|
2003-06-23 21:52:55 +02:00
|
|
|
else
|
|
|
|
{
|
2006-06-15 12:36:00 +02:00
|
|
|
/* set devmode to printer name */
|
2012-04-05 14:25:50 +02:00
|
|
|
lstrcpynW( dm->dmDeviceName, pi->pPrinterName, CCHDEVICENAME );
|
2003-06-23 21:52:55 +02:00
|
|
|
}
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
|
|
|
|
2012-05-22 17:36:25 +02:00
|
|
|
set_reg_devmode( hkeyPrinter, Default_DevModeW, dm );
|
2012-04-05 14:25:50 +02:00
|
|
|
if (!pi->pDevMode) HeapFree( GetProcessHeap(), 0, dm );
|
|
|
|
|
1999-05-22 20:53:56 +02:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(!OpenPrinterW(pi->pPrinterName, &retval, NULL)) {
|
1999-05-22 20:53:56 +02:00
|
|
|
ERR("OpenPrinter failing\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return retval;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddPrinterA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
HANDLE WINAPI AddPrinterA(LPSTR pName, DWORD Level, LPBYTE pPrinter)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING pNameW;
|
2003-02-12 02:19:25 +01:00
|
|
|
PWSTR pwstrNameW;
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_INFO_2W *piW;
|
|
|
|
PRINTER_INFO_2A *piA = (PRINTER_INFO_2A*)pPrinter;
|
|
|
|
HANDLE ret;
|
|
|
|
|
2011-02-11 17:25:34 +01:00
|
|
|
TRACE("(%s, %d, %p)\n", debugstr_a(pName), Level, pPrinter);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(Level != 2) {
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR("Level = %d, unsupported!\n", Level);
|
2000-05-26 01:02:46 +02:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return 0;
|
|
|
|
}
|
2003-02-12 02:19:25 +01:00
|
|
|
pwstrNameW = asciitounicode(&pNameW,pName);
|
2012-04-05 14:25:48 +02:00
|
|
|
piW = printer_info_AtoW( piA, Level );
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
ret = AddPrinterW(pwstrNameW, Level, (LPBYTE)piW);
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2012-04-05 14:25:48 +02:00
|
|
|
free_printer_info( piW, Level );
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlFreeUnicodeString(&pNameW);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ClosePrinter [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ClosePrinter(HANDLE hPrinter)
|
|
|
|
{
|
2005-09-29 15:34:34 +02:00
|
|
|
UINT_PTR i = (UINT_PTR)hPrinter;
|
2005-07-05 13:00:09 +02:00
|
|
|
opened_printer_t *printer = NULL;
|
2005-07-06 17:44:15 +02:00
|
|
|
BOOL ret = FALSE;
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2007-01-15 05:38:22 +01:00
|
|
|
TRACE("(%p)\n", hPrinter);
|
1999-08-15 18:34:22 +02:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
|
|
|
|
if ((i > 0) && (i <= nb_printer_handles))
|
|
|
|
printer = printer_handles[i - 1];
|
|
|
|
|
2007-01-15 05:38:22 +01:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
if(printer)
|
|
|
|
{
|
2005-07-06 17:44:15 +02:00
|
|
|
struct list *cursor, *cursor2;
|
2005-07-08 16:19:18 +02:00
|
|
|
|
2009-05-07 00:11:33 +02:00
|
|
|
TRACE("closing %s (doc: %p)\n", debugstr_w(printer->name), printer->doc);
|
2007-01-15 05:38:22 +01:00
|
|
|
|
2009-05-05 05:24:34 +02:00
|
|
|
if (printer->backend_printer) {
|
|
|
|
backend->fpClosePrinter(printer->backend_printer);
|
|
|
|
}
|
|
|
|
|
2005-07-08 16:19:18 +02:00
|
|
|
if(printer->doc)
|
|
|
|
EndDocPrinter(hPrinter);
|
|
|
|
|
2005-07-19 21:12:13 +02:00
|
|
|
if(InterlockedDecrement(&printer->queue->ref) == 0)
|
2005-07-06 17:44:15 +02:00
|
|
|
{
|
2005-07-19 21:12:13 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &printer->queue->jobs)
|
|
|
|
{
|
|
|
|
job_t *job = LIST_ENTRY(cursor, job_t, entry);
|
|
|
|
ScheduleJob(hPrinter, job->job_id);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, printer->queue);
|
2005-07-06 17:44:15 +02:00
|
|
|
}
|
2009-05-07 00:11:33 +02:00
|
|
|
|
2012-03-30 15:39:41 +02:00
|
|
|
free_printer_entry( printer );
|
2005-07-06 17:44:15 +02:00
|
|
|
printer_handles[i - 1] = NULL;
|
|
|
|
ret = TRUE;
|
2005-07-05 13:00:09 +02:00
|
|
|
}
|
2005-07-06 17:44:15 +02:00
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeleteFormA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteFormA(HANDLE hPrinter, LPSTR pFormName)
|
|
|
|
{
|
2002-10-22 02:47:33 +02:00
|
|
|
FIXME("(%p,%s): stub\n", hPrinter, pFormName);
|
2014-01-27 22:26:48 +01:00
|
|
|
return TRUE;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeleteFormW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteFormW(HANDLE hPrinter, LPWSTR pFormName)
|
|
|
|
{
|
2002-10-22 02:47:33 +02:00
|
|
|
FIXME("(%p,%s): stub\n", hPrinter, debugstr_w(pFormName));
|
2014-01-27 22:26:48 +01:00
|
|
|
return TRUE;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
2003-11-05 01:36:47 +01:00
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* DeletePrinter [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrinter(HANDLE hPrinter)
|
|
|
|
{
|
2005-07-05 13:00:09 +02:00
|
|
|
LPCWSTR lpNameW = get_opened_printer_name(hPrinter);
|
2005-03-31 12:06:46 +02:00
|
|
|
HKEY hkeyPrinters, hkey;
|
2012-04-20 12:19:28 +02:00
|
|
|
WCHAR def[MAX_PATH];
|
|
|
|
DWORD size = sizeof( def ) / sizeof( def[0] );
|
2000-05-26 01:02:46 +02:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
if(!lpNameW) {
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-05-21 14:35:29 +02:00
|
|
|
if(RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) == ERROR_SUCCESS) {
|
2007-06-05 18:47:17 +02:00
|
|
|
RegDeleteTreeW(hkeyPrinters, lpNameW);
|
2003-11-05 01:36:47 +01:00
|
|
|
RegCloseKey(hkeyPrinters);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2003-11-05 01:36:47 +01:00
|
|
|
WriteProfileStringW(devicesW, lpNameW, NULL);
|
2008-05-06 20:26:05 +02:00
|
|
|
WriteProfileStringW(PrinterPortsW, lpNameW, NULL);
|
|
|
|
|
2005-03-31 12:06:46 +02:00
|
|
|
if(RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey) == ERROR_SUCCESS) {
|
|
|
|
RegDeleteValueW(hkey, lpNameW);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2008-05-06 20:26:05 +02:00
|
|
|
|
|
|
|
if(RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey) == ERROR_SUCCESS) {
|
|
|
|
RegDeleteValueW(hkey, lpNameW);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2012-04-20 12:19:28 +02:00
|
|
|
|
|
|
|
if (GetDefaultPrinterW( def, &size ) && !strcmpW( def, lpNameW ))
|
|
|
|
{
|
|
|
|
WriteProfileStringW( windowsW, deviceW, NULL );
|
|
|
|
if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey ))
|
|
|
|
{
|
|
|
|
RegDeleteValueW( hkey, deviceW );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
SetDefaultPrinterW( NULL );
|
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
return TRUE;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetPrinterA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2012-04-05 14:25:49 +02:00
|
|
|
BOOL WINAPI SetPrinterA( HANDLE printer, DWORD level, LPBYTE data, DWORD command )
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2012-04-05 14:25:49 +02:00
|
|
|
BYTE *dataW = data;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (level != 0)
|
|
|
|
{
|
|
|
|
dataW = printer_info_AtoW( data, level );
|
|
|
|
if (!dataW) return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SetPrinterW( printer, level, dataW, command );
|
|
|
|
|
|
|
|
if (dataW != data) free_printer_info( dataW, level );
|
|
|
|
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 20:08:57 +02:00
|
|
|
static void set_printer_2( HKEY key, const PRINTER_INFO_2W *pi )
|
|
|
|
{
|
|
|
|
set_reg_szW( key, NameW, pi->pPrinterName );
|
|
|
|
set_reg_szW( key, Share_NameW, pi->pShareName );
|
|
|
|
set_reg_szW( key, PortW, pi->pPortName );
|
|
|
|
set_reg_szW( key, Printer_DriverW, pi->pDriverName );
|
|
|
|
set_reg_szW( key, DescriptionW, pi->pComment );
|
|
|
|
set_reg_szW( key, LocationW, pi->pLocation );
|
|
|
|
|
|
|
|
if (pi->pDevMode)
|
|
|
|
set_reg_devmode( key, Default_DevModeW, pi->pDevMode );
|
|
|
|
|
|
|
|
set_reg_szW( key, Separator_FileW, pi->pSepFile );
|
|
|
|
set_reg_szW( key, Print_ProcessorW, pi->pPrintProcessor );
|
|
|
|
set_reg_szW( key, DatatypeW, pi->pDatatype );
|
|
|
|
set_reg_szW( key, ParametersW, pi->pParameters );
|
|
|
|
|
2012-05-22 17:36:25 +02:00
|
|
|
set_reg_DWORD( key, AttributesW, pi->Attributes );
|
|
|
|
set_reg_DWORD( key, PriorityW, pi->Priority );
|
|
|
|
set_reg_DWORD( key, Default_PriorityW, pi->DefaultPriority );
|
|
|
|
set_reg_DWORD( key, StartTimeW, pi->StartTime );
|
|
|
|
set_reg_DWORD( key, UntilTimeW, pi->UntilTime );
|
2012-05-10 20:08:57 +02:00
|
|
|
}
|
|
|
|
|
2012-04-05 14:25:51 +02:00
|
|
|
static BOOL set_printer_9( HKEY key, const PRINTER_INFO_9W *pi )
|
|
|
|
{
|
|
|
|
if (!pi->pDevMode) return FALSE;
|
|
|
|
|
|
|
|
set_reg_devmode( key, Default_DevModeW, pi->pDevMode );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetPrinterW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetPrinterW( HANDLE printer, DWORD level, LPBYTE data, DWORD command )
|
|
|
|
{
|
|
|
|
HKEY key;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE( "(%p, %d, %p, %d)\n", printer, level, data, command );
|
|
|
|
|
|
|
|
if (command != 0) FIXME( "Ignoring command %d\n", command );
|
|
|
|
|
|
|
|
if (WINSPOOL_GetOpenedPrinterRegKey( printer, &key ))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
2012-05-10 20:08:57 +02:00
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_2W *pi2 = (PRINTER_INFO_2W *)data;
|
|
|
|
set_printer_2( key, pi2 );
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-05 14:25:51 +02:00
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_9W *pi = (PRINTER_INFO_9W *)data;
|
|
|
|
ret = set_printer_9( key, pi );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME( "Unimplemented level %d\n", level );
|
|
|
|
SetLastError( ERROR_INVALID_LEVEL );
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey( key );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetJobA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetJobA(HANDLE hPrinter, DWORD JobId, DWORD Level,
|
2005-07-13 16:14:37 +02:00
|
|
|
LPBYTE pJob, DWORD Command)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2005-07-12 21:19:09 +02:00
|
|
|
BOOL ret;
|
|
|
|
LPBYTE JobW;
|
|
|
|
UNICODE_STRING usBuffer;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %d, %d, %p, %d)\n",hPrinter, JobId, Level, pJob, Command);
|
2005-07-12 21:19:09 +02:00
|
|
|
|
|
|
|
/* JobId, pPrinterName, pMachineName, pDriverName, Size, Submitted, Time and TotalPages
|
|
|
|
are all ignored by SetJob, so we don't bother copying them */
|
|
|
|
switch(Level)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
JobW = NULL;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
JOB_INFO_1W *info1W = HeapAlloc(GetProcessHeap(), 0, sizeof(*info1W));
|
|
|
|
JOB_INFO_1A *info1A = (JOB_INFO_1A*)pJob;
|
|
|
|
|
|
|
|
JobW = (LPBYTE)info1W;
|
|
|
|
info1W->pUserName = asciitounicode(&usBuffer, info1A->pUserName);
|
|
|
|
info1W->pDocument = asciitounicode(&usBuffer, info1A->pDocument);
|
|
|
|
info1W->pDatatype = asciitounicode(&usBuffer, info1A->pDatatype);
|
|
|
|
info1W->pStatus = asciitounicode(&usBuffer, info1A->pStatus);
|
|
|
|
info1W->Status = info1A->Status;
|
|
|
|
info1W->Priority = info1A->Priority;
|
|
|
|
info1W->Position = info1A->Position;
|
|
|
|
info1W->PagesPrinted = info1A->PagesPrinted;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
JOB_INFO_2W *info2W = HeapAlloc(GetProcessHeap(), 0, sizeof(*info2W));
|
|
|
|
JOB_INFO_2A *info2A = (JOB_INFO_2A*)pJob;
|
|
|
|
|
|
|
|
JobW = (LPBYTE)info2W;
|
|
|
|
info2W->pUserName = asciitounicode(&usBuffer, info2A->pUserName);
|
|
|
|
info2W->pDocument = asciitounicode(&usBuffer, info2A->pDocument);
|
|
|
|
info2W->pNotifyName = asciitounicode(&usBuffer, info2A->pNotifyName);
|
|
|
|
info2W->pDatatype = asciitounicode(&usBuffer, info2A->pDatatype);
|
|
|
|
info2W->pPrintProcessor = asciitounicode(&usBuffer, info2A->pPrintProcessor);
|
|
|
|
info2W->pParameters = asciitounicode(&usBuffer, info2A->pParameters);
|
|
|
|
info2W->pDevMode = info2A->pDevMode ? GdiConvertToDevmodeW(info2A->pDevMode) : NULL;
|
|
|
|
info2W->pStatus = asciitounicode(&usBuffer, info2A->pStatus);
|
|
|
|
info2W->pSecurityDescriptor = info2A->pSecurityDescriptor;
|
|
|
|
info2W->Status = info2A->Status;
|
|
|
|
info2W->Priority = info2A->Priority;
|
|
|
|
info2W->Position = info2A->Position;
|
|
|
|
info2W->StartTime = info2A->StartTime;
|
|
|
|
info2W->UntilTime = info2A->UntilTime;
|
|
|
|
info2W->PagesPrinted = info2A->PagesPrinted;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
JobW = HeapAlloc(GetProcessHeap(), 0, sizeof(JOB_INFO_3));
|
|
|
|
memcpy(JobW, pJob, sizeof(JOB_INFO_3));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SetJobW(hPrinter, JobId, Level, JobW, Command);
|
|
|
|
|
|
|
|
switch(Level)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
JOB_INFO_1W *info1W = (JOB_INFO_1W*)JobW;
|
|
|
|
HeapFree(GetProcessHeap(), 0, info1W->pUserName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info1W->pDocument);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info1W->pDatatype);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info1W->pStatus);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
JOB_INFO_2W *info2W = (JOB_INFO_2W*)JobW;
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pUserName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pDocument);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pNotifyName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pDatatype);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pPrintProcessor);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pParameters);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pDevMode);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info2W->pStatus);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, JobW);
|
|
|
|
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetJobW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level,
|
2005-07-13 16:14:37 +02:00
|
|
|
LPBYTE pJob, DWORD Command)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2005-07-13 16:14:37 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
job_t *job;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %d, %d, %p, %d)\n", hPrinter, JobId, Level, pJob, Command);
|
2005-07-13 16:14:37 +02:00
|
|
|
FIXME("Ignoring everything other than document title\n");
|
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
job = get_job(hPrinter, JobId);
|
|
|
|
if(!job)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
switch(Level)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
JOB_INFO_1W *info1 = (JOB_INFO_1W*)pJob;
|
|
|
|
HeapFree(GetProcessHeap(), 0, job->document_title);
|
|
|
|
job->document_title = strdupW(info1->pDocument);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
JOB_INFO_2W *info2 = (JOB_INFO_2W*)pJob;
|
|
|
|
HeapFree(GetProcessHeap(), 0, job->document_title);
|
|
|
|
job->document_title = strdupW(info2->pDocument);
|
2010-09-20 16:26:49 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->devmode);
|
2012-03-30 15:39:40 +02:00
|
|
|
job->devmode = dup_devmode( info2->pDevMode );
|
2005-07-13 16:14:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2002-12-17 22:00:38 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* EndDocPrinter [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EndDocPrinter(HANDLE hPrinter)
|
|
|
|
{
|
2005-07-08 16:19:18 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
TRACE("(%p)\n", hPrinter);
|
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
|
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!printer->doc)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_SPL_NO_STARTDOC);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(printer->doc->hf);
|
|
|
|
ScheduleJob(hPrinter, printer->doc->job_id);
|
|
|
|
HeapFree(GetProcessHeap(), 0, printer->doc);
|
|
|
|
printer->doc = NULL;
|
|
|
|
ret = TRUE;
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
2002-12-17 22:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EndPagePrinter [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EndPagePrinter(HANDLE hPrinter)
|
|
|
|
{
|
2005-07-08 16:19:18 +02:00
|
|
|
FIXME("(%p): stub\n", hPrinter);
|
|
|
|
return TRUE;
|
2002-12-17 22:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* StartDocPrinterA [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI StartDocPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo)
|
|
|
|
{
|
2005-06-30 20:10:59 +02:00
|
|
|
UNICODE_STRING usBuffer;
|
|
|
|
DOC_INFO_2W doc2W;
|
|
|
|
DOC_INFO_2A *doc2 = (DOC_INFO_2A*)pDocInfo;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
/* DOC_INFO_1, 2 and 3 all have the strings in the same place with either two (DOC_INFO_2)
|
|
|
|
or one (DOC_INFO_3) extra DWORDs */
|
|
|
|
|
|
|
|
switch(Level) {
|
|
|
|
case 2:
|
|
|
|
doc2W.JobId = doc2->JobId;
|
|
|
|
/* fall through */
|
|
|
|
case 3:
|
|
|
|
doc2W.dwMode = doc2->dwMode;
|
|
|
|
/* fall through */
|
|
|
|
case 1:
|
|
|
|
doc2W.pDocName = asciitounicode(&usBuffer, doc2->pDocName);
|
|
|
|
doc2W.pOutputFile = asciitounicode(&usBuffer, doc2->pOutputFile);
|
|
|
|
doc2W.pDatatype = asciitounicode(&usBuffer, doc2->pDatatype);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = StartDocPrinterW(hPrinter, Level, (LPBYTE)&doc2W);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, doc2W.pDatatype);
|
|
|
|
HeapFree(GetProcessHeap(), 0, doc2W.pOutputFile);
|
|
|
|
HeapFree(GetProcessHeap(), 0, doc2W.pDocName);
|
|
|
|
|
|
|
|
return ret;
|
2002-12-17 22:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* StartDocPrinterW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI StartDocPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo)
|
|
|
|
{
|
2005-06-30 20:10:59 +02:00
|
|
|
DOC_INFO_2W *doc = (DOC_INFO_2W *)pDocInfo;
|
2005-07-08 16:19:18 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
BYTE addjob_buf[MAX_PATH * sizeof(WCHAR) + sizeof(ADDJOB_INFO_1W)];
|
|
|
|
ADDJOB_INFO_1W *addjob = (ADDJOB_INFO_1W*) addjob_buf;
|
2005-07-13 16:14:37 +02:00
|
|
|
JOB_INFO_1W job_info;
|
2005-07-08 16:19:18 +02:00
|
|
|
DWORD needed, ret = 0;
|
|
|
|
HANDLE hf;
|
|
|
|
WCHAR *filename;
|
2010-08-12 14:37:36 +02:00
|
|
|
job_t *job;
|
2005-06-30 20:10:59 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(hPrinter = %p, Level = %d, pDocInfo = %p {pDocName = %s, pOutputFile = %s, pDatatype = %s}):\n",
|
2005-06-30 20:10:59 +02:00
|
|
|
hPrinter, Level, doc, debugstr_w(doc->pDocName), debugstr_w(doc->pOutputFile),
|
|
|
|
debugstr_w(doc->pDatatype));
|
2005-07-08 16:19:18 +02:00
|
|
|
|
|
|
|
if(Level < 1 || Level > 3)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(printer->doc)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PRINTER_STATE);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Even if we're printing to a file we still add a print job, we'll
|
|
|
|
just ignore the spool file name */
|
|
|
|
|
|
|
|
if(!AddJobW(hPrinter, 1, addjob_buf, sizeof(addjob_buf), &needed))
|
|
|
|
{
|
2007-01-18 11:37:51 +01:00
|
|
|
ERR("AddJob failed gle %u\n", GetLastError());
|
2005-07-08 16:19:18 +02:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2010-08-12 14:37:36 +02:00
|
|
|
/* use pOutputFile only, when it is a real filename */
|
|
|
|
if ((doc->pOutputFile) && is_local_file(doc->pOutputFile))
|
2005-07-08 16:19:18 +02:00
|
|
|
filename = doc->pOutputFile;
|
|
|
|
else
|
|
|
|
filename = addjob->Path;
|
|
|
|
|
|
|
|
hf = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if(hf == INVALID_HANDLE_VALUE)
|
|
|
|
goto end;
|
|
|
|
|
2005-07-13 16:14:37 +02:00
|
|
|
memset(&job_info, 0, sizeof(job_info));
|
|
|
|
job_info.pDocument = doc->pDocName;
|
|
|
|
SetJobW(hPrinter, addjob->JobId, 1, (LPBYTE)&job_info, 0);
|
2005-07-08 16:19:18 +02:00
|
|
|
|
|
|
|
printer->doc = HeapAlloc(GetProcessHeap(), 0, sizeof(*printer->doc));
|
|
|
|
printer->doc->hf = hf;
|
|
|
|
ret = printer->doc->job_id = addjob->JobId;
|
2010-08-12 14:37:36 +02:00
|
|
|
job = get_job(hPrinter, ret);
|
|
|
|
job->portname = strdupW(doc->pOutputFile);
|
|
|
|
|
2005-07-08 16:19:18 +02:00
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
|
|
|
|
return ret;
|
2002-12-17 22:00:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* StartPagePrinter [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI StartPagePrinter(HANDLE hPrinter)
|
|
|
|
{
|
2005-07-08 16:19:18 +02:00
|
|
|
FIXME("(%p): stub\n", hPrinter);
|
|
|
|
return TRUE;
|
2002-12-17 22:00:38 +01:00
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetFormA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetFormA(HANDLE hPrinter, LPSTR pFormName, DWORD Level,
|
|
|
|
LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%s,%d,%p,%d,%p): stub\n",hPrinter,pFormName,
|
2002-06-01 01:06:46 +02:00
|
|
|
Level,pForm,cbBuf,pcbNeeded);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetFormW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
|
|
|
|
LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%s,%d,%p,%d,%p): stub\n",hPrinter,
|
1999-05-17 18:20:51 +02:00
|
|
|
debugstr_w(pFormName),Level,pForm,cbBuf,pcbNeeded);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetFormA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetFormA(HANDLE hPrinter, LPSTR pFormName, DWORD Level,
|
|
|
|
LPBYTE pForm)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%s,%d,%p): stub\n",hPrinter,pFormName,Level,pForm);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetFormW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
|
|
|
|
LPBYTE pForm)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%p,%d,%p): stub\n",hPrinter,pFormName,Level,pForm);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ReadPrinter [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ReadPrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf,
|
|
|
|
LPDWORD pNoBytesRead)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,%p,%d,%p): stub\n",hPrinter,pBuf,cbBuf,pNoBytesRead);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ResetPrinterA [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ResetPrinterA(HANDLE hPrinter, LPPRINTER_DEFAULTSA pDefault)
|
|
|
|
{
|
2002-10-22 02:47:33 +02:00
|
|
|
FIXME("(%p, %p): stub\n", hPrinter, pDefault);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ResetPrinterW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ResetPrinterW(HANDLE hPrinter, LPPRINTER_DEFAULTSW pDefault)
|
|
|
|
{
|
2002-10-22 02:47:33 +02:00
|
|
|
FIXME("(%p, %p): stub\n", hPrinter, pDefault);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:05:27 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* get_filename_from_reg [internal]
|
|
|
|
*
|
|
|
|
* Get ValueName from hkey storing result in out
|
|
|
|
* when the Value in the registry has only a filename, use driverdir as prefix
|
|
|
|
* outlen is space left in out
|
|
|
|
* String is stored either as unicode or ascii
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL get_filename_from_reg(HKEY hkey, LPCWSTR driverdir, DWORD dirlen, LPCWSTR ValueName,
|
2009-12-01 17:46:13 +01:00
|
|
|
LPBYTE out, DWORD outlen, LPDWORD needed)
|
2007-07-26 23:05:27 +02:00
|
|
|
{
|
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
DWORD size;
|
|
|
|
DWORD type;
|
|
|
|
LONG ret;
|
|
|
|
LPWSTR buffer = filename;
|
|
|
|
LPWSTR ptr;
|
|
|
|
|
|
|
|
*needed = 0;
|
|
|
|
size = sizeof(filename);
|
|
|
|
buffer[0] = '\0';
|
|
|
|
ret = RegQueryValueExW(hkey, ValueName, NULL, &type, (LPBYTE) buffer, &size);
|
|
|
|
if (ret == ERROR_MORE_DATA) {
|
|
|
|
TRACE("need dynamic buffer: %u\n", size);
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!buffer) {
|
|
|
|
/* No Memory is bad */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buffer[0] = '\0';
|
|
|
|
ret = RegQueryValueExW(hkey, ValueName, NULL, &type, (LPBYTE) buffer, &size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret != ERROR_SUCCESS) || (!buffer[0])) {
|
|
|
|
if (buffer != filename) HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = buffer;
|
|
|
|
while (ptr) {
|
|
|
|
/* do we have a full path ? */
|
|
|
|
ret = (((buffer[0] == '\\') && (buffer[1] == '\\')) ||
|
|
|
|
(buffer[0] && (buffer[1] == ':') && (buffer[2] == '\\')) );
|
|
|
|
|
|
|
|
if (!ret) {
|
|
|
|
/* we must build the full Path */
|
|
|
|
*needed += dirlen;
|
|
|
|
if ((out) && (outlen > dirlen)) {
|
2009-12-01 17:46:13 +01:00
|
|
|
lstrcpyW((LPWSTR)out, driverdir);
|
2007-07-26 23:05:27 +02:00
|
|
|
out += dirlen;
|
|
|
|
outlen -= dirlen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
out = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write the filename */
|
2009-12-01 17:46:13 +01:00
|
|
|
size = (lstrlenW(ptr) + 1) * sizeof(WCHAR);
|
|
|
|
if ((out) && (outlen >= size)) {
|
|
|
|
lstrcpyW((LPWSTR)out, ptr);
|
|
|
|
out += size;
|
|
|
|
outlen -= size;
|
2007-07-26 23:05:27 +02:00
|
|
|
}
|
|
|
|
else
|
2009-12-01 17:46:13 +01:00
|
|
|
out = NULL;
|
2007-07-26 23:05:27 +02:00
|
|
|
*needed += size;
|
|
|
|
ptr += lstrlenW(ptr)+1;
|
|
|
|
if ((type != REG_MULTI_SZ) || (!ptr[0])) ptr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer != filename) HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
|
|
|
/* write the multisz-termination */
|
|
|
|
if (type == REG_MULTI_SZ) {
|
2009-12-01 17:46:13 +01:00
|
|
|
size = sizeof(WCHAR);
|
2007-07-26 23:05:27 +02:00
|
|
|
|
|
|
|
*needed += size;
|
|
|
|
if (out && (outlen >= size)) {
|
|
|
|
memset (out, 0, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
/*****************************************************************************
|
2000-05-26 01:02:46 +02:00
|
|
|
* WINSPOOL_GetStringFromReg
|
1999-07-10 13:58:50 +02:00
|
|
|
*
|
2000-05-26 01:02:46 +02:00
|
|
|
* Get ValueName from hkey storing result in ptr. buflen is space left in ptr
|
2009-12-01 17:46:27 +01:00
|
|
|
* String is stored as unicode.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
static BOOL WINSPOOL_GetStringFromReg(HKEY hkey, LPCWSTR ValueName, LPBYTE ptr,
|
2009-12-01 17:46:27 +01:00
|
|
|
DWORD buflen, DWORD *needed)
|
1999-07-10 13:58:50 +02:00
|
|
|
{
|
|
|
|
DWORD sz = buflen, type;
|
|
|
|
LONG ret;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
ret = RegQueryValueExW(hkey, ValueName, 0, &type, ptr, &sz);
|
2000-05-26 01:02:46 +02:00
|
|
|
if(ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA) {
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN("Got ret = %d\n", ret);
|
2000-05-26 01:02:46 +02:00
|
|
|
*needed = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-04-14 15:34:57 +02:00
|
|
|
/* add space for terminating '\0' */
|
2009-12-01 17:46:27 +01:00
|
|
|
sz += sizeof(WCHAR);
|
2000-05-26 01:02:46 +02:00
|
|
|
*needed = sz;
|
2006-04-14 15:34:57 +02:00
|
|
|
|
|
|
|
if (ptr)
|
2009-12-01 17:46:27 +01:00
|
|
|
TRACE("%s: %s\n", debugstr_w(ValueName), debugstr_w((LPCWSTR)ptr));
|
2006-04-14 15:34:57 +02:00
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-09-07 20:35:58 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* WINSPOOL_GetDefaultDevMode
|
|
|
|
*
|
|
|
|
* Get a default DevMode values for wineps.
|
2013-02-12 08:21:26 +01:00
|
|
|
*/
|
|
|
|
static void WINSPOOL_GetDefaultDevMode(LPBYTE ptr, DWORD buflen, DWORD *needed)
|
|
|
|
{
|
|
|
|
static const WCHAR winepsW[] = { 'w','i','n','e','p','s','.','d','r','v',0 };
|
|
|
|
|
|
|
|
if (buflen >= sizeof(DEVMODEW))
|
|
|
|
{
|
|
|
|
DEVMODEW *dm = (DEVMODEW *)ptr;
|
|
|
|
|
|
|
|
/* the driver will update registry with real values */
|
|
|
|
memset(dm, 0, sizeof(*dm));
|
|
|
|
dm->dmSize = sizeof(*dm);
|
|
|
|
lstrcpyW(dm->dmDeviceName, winepsW);
|
|
|
|
}
|
2009-12-01 17:46:33 +01:00
|
|
|
*needed = sizeof(DEVMODEW);
|
2001-09-07 20:35:58 +02:00
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* WINSPOOL_GetDevModeFromReg
|
|
|
|
*
|
|
|
|
* Get ValueName from hkey storing result in ptr. buflen is space left in ptr
|
|
|
|
* DevMode is stored either as unicode or ascii.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
static BOOL WINSPOOL_GetDevModeFromReg(HKEY hkey, LPCWSTR ValueName,
|
|
|
|
LPBYTE ptr,
|
2009-12-01 17:46:41 +01:00
|
|
|
DWORD buflen, DWORD *needed)
|
2000-05-26 01:02:46 +02:00
|
|
|
{
|
|
|
|
DWORD sz = buflen, type;
|
|
|
|
LONG ret;
|
1999-07-10 13:58:50 +02:00
|
|
|
|
2001-09-07 20:35:58 +02:00
|
|
|
if (ptr && buflen>=sizeof(DEVMODEA)) memset(ptr, 0, sizeof(DEVMODEA));
|
2000-05-26 01:02:46 +02:00
|
|
|
ret = RegQueryValueExW(hkey, ValueName, 0, &type, ptr, &sz);
|
2000-08-16 14:43:00 +02:00
|
|
|
if ((ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA)) sz = 0;
|
|
|
|
if (sz < sizeof(DEVMODEA))
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("corrupted registry for %s ( size %d)\n",debugstr_w(ValueName),sz);
|
2001-05-09 19:10:41 +02:00
|
|
|
return FALSE;
|
1999-07-10 13:58:50 +02:00
|
|
|
}
|
2000-08-16 14:43:00 +02:00
|
|
|
/* ensures that dmSize is not erratically bogus if registry is invalid */
|
|
|
|
if (ptr && ((DEVMODEA*)ptr)->dmSize < sizeof(DEVMODEA))
|
|
|
|
((DEVMODEA*)ptr)->dmSize = sizeof(DEVMODEA);
|
2009-12-01 17:46:41 +01:00
|
|
|
sz += (CCHDEVICENAME + CCHFORMNAME);
|
2009-12-03 10:18:19 +01:00
|
|
|
if (ptr && (buflen >= sz)) {
|
2009-12-01 17:46:41 +01:00
|
|
|
DEVMODEW *dmW = GdiConvertToDevmodeW((DEVMODEA*)ptr);
|
|
|
|
memcpy(ptr, dmW, sz);
|
|
|
|
HeapFree(GetProcessHeap(),0,dmW);
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
1999-07-10 13:58:50 +02:00
|
|
|
*needed = sz;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-04-12 15:08:22 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* WINSPOOL_GetPrinter_1
|
|
|
|
*
|
2009-12-01 17:46:20 +01:00
|
|
|
* Fills out a PRINTER_INFO_1W struct storing the strings in buf.
|
2007-04-12 15:08:22 +02:00
|
|
|
*/
|
|
|
|
static BOOL WINSPOOL_GetPrinter_1(HKEY hkeyPrinter, PRINTER_INFO_1W *pi1,
|
2009-12-01 17:46:20 +01:00
|
|
|
LPBYTE buf, DWORD cbBuf, LPDWORD pcbNeeded)
|
2007-04-12 15:08:22 +02:00
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
|
2007-04-12 15:08:22 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi1->pName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: pDescription should be something like "Name,Driver_Name,". */
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
|
2007-04-12 15:08:22 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi1->pDescription = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, DescriptionW, ptr, left, &size)) {
|
2007-04-12 15:08:22 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi1->pComment = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pi1) pi1->Flags = PRINTER_ENUM_ICON8; /* We're a printer */
|
|
|
|
|
|
|
|
if(!space && pi1) /* zero out pi1 if we can't completely fill buf */
|
|
|
|
memset(pi1, 0, sizeof(*pi1));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
/*********************************************************************
|
2000-05-26 01:02:46 +02:00
|
|
|
* WINSPOOL_GetPrinter_2
|
1999-09-10 16:37:29 +02:00
|
|
|
*
|
2009-12-01 17:46:20 +01:00
|
|
|
* Fills out a PRINTER_INFO_2W struct storing the strings in buf.
|
1999-09-10 16:37:29 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
|
2009-12-01 17:46:20 +01:00
|
|
|
LPBYTE buf, DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-09-10 16:37:29 +02:00
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pPrinterName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, Share_NameW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pShareName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, PortW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pPortName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, Printer_DriverW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pDriverName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, DescriptionW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pComment = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, LocationW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pLocation = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:41 +01:00
|
|
|
if(WINSPOOL_GetDevModeFromReg(hkeyPrinter, Default_DevModeW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pDevMode = (LPDEVMODEW)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2001-09-07 20:35:58 +02:00
|
|
|
else
|
|
|
|
{
|
2009-12-01 17:46:33 +01:00
|
|
|
WINSPOOL_GetDefaultDevMode(ptr, left, &size);
|
2001-09-07 20:35:58 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pDevMode = (LPDEVMODEW)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, Separator_FileW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pSepFile = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, Print_ProcessorW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pPrintProcessor = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, DatatypeW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pDatatype = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, ParametersW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi2->pParameters = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
if(pi2) {
|
2012-05-31 14:57:39 +02:00
|
|
|
pi2->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
|
|
|
|
pi2->Priority = get_dword_from_reg( hkeyPrinter, PriorityW );
|
|
|
|
pi2->DefaultPriority = get_dword_from_reg( hkeyPrinter, Default_PriorityW );
|
|
|
|
pi2->StartTime = get_dword_from_reg( hkeyPrinter, StartTimeW );
|
|
|
|
pi2->UntilTime = get_dword_from_reg( hkeyPrinter, UntilTimeW );
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
|
|
|
|
if(!space && pi2) /* zero out pi2 if we can't completely fill buf */
|
|
|
|
memset(pi2, 0, sizeof(*pi2));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2000-05-26 01:02:46 +02:00
|
|
|
* WINSPOOL_GetPrinter_4
|
1999-09-10 16:37:29 +02:00
|
|
|
*
|
2000-05-26 01:02:46 +02:00
|
|
|
* Fills out a PRINTER_INFO_4 struct storing the strings in buf.
|
1999-09-10 16:37:29 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
static BOOL WINSPOOL_GetPrinter_4(HKEY hkeyPrinter, PRINTER_INFO_4W *pi4,
|
2009-12-01 17:46:20 +01:00
|
|
|
LPBYTE buf, DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-09-10 16:37:29 +02:00
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi4->pPrinterName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
if(pi4) {
|
2012-05-31 14:57:39 +02:00
|
|
|
pi4->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
|
|
|
|
if(!space && pi4) /* zero out pi4 if we can't completely fill buf */
|
|
|
|
memset(pi4, 0, sizeof(*pi4));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
2000-05-26 01:02:46 +02:00
|
|
|
* WINSPOOL_GetPrinter_5
|
1999-09-10 16:37:29 +02:00
|
|
|
*
|
2000-05-26 01:02:46 +02:00
|
|
|
* Fills out a PRINTER_INFO_5 struct storing the strings in buf.
|
1999-09-10 16:37:29 +02:00
|
|
|
*/
|
2000-05-26 01:02:46 +02:00
|
|
|
static BOOL WINSPOOL_GetPrinter_5(HKEY hkeyPrinter, PRINTER_INFO_5W *pi5,
|
2009-12-01 17:46:20 +01:00
|
|
|
LPBYTE buf, DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-09-10 16:37:29 +02:00
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi5->pPrinterName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
2009-12-01 17:46:27 +01:00
|
|
|
if(WINSPOOL_GetStringFromReg(hkeyPrinter, PortW, ptr, left, &size)) {
|
2000-05-26 01:02:46 +02:00
|
|
|
if(space && size <= left) {
|
|
|
|
pi5->pPortName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
if(pi5) {
|
2012-05-31 14:57:39 +02:00
|
|
|
pi5->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
|
|
|
|
pi5->DeviceNotSelectedTimeout = get_dword_from_reg( hkeyPrinter, dnsTimeoutW );
|
|
|
|
pi5->TransmissionRetryTimeout = get_dword_from_reg( hkeyPrinter, txTimeoutW );
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
|
|
|
|
if(!space && pi5) /* zero out pi5 if we can't completely fill buf */
|
|
|
|
memset(pi5, 0, sizeof(*pi5));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
1999-07-10 13:58:50 +02:00
|
|
|
|
2008-02-26 23:09:55 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* WINSPOOL_GetPrinter_7
|
|
|
|
*
|
|
|
|
* Fills out a PRINTER_INFO_7 struct storing the strings in buf.
|
|
|
|
*/
|
|
|
|
static BOOL WINSPOOL_GetPrinter_7(HKEY hkeyPrinter, PRINTER_INFO_7W *pi7, LPBYTE buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
2008-02-26 23:09:55 +01:00
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:27 +01:00
|
|
|
if (! WINSPOOL_GetStringFromReg(hkeyPrinter, ObjectGUIDW, ptr, left, &size))
|
2008-02-26 23:09:55 +01:00
|
|
|
{
|
2009-12-01 00:04:50 +01:00
|
|
|
ptr = NULL;
|
|
|
|
size = sizeof(pi7->pszObjectGUID);
|
2008-02-26 23:09:55 +01:00
|
|
|
}
|
2009-12-01 00:04:50 +01:00
|
|
|
if (space && size <= left) {
|
|
|
|
pi7->pszObjectGUID = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
2008-02-26 23:09:55 +01:00
|
|
|
if (pi7) {
|
|
|
|
/* We do not have a Directory Service */
|
|
|
|
pi7->dwAction = DSPRINT_UNPUBLISH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!space && pi7) /* zero out pi7 if we can't completely fill buf */
|
|
|
|
memset(pi7, 0, sizeof(*pi7));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
2008-02-28 21:46:17 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* WINSPOOL_GetPrinter_9
|
|
|
|
*
|
2009-12-01 17:46:20 +01:00
|
|
|
* Fills out a PRINTER_INFO_9AW struct storing the strings in buf.
|
2008-02-28 21:46:17 +01:00
|
|
|
*/
|
|
|
|
static BOOL WINSPOOL_GetPrinter_9(HKEY hkeyPrinter, PRINTER_INFO_9W *pi9, LPBYTE buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
2008-02-28 21:46:17 +01:00
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
2009-12-01 17:46:41 +01:00
|
|
|
if(WINSPOOL_GetDevModeFromReg(hkeyPrinter, Default_DevModeW, buf, cbBuf, &size)) {
|
2008-02-28 21:46:17 +01:00
|
|
|
if(space && size <= cbBuf) {
|
|
|
|
pi9->pDevMode = (LPDEVMODEW)buf;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-12-01 17:46:33 +01:00
|
|
|
WINSPOOL_GetDefaultDevMode(buf, cbBuf, &size);
|
2008-02-28 21:46:17 +01:00
|
|
|
if(space && size <= cbBuf) {
|
|
|
|
pi9->pDevMode = (LPDEVMODEW)buf;
|
|
|
|
} else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!space && pi9) /* zero out pi9 if we can't completely fill buf */
|
|
|
|
memset(pi9, 0, sizeof(*pi9));
|
|
|
|
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2009-12-01 00:04:35 +01:00
|
|
|
* GetPrinterW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2009-12-01 00:04:35 +01:00
|
|
|
BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2012-04-19 14:43:24 +02:00
|
|
|
DWORD size, needed = 0, err;
|
1999-07-10 13:58:50 +02:00
|
|
|
LPBYTE ptr = NULL;
|
2012-04-19 14:43:24 +02:00
|
|
|
HKEY hkeyPrinter;
|
1999-09-10 16:37:29 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p,%d,%p,%d,%p)\n",hPrinter,Level,pPrinter,cbBuf, pcbNeeded);
|
1999-05-17 18:20:51 +02:00
|
|
|
|
2012-04-19 14:43:24 +02:00
|
|
|
err = WINSPOOL_GetOpenedPrinterRegKey( hPrinter, &hkeyPrinter );
|
|
|
|
if (err)
|
2001-02-28 06:26:08 +01:00
|
|
|
{
|
2012-04-19 14:43:24 +02:00
|
|
|
SetLastError( err );
|
|
|
|
return FALSE;
|
1999-07-10 13:58:50 +02:00
|
|
|
}
|
1999-05-17 18:20:51 +02:00
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
switch(Level) {
|
|
|
|
case 2:
|
|
|
|
{
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_INFO_2W *pi2 = (PRINTER_INFO_2W *)pPrinter;
|
1999-07-10 13:58:50 +02:00
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
size = sizeof(PRINTER_INFO_2W);
|
1999-07-10 13:58:50 +02:00
|
|
|
if(size <= cbBuf) {
|
|
|
|
ptr = pPrinter + size;
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pPrinter, 0, size);
|
1999-09-10 16:37:29 +02:00
|
|
|
} else {
|
|
|
|
pi2 = NULL;
|
1999-07-10 13:58:50 +02:00
|
|
|
cbBuf = 0;
|
1999-09-10 16:37:29 +02:00
|
|
|
}
|
2009-12-01 17:46:20 +01:00
|
|
|
ret = WINSPOOL_GetPrinter_2(hkeyPrinter, pi2, ptr, cbBuf, &needed);
|
1999-07-10 13:58:50 +02:00
|
|
|
needed += size;
|
1999-09-10 16:37:29 +02:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-09-10 16:37:29 +02:00
|
|
|
case 4:
|
|
|
|
{
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_INFO_4W *pi4 = (PRINTER_INFO_4W *)pPrinter;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
size = sizeof(PRINTER_INFO_4W);
|
1999-09-10 16:37:29 +02:00
|
|
|
if(size <= cbBuf) {
|
|
|
|
ptr = pPrinter + size;
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pPrinter, 0, size);
|
|
|
|
} else {
|
|
|
|
pi4 = NULL;
|
1999-07-10 13:58:50 +02:00
|
|
|
cbBuf = 0;
|
1999-09-10 16:37:29 +02:00
|
|
|
}
|
2009-12-01 17:46:20 +01:00
|
|
|
ret = WINSPOOL_GetPrinter_4(hkeyPrinter, pi4, ptr, cbBuf, &needed);
|
1999-07-10 13:58:50 +02:00
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
}
|
1999-09-10 16:37:29 +02:00
|
|
|
|
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
case 5:
|
|
|
|
{
|
2000-05-26 01:02:46 +02:00
|
|
|
PRINTER_INFO_5W *pi5 = (PRINTER_INFO_5W *)pPrinter;
|
1999-07-10 13:58:50 +02:00
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
size = sizeof(PRINTER_INFO_5W);
|
1999-07-10 13:58:50 +02:00
|
|
|
if(size <= cbBuf) {
|
|
|
|
ptr = pPrinter + size;
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pPrinter, 0, size);
|
1999-09-10 16:37:29 +02:00
|
|
|
} else {
|
|
|
|
pi5 = NULL;
|
1999-07-10 13:58:50 +02:00
|
|
|
cbBuf = 0;
|
1999-09-10 16:37:29 +02:00
|
|
|
}
|
1999-07-10 13:58:50 +02:00
|
|
|
|
2009-12-01 17:46:20 +01:00
|
|
|
ret = WINSPOOL_GetPrinter_5(hkeyPrinter, pi5, ptr, cbBuf, &needed);
|
1999-07-10 13:58:50 +02:00
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-26 23:09:55 +01:00
|
|
|
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_6 *pi6 = (PRINTER_INFO_6 *) pPrinter;
|
|
|
|
|
|
|
|
size = sizeof(PRINTER_INFO_6);
|
|
|
|
if (size <= cbBuf) {
|
|
|
|
/* FIXME: We do not update the status yet */
|
2012-05-31 14:57:39 +02:00
|
|
|
pi6->dwStatus = get_dword_from_reg( hkeyPrinter, StatusW );
|
2008-02-26 23:09:55 +01:00
|
|
|
ret = TRUE;
|
|
|
|
} else {
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_7W *pi7 = (PRINTER_INFO_7W *) pPrinter;
|
|
|
|
|
|
|
|
size = sizeof(PRINTER_INFO_7W);
|
|
|
|
if (size <= cbBuf) {
|
|
|
|
ptr = pPrinter + size;
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pPrinter, 0, size);
|
|
|
|
} else {
|
|
|
|
pi7 = NULL;
|
|
|
|
cbBuf = 0;
|
|
|
|
}
|
|
|
|
|
2009-12-01 17:46:20 +01:00
|
|
|
ret = WINSPOOL_GetPrinter_7(hkeyPrinter, pi7, ptr, cbBuf, &needed);
|
2008-02-26 23:09:55 +01:00
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-02 19:40:09 +02:00
|
|
|
case 8:
|
|
|
|
/* 8 is the global default printer info and 9 already gets it instead of the per-user one */
|
|
|
|
/* still, PRINTER_INFO_8W is the same as PRINTER_INFO_9W */
|
|
|
|
/* fall through */
|
2008-02-28 21:46:17 +01:00
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
PRINTER_INFO_9W *pi9 = (PRINTER_INFO_9W *)pPrinter;
|
|
|
|
|
|
|
|
size = sizeof(PRINTER_INFO_9W);
|
|
|
|
if(size <= cbBuf) {
|
|
|
|
ptr = pPrinter + size;
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pPrinter, 0, size);
|
|
|
|
} else {
|
|
|
|
pi9 = NULL;
|
|
|
|
cbBuf = 0;
|
|
|
|
}
|
|
|
|
|
2009-12-01 17:46:20 +01:00
|
|
|
ret = WINSPOOL_GetPrinter_9(hkeyPrinter, pi9, ptr, cbBuf, &needed);
|
2008-02-28 21:46:17 +01:00
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
default:
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("Unimplemented level %d\n", Level);
|
1999-07-10 13:58:50 +02:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("returning %d needed = %d\n", ret, needed);
|
1999-07-10 13:58:50 +02:00
|
|
|
if(pcbNeeded) *pcbNeeded = needed;
|
1999-09-10 16:37:29 +02:00
|
|
|
if(!ret)
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetPrinterA [WINSPOOL.@]
|
2000-05-26 01:02:46 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
|
1999-05-17 18:20:51 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
2009-12-01 00:04:35 +01:00
|
|
|
BOOL ret;
|
|
|
|
LPBYTE buf = NULL;
|
|
|
|
|
|
|
|
if (cbBuf)
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, cbBuf);
|
|
|
|
|
|
|
|
ret = GetPrinterW(hPrinter, Level, buf, cbBuf, pcbNeeded);
|
|
|
|
if (ret)
|
|
|
|
convert_printerinfo_W_to_A(pPrinter, buf, Level, cbBuf, 1);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
|
|
|
return ret;
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/*****************************************************************************
|
2009-12-01 00:04:09 +01:00
|
|
|
* WINSPOOL_EnumPrintersW
|
1999-10-31 18:34:31 +01:00
|
|
|
*
|
2009-12-01 00:04:09 +01:00
|
|
|
* Implementation of EnumPrintersW
|
1999-10-31 18:34:31 +01:00
|
|
|
*/
|
2009-12-01 00:04:09 +01:00
|
|
|
static BOOL WINSPOOL_EnumPrintersW(DWORD dwType, LPWSTR lpszName,
|
2000-05-26 01:02:46 +02:00
|
|
|
DWORD dwLevel, LPBYTE lpbPrinters,
|
|
|
|
DWORD cbBuf, LPDWORD lpdwNeeded,
|
2009-12-01 00:04:09 +01:00
|
|
|
LPDWORD lpdwReturned)
|
1999-10-31 18:34:31 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
HKEY hkeyPrinters, hkeyPrinter;
|
2000-05-26 01:02:46 +02:00
|
|
|
WCHAR PrinterName[255];
|
1999-10-31 18:34:31 +01:00
|
|
|
DWORD needed = 0, number = 0;
|
|
|
|
DWORD used, i, left;
|
|
|
|
PBYTE pi, buf;
|
|
|
|
|
|
|
|
if(lpbPrinters)
|
|
|
|
memset(lpbPrinters, 0, cbBuf);
|
|
|
|
if(lpdwReturned)
|
|
|
|
*lpdwReturned = 0;
|
2001-01-09 21:52:17 +01:00
|
|
|
if(lpdwNeeded)
|
|
|
|
*lpdwNeeded = 0;
|
|
|
|
|
|
|
|
/* PRINTER_ENUM_DEFAULT is only supported under win9x, we behave like NT */
|
|
|
|
if(dwType == PRINTER_ENUM_DEFAULT)
|
|
|
|
return TRUE;
|
1999-10-31 18:34:31 +01:00
|
|
|
|
2002-09-09 21:19:18 +02:00
|
|
|
if (dwType & PRINTER_ENUM_CONNECTIONS) {
|
2007-01-21 20:49:34 +01:00
|
|
|
TRACE("ignoring PRINTER_ENUM_CONNECTIONS\n");
|
|
|
|
dwType &= ~PRINTER_ENUM_CONNECTIONS; /* we don't handle that */
|
|
|
|
if (!dwType) {
|
|
|
|
FIXME("We don't handle PRINTER_ENUM_CONNECTIONS\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-09-09 21:19:18 +02:00
|
|
|
}
|
|
|
|
|
1999-10-31 18:34:31 +01:00
|
|
|
if (!((dwType & PRINTER_ENUM_LOCAL) || (dwType & PRINTER_ENUM_NAME))) {
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("dwType = %08x\n", dwType);
|
1999-10-31 18:34:31 +01:00
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-05-21 14:35:29 +02:00
|
|
|
if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
|
1999-10-31 18:34:31 +01:00
|
|
|
ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create Printers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-11-28 20:47:58 +01:00
|
|
|
if(RegQueryInfoKeyA(hkeyPrinters, NULL, NULL, NULL, &number, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
ERR("Can't query Printers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("Found %d printers\n", number);
|
1999-10-31 18:34:31 +01:00
|
|
|
|
|
|
|
switch(dwLevel) {
|
|
|
|
case 1:
|
2007-04-12 15:08:22 +02:00
|
|
|
used = number * sizeof(PRINTER_INFO_1W);
|
|
|
|
break;
|
1999-10-31 18:34:31 +01:00
|
|
|
case 2:
|
2000-05-26 01:02:46 +02:00
|
|
|
used = number * sizeof(PRINTER_INFO_2W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2000-05-26 01:02:46 +02:00
|
|
|
used = number * sizeof(PRINTER_INFO_4W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2000-05-26 01:02:46 +02:00
|
|
|
used = number * sizeof(PRINTER_INFO_5W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pi = (used <= cbBuf) ? lpbPrinters : NULL;
|
|
|
|
|
|
|
|
for(i = 0; i < number; i++) {
|
2007-12-01 17:43:37 +01:00
|
|
|
if(RegEnumKeyW(hkeyPrinters, i, PrinterName, sizeof(PrinterName)/sizeof(PrinterName[0])) !=
|
1999-10-31 18:34:31 +01:00
|
|
|
ERROR_SUCCESS) {
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR("Can't enum key number %d\n", i);
|
1999-10-31 18:34:31 +01:00
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("Printer %d is %s\n", i, debugstr_w(PrinterName));
|
2000-05-26 01:02:46 +02:00
|
|
|
if(RegOpenKeyW(hkeyPrinters, PrinterName, &hkeyPrinter) !=
|
1999-10-31 18:34:31 +01:00
|
|
|
ERROR_SUCCESS) {
|
2000-05-26 01:02:46 +02:00
|
|
|
ERR("Can't open key %s\n", debugstr_w(PrinterName));
|
1999-10-31 18:34:31 +01:00
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cbBuf > used) {
|
|
|
|
buf = lpbPrinters + used;
|
|
|
|
left = cbBuf - used;
|
|
|
|
} else {
|
|
|
|
buf = NULL;
|
|
|
|
left = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(dwLevel) {
|
2007-04-12 15:08:22 +02:00
|
|
|
case 1:
|
|
|
|
WINSPOOL_GetPrinter_1(hkeyPrinter, (PRINTER_INFO_1W *)pi, buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
left, &needed);
|
2007-04-12 15:08:22 +02:00
|
|
|
used += needed;
|
|
|
|
if(pi) pi += sizeof(PRINTER_INFO_1W);
|
|
|
|
break;
|
1999-10-31 18:34:31 +01:00
|
|
|
case 2:
|
2000-05-26 01:02:46 +02:00
|
|
|
WINSPOOL_GetPrinter_2(hkeyPrinter, (PRINTER_INFO_2W *)pi, buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
left, &needed);
|
1999-10-31 18:34:31 +01:00
|
|
|
used += needed;
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pi) pi += sizeof(PRINTER_INFO_2W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2000-05-26 01:02:46 +02:00
|
|
|
WINSPOOL_GetPrinter_4(hkeyPrinter, (PRINTER_INFO_4W *)pi, buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
left, &needed);
|
1999-10-31 18:34:31 +01:00
|
|
|
used += needed;
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pi) pi += sizeof(PRINTER_INFO_4W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2000-05-26 01:02:46 +02:00
|
|
|
WINSPOOL_GetPrinter_5(hkeyPrinter, (PRINTER_INFO_5W *)pi, buf,
|
2009-12-01 17:46:20 +01:00
|
|
|
left, &needed);
|
1999-10-31 18:34:31 +01:00
|
|
|
used += needed;
|
2000-05-26 01:02:46 +02:00
|
|
|
if(pi) pi += sizeof(PRINTER_INFO_5W);
|
1999-10-31 18:34:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Shouldn't be here!\n");
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
|
|
|
|
if(lpdwNeeded)
|
|
|
|
*lpdwNeeded = used;
|
2000-05-26 01:02:46 +02:00
|
|
|
|
1999-10-31 18:34:31 +01:00
|
|
|
if(used > cbBuf) {
|
|
|
|
if(lpbPrinters)
|
|
|
|
memset(lpbPrinters, 0, cbBuf);
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if(lpdwReturned)
|
2002-06-01 01:06:46 +02:00
|
|
|
*lpdwReturned = number;
|
1999-10-31 18:34:31 +01:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
|
1999-10-31 18:34:31 +01:00
|
|
|
/******************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPrintersW [WINSPOOL.@]
|
1999-10-31 18:34:31 +01:00
|
|
|
*
|
2000-05-26 01:02:46 +02:00
|
|
|
* Enumerates the available printers, print servers and print
|
|
|
|
* providers, depending on the specified flags, name and level.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* If level is set to 1:
|
2007-04-12 15:08:22 +02:00
|
|
|
* Returns an array of PRINTER_INFO_1 data structures in the
|
|
|
|
* lpbPrinters buffer.
|
2000-05-26 01:02:46 +02:00
|
|
|
*
|
|
|
|
* If level is set to 2:
|
|
|
|
* Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
|
2002-06-01 01:06:46 +02:00
|
|
|
* Returns an array of PRINTER_INFO_2 data structures in the
|
|
|
|
* lpbPrinters buffer. Note that according to MSDN also an
|
2000-05-26 01:02:46 +02:00
|
|
|
* OpenPrinter should be performed on every remote printer.
|
|
|
|
*
|
|
|
|
* If level is set to 4 (officially WinNT only):
|
|
|
|
* Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
|
|
|
|
* Fast: Only the registry is queried to retrieve printer names,
|
|
|
|
* no connection to the driver is made.
|
2002-06-01 01:06:46 +02:00
|
|
|
* Returns an array of PRINTER_INFO_4 data structures in the
|
2000-05-26 01:02:46 +02:00
|
|
|
* lpbPrinters buffer.
|
|
|
|
*
|
|
|
|
* If level is set to 5 (officially WinNT4/Win9x only):
|
|
|
|
* Fast: Only the registry is queried to retrieve printer names,
|
|
|
|
* no connection to the driver is made.
|
2002-06-01 01:06:46 +02:00
|
|
|
* Returns an array of PRINTER_INFO_5 data structures in the
|
2000-05-26 01:02:46 +02:00
|
|
|
* lpbPrinters buffer.
|
|
|
|
*
|
|
|
|
* If level set to 3 or 6+:
|
2001-02-28 06:26:08 +01:00
|
|
|
* returns zero (failure!)
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2001-02-28 06:26:08 +01:00
|
|
|
* Returns nonzero (TRUE) on success, or zero on failure, use GetLastError
|
2000-05-26 01:02:46 +02:00
|
|
|
* for information.
|
|
|
|
*
|
|
|
|
* BUGS:
|
|
|
|
* - Only PRINTER_ENUM_LOCAL and PRINTER_ENUM_NAME are implemented.
|
|
|
|
* - Only levels 2, 4 and 5 are implemented at the moment.
|
|
|
|
* - 16-bit printer drivers are not enumerated.
|
2002-06-01 01:06:46 +02:00
|
|
|
* - Returned amount of bytes used/needed does not match the real Windoze
|
|
|
|
* implementation (as in this implementation, all strings are part
|
2000-05-26 01:02:46 +02:00
|
|
|
* of the buffer, whereas Win32 keeps them somewhere else)
|
|
|
|
* - At level 2, EnumPrinters should also call OpenPrinter for remote printers.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* - In a regular Wine installation, no registry settings for printers
|
|
|
|
* exist, which makes this function return an empty list.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrintersW(
|
2000-12-02 00:58:28 +01:00
|
|
|
DWORD dwType, /* [in] Types of print objects to enumerate */
|
|
|
|
LPWSTR lpszName, /* [in] name of objects to enumerate */
|
|
|
|
DWORD dwLevel, /* [in] type of printer info structure */
|
|
|
|
LPBYTE lpbPrinters, /* [out] buffer which receives info */
|
|
|
|
DWORD cbBuf, /* [in] max size of buffer in bytes */
|
|
|
|
LPDWORD lpdwNeeded, /* [out] pointer to var: # bytes used/needed */
|
|
|
|
LPDWORD lpdwReturned /* [out] number of entries returned */
|
2000-05-26 01:02:46 +02:00
|
|
|
)
|
|
|
|
{
|
2009-12-01 00:04:09 +01:00
|
|
|
return WINSPOOL_EnumPrintersW(dwType, lpszName, dwLevel, lpbPrinters, cbBuf,
|
|
|
|
lpdwNeeded, lpdwReturned);
|
2000-05-26 01:02:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2008-03-22 19:28:50 +01:00
|
|
|
* EnumPrintersA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
* See EnumPrintersW
|
2000-05-26 01:02:46 +02:00
|
|
|
*
|
1999-10-31 18:34:31 +01:00
|
|
|
*/
|
2008-03-22 19:28:50 +01:00
|
|
|
BOOL WINAPI EnumPrintersA(DWORD flags, LPSTR pName, DWORD level, LPBYTE pPrinters,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
1999-10-31 18:34:31 +01:00
|
|
|
{
|
2008-03-22 19:28:50 +01:00
|
|
|
BOOL ret;
|
|
|
|
UNICODE_STRING pNameU;
|
|
|
|
LPWSTR pNameW;
|
|
|
|
LPBYTE pPrintersW;
|
|
|
|
|
|
|
|
TRACE("(0x%x, %s, %u, %p, %d, %p, %p)\n", flags, debugstr_a(pName), level,
|
|
|
|
pPrinters, cbBuf, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
pNameW = asciitounicode(&pNameU, pName);
|
2006-12-04 15:32:36 +01:00
|
|
|
|
2008-03-22 19:28:50 +01:00
|
|
|
/* Request a buffer with a size, that is big enough for EnumPrintersW.
|
|
|
|
MS Office need this */
|
|
|
|
pPrintersW = (pPrinters && cbBuf) ? HeapAlloc(GetProcessHeap(), 0, cbBuf) : NULL;
|
|
|
|
|
|
|
|
ret = EnumPrintersW(flags, pNameW, level, pPrintersW, cbBuf, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&pNameU);
|
|
|
|
if (ret) {
|
|
|
|
convert_printerinfo_W_to_A(pPrinters, pPrintersW, level, *pcbNeeded, *pcReturned);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pPrintersW);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
1999-10-31 18:34:31 +01:00
|
|
|
}
|
|
|
|
|
2000-09-29 23:05:11 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* WINSPOOL_GetDriverInfoFromReg [internal]
|
|
|
|
*
|
|
|
|
* Enters the information from the registry into the DRIVER_INFO struct
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* zero if the printer driver does not exist in the registry
|
|
|
|
* (only if Level > 1) otherwise nonzero
|
|
|
|
*/
|
|
|
|
static BOOL WINSPOOL_GetDriverInfoFromReg(
|
|
|
|
HKEY hkeyDrivers,
|
|
|
|
LPWSTR DriverName,
|
2007-07-22 17:21:25 +02:00
|
|
|
const printenv_t * env,
|
2000-09-29 23:05:11 +02:00
|
|
|
DWORD Level,
|
|
|
|
LPBYTE ptr, /* DRIVER_INFO */
|
|
|
|
LPBYTE pDriverStrings, /* strings buffer */
|
|
|
|
DWORD cbBuf, /* size of string buffer */
|
2009-12-01 17:46:13 +01:00
|
|
|
LPDWORD pcbNeeded) /* space needed for str. */
|
2006-04-14 15:34:57 +02:00
|
|
|
{
|
|
|
|
DWORD size, tmp;
|
2000-09-29 23:05:11 +02:00
|
|
|
HKEY hkeyDriver;
|
2007-07-26 23:05:27 +02:00
|
|
|
WCHAR driverdir[MAX_PATH];
|
|
|
|
DWORD dirlen;
|
2000-09-29 23:05:11 +02:00
|
|
|
LPBYTE strPtr = pDriverStrings;
|
2007-07-22 17:21:25 +02:00
|
|
|
LPDRIVER_INFO_8W di = (LPDRIVER_INFO_8W) ptr;
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2009-12-01 17:46:13 +01:00
|
|
|
TRACE("(%p, %s, %p, %d, %p, %p, %d)\n", hkeyDrivers,
|
2007-07-22 17:21:25 +02:00
|
|
|
debugstr_w(DriverName), env,
|
2009-12-01 17:46:13 +01:00
|
|
|
Level, di, pDriverStrings, cbBuf);
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2007-07-26 23:14:55 +02:00
|
|
|
if (di) ZeroMemory(di, di_sizeof[Level]);
|
|
|
|
|
2009-12-01 17:46:13 +01:00
|
|
|
*pcbNeeded = (lstrlenW(DriverName) + 1) * sizeof(WCHAR);
|
|
|
|
if (*pcbNeeded <= cbBuf)
|
|
|
|
strcpyW((LPWSTR)strPtr, DriverName);
|
2007-07-22 17:21:25 +02:00
|
|
|
|
|
|
|
/* pName for level 1 has a different offset! */
|
|
|
|
if (Level == 1) {
|
|
|
|
if (di) ((LPDRIVER_INFO_1W) di)->pName = (LPWSTR) strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-07-22 17:21:25 +02:00
|
|
|
/* .cVersion and .pName for level > 1 */
|
|
|
|
if (di) {
|
|
|
|
di->cVersion = env->driverversion;
|
|
|
|
di->pName = (LPWSTR) strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:05:27 +02:00
|
|
|
/* Reserve Space for the largest subdir and a Backslash*/
|
|
|
|
size = sizeof(driverdir) - sizeof(Version3_SubdirW) - sizeof(WCHAR);
|
|
|
|
if (!GetPrinterDriverDirectoryW(NULL, (LPWSTR) env->envname, 1, (LPBYTE) driverdir, size, &size)) {
|
|
|
|
/* Should never Fail */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
lstrcatW(driverdir, env->versionsubdir);
|
|
|
|
lstrcatW(driverdir, backslashW);
|
|
|
|
|
|
|
|
/* dirlen must not include the terminating zero */
|
2009-12-01 17:46:13 +01:00
|
|
|
dirlen = lstrlenW(driverdir) * sizeof(WCHAR);
|
2007-07-26 23:05:27 +02:00
|
|
|
|
2007-07-22 17:21:25 +02:00
|
|
|
if (!DriverName[0] || RegOpenKeyW(hkeyDrivers, DriverName, &hkeyDriver) != ERROR_SUCCESS) {
|
2007-01-18 11:37:51 +01:00
|
|
|
ERR("Can't find driver %s in registry\n", debugstr_w(DriverName));
|
2000-09-29 23:05:11 +02:00
|
|
|
SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER); /* ? */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-07-22 17:21:25 +02:00
|
|
|
/* pEnvironment */
|
2009-12-01 17:46:13 +01:00
|
|
|
size = (lstrlenW(env->envname) + 1) * sizeof(WCHAR);
|
2007-07-22 17:21:25 +02:00
|
|
|
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-22 17:21:25 +02:00
|
|
|
if (*pcbNeeded <= cbBuf) {
|
2009-12-01 17:46:13 +01:00
|
|
|
lstrcpyW((LPWSTR)strPtr, env->envname);
|
2007-07-22 17:21:25 +02:00
|
|
|
if (di) di->pEnvironment = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:05:27 +02:00
|
|
|
/* .pDriverPath is the Graphics rendering engine.
|
|
|
|
The full Path is required to avoid a crash in some apps */
|
2009-12-01 17:46:13 +01:00
|
|
|
if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, DriverW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:05:27 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:13 +01:00
|
|
|
get_filename_from_reg(hkeyDriver, driverdir, dirlen, DriverW, strPtr, size, &tmp);
|
2007-07-26 23:05:27 +02:00
|
|
|
|
|
|
|
if (di) di->pDriverPath = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
/* .pDataFile: For postscript-drivers, this is the ppd-file */
|
2009-12-01 17:46:13 +01:00
|
|
|
if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Data_FileW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:24:31 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:13 +01:00
|
|
|
get_filename_from_reg(hkeyDriver, driverdir, dirlen, Data_FileW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pDataFile = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
/* .pConfigFile is the Driver user Interface */
|
2009-12-01 17:46:13 +01:00
|
|
|
if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Configuration_FileW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:24:31 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:13 +01:00
|
|
|
get_filename_from_reg(hkeyDriver, driverdir, dirlen, Configuration_FileW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pConfigFile = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
if (Level == 2 ) {
|
2000-09-29 23:05:11 +02:00
|
|
|
RegCloseKey(hkeyDriver);
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("buffer space %d required %d\n", cbBuf, *pcbNeeded);
|
2000-09-29 23:05:11 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
if (Level == 5 ) {
|
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
FIXME("level 5: incomplete\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .pHelpFile */
|
2009-12-01 17:46:13 +01:00
|
|
|
if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Help_FileW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:24:31 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:13 +01:00
|
|
|
get_filename_from_reg(hkeyDriver, driverdir, dirlen, Help_FileW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pHelpFile = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
/* .pDependentFiles */
|
2009-12-01 17:46:13 +01:00
|
|
|
if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Dependent_FilesW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:24:31 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:13 +01:00
|
|
|
get_filename_from_reg(hkeyDriver, driverdir, dirlen, Dependent_FilesW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pDependentFiles = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
2007-08-24 20:05:57 +02:00
|
|
|
else if (GetVersion() & 0x80000000) {
|
2007-09-27 18:57:51 +02:00
|
|
|
/* PowerPoint XP expects that pDependentFiles is always valid on win9x */
|
2009-12-01 17:46:13 +01:00
|
|
|
size = 2 * sizeof(WCHAR);
|
2007-08-24 20:05:57 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if ((*pcbNeeded <= cbBuf) && strPtr) ZeroMemory(strPtr, size);
|
|
|
|
|
|
|
|
if (di) di->pDependentFiles = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
/* .pMonitorName is the optional Language Monitor */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, MonitorW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
2007-07-26 23:24:31 +02:00
|
|
|
if (*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, MonitorW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pMonitorName = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:24:31 +02:00
|
|
|
/* .pDefaultDataType */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, DatatypeW, strPtr, 0, &size)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, DatatypeW, strPtr, size, &size);
|
2007-07-26 23:24:31 +02:00
|
|
|
|
|
|
|
if (di) di->pDefaultDataType = (LPWSTR)strPtr;
|
2000-09-29 23:05:11 +02:00
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:37:22 +02:00
|
|
|
if (Level == 3 ) {
|
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
TRACE("buffer space %d required %d\n", cbBuf, *pcbNeeded);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .pszzPreviousNames */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, Previous_NamesW, strPtr, 0, &size)) {
|
2007-07-26 23:37:22 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, Previous_NamesW, strPtr, size, &size);
|
2007-07-26 23:37:22 +02:00
|
|
|
|
|
|
|
if (di) di->pszzPreviousNames = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Level == 4 ) {
|
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
TRACE("buffer space %d required %d\n", cbBuf, *pcbNeeded);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* support is missing, but not important enough for a FIXME */
|
|
|
|
TRACE("%s: DriverDate + DriverVersion not supported\n", debugstr_w(DriverName));
|
|
|
|
|
|
|
|
/* .pszMfgName */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, ManufacturerW, strPtr, 0, &size)) {
|
2007-07-26 23:37:22 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, ManufacturerW, strPtr, size, &size);
|
2007-07-26 23:37:22 +02:00
|
|
|
|
|
|
|
if (di) di->pszMfgName = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .pszOEMUrl */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, OEM_UrlW, strPtr, 0, &size)) {
|
2007-07-26 23:37:22 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, OEM_UrlW, strPtr, size, &size);
|
2007-07-26 23:37:22 +02:00
|
|
|
|
|
|
|
if (di) di->pszOEMUrl = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .pszHardwareID */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, HardwareIDW, strPtr, 0, &size)) {
|
2007-07-26 23:37:22 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, HardwareIDW, strPtr, size, &size);
|
2007-07-26 23:37:22 +02:00
|
|
|
|
|
|
|
if (di) di->pszHardwareID = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .pszProvider */
|
2009-12-01 17:46:27 +01:00
|
|
|
if (WINSPOOL_GetStringFromReg(hkeyDriver, ProviderW, strPtr, 0, &size)) {
|
2007-07-26 23:37:22 +02:00
|
|
|
*pcbNeeded += size;
|
|
|
|
if(*pcbNeeded <= cbBuf)
|
2009-12-01 17:46:27 +01:00
|
|
|
WINSPOOL_GetStringFromReg(hkeyDriver, ProviderW, strPtr, size, &size);
|
2007-07-26 23:37:22 +02:00
|
|
|
|
|
|
|
if (di) di->pszProvider = (LPWSTR)strPtr;
|
|
|
|
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Level == 6 ) {
|
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* support is missing, but not important enough for a FIXME */
|
|
|
|
TRACE("level 8: incomplete\n");
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("buffer space %d required %d\n", cbBuf, *pcbNeeded);
|
2000-09-29 23:05:11 +02:00
|
|
|
RegCloseKey(hkeyDriver);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-07-10 13:58:50 +02:00
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2009-12-01 00:05:15 +01:00
|
|
|
* GetPrinterDriverW [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2009-12-01 00:05:15 +01:00
|
|
|
BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment,
|
|
|
|
DWORD Level, LPBYTE pDriverInfo,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2001-02-28 06:26:08 +01:00
|
|
|
LPCWSTR name;
|
2000-05-26 01:02:46 +02:00
|
|
|
WCHAR DriverName[100];
|
2000-09-29 23:05:11 +02:00
|
|
|
DWORD ret, type, size, needed = 0;
|
1999-07-10 13:58:50 +02:00
|
|
|
LPBYTE ptr = NULL;
|
2012-04-19 14:43:24 +02:00
|
|
|
HKEY hkeyPrinter, hkeyDrivers;
|
2007-07-22 17:21:25 +02:00
|
|
|
const printenv_t * env;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p,%s,%d,%p,%d,%p)\n",hPrinter,debugstr_w(pEnvironment),
|
2000-05-26 01:02:46 +02:00
|
|
|
Level,pDriverInfo,cbBuf, pcbNeeded);
|
1999-05-22 20:53:56 +02:00
|
|
|
|
2009-12-23 18:21:32 +01:00
|
|
|
if (cbBuf > 0)
|
|
|
|
ZeroMemory(pDriverInfo, cbBuf);
|
2000-02-25 22:38:17 +01:00
|
|
|
|
2005-07-05 13:00:09 +02:00
|
|
|
if (!(name = get_opened_printer_name(hPrinter))) {
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-07-22 17:21:25 +02:00
|
|
|
|
2007-07-26 23:14:55 +02:00
|
|
|
if (Level < 1 || Level == 7 || Level > 8) {
|
1999-07-10 13:58:50 +02:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
2007-07-22 17:21:25 +02:00
|
|
|
return FALSE;
|
1999-07-10 13:58:50 +02:00
|
|
|
}
|
2007-07-22 17:21:25 +02:00
|
|
|
|
|
|
|
env = validate_envW(pEnvironment);
|
|
|
|
if (!env) return FALSE; /* SetLastError() is in validate_envW */
|
|
|
|
|
2012-04-19 14:43:24 +02:00
|
|
|
ret = open_printer_reg_key( name, &hkeyPrinter );
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ERR( "Can't find opened printer %s in registry\n", debugstr_w(name) );
|
|
|
|
SetLastError( ret );
|
|
|
|
return FALSE;
|
1999-07-10 13:58:50 +02:00
|
|
|
}
|
2012-04-19 14:43:24 +02:00
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
size = sizeof(DriverName);
|
2001-10-28 22:16:38 +01:00
|
|
|
DriverName[0] = 0;
|
2000-05-26 01:02:46 +02:00
|
|
|
ret = RegQueryValueExW(hkeyPrinter, Printer_DriverW, 0, &type,
|
|
|
|
(LPBYTE)DriverName, &size);
|
1999-07-10 13:58:50 +02:00
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
if(ret != ERROR_SUCCESS) {
|
2001-02-28 06:26:08 +01:00
|
|
|
ERR("Can't get DriverName for printer %s\n", debugstr_w(name));
|
1999-07-10 13:58:50 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2000-11-06 06:26:00 +01:00
|
|
|
|
2009-12-01 00:03:58 +01:00
|
|
|
hkeyDrivers = WINSPOOL_OpenDriverReg(pEnvironment);
|
2000-11-06 06:26:00 +01:00
|
|
|
if(!hkeyDrivers) {
|
1999-07-10 13:58:50 +02:00
|
|
|
ERR("Can't create Drivers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-07-26 23:14:55 +02:00
|
|
|
size = di_sizeof[Level];
|
|
|
|
if ((size <= cbBuf) && pDriverInfo)
|
1999-07-10 13:58:50 +02:00
|
|
|
ptr = pDriverInfo + size;
|
|
|
|
|
2000-09-29 23:05:11 +02:00
|
|
|
if(!WINSPOOL_GetDriverInfoFromReg(hkeyDrivers, DriverName,
|
2007-07-26 23:14:55 +02:00
|
|
|
env, Level, pDriverInfo, ptr,
|
2000-09-29 23:05:11 +02:00
|
|
|
(cbBuf < size) ? 0 : cbBuf - size,
|
2009-12-01 17:46:13 +01:00
|
|
|
&needed)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
return FALSE;
|
1999-07-10 13:58:50 +02:00
|
|
|
}
|
2000-09-29 23:05:11 +02:00
|
|
|
|
1999-07-10 13:58:50 +02:00
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
|
2000-11-12 04:39:53 +01:00
|
|
|
if(pcbNeeded) *pcbNeeded = size + needed;
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("buffer space %d required %d\n", cbBuf, size + needed);
|
2009-12-23 18:21:17 +01:00
|
|
|
if(cbBuf >= size + needed) return TRUE;
|
1999-07-10 13:58:50 +02:00
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
1999-05-17 18:20:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-26 01:02:46 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* GetPrinterDriverA [WINSPOOL.@]
|
2000-05-26 01:02:46 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment,
|
|
|
|
DWORD Level, LPBYTE pDriverInfo,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING pEnvW;
|
2003-02-12 02:19:25 +01:00
|
|
|
PWSTR pwstrEnvW;
|
2009-12-01 00:05:15 +01:00
|
|
|
LPBYTE buf = NULL;
|
|
|
|
|
|
|
|
if (cbBuf)
|
2009-12-23 18:21:32 +01:00
|
|
|
{
|
|
|
|
ZeroMemory(pDriverInfo, cbBuf);
|
2009-12-01 00:05:15 +01:00
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, cbBuf);
|
2009-12-23 18:21:32 +01:00
|
|
|
}
|
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
pwstrEnvW = asciitounicode(&pEnvW, pEnvironment);
|
2009-12-01 00:05:15 +01:00
|
|
|
ret = GetPrinterDriverW(hPrinter, pwstrEnvW, Level, buf,
|
|
|
|
cbBuf, pcbNeeded);
|
|
|
|
if (ret)
|
|
|
|
convert_driverinfo_W_to_A(pDriverInfo, buf, Level, cbBuf, 1);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
|
2003-01-24 00:07:38 +01:00
|
|
|
RtlFreeUnicodeString(&pEnvW);
|
2000-05-26 01:02:46 +02:00
|
|
|
return ret;
|
|
|
|
}
|
1999-05-22 20:53:56 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2003-01-03 04:04:46 +01:00
|
|
|
* GetPrinterDriverDirectoryW [WINSPOOL.@]
|
2005-11-28 17:29:38 +01:00
|
|
|
*
|
|
|
|
* Return the PATH for the Printer-Drivers (UNICODE)
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername (NT only) or NULL (local Computer)
|
|
|
|
* pEnvironment [I] Printing-Environment (see below) or NULL (Default)
|
|
|
|
* Level [I] Structure-Level (must be 1)
|
|
|
|
* pDriverDirectory [O] PTR to Buffer that receives the Result
|
|
|
|
* cbBuf [I] Size of Buffer at pDriverDirectory
|
|
|
|
* pcbNeeded [O] PTR to DWORD that receives the size in Bytes used /
|
|
|
|
* required for pDriverDirectory
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE and in pcbNeeded the Bytes used in pDriverDirectory
|
|
|
|
* Failure: FALSE and in pcbNeeded the Bytes required for pDriverDirectory,
|
2005-12-02 16:15:09 +01:00
|
|
|
* if cbBuf is too small
|
2005-11-28 17:29:38 +01:00
|
|
|
*
|
|
|
|
* Native Values returned in pDriverDirectory on Success:
|
|
|
|
*| NT(Windows NT x86): "%winsysdir%\\spool\\DRIVERS\\w32x86"
|
|
|
|
*| NT(Windows 4.0): "%winsysdir%\\spool\\DRIVERS\\win40"
|
|
|
|
*| win9x(Windows 4.0): "%winsysdir%"
|
|
|
|
*
|
|
|
|
* "%winsysdir%" is the Value from GetSystemDirectoryW()
|
|
|
|
*
|
|
|
|
* FIXME
|
2006-02-01 12:32:10 +01:00
|
|
|
*- Only NULL or "" is supported for pName
|
2005-11-28 17:29:38 +01:00
|
|
|
*
|
1999-05-22 20:53:56 +02:00
|
|
|
*/
|
2003-01-03 04:04:46 +01:00
|
|
|
BOOL WINAPI GetPrinterDriverDirectoryW(LPWSTR pName, LPWSTR pEnvironment,
|
1999-05-22 20:53:56 +02:00
|
|
|
DWORD Level, LPBYTE pDriverDirectory,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(pName),
|
2003-01-03 04:04:46 +01:00
|
|
|
debugstr_w(pEnvironment), Level, pDriverDirectory, cbBuf, pcbNeeded);
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2008-02-04 09:51:38 +01:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2008-02-04 09:51:38 +01:00
|
|
|
if (Level != 1) {
|
|
|
|
/* (Level != 1) is ignored in win9x */
|
2006-01-18 12:26:32 +01:00
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
1999-05-22 20:53:56 +02:00
|
|
|
}
|
2008-02-04 09:51:38 +01:00
|
|
|
if (pcbNeeded == NULL) {
|
|
|
|
/* (pcbNeeded == NULL) is ignored in win9x */
|
2006-01-18 12:26:32 +01:00
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
1999-05-22 20:53:56 +02:00
|
|
|
}
|
2008-02-04 09:51:38 +01:00
|
|
|
|
|
|
|
return backend->fpGetPrinterDriverDirectory(pName, pEnvironment, Level,
|
|
|
|
pDriverDirectory, cbBuf, pcbNeeded);
|
|
|
|
|
1999-05-22 20:53:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2003-01-03 04:04:46 +01:00
|
|
|
* GetPrinterDriverDirectoryA [WINSPOOL.@]
|
2005-11-28 17:29:38 +01:00
|
|
|
*
|
|
|
|
* Return the PATH for the Printer-Drivers (ANSI)
|
|
|
|
*
|
|
|
|
* See GetPrinterDriverDirectoryW.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* On NT, pDriverDirectory need the same Size as the Unicode-Version
|
|
|
|
*
|
1999-05-22 20:53:56 +02:00
|
|
|
*/
|
2003-01-03 04:04:46 +01:00
|
|
|
BOOL WINAPI GetPrinterDriverDirectoryA(LPSTR pName, LPSTR pEnvironment,
|
1999-05-22 20:53:56 +02:00
|
|
|
DWORD Level, LPBYTE pDriverDirectory,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
|
|
|
{
|
2003-01-03 04:04:46 +01:00
|
|
|
UNICODE_STRING nameW, environmentW;
|
1999-05-22 20:53:56 +02:00
|
|
|
BOOL ret;
|
2003-01-03 04:04:46 +01:00
|
|
|
DWORD pcbNeededW;
|
|
|
|
INT len = cbBuf * sizeof(WCHAR)/sizeof(CHAR);
|
|
|
|
WCHAR *driverDirectoryW = NULL;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_a(pName),
|
2006-01-18 12:26:32 +01:00
|
|
|
debugstr_a(pEnvironment), Level, pDriverDirectory, cbBuf, pcbNeeded);
|
|
|
|
|
2003-01-03 04:04:46 +01:00
|
|
|
if (len) driverDirectoryW = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
|
|
|
|
if(pName) RtlCreateUnicodeStringFromAsciiz(&nameW, pName);
|
|
|
|
else nameW.Buffer = NULL;
|
|
|
|
if(pEnvironment) RtlCreateUnicodeStringFromAsciiz(&environmentW, pEnvironment);
|
|
|
|
else environmentW.Buffer = NULL;
|
|
|
|
|
|
|
|
ret = GetPrinterDriverDirectoryW( nameW.Buffer, environmentW.Buffer, Level,
|
|
|
|
(LPBYTE)driverDirectoryW, len, &pcbNeededW );
|
|
|
|
if (ret) {
|
2003-01-15 01:51:16 +01:00
|
|
|
DWORD needed;
|
2006-01-18 12:26:32 +01:00
|
|
|
needed = WideCharToMultiByte( CP_ACP, 0, driverDirectoryW, -1,
|
2005-08-19 12:04:03 +02:00
|
|
|
(LPSTR)pDriverDirectory, cbBuf, NULL, NULL);
|
2003-01-08 20:52:25 +01:00
|
|
|
if(pcbNeeded)
|
2003-01-15 01:51:16 +01:00
|
|
|
*pcbNeeded = needed;
|
2012-08-14 23:28:13 +02:00
|
|
|
ret = needed <= cbBuf;
|
2003-01-03 04:04:46 +01:00
|
|
|
} else
|
2003-01-08 20:52:25 +01:00
|
|
|
if(pcbNeeded) *pcbNeeded = pcbNeededW * sizeof(CHAR)/sizeof(WCHAR);
|
2003-01-03 04:04:46 +01:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("required: 0x%x/%d\n", pcbNeeded ? *pcbNeeded : 0, pcbNeeded ? *pcbNeeded : 0);
|
2003-01-03 04:04:46 +01:00
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, driverDirectoryW );
|
2003-01-03 04:04:46 +01:00
|
|
|
RtlFreeUnicodeString(&environmentW);
|
|
|
|
RtlFreeUnicodeString(&nameW);
|
1999-05-22 20:53:56 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* AddPrinterDriverA [WINSPOOL.@]
|
2007-08-24 00:02:11 +02:00
|
|
|
*
|
|
|
|
* See AddPrinterDriverW.
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
1999-05-22 20:53:56 +02:00
|
|
|
BOOL WINAPI AddPrinterDriverA(LPSTR pName, DWORD level, LPBYTE pDriverInfo)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2007-08-24 00:02:11 +02:00
|
|
|
TRACE("(%s, %d, %p)\n", debugstr_a(pName), level, pDriverInfo);
|
|
|
|
return AddPrinterDriverExA(pName, level, pDriverInfo, APD_COPY_NEW_FILES);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
|
2007-08-24 00:02:11 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddPrinterDriverW (WINSPOOL.@)
|
|
|
|
*
|
|
|
|
* Install a Printer Driver
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* level [I] Level for the supplied DRIVER_INFO_*W struct
|
|
|
|
* pDriverInfo [I] PTR to DRIVER_INFO_*W struct with the Driver Parameter
|
|
|
|
*
|
|
|
|
* RESULTS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
1999-05-17 18:20:51 +02:00
|
|
|
*/
|
2007-08-24 00:02:11 +02:00
|
|
|
BOOL WINAPI AddPrinterDriverW(LPWSTR pName, DWORD level, LPBYTE pDriverInfo)
|
1999-05-17 18:20:51 +02:00
|
|
|
{
|
2007-08-24 00:02:11 +02:00
|
|
|
TRACE("(%s, %d, %p)\n", debugstr_w(pName), level, pDriverInfo);
|
|
|
|
return AddPrinterDriverExW(pName, level, pDriverInfo, APD_COPY_NEW_FILES);
|
1999-05-17 18:20:51 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* AddPrintProcessorA [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrintProcessorA(LPSTR pName, LPSTR pEnvironment, LPSTR pPathName,
|
|
|
|
LPSTR pPrintProcessorName)
|
|
|
|
{
|
|
|
|
FIXME("(%s,%s,%s,%s): stub\n", debugstr_a(pName), debugstr_a(pEnvironment),
|
|
|
|
debugstr_a(pPathName), debugstr_a(pPrintProcessorName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* AddPrintProcessorW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrintProcessorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pPathName,
|
|
|
|
LPWSTR pPrintProcessorName)
|
|
|
|
{
|
|
|
|
FIXME("(%s,%s,%s,%s): stub\n", debugstr_w(pName), debugstr_w(pEnvironment),
|
|
|
|
debugstr_w(pPathName), debugstr_w(pPrintProcessorName));
|
2010-11-16 09:07:50 +01:00
|
|
|
return TRUE;
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* AddPrintProvidorA [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrintProvidorA(LPSTR pName, DWORD Level, LPBYTE pProviderInfo)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%s,0x%08x,%p): stub\n", debugstr_a(pName), Level, pProviderInfo);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* AddPrintProvidorW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrintProvidorW(LPWSTR pName, DWORD Level, LPBYTE pProviderInfo)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%s,0x%08x,%p): stub\n", debugstr_w(pName), Level, pProviderInfo);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* AdvancedDocumentPropertiesA [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI AdvancedDocumentPropertiesA(HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName,
|
|
|
|
PDEVMODEA pDevModeOutput, PDEVMODEA pDevModeInput)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%s,%p,%p): stub\n", hWnd, hPrinter, debugstr_a(pDeviceName),
|
|
|
|
pDevModeOutput, pDevModeInput);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* AdvancedDocumentPropertiesW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
LONG WINAPI AdvancedDocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName,
|
|
|
|
PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p,%s,%p,%p): stub\n", hWnd, hPrinter, debugstr_w(pDeviceName),
|
|
|
|
pDevModeOutput, pDevModeInput);
|
|
|
|
return 0;
|
|
|
|
}
|
1999-05-17 18:20:51 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* PrinterProperties [WINSPOOL.@]
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
|
|
|
* Displays a dialog to set the properties of the printer.
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* RETURNS
|
2001-02-28 06:26:08 +01:00
|
|
|
* nonzero on success or zero on failure
|
1999-05-17 18:20:51 +02:00
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* implemented as stub only
|
|
|
|
*/
|
2000-12-02 00:58:28 +01:00
|
|
|
BOOL WINAPI PrinterProperties(HWND hWnd, /* [in] handle to parent window */
|
|
|
|
HANDLE hPrinter /* [in] handle to printer object */
|
1999-05-17 18:20:51 +02:00
|
|
|
){
|
2002-10-22 02:47:33 +02:00
|
|
|
FIXME("(%p,%p): stub\n", hWnd, hPrinter);
|
1999-05-17 18:20:51 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-07-23 21:23:49 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumJobsA [WINSPOOL.@]
|
1999-07-23 21:23:49 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumJobsA(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
|
|
|
|
DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded,
|
|
|
|
LPDWORD pcReturned)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,first=%d,no=%d,level=%d,job=%p,cb=%d,%p,%p), stub!\n",
|
2002-11-12 03:22:24 +01:00
|
|
|
hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned
|
|
|
|
);
|
1999-07-23 21:23:49 +02:00
|
|
|
if(pcbNeeded) *pcbNeeded = 0;
|
|
|
|
if(pcReturned) *pcReturned = 0;
|
2002-11-12 03:22:24 +01:00
|
|
|
return FALSE;
|
1999-07-23 21:23:49 +02:00
|
|
|
}
|
|
|
|
|
1999-05-17 18:20:51 +02:00
|
|
|
|
1999-07-23 21:23:49 +02:00
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumJobsW [WINSPOOL.@]
|
1999-07-23 21:23:49 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumJobsW(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
|
|
|
|
DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded,
|
|
|
|
LPDWORD pcReturned)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("(%p,first=%d,no=%d,level=%d,job=%p,cb=%d,%p,%p), stub!\n",
|
2002-11-12 03:22:24 +01:00
|
|
|
hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned
|
|
|
|
);
|
1999-07-23 21:23:49 +02:00
|
|
|
if(pcbNeeded) *pcbNeeded = 0;
|
|
|
|
if(pcReturned) *pcReturned = 0;
|
2002-11-12 03:22:24 +01:00
|
|
|
return FALSE;
|
1999-07-23 21:23:49 +02:00
|
|
|
}
|
2000-09-29 23:05:11 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* WINSPOOL_EnumPrinterDrivers [internal]
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Delivers information about all printer drivers installed on the
|
2000-09-29 23:05:11 +02:00
|
|
|
* localhost or a given server
|
|
|
|
*
|
|
|
|
* RETURNS
|
2001-02-28 06:26:08 +01:00
|
|
|
* nonzero on success or zero on failure. If the buffer for the returned
|
2000-09-29 23:05:11 +02:00
|
|
|
* information is too small the function will return an error
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* - only implemented for localhost, foreign hosts will return an error
|
|
|
|
*/
|
2007-02-18 11:51:09 +01:00
|
|
|
static BOOL WINSPOOL_EnumPrinterDrivers(LPWSTR pName, LPCWSTR pEnvironment,
|
2000-09-29 23:05:11 +02:00
|
|
|
DWORD Level, LPBYTE pDriverInfo,
|
2009-12-01 17:46:07 +01:00
|
|
|
DWORD driver_index,
|
2000-09-29 23:05:11 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded,
|
2009-12-01 17:46:07 +01:00
|
|
|
LPDWORD pcFound, DWORD data_offset)
|
2000-09-29 23:05:11 +02:00
|
|
|
|
|
|
|
{ HKEY hkeyDrivers;
|
2009-12-01 17:46:07 +01:00
|
|
|
DWORD i, size = 0;
|
2007-07-22 17:21:25 +02:00
|
|
|
const printenv_t * env;
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
TRACE("%s,%s,%d,%p,%d,%d,%d\n",
|
2000-09-29 23:05:11 +02:00
|
|
|
debugstr_w(pName), debugstr_w(pEnvironment),
|
2009-12-01 17:46:07 +01:00
|
|
|
Level, pDriverInfo, driver_index, cbBuf, data_offset);
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2007-07-22 17:21:25 +02:00
|
|
|
env = validate_envW(pEnvironment);
|
|
|
|
if (!env) return FALSE; /* SetLastError() is in validate_envW */
|
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
*pcFound = 0;
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2009-12-01 00:03:58 +01:00
|
|
|
hkeyDrivers = WINSPOOL_OpenDriverReg(pEnvironment);
|
2000-11-06 06:26:00 +01:00
|
|
|
if(!hkeyDrivers) {
|
2000-09-29 23:05:11 +02:00
|
|
|
ERR("Can't open Drivers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
if(RegQueryInfoKeyA(hkeyDrivers, NULL, NULL, NULL, pcFound, NULL, NULL,
|
2000-09-29 23:05:11 +02:00
|
|
|
NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
|
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
ERR("Can't query Drivers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-12-01 17:46:07 +01:00
|
|
|
TRACE("Found %d Drivers\n", *pcFound);
|
2000-09-29 23:05:11 +02:00
|
|
|
|
|
|
|
/* get size of single struct
|
|
|
|
* unicode and ascii structure have the same size
|
|
|
|
*/
|
2007-07-26 23:14:55 +02:00
|
|
|
size = di_sizeof[Level];
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
if (data_offset == 0)
|
|
|
|
data_offset = size * (*pcFound);
|
|
|
|
*pcbNeeded = data_offset;
|
|
|
|
|
|
|
|
for( i = 0; i < *pcFound; i++) {
|
|
|
|
WCHAR DriverNameW[255];
|
|
|
|
PBYTE table_ptr = NULL;
|
|
|
|
PBYTE data_ptr = NULL;
|
|
|
|
DWORD needed = 0;
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2007-12-01 17:43:37 +01:00
|
|
|
if(RegEnumKeyW(hkeyDrivers, i, DriverNameW, sizeof(DriverNameW)/sizeof(DriverNameW[0]))
|
2000-09-29 23:05:11 +02:00
|
|
|
!= ERROR_SUCCESS) {
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR("Can't enum key number %d\n", i);
|
2000-09-29 23:05:11 +02:00
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-12-01 17:46:07 +01:00
|
|
|
|
|
|
|
if (pDriverInfo && ((driver_index + i + 1) * size) <= cbBuf)
|
|
|
|
table_ptr = pDriverInfo + (driver_index + i) * size;
|
|
|
|
if (pDriverInfo && *pcbNeeded <= cbBuf)
|
|
|
|
data_ptr = pDriverInfo + *pcbNeeded;
|
|
|
|
|
2000-09-29 23:05:11 +02:00
|
|
|
if(!WINSPOOL_GetDriverInfoFromReg(hkeyDrivers, DriverNameW,
|
2009-12-01 17:46:07 +01:00
|
|
|
env, Level, table_ptr, data_ptr,
|
2000-09-29 23:05:11 +02:00
|
|
|
(cbBuf < *pcbNeeded) ? 0 : cbBuf - *pcbNeeded,
|
2009-12-01 17:46:13 +01:00
|
|
|
&needed)) {
|
2000-09-29 23:05:11 +02:00
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-12-01 17:46:07 +01:00
|
|
|
|
2009-03-24 10:27:01 +01:00
|
|
|
*pcbNeeded += needed;
|
2000-09-29 23:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkeyDrivers);
|
|
|
|
|
|
|
|
if(cbBuf < *pcbNeeded){
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPrinterDriversW [WINSPOOL.@]
|
2000-09-29 23:05:11 +02:00
|
|
|
*
|
|
|
|
* see function EnumPrinterDrivers for RETURNS, BUGS
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
|
|
|
|
LPBYTE pDriverInfo, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, LPDWORD pcReturned)
|
|
|
|
{
|
2009-03-24 10:27:01 +01:00
|
|
|
static const WCHAR allW[] = {'a','l','l',0};
|
2009-12-01 17:46:07 +01:00
|
|
|
BOOL ret;
|
|
|
|
DWORD found;
|
|
|
|
|
|
|
|
if ((pcbNeeded == NULL) || (pcReturned == NULL))
|
|
|
|
{
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-03-24 10:27:01 +01:00
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
/* check for local drivers */
|
|
|
|
if((pName) && (pName[0])) {
|
|
|
|
FIXME("remote drivers (%s) not supported!\n", debugstr_w(pName));
|
|
|
|
SetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check input parameter */
|
|
|
|
if ((Level < 1) || (Level == 7) || (Level > 8)) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pDriverInfo && cbBuf > 0)
|
|
|
|
memset( pDriverInfo, 0, cbBuf);
|
|
|
|
|
|
|
|
/* Exception: pull all printers */
|
2009-03-24 10:27:01 +01:00
|
|
|
if (pEnvironment && !strcmpW(pEnvironment, allW))
|
|
|
|
{
|
2009-12-01 17:46:07 +01:00
|
|
|
DWORD i, needed, bufsize = cbBuf;
|
|
|
|
DWORD total_found = 0;
|
|
|
|
DWORD data_offset;
|
|
|
|
|
|
|
|
/* Precompute the overall total; we need this to know
|
|
|
|
where pointers end and data begins (i.e. data_offset) */
|
|
|
|
for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++)
|
|
|
|
{
|
|
|
|
needed = found = 0;
|
|
|
|
ret = WINSPOOL_EnumPrinterDrivers(pName, all_printenv[i]->envname, Level,
|
|
|
|
NULL, 0, 0, &needed, &found, 0);
|
|
|
|
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
|
|
|
|
total_found += found;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_offset = di_sizeof[Level] * total_found;
|
2009-03-24 10:27:01 +01:00
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
*pcReturned = 0;
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
total_found = 0;
|
2009-03-24 10:27:01 +01:00
|
|
|
for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++)
|
|
|
|
{
|
2009-12-01 17:46:07 +01:00
|
|
|
needed = found = 0;
|
2009-03-24 10:27:01 +01:00
|
|
|
ret = WINSPOOL_EnumPrinterDrivers(pName, all_printenv[i]->envname, Level,
|
2009-12-01 17:46:07 +01:00
|
|
|
pDriverInfo, total_found, bufsize, &needed, &found, data_offset);
|
2009-03-24 10:27:01 +01:00
|
|
|
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
|
|
|
|
else if (ret)
|
2009-12-01 17:46:07 +01:00
|
|
|
*pcReturned += found;
|
|
|
|
*pcbNeeded = needed;
|
|
|
|
data_offset = needed;
|
|
|
|
total_found += found;
|
2009-03-24 10:27:01 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2009-12-01 17:46:07 +01:00
|
|
|
|
|
|
|
/* Normal behavior */
|
|
|
|
ret = WINSPOOL_EnumPrinterDrivers(pName, pEnvironment, Level, pDriverInfo,
|
|
|
|
0, cbBuf, pcbNeeded, &found, 0);
|
|
|
|
if (ret)
|
|
|
|
*pcReturned = found;
|
|
|
|
|
|
|
|
return ret;
|
2000-09-29 23:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPrinterDriversA [WINSPOOL.@]
|
2000-09-29 23:05:11 +02:00
|
|
|
*
|
|
|
|
* see function EnumPrinterDrivers for RETURNS, BUGS
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrinterDriversA(LPSTR pName, LPSTR pEnvironment, DWORD Level,
|
|
|
|
LPBYTE pDriverInfo, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, LPDWORD pcReturned)
|
2009-03-24 10:27:01 +01:00
|
|
|
{
|
|
|
|
BOOL ret;
|
2003-01-24 00:07:38 +01:00
|
|
|
UNICODE_STRING pNameW, pEnvironmentW;
|
2003-02-12 02:19:25 +01:00
|
|
|
PWSTR pwstrNameW, pwstrEnvironmentW;
|
2009-12-01 17:46:07 +01:00
|
|
|
LPBYTE buf = NULL;
|
|
|
|
|
|
|
|
if (cbBuf)
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, cbBuf);
|
2003-01-24 00:07:38 +01:00
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
pwstrNameW = asciitounicode(&pNameW, pName);
|
|
|
|
pwstrEnvironmentW = asciitounicode(&pEnvironmentW, pEnvironment);
|
2000-09-29 23:05:11 +02:00
|
|
|
|
2009-12-01 17:46:07 +01:00
|
|
|
ret = EnumPrinterDriversW(pwstrNameW, pwstrEnvironmentW, Level,
|
|
|
|
buf, cbBuf, pcbNeeded, pcReturned);
|
|
|
|
if (ret)
|
|
|
|
convert_driverinfo_W_to_A(pDriverInfo, buf, Level, cbBuf, *pcReturned);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2009-03-24 10:27:01 +01:00
|
|
|
|
2003-02-12 02:19:25 +01:00
|
|
|
RtlFreeUnicodeString(&pNameW);
|
|
|
|
RtlFreeUnicodeString(&pEnvironmentW);
|
2000-09-29 23:05:11 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2000-11-28 23:33:46 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPortsA (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* See EnumPortsW.
|
|
|
|
*
|
2000-11-28 23:33:46 +01:00
|
|
|
*/
|
2006-11-04 00:27:31 +01:00
|
|
|
BOOL WINAPI EnumPortsA( LPSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, LPDWORD pcReturned)
|
2000-11-28 23:33:46 +01:00
|
|
|
{
|
2006-11-04 00:27:31 +01:00
|
|
|
BOOL res;
|
|
|
|
LPBYTE bufferW = NULL;
|
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
DWORD needed = 0;
|
|
|
|
DWORD numentries = 0;
|
|
|
|
INT len;
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_a(pName), Level, pPorts,
|
|
|
|
cbBuf, pcbNeeded, pcReturned);
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
/* convert servername to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
2003-05-20 01:19:21 +02:00
|
|
|
}
|
2006-11-04 00:27:31 +01:00
|
|
|
/* alloc (userbuffersize*sizeof(WCHAR) and try to enum the Ports */
|
|
|
|
needed = cbBuf * sizeof(WCHAR);
|
|
|
|
if (needed) bufferW = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
res = EnumPortsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
if (pcbNeeded) needed = *pcbNeeded;
|
|
|
|
/* HeapReAlloc return NULL, when bufferW was NULL */
|
|
|
|
bufferW = (bufferW) ? HeapReAlloc(GetProcessHeap(), 0, bufferW, needed) :
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, needed);
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
/* Try again with the large Buffer */
|
|
|
|
res = EnumPortsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
2003-05-20 01:19:21 +02:00
|
|
|
}
|
2006-11-04 00:27:31 +01:00
|
|
|
needed = pcbNeeded ? *pcbNeeded : 0;
|
|
|
|
numentries = pcReturned ? *pcReturned : 0;
|
2004-10-18 21:38:57 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
/*
|
|
|
|
W2k require the buffersize from EnumPortsW also for EnumPortsA.
|
|
|
|
We use the smaller Ansi-Size to avoid conflicts with fixed Buffers of old Apps.
|
|
|
|
*/
|
|
|
|
if (res) {
|
2007-01-18 11:35:50 +01:00
|
|
|
/* EnumPortsW collected all Data. Parse them to calculate ANSI-Size */
|
2006-11-04 00:27:31 +01:00
|
|
|
DWORD entrysize = 0;
|
|
|
|
DWORD index;
|
|
|
|
LPSTR ptr;
|
|
|
|
LPPORT_INFO_2W pi2w;
|
|
|
|
LPPORT_INFO_2A pi2a;
|
|
|
|
|
|
|
|
needed = 0;
|
|
|
|
entrysize = (Level == 1) ? sizeof(PORT_INFO_1A) : sizeof(PORT_INFO_2A);
|
|
|
|
|
|
|
|
/* First pass: calculate the size for all Entries */
|
|
|
|
pi2w = (LPPORT_INFO_2W) bufferW;
|
|
|
|
pi2a = (LPPORT_INFO_2A) pPorts;
|
|
|
|
index = 0;
|
|
|
|
while (index < numentries) {
|
|
|
|
index++;
|
|
|
|
needed += entrysize; /* PORT_INFO_?A */
|
|
|
|
TRACE("%p: parsing #%d (%s)\n", pi2w, index, debugstr_w(pi2w->pPortName));
|
|
|
|
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pPortName, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (Level > 1) {
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pMonitorName, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, pi2w->pDescription, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
/* use LPBYTE with entrysize to avoid double code (PORT_INFO_1 + PORT_INFO_2) */
|
|
|
|
pi2w = (LPPORT_INFO_2W) (((LPBYTE)pi2w) + entrysize);
|
|
|
|
pi2a = (LPPORT_INFO_2A) (((LPBYTE)pi2a) + entrysize);
|
2004-10-04 22:40:44 +02:00
|
|
|
}
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
/* check for errors and quit on failure */
|
|
|
|
if (cbBuf < needed) {
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
res = FALSE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
len = entrysize * numentries; /* room for all PORT_INFO_?A */
|
|
|
|
ptr = (LPSTR) &pPorts[len]; /* room for strings */
|
|
|
|
cbBuf -= len ; /* free Bytes in the user-Buffer */
|
|
|
|
pi2w = (LPPORT_INFO_2W) bufferW;
|
|
|
|
pi2a = (LPPORT_INFO_2A) pPorts;
|
|
|
|
index = 0;
|
|
|
|
/* Second Pass: Fill the User Buffer (if we have one) */
|
|
|
|
while ((index < numentries) && pPorts) {
|
|
|
|
index++;
|
|
|
|
TRACE("%p: writing PORT_INFO_%dA #%d\n", pi2a, Level, index);
|
|
|
|
pi2a->pPortName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, pi2w->pPortName, -1,
|
|
|
|
ptr, cbBuf , NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
if (Level > 1) {
|
|
|
|
pi2a->pMonitorName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, pi2w->pMonitorName, -1,
|
|
|
|
ptr, cbBuf, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
|
|
|
|
pi2a->pDescription = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, pi2w->pDescription, -1,
|
|
|
|
ptr, cbBuf, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
|
|
|
|
pi2a->fPortType = pi2w->fPortType;
|
|
|
|
pi2a->Reserved = 0; /* documented: "must be zero" */
|
|
|
|
|
2003-05-20 01:19:21 +02:00
|
|
|
}
|
2006-11-04 00:27:31 +01:00
|
|
|
/* use LPBYTE with entrysize to avoid double code (PORT_INFO_1 + PORT_INFO_2) */
|
|
|
|
pi2w = (LPPORT_INFO_2W) (((LPBYTE)pi2w) + entrysize);
|
|
|
|
pi2a = (LPPORT_INFO_2A) (((LPBYTE)pi2a) + entrysize);
|
2004-10-18 21:38:57 +02:00
|
|
|
}
|
2003-05-20 01:19:21 +02:00
|
|
|
}
|
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
cleanup:
|
|
|
|
if (pcbNeeded) *pcbNeeded = needed;
|
|
|
|
if (pcReturned) *pcReturned = (res) ? numentries : 0;
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2006-11-04 00:27:31 +01:00
|
|
|
TRACE("returning %d with %d (%d byte for %d of %d entries)\n",
|
|
|
|
(res), GetLastError(), needed, (res)? numentries : 0, numentries);
|
|
|
|
|
|
|
|
return (res);
|
2003-05-20 01:19:21 +02:00
|
|
|
|
2000-11-28 23:33:46 +01:00
|
|
|
}
|
2001-02-12 02:26:47 +01:00
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumPortsW (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* Enumerate available Ports
|
|
|
|
*
|
|
|
|
* PARAMS
|
2009-02-08 16:45:08 +01:00
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* Level [I] Structure-Level (1 or 2)
|
|
|
|
* pPorts [O] PTR to Buffer that receives the Result
|
|
|
|
* cbBuf [I] Size of Buffer at pPorts
|
|
|
|
* pcbNeeded [O] PTR to DWORD that receives the size in Bytes used / required for pPorts
|
|
|
|
* pcReturned [O] PTR to DWORD that receives the number of Ports in pPorts
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
2009-02-08 16:45:08 +01:00
|
|
|
* Failure: FALSE and in pcbNeeded the Bytes required for pPorts, if cbBuf is too small
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
2006-11-04 00:27:16 +01:00
|
|
|
BOOL WINAPI EnumPortsW(LPWSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2006-11-04 00:27:16 +01:00
|
|
|
|
|
|
|
TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_w(pName), Level, pPorts,
|
|
|
|
cbBuf, pcbNeeded, pcReturned);
|
|
|
|
|
2009-02-08 16:45:08 +01:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-11-04 00:27:16 +01:00
|
|
|
|
|
|
|
/* Level is not checked in win9x */
|
|
|
|
if (!Level || (Level > 2)) {
|
|
|
|
WARN("level (%d) is ignored in win9x\n", Level);
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
2009-02-08 16:45:08 +01:00
|
|
|
return FALSE;
|
2006-11-04 00:27:16 +01:00
|
|
|
}
|
2009-02-08 16:45:08 +01:00
|
|
|
if (!pcbNeeded || (!pPorts && (cbBuf > 0))) {
|
2006-11-04 00:27:16 +01:00
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
2009-02-08 16:45:08 +01:00
|
|
|
return FALSE;
|
2006-11-04 00:27:16 +01:00
|
|
|
}
|
|
|
|
|
2009-02-08 16:45:08 +01:00
|
|
|
return backend->fpEnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
2004-03-07 04:46:54 +01:00
|
|
|
|
2002-01-22 01:49:24 +01:00
|
|
|
/******************************************************************************
|
2004-03-07 04:46:54 +01:00
|
|
|
* GetDefaultPrinterW (WINSPOOL.@)
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* This function must read the value from data 'device' of key
|
|
|
|
* HCU\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows
|
2002-01-22 01:49:24 +01:00
|
|
|
*/
|
2004-03-07 04:46:54 +01:00
|
|
|
BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
|
2002-01-22 01:49:24 +01:00
|
|
|
{
|
2004-03-07 04:46:54 +01:00
|
|
|
BOOL retval = TRUE;
|
|
|
|
DWORD insize, len;
|
|
|
|
WCHAR *buffer, *ptr;
|
2002-01-22 01:49:24 +01:00
|
|
|
|
2004-03-07 04:46:54 +01:00
|
|
|
if (!namesize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-01-22 01:49:24 +01:00
|
|
|
|
2004-03-07 04:46:54 +01:00
|
|
|
/* make the buffer big enough for the stuff from the profile/registry,
|
|
|
|
* the content must fit into the local buffer to compute the correct
|
2005-05-06 17:44:31 +02:00
|
|
|
* size even if the extern buffer is too small or not given.
|
2004-03-07 04:46:54 +01:00
|
|
|
* (20 for ,driver,port) */
|
|
|
|
insize = *namesize;
|
|
|
|
len = max(100, (insize + 20));
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
|
2002-01-22 01:49:24 +01:00
|
|
|
|
2004-03-07 04:46:54 +01:00
|
|
|
if (!GetProfileStringW(windowsW, deviceW, emptyStringW, buffer, len))
|
|
|
|
{
|
|
|
|
SetLastError (ERROR_FILE_NOT_FOUND);
|
|
|
|
retval = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
TRACE("%s\n", debugstr_w(buffer));
|
|
|
|
|
|
|
|
if ((ptr = strchrW(buffer, ',')) == NULL)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_NAME);
|
|
|
|
retval = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
2002-01-22 01:49:24 +01:00
|
|
|
|
2004-03-07 04:46:54 +01:00
|
|
|
*ptr = 0;
|
|
|
|
*namesize = strlenW(buffer) + 1;
|
|
|
|
if(!name || (*namesize > insize))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
retval = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
strcpyW(name, buffer);
|
|
|
|
|
|
|
|
end:
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, buffer);
|
2004-03-07 04:46:54 +01:00
|
|
|
return retval;
|
2002-01-22 01:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2004-03-07 04:46:54 +01:00
|
|
|
* GetDefaultPrinterA (WINSPOOL.@)
|
2002-01-22 01:49:24 +01:00
|
|
|
*/
|
2004-03-07 04:46:54 +01:00
|
|
|
BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize)
|
2002-01-22 01:49:24 +01:00
|
|
|
{
|
2004-03-07 04:46:54 +01:00
|
|
|
BOOL retval = TRUE;
|
|
|
|
DWORD insize = 0;
|
|
|
|
WCHAR *bufferW = NULL;
|
|
|
|
|
|
|
|
if (!namesize)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(name && *namesize) {
|
|
|
|
insize = *namesize;
|
|
|
|
bufferW = HeapAlloc( GetProcessHeap(), 0, insize * sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!GetDefaultPrinterW( bufferW, namesize)) {
|
|
|
|
retval = FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
*namesize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, name, insize,
|
|
|
|
NULL, NULL);
|
|
|
|
if (!*namesize)
|
|
|
|
{
|
|
|
|
*namesize = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("0x%08x/0x%08x:%s\n", *namesize, insize, debugstr_w(bufferW));
|
2004-03-07 04:46:54 +01:00
|
|
|
|
|
|
|
end:
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, bufferW);
|
2004-03-07 04:46:54 +01:00
|
|
|
return retval;
|
2002-01-22 01:49:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-20 11:51:04 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* SetDefaultPrinterW (WINSPOOL.204)
|
|
|
|
*
|
|
|
|
* Set the Name of the Default Printer
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszPrinter [I] Name of the Printer or NULL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: True
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* When the Parameter is NULL or points to an Empty String and
|
|
|
|
* a Default Printer was already present, then this Function changes nothing.
|
|
|
|
* Without a Default Printer and NULL (or an Empty String) as Parameter,
|
|
|
|
* the First enumerated local Printer is used.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
|
|
|
|
{
|
2010-10-13 00:25:17 +02:00
|
|
|
WCHAR default_printer[MAX_PATH];
|
|
|
|
LPWSTR buffer = NULL;
|
|
|
|
HKEY hreg;
|
|
|
|
DWORD size;
|
|
|
|
DWORD namelen;
|
|
|
|
LONG lres;
|
2006-02-20 11:51:04 +01:00
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_w(pszPrinter));
|
2010-10-13 00:25:17 +02:00
|
|
|
if ((pszPrinter == NULL) || (pszPrinter[0] == '\0')) {
|
2006-02-20 11:51:04 +01:00
|
|
|
|
2010-10-13 00:25:17 +02:00
|
|
|
default_printer[0] = '\0';
|
|
|
|
size = sizeof(default_printer)/sizeof(WCHAR);
|
|
|
|
|
|
|
|
/* if we have a default Printer, do nothing. */
|
|
|
|
if (GetDefaultPrinterW(default_printer, &size))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
pszPrinter = NULL;
|
|
|
|
/* we have no default Printer: search local Printers and use the first */
|
|
|
|
if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE, PrintersW, 0, KEY_READ, &hreg)) {
|
|
|
|
|
|
|
|
default_printer[0] = '\0';
|
|
|
|
size = sizeof(default_printer)/sizeof(WCHAR);
|
|
|
|
if (!RegEnumKeyExW(hreg, 0, default_printer, &size, NULL, NULL, NULL, NULL)) {
|
|
|
|
|
|
|
|
pszPrinter = default_printer;
|
|
|
|
TRACE("using %s\n", debugstr_w(pszPrinter));
|
|
|
|
}
|
|
|
|
RegCloseKey(hreg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pszPrinter == NULL) {
|
|
|
|
TRACE("no local printer found\n");
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "pszPrinter" is never empty or NULL here. */
|
|
|
|
namelen = lstrlenW(pszPrinter);
|
|
|
|
size = namelen + (MAX_PATH * 2) + 3; /* printer,driver,port and a 0 */
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
|
|
|
if (!buffer ||
|
|
|
|
(RegOpenKeyExW(HKEY_CURRENT_USER, user_printers_reg_key, 0, KEY_READ, &hreg) != ERROR_SUCCESS)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read the devices entry for the printer (driver,port) to build the string for the
|
|
|
|
default device entry (printer,driver,port) */
|
|
|
|
memcpy(buffer, pszPrinter, namelen * sizeof(WCHAR));
|
|
|
|
buffer[namelen] = ',';
|
|
|
|
namelen++; /* move index to the start of the driver */
|
|
|
|
|
|
|
|
size = ((MAX_PATH * 2) + 2) * sizeof(WCHAR); /* driver,port and a 0 */
|
|
|
|
lres = RegQueryValueExW(hreg, pszPrinter, NULL, NULL, (LPBYTE) (&buffer[namelen]), &size);
|
|
|
|
if (!lres) {
|
|
|
|
TRACE("set device to %s\n", debugstr_w(buffer));
|
|
|
|
|
|
|
|
if (!WriteProfileStringW(windowsW, deviceW, buffer)) {
|
|
|
|
TRACE("failed to set the device entry: %d\n", GetLastError());
|
|
|
|
lres = ERROR_INVALID_PRINTER_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove the next section, when INIFileMapping is implemented */
|
|
|
|
{
|
|
|
|
HKEY hdev;
|
|
|
|
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hdev)) {
|
|
|
|
RegSetValueExW(hdev, deviceW, 0, REG_SZ, (LPBYTE)buffer, (lstrlenW(buffer) + 1) * sizeof(WCHAR));
|
|
|
|
RegCloseKey(hdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lres != ERROR_FILE_NOT_FOUND)
|
|
|
|
FIXME("RegQueryValueExW failed with %d for %s\n", lres, debugstr_w(pszPrinter));
|
|
|
|
|
|
|
|
SetLastError(ERROR_INVALID_PRINTER_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hreg);
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
return (lres == ERROR_SUCCESS);
|
2006-02-20 11:51:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetDefaultPrinterA (WINSPOOL.202)
|
|
|
|
*
|
|
|
|
* See SetDefaultPrinterW.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetDefaultPrinterA(LPCSTR pszPrinter)
|
|
|
|
{
|
2010-10-13 00:25:17 +02:00
|
|
|
LPWSTR bufferW = NULL;
|
|
|
|
BOOL res;
|
2006-02-20 11:51:04 +01:00
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_a(pszPrinter));
|
2010-10-13 00:25:17 +02:00
|
|
|
if(pszPrinter) {
|
|
|
|
INT len = MultiByteToWideChar(CP_ACP, 0, pszPrinter, -1, NULL, 0);
|
|
|
|
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (bufferW) MultiByteToWideChar(CP_ACP, 0, pszPrinter, -1, bufferW, len);
|
|
|
|
}
|
|
|
|
res = SetDefaultPrinterW(bufferW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
|
|
|
return res;
|
2006-02-20 11:51:04 +01:00
|
|
|
}
|
|
|
|
|
2001-02-12 02:26:47 +01:00
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SetPrinterDataExA (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
2003-11-11 21:38:51 +01:00
|
|
|
DWORD WINAPI SetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
|
|
|
|
LPCSTR pValueName, DWORD Type,
|
2001-02-12 02:26:47 +01:00
|
|
|
LPBYTE pData, DWORD cbData)
|
|
|
|
{
|
|
|
|
HKEY hkeyPrinter, hkeySubkey;
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %s, %s %08x, %p, %08x)\n", hPrinter, debugstr_a(pKeyName),
|
2001-02-12 02:26:47 +01:00
|
|
|
debugstr_a(pValueName), Type, pData, cbData);
|
|
|
|
|
|
|
|
if((ret = WINSPOOL_GetOpenedPrinterRegKey(hPrinter, &hkeyPrinter))
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if((ret = RegCreateKeyA(hkeyPrinter, pKeyName, &hkeySubkey))
|
|
|
|
!= ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create subkey %s\n", debugstr_a(pKeyName));
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = RegSetValueExA(hkeySubkey, pValueName, 0, Type, pData, cbData);
|
|
|
|
RegCloseKey(hkeySubkey);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SetPrinterDataExW (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
2003-11-11 21:38:51 +01:00
|
|
|
DWORD WINAPI SetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
|
|
|
|
LPCWSTR pValueName, DWORD Type,
|
2001-02-12 02:26:47 +01:00
|
|
|
LPBYTE pData, DWORD cbData)
|
|
|
|
{
|
|
|
|
HKEY hkeyPrinter, hkeySubkey;
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %s, %s %08x, %p, %08x)\n", hPrinter, debugstr_w(pKeyName),
|
2001-02-12 02:26:47 +01:00
|
|
|
debugstr_w(pValueName), Type, pData, cbData);
|
|
|
|
|
|
|
|
if((ret = WINSPOOL_GetOpenedPrinterRegKey(hPrinter, &hkeyPrinter))
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if((ret = RegCreateKeyW(hkeyPrinter, pKeyName, &hkeySubkey))
|
|
|
|
!= ERROR_SUCCESS) {
|
|
|
|
ERR("Can't create subkey %s\n", debugstr_w(pKeyName));
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
ret = RegSetValueExW(hkeySubkey, pValueName, 0, Type, pData, cbData);
|
|
|
|
RegCloseKey(hkeySubkey);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SetPrinterDataA (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetPrinterDataA(HANDLE hPrinter, LPSTR pValueName, DWORD Type,
|
|
|
|
LPBYTE pData, DWORD cbData)
|
|
|
|
{
|
|
|
|
return SetPrinterDataExA(hPrinter, "PrinterDriverData", pValueName, Type,
|
|
|
|
pData, cbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* SetPrinterDataW (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetPrinterDataW(HANDLE hPrinter, LPWSTR pValueName, DWORD Type,
|
|
|
|
LPBYTE pData, DWORD cbData)
|
|
|
|
{
|
|
|
|
return SetPrinterDataExW(hPrinter, PrinterDriverDataW, pValueName, Type,
|
|
|
|
pData, cbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* GetPrinterDataExA (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
2003-11-11 21:38:51 +01:00
|
|
|
DWORD WINAPI GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
|
|
|
|
LPCSTR pValueName, LPDWORD pType,
|
2001-02-12 02:26:47 +01:00
|
|
|
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
|
|
|
|
{
|
2010-06-15 17:25:16 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
HKEY hkeyPrinters, hkeyPrinter = 0, hkeySubkey = 0;
|
2001-02-12 02:26:47 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
TRACE("(%p, %s, %s, %p, %p, %u, %p)\n", hPrinter, debugstr_a(pKeyName),
|
|
|
|
debugstr_a(pValueName), pType, pData, nSize, pcbNeeded);
|
2001-02-12 02:26:47 +01:00
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer) return ERROR_INVALID_HANDLE;
|
2001-02-12 02:26:47 +01:00
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
|
|
|
|
if (ret) return ret;
|
|
|
|
|
2010-06-16 00:42:23 +02:00
|
|
|
TRACE("printer->name: %s\n", debugstr_w(printer->name));
|
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
if (printer->name) {
|
|
|
|
|
|
|
|
ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
|
|
|
|
if (ret) {
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if((ret = RegOpenKeyA(hkeyPrinter, pKeyName, &hkeySubkey)) != ERROR_SUCCESS) {
|
|
|
|
WARN("Can't open subkey %s: %d\n", debugstr_a(pKeyName), ret);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return ret;
|
|
|
|
}
|
2001-02-12 02:26:47 +01:00
|
|
|
}
|
|
|
|
*pcbNeeded = nSize;
|
2010-06-15 17:25:16 +02:00
|
|
|
ret = RegQueryValueExA(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
|
|
|
|
0, pType, pData, pcbNeeded);
|
|
|
|
|
2010-06-16 00:42:23 +02:00
|
|
|
if (!ret && !pData) ret = ERROR_MORE_DATA;
|
|
|
|
|
2001-02-12 02:26:47 +01:00
|
|
|
RegCloseKey(hkeySubkey);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
2010-06-15 17:25:16 +02:00
|
|
|
RegCloseKey(hkeyPrinters);
|
2010-06-16 00:42:23 +02:00
|
|
|
|
|
|
|
TRACE("--> %d\n", ret);
|
2001-02-12 02:26:47 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* GetPrinterDataExW (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
2003-11-11 21:38:51 +01:00
|
|
|
DWORD WINAPI GetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
|
|
|
|
LPCWSTR pValueName, LPDWORD pType,
|
2001-02-12 02:26:47 +01:00
|
|
|
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
|
|
|
|
{
|
2010-06-15 17:25:16 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
HKEY hkeyPrinters, hkeyPrinter = 0, hkeySubkey = 0;
|
2001-02-12 02:26:47 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
TRACE("(%p, %s, %s, %p, %p, %u, %p)\n", hPrinter, debugstr_w(pKeyName),
|
|
|
|
debugstr_w(pValueName), pType, pData, nSize, pcbNeeded);
|
2001-02-12 02:26:47 +01:00
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer) return ERROR_INVALID_HANDLE;
|
2001-02-12 02:26:47 +01:00
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
|
|
|
|
if (ret) return ret;
|
|
|
|
|
2010-06-16 00:42:23 +02:00
|
|
|
TRACE("printer->name: %s\n", debugstr_w(printer->name));
|
|
|
|
|
2010-06-15 17:25:16 +02:00
|
|
|
if (printer->name) {
|
|
|
|
|
|
|
|
ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
|
|
|
|
if (ret) {
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if((ret = RegOpenKeyW(hkeyPrinter, pKeyName, &hkeySubkey)) != ERROR_SUCCESS) {
|
|
|
|
WARN("Can't open subkey %s: %d\n", debugstr_w(pKeyName), ret);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
|
|
|
RegCloseKey(hkeyPrinters);
|
|
|
|
return ret;
|
|
|
|
}
|
2001-02-12 02:26:47 +01:00
|
|
|
}
|
|
|
|
*pcbNeeded = nSize;
|
2010-06-15 17:25:16 +02:00
|
|
|
ret = RegQueryValueExW(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
|
|
|
|
0, pType, pData, pcbNeeded);
|
|
|
|
|
2010-06-16 00:42:23 +02:00
|
|
|
if (!ret && !pData) ret = ERROR_MORE_DATA;
|
|
|
|
|
2001-02-12 02:26:47 +01:00
|
|
|
RegCloseKey(hkeySubkey);
|
|
|
|
RegCloseKey(hkeyPrinter);
|
2010-06-15 17:25:16 +02:00
|
|
|
RegCloseKey(hkeyPrinters);
|
2010-06-16 00:42:23 +02:00
|
|
|
|
|
|
|
TRACE("--> %d\n", ret);
|
2001-02-12 02:26:47 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* GetPrinterDataA (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetPrinterDataA(HANDLE hPrinter, LPSTR pValueName, LPDWORD pType,
|
|
|
|
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
|
|
|
|
{
|
|
|
|
return GetPrinterDataExA(hPrinter, "PrinterDriverData", pValueName, pType,
|
|
|
|
pData, nSize, pcbNeeded);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-21 01:03:14 +02:00
|
|
|
* GetPrinterDataW (WINSPOOL.@)
|
2001-02-12 02:26:47 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetPrinterDataW(HANDLE hPrinter, LPWSTR pValueName, LPDWORD pType,
|
|
|
|
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
|
|
|
|
{
|
|
|
|
return GetPrinterDataExW(hPrinter, PrinterDriverDataW, pValueName, pType,
|
|
|
|
pData, nSize, pcbNeeded);
|
|
|
|
}
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPrinterDataExW [WINSPOOL.@]
|
2001-02-21 05:00:40 +01:00
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
|
|
|
|
LPBYTE pEnumValues, DWORD cbEnumValues,
|
|
|
|
LPDWORD pcbEnumValues, LPDWORD pnEnumValues)
|
|
|
|
{
|
|
|
|
HKEY hkPrinter, hkSubKey;
|
|
|
|
DWORD r, ret, dwIndex, cValues, cbMaxValueNameLen,
|
|
|
|
cbValueNameLen, cbMaxValueLen, cbValueLen,
|
|
|
|
cbBufSize, dwType;
|
|
|
|
LPWSTR lpValueName;
|
|
|
|
HANDLE hHeap;
|
|
|
|
PBYTE lpValue;
|
|
|
|
PPRINTER_ENUM_VALUESW ppev;
|
|
|
|
|
2002-10-22 02:47:33 +02:00
|
|
|
TRACE ("%p %s\n", hPrinter, debugstr_w (pKeyName));
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
if (pKeyName == NULL || *pKeyName == 0)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ret = WINSPOOL_GetOpenedPrinterRegKey (hPrinter, &hkPrinter);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("WINSPOOL_GetOpenedPrinterRegKey (%p) returned %i\n",
|
2001-02-21 05:00:40 +01:00
|
|
|
hPrinter, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegOpenKeyExW (hkPrinter, pKeyName, 0, KEY_READ, &hkSubKey);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = RegCloseKey (hkPrinter);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
|
|
|
TRACE ("RegOpenKeyExW (%p, %s) returned %i\n", hPrinter,
|
2001-02-21 05:00:40 +01:00
|
|
|
debugstr_w (pKeyName), ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegCloseKey (hkPrinter);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("RegCloseKey returned %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegQueryInfoKeyW (hkSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&cValues, &cbMaxValueNameLen, &cbMaxValueLen, NULL, NULL);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
|
|
|
TRACE ("RegQueryInfoKeyW (%p) returned %i\n", hkSubKey, ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("RegQueryInfoKeyW returned cValues = %i, cbMaxValueNameLen = %i, "
|
|
|
|
"cbMaxValueLen = %i\n", cValues, cbMaxValueNameLen, cbMaxValueLen);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
if (cValues == 0) /* empty key */
|
|
|
|
{
|
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
*pcbEnumValues = *pnEnumValues = 0;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
++cbMaxValueNameLen; /* allow for trailing '\0' */
|
|
|
|
|
|
|
|
hHeap = GetProcessHeap ();
|
2003-01-15 00:43:41 +01:00
|
|
|
if (hHeap == NULL)
|
2001-02-21 05:00:40 +01:00
|
|
|
{
|
|
|
|
ERR ("GetProcessHeap failed\n");
|
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpValueName = HeapAlloc (hHeap, 0, cbMaxValueNameLen * sizeof (WCHAR));
|
|
|
|
if (lpValueName == NULL)
|
|
|
|
{
|
2006-10-20 12:16:45 +02:00
|
|
|
ERR ("Failed to allocate %i WCHARs from process heap\n", cbMaxValueNameLen);
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpValue = HeapAlloc (hHeap, 0, cbMaxValueLen);
|
|
|
|
if (lpValue == NULL)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("Failed to allocate %i bytes from process heap\n", cbMaxValueLen);
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE ("pass 1: calculating buffer required for all names and values\n");
|
|
|
|
|
|
|
|
cbBufSize = cValues * sizeof (PRINTER_ENUM_VALUESW);
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("%i bytes required for %i headers\n", cbBufSize, cValues);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
for (dwIndex = 0; dwIndex < cValues; ++dwIndex)
|
|
|
|
{
|
|
|
|
cbValueNameLen = cbMaxValueNameLen; cbValueLen = cbMaxValueLen;
|
|
|
|
ret = RegEnumValueW (hkSubKey, dwIndex, lpValueName, &cbValueNameLen,
|
|
|
|
NULL, NULL, lpValue, &cbValueLen);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (HeapFree (hHeap, 0, lpValue) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
|
|
|
TRACE ("RegEnumValueW (%i) returned %i\n", dwIndex, ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-10-20 12:16:45 +02:00
|
|
|
TRACE ("%s [%i]: name needs %i WCHARs, data needs %i bytes\n",
|
2001-02-21 05:00:40 +01:00
|
|
|
debugstr_w (lpValueName), dwIndex,
|
2006-10-20 12:16:45 +02:00
|
|
|
cbValueNameLen + 1, cbValueLen);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
cbBufSize += (cbValueNameLen + 1) * sizeof (WCHAR);
|
|
|
|
cbBufSize += cbValueLen;
|
|
|
|
}
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("%i bytes required for all %i values\n", cbBufSize, cValues);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
*pcbEnumValues = cbBufSize;
|
|
|
|
*pnEnumValues = cValues;
|
|
|
|
|
|
|
|
if (cbEnumValues < cbBufSize) /* buffer too small */
|
|
|
|
{
|
|
|
|
if (HeapFree (hHeap, 0, lpValue) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
|
|
|
TRACE ("%i byte buffer is not large enough\n", cbEnumValues);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE ("pass 2: copying all names and values to buffer\n");
|
|
|
|
|
|
|
|
ppev = (PPRINTER_ENUM_VALUESW) pEnumValues; /* array of structs */
|
|
|
|
pEnumValues += cValues * sizeof (PRINTER_ENUM_VALUESW);
|
|
|
|
|
|
|
|
for (dwIndex = 0; dwIndex < cValues; ++dwIndex)
|
|
|
|
{
|
|
|
|
cbValueNameLen = cbMaxValueNameLen; cbValueLen = cbMaxValueLen;
|
|
|
|
ret = RegEnumValueW (hkSubKey, dwIndex, lpValueName, &cbValueNameLen,
|
|
|
|
NULL, &dwType, lpValue, &cbValueLen);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (HeapFree (hHeap, 0, lpValue) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
|
|
|
TRACE ("RegEnumValueW (%i) returned %i\n", dwIndex, ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
cbValueNameLen = (cbValueNameLen + 1) * sizeof (WCHAR);
|
|
|
|
memcpy (pEnumValues, lpValueName, cbValueNameLen);
|
|
|
|
ppev[dwIndex].pValueName = (LPWSTR) pEnumValues;
|
|
|
|
pEnumValues += cbValueNameLen;
|
|
|
|
|
|
|
|
/* return # of *bytes* (including trailing \0), not # of chars */
|
|
|
|
ppev[dwIndex].cbValueName = cbValueNameLen;
|
|
|
|
|
|
|
|
ppev[dwIndex].dwType = dwType;
|
|
|
|
|
|
|
|
memcpy (pEnumValues, lpValue, cbValueLen);
|
|
|
|
ppev[dwIndex].pData = pEnumValues;
|
|
|
|
pEnumValues += cbValueLen;
|
|
|
|
|
|
|
|
ppev[dwIndex].cbData = cbValueLen;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("%s [%i]: copied name (%i bytes) and data (%i bytes)\n",
|
2001-02-21 05:00:40 +01:00
|
|
|
debugstr_w (lpValueName), dwIndex, cbValueNameLen, cbValueLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HeapFree (hHeap, 0, lpValue) == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("HeapFree failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HeapFree (hHeap, 0, lpValueName) == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("HeapFree failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
r = RegCloseKey (hkSubKey);
|
|
|
|
if (r != ERROR_SUCCESS)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("RegCloseKey returned %i\n", r);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegCloseKey (hkSubKey);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("RegCloseKey returned %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* EnumPrinterDataExA [WINSPOOL.@]
|
2001-02-21 05:00:40 +01:00
|
|
|
*
|
|
|
|
* This functions returns value names and REG_SZ, REG_EXPAND_SZ, and
|
|
|
|
* REG_MULTI_SZ values as ASCII strings in Unicode-sized buffers. This is
|
|
|
|
* what Windows 2000 SP1 does.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
|
|
|
|
LPBYTE pEnumValues, DWORD cbEnumValues,
|
|
|
|
LPDWORD pcbEnumValues, LPDWORD pnEnumValues)
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
LPWSTR pKeyNameW;
|
|
|
|
DWORD ret, dwIndex, dwBufSize;
|
|
|
|
HANDLE hHeap;
|
|
|
|
LPSTR pBuffer;
|
|
|
|
|
2002-10-22 02:47:33 +02:00
|
|
|
TRACE ("%p %s\n", hPrinter, pKeyName);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
if (pKeyName == NULL || *pKeyName == 0)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar (CP_ACP, 0, pKeyName, -1, NULL, 0);
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("MultiByteToWideChar failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
hHeap = GetProcessHeap ();
|
2003-01-15 00:43:41 +01:00
|
|
|
if (hHeap == NULL)
|
2001-02-21 05:00:40 +01:00
|
|
|
{
|
|
|
|
ERR ("GetProcessHeap failed\n");
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
pKeyNameW = HeapAlloc (hHeap, 0, len * sizeof (WCHAR));
|
|
|
|
if (pKeyNameW == NULL)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("Failed to allocate %i bytes from process heap\n",
|
2006-10-20 12:16:45 +02:00
|
|
|
(LONG)(len * sizeof (WCHAR)));
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MultiByteToWideChar (CP_ACP, 0, pKeyName, -1, pKeyNameW, len) == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("MultiByteToWideChar failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, pKeyNameW) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = EnumPrinterDataExW (hPrinter, pKeyNameW, pEnumValues, cbEnumValues,
|
|
|
|
pcbEnumValues, pnEnumValues);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (HeapFree (hHeap, 0, pKeyNameW) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
|
|
|
TRACE ("EnumPrinterDataExW returned %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HeapFree (hHeap, 0, pKeyNameW) == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("HeapFree failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
if (*pnEnumValues == 0) /* empty key */
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
dwBufSize = 0;
|
|
|
|
for (dwIndex = 0; dwIndex < *pnEnumValues; ++dwIndex)
|
|
|
|
{
|
|
|
|
PPRINTER_ENUM_VALUESW ppev =
|
|
|
|
&((PPRINTER_ENUM_VALUESW) pEnumValues)[dwIndex];
|
|
|
|
|
|
|
|
if (dwBufSize < ppev->cbValueName)
|
|
|
|
dwBufSize = ppev->cbValueName;
|
|
|
|
|
|
|
|
if (dwBufSize < ppev->cbData && (ppev->dwType == REG_SZ ||
|
|
|
|
ppev->dwType == REG_EXPAND_SZ || ppev->dwType == REG_MULTI_SZ))
|
|
|
|
dwBufSize = ppev->cbData;
|
|
|
|
}
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE ("Largest Unicode name or value is %i bytes\n", dwBufSize);
|
2001-02-21 05:00:40 +01:00
|
|
|
|
|
|
|
pBuffer = HeapAlloc (hHeap, 0, dwBufSize);
|
|
|
|
if (pBuffer == NULL)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("Failed to allocate %i bytes from process heap\n", dwBufSize);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (dwIndex = 0; dwIndex < *pnEnumValues; ++dwIndex)
|
|
|
|
{
|
|
|
|
PPRINTER_ENUM_VALUESW ppev =
|
|
|
|
&((PPRINTER_ENUM_VALUESW) pEnumValues)[dwIndex];
|
|
|
|
|
|
|
|
len = WideCharToMultiByte (CP_ACP, 0, ppev->pValueName,
|
|
|
|
ppev->cbValueName / sizeof (WCHAR), pBuffer, dwBufSize, NULL,
|
|
|
|
NULL);
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("WideCharToMultiByte failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, pBuffer) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (ppev->pValueName, pBuffer, len);
|
|
|
|
|
|
|
|
TRACE ("Converted '%s' from Unicode to ASCII\n", pBuffer);
|
|
|
|
|
|
|
|
if (ppev->dwType != REG_SZ && ppev->dwType != REG_EXPAND_SZ &&
|
|
|
|
ppev->dwType != REG_MULTI_SZ)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte (CP_ACP, 0, (LPWSTR) ppev->pData,
|
|
|
|
ppev->cbData / sizeof (WCHAR), pBuffer, dwBufSize, NULL, NULL);
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("WideCharToMultiByte failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
if (HeapFree (hHeap, 0, pBuffer) == 0)
|
2006-10-13 11:51:23 +02:00
|
|
|
WARN ("HeapFree failed with code %i\n", GetLastError ());
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (ppev->pData, pBuffer, len);
|
|
|
|
|
|
|
|
TRACE ("Converted '%s' from Unicode to ASCII\n", pBuffer);
|
|
|
|
TRACE (" (only first string of REG_MULTI_SZ printed)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HeapFree (hHeap, 0, pBuffer) == 0)
|
|
|
|
{
|
|
|
|
ret = GetLastError ();
|
2006-10-13 11:51:23 +02:00
|
|
|
ERR ("HeapFree failed with code %i\n", ret);
|
2001-02-21 05:00:40 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2003-05-14 00:25:12 +02:00
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* AbortPrinter (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AbortPrinter( HANDLE hPrinter )
|
|
|
|
{
|
|
|
|
FIXME("(%p), stub!\n", hPrinter);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-05-14 00:25:12 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* AddPortA (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* See AddPortW.
|
|
|
|
*
|
2003-05-14 00:25:12 +02:00
|
|
|
*/
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
BOOL WINAPI AddPortA(LPSTR pName, HWND hWnd, LPSTR pMonitorName)
|
2003-05-14 00:25:12 +02:00
|
|
|
{
|
2006-11-28 00:49:54 +01:00
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR monitorW = NULL;
|
|
|
|
DWORD len;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %s)\n",debugstr_a(pName), hWnd, debugstr_a(pMonitorName));
|
|
|
|
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pMonitorName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, NULL, 0);
|
|
|
|
monitorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, monitorW, len);
|
|
|
|
}
|
|
|
|
res = AddPortW(nameW, hWnd, monitorW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, monitorW);
|
|
|
|
return res;
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddPortW (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* Add a Port for a specific Monitor
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* hWnd [I] Handle to parent Window for the Dialog-Box
|
|
|
|
* pMonitorName [I] Name of the Monitor that manage the Port
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPortW(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName)
|
|
|
|
{
|
2006-11-28 00:49:06 +01:00
|
|
|
TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pMonitorName));
|
|
|
|
|
2009-09-29 13:27:53 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-11-28 00:49:06 +01:00
|
|
|
|
|
|
|
if (!pMonitorName) {
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-29 13:27:53 +02:00
|
|
|
return backend->fpAddPort(pName, hWnd, pMonitorName);
|
2003-05-14 00:25:12 +02:00
|
|
|
}
|
2003-08-12 20:54:26 +02:00
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* AddPortExA (WINSPOOL.@)
|
|
|
|
*
|
2005-12-06 10:57:01 +01:00
|
|
|
* See AddPortExW.
|
|
|
|
*
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
*/
|
2007-06-04 00:23:55 +02:00
|
|
|
BOOL WINAPI AddPortExA(LPSTR pName, DWORD level, LPBYTE pBuffer, LPSTR pMonitorName)
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
{
|
2007-06-04 00:23:55 +02:00
|
|
|
PORT_INFO_2W pi2W;
|
|
|
|
PORT_INFO_2A * pi2A;
|
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR monitorW = NULL;
|
|
|
|
DWORD len;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
pi2A = (PORT_INFO_2A *) pBuffer;
|
|
|
|
|
|
|
|
TRACE("(%s, %d, %p, %s): %s\n", debugstr_a(pName), level, pBuffer,
|
|
|
|
debugstr_a(pMonitorName), debugstr_a(pi2A ? pi2A->pPortName : NULL));
|
|
|
|
|
|
|
|
if ((level < 1) || (level > 2)) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pi2A) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pMonitorName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, NULL, 0);
|
|
|
|
monitorW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pMonitorName, -1, monitorW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(&pi2W, sizeof(PORT_INFO_2W));
|
|
|
|
|
|
|
|
if (pi2A->pPortName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pPortName, -1, NULL, 0);
|
|
|
|
pi2W.pPortName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pi2A->pPortName, -1, pi2W.pPortName, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level > 1) {
|
|
|
|
if (pi2A->pMonitorName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pMonitorName, -1, NULL, 0);
|
|
|
|
pi2W.pMonitorName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pi2A->pMonitorName, -1, pi2W.pMonitorName, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pi2A->pDescription) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pi2A->pDescription, -1, NULL, 0);
|
|
|
|
pi2W.pDescription = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pi2A->pDescription, -1, pi2W.pDescription, len);
|
|
|
|
}
|
|
|
|
pi2W.fPortType = pi2A->fPortType;
|
|
|
|
pi2W.Reserved = pi2A->Reserved;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = AddPortExW(nameW, level, (LPBYTE) &pi2W, monitorW);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, monitorW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi2W.pPortName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi2W.pMonitorName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi2W.pDescription);
|
|
|
|
return res;
|
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddPortExW (WINSPOOL.@)
|
|
|
|
*
|
2005-12-06 10:57:01 +01:00
|
|
|
* Add a Port for a specific Monitor, without presenting a user interface
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
2007-06-04 00:23:55 +02:00
|
|
|
* level [I] Structure-Level (1 or 2) for pBuffer
|
|
|
|
* pBuffer [I] PTR to: PORT_INFO_1 or PORT_INFO_2
|
|
|
|
* pMonitorName [I] Name of the Monitor that manage the Port
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
*/
|
2007-06-04 00:23:55 +02:00
|
|
|
BOOL WINAPI AddPortExW(LPWSTR pName, DWORD level, LPBYTE pBuffer, LPWSTR pMonitorName)
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
{
|
2007-06-04 00:23:55 +02:00
|
|
|
PORT_INFO_2W * pi2;
|
|
|
|
|
|
|
|
pi2 = (PORT_INFO_2W *) pBuffer;
|
|
|
|
|
|
|
|
TRACE("(%s, %d, %p, %s): %s %s %s\n", debugstr_w(pName), level, pBuffer,
|
|
|
|
debugstr_w(pMonitorName), debugstr_w(pi2 ? pi2->pPortName : NULL),
|
|
|
|
debugstr_w(((level > 1) && pi2) ? pi2->pMonitorName : NULL),
|
|
|
|
debugstr_w(((level > 1) && pi2) ? pi2->pDescription : NULL));
|
|
|
|
|
2009-09-30 09:57:11 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2007-06-04 00:23:55 +02:00
|
|
|
|
2007-06-18 00:58:49 +02:00
|
|
|
if ((!pi2) || (!pMonitorName) || (!pMonitorName[0])) {
|
2007-06-04 00:23:55 +02:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-30 09:57:11 +02:00
|
|
|
return backend->fpAddPortEx(pName, level, pBuffer, pMonitorName);
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddPrinterConnectionA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrinterConnectionA( LPSTR pName )
|
|
|
|
{
|
|
|
|
FIXME("%s\n", debugstr_a(pName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AddPrinterConnectionW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AddPrinterConnectionW( LPWSTR pName )
|
|
|
|
{
|
|
|
|
FIXME("%s\n", debugstr_w(pName));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-08-12 20:54:26 +02:00
|
|
|
/******************************************************************************
|
2007-08-15 23:30:59 +02:00
|
|
|
* AddPrinterDriverExW (WINSPOOL.@)
|
|
|
|
*
|
|
|
|
* Install a Printer Driver with the Option to upgrade / downgrade the Files
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* level [I] Level for the supplied DRIVER_INFO_*W struct
|
|
|
|
* pDriverInfo [I] PTR to DRIVER_INFO_*W struct with the Driver Parameter
|
|
|
|
* dwFileCopyFlags [I] How to Copy / Upgrade / Downgrade the needed Files
|
|
|
|
*
|
|
|
|
* RESULTS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
2003-08-12 20:54:26 +02:00
|
|
|
*/
|
2007-08-15 23:30:59 +02:00
|
|
|
BOOL WINAPI AddPrinterDriverExW( LPWSTR pName, DWORD level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags)
|
2003-08-12 20:54:26 +02:00
|
|
|
{
|
2007-08-15 23:30:59 +02:00
|
|
|
TRACE("(%s, %d, %p, 0x%x)\n", debugstr_w(pName), level, pDriverInfo, dwFileCopyFlags);
|
|
|
|
|
2008-02-08 00:41:24 +01:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
|
|
|
|
2007-08-15 23:30:59 +02:00
|
|
|
if (level < 2 || level == 5 || level == 7 || level > 8) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pDriverInfo) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-08 00:41:24 +01:00
|
|
|
return backend->fpAddPrinterDriverEx(pName, level, pDriverInfo, dwFileCopyFlags);
|
2003-08-12 20:54:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2007-08-16 05:18:08 +02:00
|
|
|
* AddPrinterDriverExA (WINSPOOL.@)
|
|
|
|
*
|
|
|
|
* See AddPrinterDriverExW.
|
|
|
|
*
|
2003-08-12 20:54:26 +02:00
|
|
|
*/
|
2007-08-16 05:18:08 +02:00
|
|
|
BOOL WINAPI AddPrinterDriverExA(LPSTR pName, DWORD Level, LPBYTE pDriverInfo, DWORD dwFileCopyFlags)
|
2003-08-12 20:54:26 +02:00
|
|
|
{
|
2007-08-16 05:18:08 +02:00
|
|
|
DRIVER_INFO_8A *diA;
|
|
|
|
DRIVER_INFO_8W diW;
|
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
DWORD lenA;
|
|
|
|
DWORD len;
|
2013-10-09 00:06:16 +02:00
|
|
|
BOOL res = FALSE;
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
TRACE("(%s, %d, %p, 0x%x)\n", debugstr_a(pName), Level, pDriverInfo, dwFileCopyFlags);
|
|
|
|
|
2007-08-16 05:18:08 +02:00
|
|
|
diA = (DRIVER_INFO_8A *) pDriverInfo;
|
|
|
|
ZeroMemory(&diW, sizeof(diW));
|
|
|
|
|
|
|
|
if (Level < 2 || Level == 5 || Level == 7 || Level > 8) {
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (diA == NULL) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert servername to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* common fields */
|
|
|
|
diW.cVersion = diA->cVersion;
|
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if (diA->pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pName, -1, NULL, 0);
|
|
|
|
diW.pName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pName, -1, diW.pName, len);
|
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if (diA->pEnvironment) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pEnvironment, -1, NULL, 0);
|
|
|
|
diW.pEnvironment = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pEnvironment, -1, diW.pEnvironment, len);
|
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if (diA->pDriverPath) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pDriverPath, -1, NULL, 0);
|
|
|
|
diW.pDriverPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pDriverPath, -1, diW.pDriverPath, len);
|
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if (diA->pDataFile) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pDataFile, -1, NULL, 0);
|
|
|
|
diW.pDataFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pDataFile, -1, diW.pDataFile, len);
|
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if (diA->pConfigFile) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pConfigFile, -1, NULL, 0);
|
|
|
|
diW.pConfigFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pConfigFile, -1, diW.pConfigFile, len);
|
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 2) && diA->pDependentFiles) {
|
2007-08-16 05:18:08 +02:00
|
|
|
lenA = multi_sz_lenA(diA->pDependentFiles);
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pDependentFiles, lenA, NULL, 0);
|
|
|
|
diW.pDependentFiles = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pDependentFiles, lenA, diW.pDependentFiles, len);
|
2007-08-22 23:41:44 +02:00
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 2) && diA->pMonitorName) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pMonitorName, -1, NULL, 0);
|
|
|
|
diW.pMonitorName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pMonitorName, -1, diW.pMonitorName, len);
|
|
|
|
}
|
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 3) && diA->pDefaultDataType) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pDefaultDataType, -1, NULL, 0);
|
|
|
|
diW.pDefaultDataType = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pDefaultDataType, -1, diW.pDefaultDataType, len);
|
2007-08-22 23:41:44 +02:00
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 3) && diA->pszzPreviousNames) {
|
2007-08-16 05:18:08 +02:00
|
|
|
lenA = multi_sz_lenA(diA->pszzPreviousNames);
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pszzPreviousNames, lenA, NULL, 0);
|
|
|
|
diW.pszzPreviousNames = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pszzPreviousNames, lenA, diW.pszzPreviousNames, len);
|
|
|
|
}
|
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 5) && diA->pszMfgName) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pszMfgName, -1, NULL, 0);
|
|
|
|
diW.pszMfgName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pszMfgName, -1, diW.pszMfgName, len);
|
2007-08-22 23:41:44 +02:00
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 5) && diA->pszOEMUrl) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pszOEMUrl, -1, NULL, 0);
|
|
|
|
diW.pszOEMUrl = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pszOEMUrl, -1, diW.pszOEMUrl, len);
|
2007-08-22 23:41:44 +02:00
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 5) && diA->pszHardwareID) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pszHardwareID, -1, NULL, 0);
|
|
|
|
diW.pszHardwareID = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pszHardwareID, -1, diW.pszHardwareID, len);
|
2007-08-22 23:41:44 +02:00
|
|
|
}
|
2007-08-16 05:18:08 +02:00
|
|
|
|
2007-08-22 23:41:44 +02:00
|
|
|
if ((Level > 5) && diA->pszProvider) {
|
2007-08-16 05:18:08 +02:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, diA->pszProvider, -1, NULL, 0);
|
|
|
|
diW.pszProvider = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, diA->pszProvider, -1, diW.pszProvider, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Level > 7) {
|
|
|
|
FIXME("level %u is incomplete\n", Level);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = AddPrinterDriverExW(nameW, Level, (LPBYTE) &diW, dwFileCopyFlags);
|
|
|
|
TRACE("got %u with %u\n", res, GetLastError());
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pEnvironment);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pDriverPath);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pDataFile);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pConfigFile);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pDependentFiles);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pMonitorName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pDefaultDataType);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pszzPreviousNames);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pszMfgName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pszOEMUrl);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pszHardwareID);
|
|
|
|
HeapFree(GetProcessHeap(), 0, diW.pszProvider);
|
|
|
|
|
|
|
|
TRACE("=> %u with %u\n", res, GetLastError());
|
|
|
|
return res;
|
2003-08-12 20:54:26 +02:00
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ConfigurePortA (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* See ConfigurePortW.
|
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ConfigurePortA(LPSTR pName, HWND hWnd, LPSTR pPortName)
|
|
|
|
{
|
2006-11-09 00:04:11 +01:00
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR portW = NULL;
|
|
|
|
INT len;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
TRACE("(%s, %p, %s)\n", debugstr_a(pName), hWnd, debugstr_a(pPortName));
|
|
|
|
|
|
|
|
/* convert servername to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert portname to unicode */
|
|
|
|
if (pPortName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pPortName, -1, NULL, 0);
|
|
|
|
portW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pPortName, -1, portW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
res = ConfigurePortW(nameW, hWnd, portW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, portW);
|
|
|
|
return res;
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ConfigurePortW (WINSPOOL.@)
|
2005-12-06 10:57:01 +01:00
|
|
|
*
|
|
|
|
* Display the Configuration-Dialog for a specific Port
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* hWnd [I] Handle to parent Window for the Dialog-Box
|
|
|
|
* pPortName [I] Name of the Port, that should be configured
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ConfigurePortW(LPWSTR pName, HWND hWnd, LPWSTR pPortName)
|
|
|
|
{
|
2006-11-09 00:04:08 +01:00
|
|
|
|
|
|
|
TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
|
|
|
|
|
2009-09-28 12:48:12 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-11-09 00:04:08 +01:00
|
|
|
|
|
|
|
if (!pPortName) {
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-28 12:48:12 +02:00
|
|
|
return backend->fpConfigurePort(pName, hWnd, pPortName);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* ConnectToPrinterDlg (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI ConnectToPrinterDlg( HWND hWnd, DWORD Flags )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("%p %x\n", hWnd, Flags);
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterConnectionA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrinterConnectionA( LPSTR pName )
|
|
|
|
{
|
|
|
|
FIXME("%s\n", debugstr_a(pName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterConnectionW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrinterConnectionW( LPWSTR pName )
|
|
|
|
{
|
|
|
|
FIXME("%s\n", debugstr_w(pName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-08-12 20:54:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterDriverExW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrinterDriverExW( LPWSTR pName, LPWSTR pEnvironment,
|
|
|
|
LPWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
|
|
|
|
{
|
2006-11-07 13:27:09 +01:00
|
|
|
HKEY hkey_drivers;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%s %s %s %x %x\n", debugstr_w(pName), debugstr_w(pEnvironment),
|
2003-08-12 20:54:26 +02:00
|
|
|
debugstr_w(pDriverName), dwDeleteFlag, dwVersionFlag);
|
2006-11-07 13:27:09 +01:00
|
|
|
|
|
|
|
if(pName && pName[0])
|
|
|
|
{
|
|
|
|
FIXME("pName = %s - unsupported\n", debugstr_w(pName));
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dwDeleteFlag)
|
|
|
|
{
|
|
|
|
FIXME("dwDeleteFlag = %x - unsupported\n", dwDeleteFlag);
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-01 00:03:58 +01:00
|
|
|
hkey_drivers = WINSPOOL_OpenDriverReg(pEnvironment);
|
2006-11-07 13:27:09 +01:00
|
|
|
|
|
|
|
if(!hkey_drivers)
|
|
|
|
{
|
|
|
|
ERR("Can't open drivers key\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-06-05 18:47:17 +02:00
|
|
|
if(RegDeleteTreeW(hkey_drivers, pDriverName) == ERROR_SUCCESS)
|
2006-11-07 13:27:09 +01:00
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
RegCloseKey(hkey_drivers);
|
|
|
|
|
|
|
|
return ret;
|
2003-08-12 20:54:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterDriverExA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrinterDriverExA( LPSTR pName, LPSTR pEnvironment,
|
|
|
|
LPSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
|
|
|
|
{
|
2006-11-07 13:06:04 +01:00
|
|
|
UNICODE_STRING NameW, EnvW, DriverW;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
asciitounicode(&NameW, pName);
|
|
|
|
asciitounicode(&EnvW, pEnvironment);
|
|
|
|
asciitounicode(&DriverW, pDriverName);
|
|
|
|
|
|
|
|
ret = DeletePrinterDriverExW(NameW.Buffer, EnvW.Buffer, DriverW.Buffer, dwDeleteFlag, dwVersionFlag);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString(&DriverW);
|
|
|
|
RtlFreeUnicodeString(&EnvW);
|
|
|
|
RtlFreeUnicodeString(&NameW);
|
|
|
|
|
|
|
|
return ret;
|
2003-08-12 20:54:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterDataExW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI DeletePrinterDataExW( HANDLE hPrinter, LPCWSTR pKeyName,
|
|
|
|
LPCWSTR pValueName)
|
|
|
|
{
|
|
|
|
FIXME("%p %s %s\n", hPrinter,
|
|
|
|
debugstr_w(pKeyName), debugstr_w(pValueName));
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrinterDataExA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI DeletePrinterDataExA( HANDLE hPrinter, LPCSTR pKeyName,
|
|
|
|
LPCSTR pValueName)
|
|
|
|
{
|
|
|
|
FIXME("%p %s %s\n", hPrinter,
|
|
|
|
debugstr_a(pKeyName), debugstr_a(pValueName));
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrintProcessorA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrintProcessorA(LPSTR pName, LPSTR pEnvironment, LPSTR pPrintProcessorName)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s\n", debugstr_a(pName), debugstr_a(pEnvironment),
|
|
|
|
debugstr_a(pPrintProcessorName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrintProcessorW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrintProcessorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pPrintProcessorName)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s\n", debugstr_w(pName), debugstr_w(pEnvironment),
|
|
|
|
debugstr_w(pPrintProcessorName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrintProvidorA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrintProvidorA(LPSTR pName, LPSTR pEnvironment, LPSTR pPrintProviderName)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s\n", debugstr_a(pName), debugstr_a(pEnvironment),
|
|
|
|
debugstr_a(pPrintProviderName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* DeletePrintProvidorW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeletePrintProvidorW(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pPrintProviderName)
|
|
|
|
{
|
|
|
|
FIXME("%s %s %s\n", debugstr_w(pName), debugstr_w(pEnvironment),
|
|
|
|
debugstr_w(pPrintProviderName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* EnumFormsA (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumFormsA( HANDLE hPrinter, DWORD Level, LPBYTE pForm,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("%p %x %p %x %p %p\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
|
2006-06-16 09:54:55 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumFormsW (WINSPOOL.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumFormsW( HANDLE hPrinter, DWORD Level, LPBYTE pForm,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("%p %x %p %x %p %p\n", hPrinter, Level, pForm, cbBuf, pcbNeeded, pcReturned);
|
2006-06-16 09:54:55 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-17 02:42:46 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* EnumMonitorsA [WINSPOOL.@]
|
|
|
|
*
|
2005-12-06 11:33:52 +01:00
|
|
|
* See EnumMonitorsW.
|
|
|
|
*
|
2004-03-17 02:42:46 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumMonitorsA(LPSTR pName, DWORD Level, LPBYTE pMonitors,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
|
|
|
{
|
2006-03-31 14:32:02 +02:00
|
|
|
BOOL res;
|
|
|
|
LPBYTE bufferW = NULL;
|
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
DWORD needed = 0;
|
|
|
|
DWORD numentries = 0;
|
|
|
|
INT len;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_a(pName), Level, pMonitors,
|
2004-03-17 02:42:46 +01:00
|
|
|
cbBuf, pcbNeeded, pcReturned);
|
2006-03-31 14:32:02 +02:00
|
|
|
|
|
|
|
/* convert servername to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
/* alloc (userbuffersize*sizeof(WCHAR) and try to enum the monitors */
|
|
|
|
needed = cbBuf * sizeof(WCHAR);
|
|
|
|
if (needed) bufferW = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
res = EnumMonitorsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
if (pcbNeeded) needed = *pcbNeeded;
|
|
|
|
/* HeapReAlloc return NULL, when bufferW was NULL */
|
|
|
|
bufferW = (bufferW) ? HeapReAlloc(GetProcessHeap(), 0, bufferW, needed) :
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
/* Try again with the large Buffer */
|
|
|
|
res = EnumMonitorsW(nameW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
|
|
|
}
|
|
|
|
numentries = pcReturned ? *pcReturned : 0;
|
|
|
|
needed = 0;
|
|
|
|
/*
|
|
|
|
W2k require the buffersize from EnumMonitorsW also for EnumMonitorsA.
|
|
|
|
We use the smaller Ansi-Size to avoid conflicts with fixed Buffers of old Apps.
|
|
|
|
*/
|
|
|
|
if (res) {
|
2007-01-18 11:35:50 +01:00
|
|
|
/* EnumMonitorsW collected all Data. Parse them to calculate ANSI-Size */
|
2006-03-31 14:32:02 +02:00
|
|
|
DWORD entrysize = 0;
|
|
|
|
DWORD index;
|
|
|
|
LPSTR ptr;
|
|
|
|
LPMONITOR_INFO_2W mi2w;
|
|
|
|
LPMONITOR_INFO_2A mi2a;
|
|
|
|
|
|
|
|
/* MONITOR_INFO_*W and MONITOR_INFO_*A have the same size */
|
|
|
|
entrysize = (Level == 1) ? sizeof(MONITOR_INFO_1A) : sizeof(MONITOR_INFO_2A);
|
|
|
|
|
|
|
|
/* First pass: calculate the size for all Entries */
|
|
|
|
mi2w = (LPMONITOR_INFO_2W) bufferW;
|
|
|
|
mi2a = (LPMONITOR_INFO_2A) pMonitors;
|
|
|
|
index = 0;
|
|
|
|
while (index < numentries) {
|
|
|
|
index++;
|
|
|
|
needed += entrysize; /* MONITOR_INFO_?A */
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("%p: parsing #%d (%s)\n", mi2w, index, debugstr_w(mi2w->pName));
|
2006-03-31 14:32:02 +02:00
|
|
|
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, mi2w->pName, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (Level > 1) {
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, mi2w->pEnvironment, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, mi2w->pDLLName, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
/* use LPBYTE with entrysize to avoid double code (MONITOR_INFO_1 + MONITOR_INFO_2) */
|
|
|
|
mi2w = (LPMONITOR_INFO_2W) (((LPBYTE)mi2w) + entrysize);
|
|
|
|
mi2a = (LPMONITOR_INFO_2A) (((LPBYTE)mi2a) + entrysize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for errors and quit on failure */
|
|
|
|
if (cbBuf < needed) {
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
res = FALSE;
|
|
|
|
goto emA_cleanup;
|
|
|
|
}
|
|
|
|
len = entrysize * numentries; /* room for all MONITOR_INFO_?A */
|
|
|
|
ptr = (LPSTR) &pMonitors[len]; /* room for strings */
|
|
|
|
cbBuf -= len ; /* free Bytes in the user-Buffer */
|
|
|
|
mi2w = (LPMONITOR_INFO_2W) bufferW;
|
|
|
|
mi2a = (LPMONITOR_INFO_2A) pMonitors;
|
|
|
|
index = 0;
|
|
|
|
/* Second Pass: Fill the User Buffer (if we have one) */
|
|
|
|
while ((index < numentries) && pMonitors) {
|
|
|
|
index++;
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("%p: writing MONITOR_INFO_%dA #%d\n", mi2a, Level, index);
|
2006-03-31 14:32:02 +02:00
|
|
|
mi2a->pName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, mi2w->pName, -1,
|
|
|
|
ptr, cbBuf , NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
if (Level > 1) {
|
|
|
|
mi2a->pEnvironment = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, mi2w->pEnvironment, -1,
|
|
|
|
ptr, cbBuf, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
|
|
|
|
mi2a->pDLLName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, mi2w->pDLLName, -1,
|
|
|
|
ptr, cbBuf, NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
}
|
|
|
|
/* use LPBYTE with entrysize to avoid double code (MONITOR_INFO_1 + MONITOR_INFO_2) */
|
|
|
|
mi2w = (LPMONITOR_INFO_2W) (((LPBYTE)mi2w) + entrysize);
|
|
|
|
mi2a = (LPMONITOR_INFO_2A) (((LPBYTE)mi2a) + entrysize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emA_cleanup:
|
|
|
|
if (pcbNeeded) *pcbNeeded = needed;
|
|
|
|
if (pcReturned) *pcReturned = (res) ? numentries : 0;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("returning %d with %d (%d byte for %d entries)\n",
|
2006-03-31 14:32:02 +02:00
|
|
|
(res), GetLastError(), needed, numentries);
|
|
|
|
|
|
|
|
return (res);
|
|
|
|
|
2004-03-17 02:42:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumMonitorsW [WINSPOOL.@]
|
|
|
|
*
|
2006-03-31 14:30:10 +02:00
|
|
|
* Enumerate available Port-Monitors
|
2005-12-06 11:33:52 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* Level [I] Structure-Level (1:Win9x+NT or 2:NT only)
|
|
|
|
* pMonitors [O] PTR to Buffer that receives the Result
|
|
|
|
* cbBuf [I] Size of Buffer at pMonitors
|
|
|
|
* pcbNeeded [O] PTR to DWORD that receives the size in Bytes used / required for pMonitors
|
|
|
|
* pcReturned [O] PTR to DWORD that receives the number of Monitors in pMonitors
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
2006-03-31 14:30:10 +02:00
|
|
|
* Failure: FALSE and in pcbNeeded the Bytes required for buffer, if cbBuf is too small
|
2005-12-06 11:33:52 +01:00
|
|
|
*
|
2004-03-17 02:42:46 +01:00
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumMonitorsW(LPWSTR pName, DWORD Level, LPBYTE pMonitors,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
|
|
|
{
|
2006-03-31 14:30:10 +02:00
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%s, %d, %p, %d, %p, %p)\n", debugstr_w(pName), Level, pMonitors,
|
2004-03-17 02:42:46 +01:00
|
|
|
cbBuf, pcbNeeded, pcReturned);
|
2006-03-31 14:30:10 +02:00
|
|
|
|
2008-06-30 21:54:57 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
2006-03-31 14:30:10 +02:00
|
|
|
|
2008-07-10 23:42:55 +02:00
|
|
|
if (!pcbNeeded || !pcReturned || (!pMonitors && (cbBuf > 0))) {
|
2006-03-31 14:30:10 +02:00
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
2008-06-30 21:54:57 +02:00
|
|
|
return FALSE;
|
2006-03-31 14:30:10 +02:00
|
|
|
}
|
|
|
|
|
2008-06-30 21:54:57 +02:00
|
|
|
return backend->fpEnumMonitors(pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned);
|
2004-03-17 02:42:46 +01:00
|
|
|
}
|
|
|
|
|
2008-03-07 23:49:57 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* SpoolerInit (WINSPOOL.@)
|
|
|
|
*
|
|
|
|
* Initialize the Spooler
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The function fails on windows, when the spooler service is not running
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SpoolerInit(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-08-12 20:54:26 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* XcvDataW (WINSPOOL.@)
|
|
|
|
*
|
2007-01-05 01:11:21 +01:00
|
|
|
* Execute commands in the Printmonitor DLL
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hXcv [i] Handle from OpenPrinter (with XcvMonitor or XcvPort)
|
|
|
|
* pszDataName [i] Name of the command to execute
|
|
|
|
* pInputData [i] Buffer for extra Input Data (needed only for some commands)
|
|
|
|
* cbInputData [i] Size in Bytes of Buffer at pInputData
|
|
|
|
* pOutputData [o] Buffer to receive additional Data (needed only for some commands)
|
|
|
|
* cbOutputData [i] Size in Bytes of Buffer at pOutputData
|
|
|
|
* pcbOutputNeeded [o] PTR to receive the minimal Size in Bytes of the Buffer at pOutputData
|
|
|
|
* pdwStatus [o] PTR to receive the win32 error code from the Printmonitor DLL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Returning "TRUE" does mean, that the Printmonitor DLL was called successful.
|
|
|
|
* The execution of the command can still fail (check pdwStatus for ERROR_SUCCESS).
|
|
|
|
*
|
|
|
|
* Minimal List of commands, that a Printmonitor DLL should support:
|
|
|
|
*
|
|
|
|
*| "MonitorUI" : Return the Name of the Userinterface-DLL as WSTR in pOutputData
|
|
|
|
*| "AddPort" : Add a Port
|
|
|
|
*| "DeletePort": Delete a Port
|
|
|
|
*
|
|
|
|
* Many Printmonitors support additional commands. Examples for localspl.dll:
|
|
|
|
* "GetDefaultCommConfig", "SetDefaultCommConfig",
|
|
|
|
* "GetTransmissionRetryTimeout", "ConfigureLPTPortCommandOK"
|
|
|
|
*
|
2003-08-12 20:54:26 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI XcvDataW( HANDLE hXcv, LPCWSTR pszDataName, PBYTE pInputData,
|
|
|
|
DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData,
|
|
|
|
PDWORD pcbOutputNeeded, PDWORD pdwStatus)
|
|
|
|
{
|
2007-01-05 01:11:21 +01:00
|
|
|
opened_printer_t *printer;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p, %d, %p, %d, %p, %p)\n", hXcv, debugstr_w(pszDataName),
|
2003-08-12 20:54:26 +02:00
|
|
|
pInputData, cbInputData, pOutputData,
|
|
|
|
cbOutputData, pcbOutputNeeded, pdwStatus);
|
2007-01-05 01:11:21 +01:00
|
|
|
|
2009-05-07 00:11:33 +02:00
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
|
|
|
|
2007-01-05 01:11:21 +01:00
|
|
|
printer = get_opened_printer(hXcv);
|
2009-05-07 00:11:33 +02:00
|
|
|
if (!printer || (!printer->backend_printer)) {
|
2007-01-05 01:11:21 +01:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-01-15 05:38:28 +01:00
|
|
|
if (!pcbOutputNeeded) {
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pszDataName || !pdwStatus || (!pOutputData && (cbOutputData > 0))) {
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcbOutputNeeded = 0;
|
|
|
|
|
2009-05-07 00:11:33 +02:00
|
|
|
return backend->fpXcvData(printer->backend_printer, pszDataName, pInputData,
|
|
|
|
cbInputData, pOutputData, cbOutputData, pcbOutputNeeded, pdwStatus);
|
2007-01-05 01:11:21 +01:00
|
|
|
|
2003-08-12 20:54:26 +02:00
|
|
|
}
|
2004-10-29 23:27:38 +02:00
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrinterDataA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterDataA( HANDLE hPrinter, DWORD dwIndex, LPSTR pValueName,
|
|
|
|
DWORD cbValueName, LPDWORD pcbValueName, LPDWORD pType, LPBYTE pData,
|
|
|
|
DWORD cbData, LPDWORD pcbData )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("%p %x %p %x %p %p %p %x %p\n", hPrinter, dwIndex, pValueName,
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
cbValueName, pcbValueName, pType, pData, cbData, pcbData);
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrinterDataW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterDataW( HANDLE hPrinter, DWORD dwIndex, LPWSTR pValueName,
|
|
|
|
DWORD cbValueName, LPDWORD pcbValueName, LPDWORD pType, LPBYTE pData,
|
|
|
|
DWORD cbData, LPDWORD pcbData )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("%p %x %p %x %p %p %p %x %p\n", hPrinter, dwIndex, pValueName,
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
cbValueName, pcbValueName, pType, pData, cbData, pcbData);
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
}
|
|
|
|
|
2016-01-19 20:10:10 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrinterKeyA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterKeyA(HANDLE printer, const CHAR *key, CHAR *subkey, DWORD size, DWORD *needed)
|
|
|
|
{
|
|
|
|
FIXME("%p %s %p %x %p\n", printer, debugstr_a(key), subkey, size, needed);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrinterKeyW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI EnumPrinterKeyW(HANDLE printer, const WCHAR *key, WCHAR *subkey, DWORD size, DWORD *needed)
|
|
|
|
{
|
|
|
|
FIXME("%p %s %p %x %p\n", printer, debugstr_w(key), subkey, size, needed);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrintProcessorDatatypesA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrintProcessorDatatypesA(LPSTR pName, LPSTR pPrintProcessorName,
|
|
|
|
DWORD Level, LPBYTE pDatatypes, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, LPDWORD pcReturned)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("Stub: %s %s %d %p %d %p %p\n", debugstr_a(pName),
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
debugstr_a(pPrintProcessorName), Level, pDatatypes, cbBuf,
|
|
|
|
pcbNeeded, pcReturned);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrintProcessorDatatypesW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrintProcessorDatatypesW(LPWSTR pName, LPWSTR pPrintProcessorName,
|
|
|
|
DWORD Level, LPBYTE pDatatypes, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, LPDWORD pcReturned)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("Stub: %s %s %d %p %d %p %p\n", debugstr_w(pName),
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
debugstr_w(pPrintProcessorName), Level, pDatatypes, cbBuf,
|
|
|
|
pcbNeeded, pcReturned);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-10-29 23:27:38 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrintProcessorsA [WINSPOOL.@]
|
|
|
|
*
|
2009-10-14 23:45:00 +02:00
|
|
|
* See EnumPrintProcessorsW.
|
|
|
|
*
|
2004-10-29 23:27:38 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrintProcessorsA(LPSTR pName, LPSTR pEnvironment, DWORD Level,
|
2009-10-14 23:45:00 +02:00
|
|
|
LPBYTE pPPInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
2004-10-29 23:27:38 +02:00
|
|
|
{
|
2009-10-14 23:45:00 +02:00
|
|
|
BOOL res;
|
|
|
|
LPBYTE bufferW = NULL;
|
|
|
|
LPWSTR nameW = NULL;
|
|
|
|
LPWSTR envW = NULL;
|
|
|
|
DWORD needed = 0;
|
|
|
|
DWORD numentries = 0;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p, %p)\n", debugstr_a(pName), debugstr_a(pEnvironment),
|
|
|
|
Level, pPPInfo, cbBuf, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
/* convert names to unicode */
|
|
|
|
if (pName) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pName, -1, NULL, 0);
|
|
|
|
nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pName, -1, nameW, len);
|
|
|
|
}
|
|
|
|
if (pEnvironment) {
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, pEnvironment, -1, NULL, 0);
|
|
|
|
envW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pEnvironment, -1, envW, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* alloc (userbuffersize*sizeof(WCHAR) and try to enum the monitors */
|
|
|
|
needed = cbBuf * sizeof(WCHAR);
|
|
|
|
if (needed) bufferW = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
res = EnumPrintProcessorsW(nameW, envW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
if (pcbNeeded) needed = *pcbNeeded;
|
|
|
|
/* HeapReAlloc return NULL, when bufferW was NULL */
|
|
|
|
bufferW = (bufferW) ? HeapReAlloc(GetProcessHeap(), 0, bufferW, needed) :
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
/* Try again with the large Buffer */
|
|
|
|
res = EnumPrintProcessorsW(nameW, envW, Level, bufferW, needed, pcbNeeded, pcReturned);
|
|
|
|
}
|
|
|
|
numentries = pcReturned ? *pcReturned : 0;
|
|
|
|
needed = 0;
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
/* EnumPrintProcessorsW collected all Data. Parse them to calculate ANSI-Size */
|
|
|
|
DWORD index;
|
|
|
|
LPSTR ptr;
|
|
|
|
PPRINTPROCESSOR_INFO_1W ppiw;
|
|
|
|
PPRINTPROCESSOR_INFO_1A ppia;
|
|
|
|
|
|
|
|
/* First pass: calculate the size for all Entries */
|
|
|
|
ppiw = (PPRINTPROCESSOR_INFO_1W) bufferW;
|
|
|
|
ppia = (PPRINTPROCESSOR_INFO_1A) pPPInfo;
|
|
|
|
index = 0;
|
|
|
|
while (index < numentries) {
|
|
|
|
index++;
|
|
|
|
needed += sizeof(PRINTPROCESSOR_INFO_1A);
|
|
|
|
TRACE("%p: parsing #%d (%s)\n", ppiw, index, debugstr_w(ppiw->pName));
|
|
|
|
|
|
|
|
needed += WideCharToMultiByte(CP_ACP, 0, ppiw->pName, -1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
ppiw = (PPRINTPROCESSOR_INFO_1W) (((LPBYTE)ppiw) + sizeof(PRINTPROCESSOR_INFO_1W));
|
|
|
|
ppia = (PPRINTPROCESSOR_INFO_1A) (((LPBYTE)ppia) + sizeof(PRINTPROCESSOR_INFO_1A));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for errors and quit on failure */
|
|
|
|
if (cbBuf < needed) {
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
res = FALSE;
|
|
|
|
goto epp_cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = numentries * sizeof(PRINTPROCESSOR_INFO_1A); /* room for structs */
|
|
|
|
ptr = (LPSTR) &pPPInfo[len]; /* start of strings */
|
|
|
|
cbBuf -= len ; /* free Bytes in the user-Buffer */
|
|
|
|
ppiw = (PPRINTPROCESSOR_INFO_1W) bufferW;
|
|
|
|
ppia = (PPRINTPROCESSOR_INFO_1A) pPPInfo;
|
|
|
|
index = 0;
|
|
|
|
/* Second Pass: Fill the User Buffer (if we have one) */
|
|
|
|
while ((index < numentries) && pPPInfo) {
|
|
|
|
index++;
|
|
|
|
TRACE("%p: writing PRINTPROCESSOR_INFO_1A #%d\n", ppia, index);
|
|
|
|
ppia->pName = ptr;
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, ppiw->pName, -1,
|
|
|
|
ptr, cbBuf , NULL, NULL);
|
|
|
|
ptr += len;
|
|
|
|
cbBuf -= len;
|
|
|
|
|
|
|
|
ppiw = (PPRINTPROCESSOR_INFO_1W) (((LPBYTE)ppiw) + sizeof(PRINTPROCESSOR_INFO_1W));
|
|
|
|
ppia = (PPRINTPROCESSOR_INFO_1A) (((LPBYTE)ppia) + sizeof(PRINTPROCESSOR_INFO_1A));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
epp_cleanup:
|
|
|
|
if (pcbNeeded) *pcbNeeded = needed;
|
|
|
|
if (pcReturned) *pcReturned = (res) ? numentries : 0;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, nameW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, envW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bufferW);
|
|
|
|
|
|
|
|
TRACE("returning %d with %d (%d byte for %d entries)\n",
|
|
|
|
(res), GetLastError(), needed, numentries);
|
|
|
|
|
|
|
|
return (res);
|
2004-10-29 23:27:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* EnumPrintProcessorsW [WINSPOOL.@]
|
|
|
|
*
|
2009-10-14 23:45:00 +02:00
|
|
|
* Enumerate available Print Processors
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pName [I] Servername or NULL (local Computer)
|
|
|
|
* pEnvironment [I] Printing-Environment or NULL (Default)
|
|
|
|
* Level [I] Structure-Level (Only 1 is allowed)
|
|
|
|
* pPPInfo [O] PTR to Buffer that receives the Result
|
2009-10-16 13:40:39 +02:00
|
|
|
* cbBuf [I] Size of Buffer at pPPInfo
|
2009-10-14 23:45:00 +02:00
|
|
|
* pcbNeeded [O] PTR to DWORD that receives the size in Bytes used / required for pPPInfo
|
|
|
|
* pcReturned [O] PTR to DWORD that receives the number of Print Processors in pPPInfo
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE and in pcbNeeded the Bytes required for pPPInfo, if cbBuf is too small
|
|
|
|
*
|
2004-10-29 23:27:38 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumPrintProcessorsW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
|
2009-10-14 23:45:00 +02:00
|
|
|
LPBYTE pPPInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
|
2004-10-29 23:27:38 +02:00
|
|
|
{
|
2009-10-14 23:45:00 +02:00
|
|
|
|
|
|
|
TRACE("(%s, %s, %d, %p, %d, %p, %p)\n", debugstr_w(pName), debugstr_w(pEnvironment),
|
|
|
|
Level, pPPInfo, cbBuf, pcbNeeded, pcReturned);
|
|
|
|
|
|
|
|
if ((backend == NULL) && !load_backend()) return FALSE;
|
|
|
|
|
|
|
|
if (!pcbNeeded || !pcReturned) {
|
|
|
|
SetLastError(RPC_X_NULL_REF_POINTER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pPPInfo && (cbBuf > 0)) {
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend->fpEnumPrintProcessors(pName, pEnvironment, Level, pPPInfo,
|
|
|
|
cbBuf, pcbNeeded, pcReturned);
|
2004-10-29 23:27:38 +02:00
|
|
|
}
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* ExtDeviceMode [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LONG WINAPI ExtDeviceMode( HWND hWnd, HANDLE hInst, LPDEVMODEA pDevModeOutput,
|
|
|
|
LPSTR pDeviceName, LPSTR pPort, LPDEVMODEA pDevModeInput, LPSTR pProfile,
|
|
|
|
DWORD fMode)
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("Stub: %p %p %p %s %s %p %s %x\n", hWnd, hInst, pDevModeOutput,
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
debugstr_a(pDeviceName), debugstr_a(pPort), pDevModeInput,
|
|
|
|
debugstr_a(pProfile), fMode);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* FindClosePrinterChangeNotification [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FindClosePrinterChangeNotification( HANDLE hChange )
|
|
|
|
{
|
|
|
|
FIXME("Stub: %p\n", hChange);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* FindFirstPrinterChangeNotification [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI FindFirstPrinterChangeNotification( HANDLE hPrinter,
|
|
|
|
DWORD fdwFlags, DWORD fdwOptions, LPVOID pPrinterNotifyOptions )
|
|
|
|
{
|
2006-10-13 11:51:23 +02:00
|
|
|
FIXME("Stub: %p %x %x %p\n",
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
hPrinter, fdwFlags, fdwOptions, pPrinterNotifyOptions);
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* FindNextPrinterChangeNotification [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FindNextPrinterChangeNotification( HANDLE hChange, PDWORD pdwChange,
|
|
|
|
LPVOID pPrinterNotifyOptions, LPVOID *ppPrinterNotifyInfo )
|
|
|
|
{
|
|
|
|
FIXME("Stub: %p %p %p %p\n",
|
|
|
|
hChange, pdwChange, pPrinterNotifyOptions, ppPrinterNotifyInfo);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* FreePrinterNotifyInfo [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI FreePrinterNotifyInfo( PPRINTER_NOTIFY_INFO pPrinterNotifyInfo )
|
|
|
|
{
|
|
|
|
FIXME("Stub: %p\n", pPrinterNotifyInfo);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:13:31 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* string_to_buf
|
|
|
|
*
|
|
|
|
* Copies a unicode string into a buffer. The buffer will either contain unicode or
|
|
|
|
* ansi depending on the unicode parameter.
|
|
|
|
*/
|
|
|
|
static BOOL string_to_buf(LPCWSTR str, LPBYTE ptr, DWORD cb, DWORD *size, BOOL unicode)
|
|
|
|
{
|
|
|
|
if(!str)
|
|
|
|
{
|
|
|
|
*size = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(unicode)
|
|
|
|
{
|
|
|
|
*size = (strlenW(str) + 1) * sizeof(WCHAR);
|
|
|
|
if(*size <= cb)
|
|
|
|
{
|
|
|
|
memcpy(ptr, str, *size);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
|
|
|
|
if(*size <= cb)
|
|
|
|
{
|
2005-08-19 12:04:03 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, str, -1, (LPSTR)ptr, *size, NULL, NULL);
|
2005-07-18 15:13:31 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_job_info_1
|
|
|
|
*/
|
|
|
|
static BOOL get_job_info_1(job_t *job, JOB_INFO_1W *ji1, LPBYTE buf, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, BOOL unicode)
|
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
|
|
|
if(space)
|
|
|
|
{
|
|
|
|
ji1->JobId = job->job_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
string_to_buf(job->document_title, ptr, left, &size, unicode);
|
|
|
|
if(space && size <= left)
|
|
|
|
{
|
|
|
|
ji1->pDocument = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
|
2010-09-13 17:28:56 +02:00
|
|
|
if (job->printer_name)
|
|
|
|
{
|
|
|
|
string_to_buf(job->printer_name, ptr, left, &size, unicode);
|
|
|
|
if(space && size <= left)
|
|
|
|
{
|
|
|
|
ji1->pPrinterName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:13:31 +02:00
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_job_info_2
|
|
|
|
*/
|
|
|
|
static BOOL get_job_info_2(job_t *job, JOB_INFO_2W *ji2, LPBYTE buf, DWORD cbBuf,
|
|
|
|
LPDWORD pcbNeeded, BOOL unicode)
|
|
|
|
{
|
|
|
|
DWORD size, left = cbBuf;
|
2010-09-20 16:26:49 +02:00
|
|
|
DWORD shift;
|
2005-07-18 15:13:31 +02:00
|
|
|
BOOL space = (cbBuf > 0);
|
|
|
|
LPBYTE ptr = buf;
|
2011-04-26 03:22:32 +02:00
|
|
|
LPDEVMODEA dmA = NULL;
|
2010-09-20 16:26:49 +02:00
|
|
|
LPDEVMODEW devmode;
|
2005-07-18 15:13:31 +02:00
|
|
|
|
|
|
|
*pcbNeeded = 0;
|
|
|
|
|
|
|
|
if(space)
|
|
|
|
{
|
|
|
|
ji2->JobId = job->job_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
string_to_buf(job->document_title, ptr, left, &size, unicode);
|
|
|
|
if(space && size <= left)
|
|
|
|
{
|
|
|
|
ji2->pDocument = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
|
2010-09-13 17:28:56 +02:00
|
|
|
if (job->printer_name)
|
|
|
|
{
|
|
|
|
string_to_buf(job->printer_name, ptr, left, &size, unicode);
|
|
|
|
if(space && size <= left)
|
|
|
|
{
|
|
|
|
ji2->pPrinterName = (LPWSTR)ptr;
|
|
|
|
ptr += size;
|
|
|
|
left -= size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded += size;
|
|
|
|
}
|
|
|
|
|
2010-09-20 16:26:49 +02:00
|
|
|
if (job->devmode)
|
|
|
|
{
|
|
|
|
if (!unicode)
|
|
|
|
{
|
|
|
|
dmA = DEVMODEdupWtoA(job->devmode);
|
|
|
|
devmode = (LPDEVMODEW) dmA;
|
|
|
|
if (dmA) size = dmA->dmSize + dmA->dmDriverExtra;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
devmode = job->devmode;
|
|
|
|
size = devmode->dmSize + devmode->dmDriverExtra;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!devmode)
|
|
|
|
FIXME("Can't convert DEVMODE W to A\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* align DEVMODE to a DWORD boundary */
|
2012-04-03 12:43:39 +02:00
|
|
|
shift = (4 - (*pcbNeeded & 3)) & 3;
|
2010-09-20 16:26:49 +02:00
|
|
|
size += shift;
|
|
|
|
|
|
|
|
if (size <= left)
|
|
|
|
{
|
|
|
|
ptr += shift;
|
|
|
|
memcpy(ptr, devmode, size-shift);
|
|
|
|
ji2->pDevMode = (LPDEVMODEW)ptr;
|
|
|
|
if (!unicode) HeapFree(GetProcessHeap(), 0, dmA);
|
2012-04-03 12:43:39 +02:00
|
|
|
ptr += size-shift;
|
2010-09-20 16:26:49 +02:00
|
|
|
left -= size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
space = FALSE;
|
|
|
|
*pcbNeeded +=size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:13:31 +02:00
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_job_info
|
|
|
|
*/
|
|
|
|
static BOOL get_job_info(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob,
|
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded, BOOL unicode)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD needed = 0, size;
|
|
|
|
job_t *job;
|
|
|
|
LPBYTE ptr = pJob;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("%p %d %d %p %d %p\n", hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded);
|
2005-07-18 15:13:31 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
job = get_job(hPrinter, JobId);
|
|
|
|
if(!job)
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
switch(Level)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
size = sizeof(JOB_INFO_1W);
|
|
|
|
if(cbBuf >= size)
|
|
|
|
{
|
|
|
|
cbBuf -= size;
|
|
|
|
ptr += size;
|
|
|
|
memset(pJob, 0, size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cbBuf = 0;
|
|
|
|
ret = get_job_info_1(job, (JOB_INFO_1W *)pJob, ptr, cbBuf, &needed, unicode);
|
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
size = sizeof(JOB_INFO_2W);
|
|
|
|
if(cbBuf >= size)
|
|
|
|
{
|
|
|
|
cbBuf -= size;
|
|
|
|
ptr += size;
|
|
|
|
memset(pJob, 0, size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cbBuf = 0;
|
|
|
|
ret = get_job_info_2(job, (JOB_INFO_2W *)pJob, ptr, cbBuf, &needed, unicode);
|
|
|
|
needed += size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
size = sizeof(JOB_INFO_3);
|
|
|
|
if(cbBuf >= size)
|
|
|
|
{
|
|
|
|
cbBuf -= size;
|
|
|
|
memset(pJob, 0, size);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cbBuf = 0;
|
|
|
|
needed = size;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
SetLastError(ERROR_INVALID_LEVEL);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if(pcbNeeded)
|
|
|
|
*pcbNeeded = needed;
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* GetJobA [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetJobA(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob,
|
2005-07-18 15:13:31 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2005-07-18 15:13:31 +02:00
|
|
|
return get_job_info(hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded, FALSE);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* GetJobW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob,
|
2005-07-18 15:13:31 +02:00
|
|
|
DWORD cbBuf, LPDWORD pcbNeeded)
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
{
|
2005-07-18 15:13:31 +02:00
|
|
|
return get_job_info(hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded, TRUE);
|
Stub implementations for AddMonitorW, DeletePrinterDriverW,
DeleteMonitorW, DeletePortW, GetPrintProcessorDirectoryW,
AddPrintProcessor{A,W}, AddPrintProvidor{A,W},
AdvancedDocumentProperties{A,W}, EnumPortsW, AddPort{A,W},
ConfigurePort{A,W}, DeletePrintProcessor{A,W},
DeletePrintProvidor{A,W}, EnumPrintProcessorDatatypes{A,W},
GetJob{A,W}.
2005-01-03 21:24:39 +01:00
|
|
|
}
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
|
2005-07-10 19:39:01 +02:00
|
|
|
/*****************************************************************************
|
2010-12-07 14:14:02 +01:00
|
|
|
* schedule_pipe
|
2005-07-10 19:39:01 +02:00
|
|
|
*/
|
2010-12-07 14:14:02 +01:00
|
|
|
static BOOL schedule_pipe(LPCWSTR cmd, LPCWSTR filename)
|
2005-07-10 19:39:01 +02:00
|
|
|
{
|
2010-12-07 14:14:02 +01:00
|
|
|
#ifdef HAVE_FORK
|
|
|
|
char *unixname, *cmdA;
|
2005-07-10 19:39:01 +02:00
|
|
|
DWORD len;
|
2010-12-07 14:14:02 +01:00
|
|
|
int fds[2] = {-1, -1}, file_fd = -1, no_read;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
char buf[1024];
|
2011-11-30 23:49:14 +01:00
|
|
|
pid_t pid, wret;
|
|
|
|
int status;
|
2005-07-10 19:39:01 +02:00
|
|
|
|
|
|
|
if(!(unixname = wine_get_unix_file_name(filename)))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-12-07 14:14:02 +01:00
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, cmd, -1, NULL, 0, NULL, NULL);
|
|
|
|
cmdA = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, cmd, -1, cmdA, len, NULL, NULL);
|
2005-07-10 19:39:01 +02:00
|
|
|
|
2010-12-07 14:14:02 +01:00
|
|
|
TRACE("printing with: %s\n", cmdA);
|
2005-07-10 19:39:01 +02:00
|
|
|
|
2010-12-07 14:14:02 +01:00
|
|
|
if((file_fd = open(unixname, O_RDONLY)) == -1)
|
|
|
|
goto end;
|
2005-07-10 19:39:01 +02:00
|
|
|
|
2010-12-07 14:14:02 +01:00
|
|
|
if (pipe(fds))
|
|
|
|
{
|
|
|
|
ERR("pipe() failed!\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2011-11-30 23:49:14 +01:00
|
|
|
if ((pid = fork()) == 0)
|
2010-12-07 14:14:02 +01:00
|
|
|
{
|
|
|
|
close(0);
|
|
|
|
dup2(fds[0], 0);
|
|
|
|
close(fds[1]);
|
|
|
|
|
|
|
|
/* reset signals that we previously set to SIG_IGN */
|
|
|
|
signal(SIGPIPE, SIG_DFL);
|
|
|
|
|
|
|
|
execl("/bin/sh", "/bin/sh", "-c", cmdA, NULL);
|
|
|
|
_exit(1);
|
|
|
|
}
|
2011-11-30 23:49:14 +01:00
|
|
|
else if (pid == -1)
|
|
|
|
{
|
|
|
|
ERR("fork() failed!\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2010-12-07 14:14:02 +01:00
|
|
|
|
2012-12-12 05:54:05 +01:00
|
|
|
close(fds[0]);
|
|
|
|
fds[0] = -1;
|
2010-12-07 14:14:02 +01:00
|
|
|
while((no_read = read(file_fd, buf, sizeof(buf))) > 0)
|
|
|
|
write(fds[1], buf, no_read);
|
|
|
|
|
2011-11-30 23:49:14 +01:00
|
|
|
close(fds[1]);
|
|
|
|
fds[1] = -1;
|
|
|
|
|
|
|
|
/* reap child */
|
|
|
|
do {
|
|
|
|
wret = waitpid(pid, &status, 0);
|
|
|
|
} while (wret < 0 && errno == EINTR);
|
|
|
|
if (wret < 0)
|
|
|
|
{
|
|
|
|
ERR("waitpid() failed!\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (!WIFEXITED(status) || WEXITSTATUS(status))
|
|
|
|
{
|
|
|
|
ERR("child process failed! %d\n", status);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2010-12-07 14:14:02 +01:00
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
end:
|
|
|
|
if(file_fd != -1) close(file_fd);
|
|
|
|
if(fds[0] != -1) close(fds[0]);
|
|
|
|
if(fds[1] != -1) close(fds[1]);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, cmdA);
|
2005-07-10 19:39:01 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
2010-12-07 14:14:02 +01:00
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* schedule_lpr
|
|
|
|
*/
|
|
|
|
static BOOL schedule_lpr(LPCWSTR printer_name, LPCWSTR filename)
|
|
|
|
{
|
|
|
|
WCHAR *cmd;
|
|
|
|
const WCHAR fmtW[] = {'l','p','r',' ','-','P','\'','%','s','\'',0};
|
|
|
|
BOOL r;
|
|
|
|
|
|
|
|
cmd = HeapAlloc(GetProcessHeap(), 0, strlenW(printer_name) * sizeof(WCHAR) + sizeof(fmtW));
|
|
|
|
sprintfW(cmd, fmtW, printer_name);
|
|
|
|
|
|
|
|
r = schedule_pipe(cmd, filename);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, cmd);
|
|
|
|
return r;
|
2005-07-10 19:39:01 +02:00
|
|
|
}
|
|
|
|
|
2012-04-16 14:18:42 +02:00
|
|
|
#ifdef SONAME_LIBCUPS
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_cups_jobs_ticket_options
|
|
|
|
*
|
|
|
|
* Explicitly set CUPS options based on any %cupsJobTicket lines.
|
|
|
|
* The CUPS scheduler only looks for these in Print-File requests, and since
|
|
|
|
* cupsPrintFile uses Create-Job / Send-Document, the ticket lines don't get
|
|
|
|
* parsed.
|
|
|
|
*/
|
|
|
|
static int get_cups_job_ticket_options( const char *file, int num_options, cups_option_t **options )
|
|
|
|
{
|
|
|
|
FILE *fp = fopen( file, "r" );
|
|
|
|
char buf[257]; /* DSC max of 256 + '\0' */
|
|
|
|
const char *ps_adobe = "%!PS-Adobe-";
|
|
|
|
const char *cups_job = "%cupsJobTicket:";
|
|
|
|
|
|
|
|
if (!fp) return num_options;
|
|
|
|
if (!fgets( buf, sizeof(buf), fp )) goto end;
|
|
|
|
if (strncmp( buf, ps_adobe, strlen( ps_adobe ) )) goto end;
|
|
|
|
while (fgets( buf, sizeof(buf), fp ))
|
|
|
|
{
|
|
|
|
if (strncmp( buf, cups_job, strlen( cups_job ) )) break;
|
|
|
|
num_options = pcupsParseOptions( buf + strlen( cups_job ), num_options, options );
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
fclose( fp );
|
|
|
|
return num_options;
|
|
|
|
}
|
2013-11-01 11:43:16 +01:00
|
|
|
|
|
|
|
static int get_cups_default_options( const char *printer, int num_options, cups_option_t **options )
|
|
|
|
{
|
|
|
|
cups_dest_t *dest;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!pcupsGetNamedDest) return num_options;
|
|
|
|
|
|
|
|
dest = pcupsGetNamedDest( NULL, printer, NULL );
|
|
|
|
if (!dest) return num_options;
|
|
|
|
|
|
|
|
for (i = 0; i < dest->num_options; i++)
|
|
|
|
{
|
|
|
|
if (!pcupsGetOption( dest->options[i].name, num_options, *options ))
|
|
|
|
num_options = pcupsAddOption( dest->options[i].name, dest->options[i].value,
|
|
|
|
num_options, options );
|
|
|
|
}
|
|
|
|
|
|
|
|
pcupsFreeDests( 1, dest );
|
|
|
|
return num_options;
|
|
|
|
}
|
2012-04-16 14:18:42 +02:00
|
|
|
#endif
|
|
|
|
|
2005-07-11 15:21:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* schedule_cups
|
|
|
|
*/
|
2005-07-15 11:55:23 +02:00
|
|
|
static BOOL schedule_cups(LPCWSTR printer_name, LPCWSTR filename, LPCWSTR document_title)
|
2005-07-11 15:21:48 +02:00
|
|
|
{
|
2007-07-02 17:30:44 +02:00
|
|
|
#ifdef SONAME_LIBCUPS
|
2005-07-11 15:21:48 +02:00
|
|
|
if(pcupsPrintFile)
|
|
|
|
{
|
2008-12-03 19:24:50 +01:00
|
|
|
char *unixname, *queue, *unix_doc_title;
|
2005-07-11 15:21:48 +02:00
|
|
|
DWORD len;
|
|
|
|
BOOL ret;
|
2012-04-16 14:18:42 +02:00
|
|
|
int num_options = 0, i;
|
|
|
|
cups_option_t *options = NULL;
|
2005-07-11 15:21:48 +02:00
|
|
|
|
|
|
|
if(!(unixname = wine_get_unix_file_name(filename)))
|
|
|
|
return FALSE;
|
|
|
|
|
2008-12-03 19:24:50 +01:00
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, printer_name, -1, NULL, 0, NULL, NULL);
|
2005-07-11 15:21:48 +02:00
|
|
|
queue = HeapAlloc(GetProcessHeap(), 0, len);
|
2008-12-03 19:24:50 +01:00
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, printer_name, -1, queue, len, NULL, NULL);
|
2005-07-11 15:21:48 +02:00
|
|
|
|
2008-12-03 19:24:50 +01:00
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, document_title, -1, NULL, 0, NULL, NULL);
|
|
|
|
unix_doc_title = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, document_title, -1, unix_doc_title, len, NULL, NULL);
|
2005-07-15 11:55:23 +02:00
|
|
|
|
2012-04-16 14:18:42 +02:00
|
|
|
num_options = get_cups_job_ticket_options( unixname, num_options, &options );
|
2013-11-01 11:43:16 +01:00
|
|
|
num_options = get_cups_default_options( queue, num_options, &options );
|
2012-04-16 14:18:42 +02:00
|
|
|
|
|
|
|
TRACE( "printing via cups with options:\n" );
|
|
|
|
for (i = 0; i < num_options; i++)
|
|
|
|
TRACE( "\t%d: %s = %s\n", i, options[i].name, options[i].value );
|
|
|
|
|
|
|
|
ret = pcupsPrintFile( queue, unixname, unix_doc_title, num_options, options );
|
2016-01-28 17:30:55 +01:00
|
|
|
if (ret == 0 && pcupsLastErrorString)
|
|
|
|
WARN("cupsPrintFile failed with error %s\n", debugstr_a(pcupsLastErrorString()));
|
2012-04-16 14:18:42 +02:00
|
|
|
|
|
|
|
pcupsFreeOptions( num_options, options );
|
|
|
|
|
2008-12-03 19:24:50 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, unix_doc_title);
|
2005-07-11 15:21:48 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, queue);
|
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return schedule_lpr(printer_name, filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 15:26:19 +01:00
|
|
|
static INT_PTR CALLBACK file_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
2005-07-12 19:01:44 +02:00
|
|
|
{
|
|
|
|
LPWSTR filename;
|
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if(HIWORD(wparam) == BN_CLICKED)
|
|
|
|
{
|
|
|
|
if(LOWORD(wparam) == IDOK)
|
|
|
|
{
|
|
|
|
HANDLE hf;
|
2005-07-22 20:28:12 +02:00
|
|
|
DWORD len = SendDlgItemMessageW(hwnd, EDITBOX, WM_GETTEXTLENGTH, 0, 0);
|
2005-07-12 19:01:44 +02:00
|
|
|
LPWSTR *output;
|
|
|
|
|
|
|
|
filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
|
|
|
GetDlgItemTextW(hwnd, EDITBOX, filename, len + 1);
|
2005-07-22 20:28:12 +02:00
|
|
|
|
2005-07-12 19:01:44 +02:00
|
|
|
if(GetFileAttributesW(filename) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
WCHAR caption[200], message[200];
|
|
|
|
int mb_ret;
|
|
|
|
|
|
|
|
LoadStringW(WINSPOOL_hInstance, IDS_CAPTION, caption, sizeof(caption) / sizeof(WCHAR));
|
|
|
|
LoadStringW(WINSPOOL_hInstance, IDS_FILE_EXISTS, message, sizeof(message) / sizeof(WCHAR));
|
|
|
|
mb_ret = MessageBoxW(hwnd, message, caption, MB_OKCANCEL | MB_ICONEXCLAMATION);
|
|
|
|
if(mb_ret == IDCANCEL)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, filename);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hf = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if(hf == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
WCHAR caption[200], message[200];
|
|
|
|
|
|
|
|
LoadStringW(WINSPOOL_hInstance, IDS_CAPTION, caption, sizeof(caption) / sizeof(WCHAR));
|
|
|
|
LoadStringW(WINSPOOL_hInstance, IDS_CANNOT_OPEN, message, sizeof(message) / sizeof(WCHAR));
|
|
|
|
MessageBoxW(hwnd, message, caption, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
HeapFree(GetProcessHeap(), 0, filename);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
CloseHandle(hf);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
output = (LPWSTR *)GetWindowLongPtrW(hwnd, DWLP_USER);
|
|
|
|
*output = filename;
|
|
|
|
EndDialog(hwnd, IDOK);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if(LOWORD(wparam) == IDCANCEL)
|
|
|
|
{
|
|
|
|
EndDialog(hwnd, IDCANCEL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-07-22 20:28:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* get_filename
|
|
|
|
*/
|
|
|
|
static BOOL get_filename(LPWSTR *filename)
|
|
|
|
{
|
|
|
|
return DialogBoxParamW(WINSPOOL_hInstance, MAKEINTRESOURCEW(FILENAME_DIALOG), GetForegroundWindow(),
|
|
|
|
file_dlg_proc, (LPARAM)filename) == IDOK;
|
|
|
|
}
|
|
|
|
|
2005-07-12 19:01:44 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* schedule_file
|
|
|
|
*/
|
|
|
|
static BOOL schedule_file(LPCWSTR filename)
|
|
|
|
{
|
|
|
|
LPWSTR output = NULL;
|
|
|
|
|
2005-07-22 20:28:12 +02:00
|
|
|
if(get_filename(&output))
|
2005-07-12 19:01:44 +02:00
|
|
|
{
|
2008-09-27 22:16:26 +02:00
|
|
|
BOOL r;
|
2005-07-12 19:01:44 +02:00
|
|
|
TRACE("copy to %s\n", debugstr_w(output));
|
2008-09-27 22:16:26 +02:00
|
|
|
r = CopyFileW(filename, output, FALSE);
|
2005-07-12 19:01:44 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, output);
|
2008-09-27 22:16:26 +02:00
|
|
|
return r;
|
2005-07-12 19:01:44 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-07-20 19:48:53 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* schedule_unixfile
|
|
|
|
*/
|
|
|
|
static BOOL schedule_unixfile(LPCWSTR output, LPCWSTR filename)
|
|
|
|
{
|
|
|
|
int in_fd, out_fd, no_read;
|
|
|
|
char buf[1024];
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
char *unixname, *outputA;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if(!(unixname = wine_get_unix_file_name(filename)))
|
|
|
|
return FALSE;
|
|
|
|
|
2008-12-03 19:24:50 +01:00
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, output, -1, NULL, 0, NULL, NULL);
|
2005-07-20 19:48:53 +02:00
|
|
|
outputA = HeapAlloc(GetProcessHeap(), 0, len);
|
2008-12-03 19:24:50 +01:00
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, output, -1, outputA, len, NULL, NULL);
|
2005-07-20 19:48:53 +02:00
|
|
|
|
|
|
|
out_fd = open(outputA, O_CREAT | O_TRUNC | O_WRONLY, 0666);
|
|
|
|
in_fd = open(unixname, O_RDONLY);
|
|
|
|
if(out_fd == -1 || in_fd == -1)
|
|
|
|
goto end;
|
|
|
|
|
2006-04-08 19:17:06 +02:00
|
|
|
while((no_read = read(in_fd, buf, sizeof(buf))) > 0)
|
2005-07-20 19:48:53 +02:00
|
|
|
write(out_fd, buf, no_read);
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
end:
|
|
|
|
if(in_fd != -1) close(in_fd);
|
|
|
|
if(out_fd != -1) close(out_fd);
|
|
|
|
HeapFree(GetProcessHeap(), 0, outputA);
|
|
|
|
HeapFree(GetProcessHeap(), 0, unixname);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* ScheduleJob [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
|
|
|
|
{
|
2005-07-06 17:44:15 +02:00
|
|
|
opened_printer_t *printer;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
struct list *cursor, *cursor2;
|
|
|
|
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("(%p, %x)\n", hPrinter, dwJobID);
|
2005-07-06 17:44:15 +02:00
|
|
|
EnterCriticalSection(&printer_handles_cs);
|
|
|
|
printer = get_opened_printer(hPrinter);
|
|
|
|
if(!printer)
|
|
|
|
goto end;
|
|
|
|
|
2005-07-19 21:12:13 +02:00
|
|
|
LIST_FOR_EACH_SAFE(cursor, cursor2, &printer->queue->jobs)
|
2005-07-06 17:44:15 +02:00
|
|
|
{
|
|
|
|
job_t *job = LIST_ENTRY(cursor, job_t, entry);
|
|
|
|
HANDLE hf;
|
|
|
|
|
|
|
|
if(job->job_id != dwJobID) continue;
|
|
|
|
|
|
|
|
hf = CreateFileW(job->filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
|
|
|
if(hf != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2010-08-12 14:37:36 +02:00
|
|
|
PRINTER_INFO_5W *pi5 = NULL;
|
|
|
|
LPWSTR portname = job->portname;
|
2005-07-10 19:39:01 +02:00
|
|
|
DWORD needed;
|
2005-07-20 19:48:53 +02:00
|
|
|
HKEY hkey;
|
|
|
|
WCHAR output[1024];
|
|
|
|
static const WCHAR spooler_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
|
|
|
|
'P','r','i','n','t','i','n','g','\\','S','p','o','o','l','e','r',0};
|
2005-07-10 19:39:01 +02:00
|
|
|
|
2010-08-12 14:37:36 +02:00
|
|
|
if (!portname)
|
|
|
|
{
|
|
|
|
GetPrinterW(hPrinter, 5, NULL, 0, &needed);
|
|
|
|
pi5 = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
GetPrinterW(hPrinter, 5, (LPBYTE)pi5, needed, &needed);
|
|
|
|
portname = pi5->pPortName;
|
|
|
|
}
|
2006-10-13 11:51:23 +02:00
|
|
|
TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename),
|
2010-08-12 14:37:36 +02:00
|
|
|
debugstr_w(portname));
|
2005-07-10 19:39:01 +02:00
|
|
|
|
2005-07-20 19:48:53 +02:00
|
|
|
output[0] = 0;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Printing\Spooler */
|
|
|
|
if(RegOpenKeyW(HKEY_CURRENT_USER, spooler_key, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
DWORD type, count = sizeof(output);
|
2010-08-12 14:37:36 +02:00
|
|
|
RegQueryValueExW(hkey, portname, NULL, &type, (LPBYTE)output, &count);
|
2005-07-20 19:48:53 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
if(output[0] == '|')
|
|
|
|
{
|
2008-09-27 22:16:26 +02:00
|
|
|
ret = schedule_pipe(output + 1, job->filename);
|
2005-07-20 19:48:53 +02:00
|
|
|
}
|
|
|
|
else if(output[0])
|
|
|
|
{
|
2008-09-27 22:16:26 +02:00
|
|
|
ret = schedule_unixfile(output, job->filename);
|
2005-07-20 19:48:53 +02:00
|
|
|
}
|
2010-08-12 14:37:36 +02:00
|
|
|
else if(!strncmpW(portname, LPR_Port, strlenW(LPR_Port)))
|
2005-07-10 19:39:01 +02:00
|
|
|
{
|
2010-08-12 14:37:36 +02:00
|
|
|
ret = schedule_lpr(portname + strlenW(LPR_Port), job->filename);
|
2005-07-10 19:39:01 +02:00
|
|
|
}
|
2010-08-12 14:37:36 +02:00
|
|
|
else if(!strncmpW(portname, CUPS_Port, strlenW(CUPS_Port)))
|
2005-07-11 15:21:48 +02:00
|
|
|
{
|
2010-08-12 14:37:36 +02:00
|
|
|
ret = schedule_cups(portname + strlenW(CUPS_Port), job->filename, job->document_title);
|
2005-07-11 15:21:48 +02:00
|
|
|
}
|
2010-08-12 14:37:36 +02:00
|
|
|
else if(!strncmpW(portname, FILE_Port, strlenW(FILE_Port)))
|
2005-07-12 19:01:44 +02:00
|
|
|
{
|
2008-09-27 22:16:26 +02:00
|
|
|
ret = schedule_file(job->filename);
|
2005-07-12 19:01:44 +02:00
|
|
|
}
|
2015-08-26 00:44:18 +02:00
|
|
|
else if(isalpha(portname[0]) && portname[1] == ':')
|
|
|
|
{
|
|
|
|
TRACE("copying to %s\n", debugstr_w(portname));
|
|
|
|
ret = CopyFileW(job->filename, portname, FALSE);
|
|
|
|
}
|
2005-07-10 19:39:01 +02:00
|
|
|
else
|
|
|
|
{
|
2010-08-12 14:37:36 +02:00
|
|
|
FIXME("can't schedule to port %s\n", debugstr_w(portname));
|
2005-07-10 19:39:01 +02:00
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi5);
|
2005-07-06 17:44:15 +02:00
|
|
|
CloseHandle(hf);
|
|
|
|
DeleteFileW(job->filename);
|
|
|
|
}
|
|
|
|
list_remove(cursor);
|
2005-07-13 16:14:37 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->document_title);
|
2010-09-13 17:28:56 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->printer_name);
|
2010-08-12 14:37:36 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->portname);
|
2005-07-06 17:44:15 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->filename);
|
2010-09-20 16:26:49 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job->devmode);
|
2005-07-06 17:44:15 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, job);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
end:
|
|
|
|
LeaveCriticalSection(&printer_handles_cs);
|
|
|
|
return ret;
|
Stub implementations for AbortPrinter, AddPortEx{A,W},
AddPrinterConnection{A,W}, ConnectToPrinterDlg,
DeletePrinterConnection{A,W}, EnumForms{A,W}, EnumPrinterData{A,W],
ExtDeviceMode, Find{Close,First,Next}PrinterChangeNotification,
FreePrinterNotifyInfo, ScheduleJob.
2005-02-21 19:33:55 +01:00
|
|
|
}
|
2005-07-22 20:28:12 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* StartDocDlgA [WINSPOOL.@]
|
|
|
|
*/
|
2006-10-06 14:25:54 +02:00
|
|
|
LPSTR WINAPI StartDocDlgA( HANDLE hPrinter, DOCINFOA *doc )
|
2005-07-22 20:28:12 +02:00
|
|
|
{
|
|
|
|
UNICODE_STRING usBuffer;
|
|
|
|
DOCINFOW docW;
|
|
|
|
LPWSTR retW;
|
2006-10-06 14:25:54 +02:00
|
|
|
LPWSTR docnameW = NULL, outputW = NULL, datatypeW = NULL;
|
2005-07-22 20:28:12 +02:00
|
|
|
LPSTR ret = NULL;
|
|
|
|
|
|
|
|
docW.cbSize = sizeof(docW);
|
2006-10-06 14:25:54 +02:00
|
|
|
if (doc->lpszDocName)
|
|
|
|
{
|
|
|
|
docnameW = asciitounicode(&usBuffer, doc->lpszDocName);
|
|
|
|
if (!(docW.lpszDocName = docnameW)) return NULL;
|
|
|
|
}
|
|
|
|
if (doc->lpszOutput)
|
|
|
|
{
|
|
|
|
outputW = asciitounicode(&usBuffer, doc->lpszOutput);
|
|
|
|
if (!(docW.lpszOutput = outputW)) return NULL;
|
|
|
|
}
|
|
|
|
if (doc->lpszDatatype)
|
|
|
|
{
|
|
|
|
datatypeW = asciitounicode(&usBuffer, doc->lpszDatatype);
|
|
|
|
if (!(docW.lpszDatatype = datatypeW)) return NULL;
|
|
|
|
}
|
2005-07-22 20:28:12 +02:00
|
|
|
docW.fwType = doc->fwType;
|
|
|
|
|
|
|
|
retW = StartDocDlgW(hPrinter, &docW);
|
|
|
|
|
|
|
|
if(retW)
|
|
|
|
{
|
|
|
|
DWORD len = WideCharToMultiByte(CP_ACP, 0, retW, -1, NULL, 0, NULL, NULL);
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, retW, -1, ret, len, NULL, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, retW);
|
|
|
|
}
|
|
|
|
|
2006-10-06 14:25:54 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, datatypeW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, outputW);
|
|
|
|
HeapFree(GetProcessHeap(), 0, docnameW);
|
2005-07-22 20:28:12 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* StartDocDlgW [WINSPOOL.@]
|
|
|
|
*
|
|
|
|
* Undocumented: Apparently used by gdi32:StartDocW() to popup the file dialog
|
|
|
|
* when lpszOutput is "FILE:" or if lpszOutput is NULL and the default printer
|
|
|
|
* port is "FILE:". Also returns the full path if passed a relative path.
|
|
|
|
*
|
|
|
|
* The caller should free the returned string from the process heap.
|
|
|
|
*/
|
|
|
|
LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
|
|
|
|
{
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
DWORD len, attr;
|
|
|
|
|
|
|
|
if(doc->lpszOutput == NULL) /* Check whether default port is FILE: */
|
|
|
|
{
|
|
|
|
PRINTER_INFO_5W *pi5;
|
|
|
|
GetPrinterW(hPrinter, 5, NULL, 0, &len);
|
|
|
|
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
return NULL;
|
|
|
|
pi5 = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
GetPrinterW(hPrinter, 5, (LPBYTE)pi5, len, &len);
|
|
|
|
if(!pi5->pPortName || strcmpW(pi5->pPortName, FILE_Port))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi5);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, pi5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doc->lpszOutput == NULL || !strcmpW(doc->lpszOutput, FILE_Port))
|
|
|
|
{
|
|
|
|
LPWSTR name;
|
2007-01-11 10:19:58 +01:00
|
|
|
|
|
|
|
if (get_filename(&name))
|
2005-07-22 20:28:12 +02:00
|
|
|
{
|
|
|
|
if(!(len = GetFullPathNameW(name, 0, NULL, NULL)))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
GetFullPathNameW(name, len, ret, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, name);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(len = GetFullPathNameW(doc->lpszOutput, 0, NULL, NULL)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
GetFullPathNameW(doc->lpszOutput, len, ret, NULL);
|
|
|
|
|
|
|
|
attr = GetFileAttributesW(ret);
|
|
|
|
if(attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ret);
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2014-02-27 13:26:25 +01:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* UploadPrinterDriverPackageA [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI UploadPrinterDriverPackageA( LPCSTR server, LPCSTR path, LPCSTR env,
|
|
|
|
DWORD flags, HWND hwnd, LPSTR dst, PULONG dstlen )
|
|
|
|
{
|
|
|
|
FIXME("%s, %s, %s, %x, %p, %p, %p\n", debugstr_a(server), debugstr_a(path), debugstr_a(env),
|
|
|
|
flags, hwnd, dst, dstlen);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* UploadPrinterDriverPackageW [WINSPOOL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI UploadPrinterDriverPackageW( LPCWSTR server, LPCWSTR path, LPCWSTR env,
|
|
|
|
DWORD flags, HWND hwnd, LPWSTR dst, PULONG dstlen )
|
|
|
|
{
|
|
|
|
FIXME("%s, %s, %s, %x, %p, %p, %p\n", debugstr_w(server), debugstr_w(path), debugstr_w(env),
|
|
|
|
flags, hwnd, dst, dstlen);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|