winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
October 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1165 discussions
Start a n
N
ew thread
Nikolay Sivov : evr/presenter: Remove scaling by zoom rectangle.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: a1c057c9a75cbb7251648352748983f09390bb57 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a1c057c9a75cbb7251648352…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Tue Oct 26 19:58:30 2021 +0300 evr/presenter: Remove scaling by zoom rectangle. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/evr/presenter.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c index bf0f89df0eb..b8b18638185 100644 --- a/dlls/evr/presenter.c +++ b/dlls/evr/presenter.c @@ -460,21 +460,6 @@ static HRESULT video_presenter_get_sample_surface(IMFSample *sample, IDirect3DSu return hr; } -static void scale_rect(RECT *rect, unsigned int width, unsigned int height, const MFVideoNormalizedRect *scale) -{ - if (rect->left == 0.0f && rect->top == 0.0f && rect->right == 1.0f && rect->bottom == 1.0f) - { - SetRect(rect, 0, 0, width, height); - } - else - { - rect->left = width * scale->left; - rect->right = width * scale->right; - rect->top = height * scale->top; - rect->bottom = height * scale->bottom; - } -} - static void video_presenter_sample_present(struct video_presenter *presenter, IMFSample *sample) { IDirect3DSurface9 *surface, *backbuffer; @@ -503,7 +488,7 @@ static void video_presenter_sample_present(struct video_presenter *presenter, IM IDirect3DDevice9_StretchRect(device, surface, NULL, backbuffer, NULL, D3DTEXF_POINT); IDirect3DSurface9_GetDesc(surface, &desc); - scale_rect(&src, desc.Width, desc.Height, &presenter->src_rect); + SetRect(&src, 0, 0, desc.Width, desc.Height); IDirect3DSurface9_GetDesc(backbuffer, &desc); SetRect(&dst, 0, 0, desc.Width, desc.Height);
1
0
0
0
Piotr Caban : vcomp: Add _vcomp_for_static_simple_init_i8 implementation.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: c2297eb4f32570bea721b808a2400aef13c6f2f8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c2297eb4f32570bea721b808…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Oct 26 18:55:44 2021 +0200 vcomp: Add _vcomp_for_static_simple_init_i8 implementation. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=43546
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=48377
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vcomp/main.c | 52 +++++++++++++++ dlls/vcomp/tests/vcomp.c | 154 ++++++++++++++++++++++++++++++++++++++++++++ dlls/vcomp/vcomp.spec | 2 +- dlls/vcomp100/vcomp100.spec | 2 +- dlls/vcomp110/vcomp110.spec | 2 +- dlls/vcomp120/vcomp120.spec | 2 +- dlls/vcomp140/vcomp140.spec | 2 +- dlls/vcomp90/vcomp90.spec | 2 +- 8 files changed, 212 insertions(+), 6 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=c2297eb4f32570bea721…
1
0
0
0
Piotr Caban : vcomp: Add _vcomp_for_static_init_i8 implementation.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 750ef2a5fbf06b7d6ec2d3ac3585f9e2decddd45 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=750ef2a5fbf06b7d6ec2d3ac…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Oct 26 18:55:08 2021 +0200 vcomp: Add _vcomp_for_static_init_i8 implementation. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/vcomp/main.c | 73 +++++++++++++ dlls/vcomp/tests/vcomp.c | 254 ++++++++++++++++++++++++++++++++++++++++++++ dlls/vcomp/vcomp.spec | 2 +- dlls/vcomp100/vcomp100.spec | 2 +- dlls/vcomp110/vcomp110.spec | 2 +- dlls/vcomp120/vcomp120.spec | 2 +- dlls/vcomp140/vcomp140.spec | 2 +- dlls/vcomp90/vcomp90.spec | 2 +- 8 files changed, 333 insertions(+), 6 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=750ef2a5fbf06b7d6ec2…
1
0
0
0
Huw Davies : winspool: Move the default page size query to cups.c.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: a75c1aa78e23c5cd1b05c16f7d47cdf4cf8f5644 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a75c1aa78e23c5cd1b05c16f…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:12 2021 +0100 winspool: Move the default page size query to cups.c. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/cups.c | 97 ++++++++++++++++++++++++++++++++++++++++ dlls/winspool.drv/info.c | 108 ++++++--------------------------------------- dlls/winspool.drv/wspool.h | 7 +++ 3 files changed, 117 insertions(+), 95 deletions(-) diff --git a/dlls/winspool.drv/cups.c b/dlls/winspool.drv/cups.c index 2ce5f43fa8f..ae771eba46c 100644 --- a/dlls/winspool.drv/cups.c +++ b/dlls/winspool.drv/cups.c @@ -32,6 +32,62 @@ #include <cups/ppd.h> #endif +#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 +#endif + #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" @@ -341,3 +397,44 @@ NTSTATUS unix_get_ppd( void *args ) free( unix_ppd ); return status; } + +NTSTATUS unix_get_default_page_size( void *args ) +{ +#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H + struct get_default_page_size_params *params = args; + NTSTATUS status = STATUS_UNSUCCESSFUL; + PMPrintSession session = NULL; + PMPageFormat format = NULL; + CFStringRef paper_name; + PMPaper paper; + CFRange range; + int size; + + if (PMCreateSession( &session )) goto end; + if (PMCreatePageFormat( &format )) goto end; + if (PMSessionDefaultPageFormat( session, format )) goto end; + if (PMGetPageFormatPaper( format, &paper )) goto end; + if (PMPaperGetPPDPaperName( paper, &paper_name )) goto end; + + range.location = 0; + range.length = CFStringGetLength( paper_name ); + size = (range.length + 1) * sizeof(WCHAR); + + if (params->name_size >= size) + { + CFStringGetCharacters( paper_name, range, (UniChar*)params->name ); + params->name[range.length] = 0; + status = STATUS_SUCCESS; + } + else + status = STATUS_BUFFER_OVERFLOW; + params->name_size = size; + +end: + if (format) PMRelease( format ); + if (session) PMRelease( session ); + return status; +#else + return STATUS_NOT_IMPLEMENTED; +#endif +} diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index 5deab0083d3..a8b0a0365ae 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -48,62 +48,6 @@ # include <cups/ppd.h> #endif -#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 -#endif - #define NONAMELESSSTRUCT #define NONAMELESSUNION @@ -987,46 +931,20 @@ end: 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 + WCHAR buffer[256]; + struct get_default_page_size_params params = { .name = buffer, .name_size = sizeof(buffer) }; + NTSTATUS status; - SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)wstr, size ); - HeapFree( GetProcessHeap(), 0, wstr ); + while (1) + { + status = UNIX_CALL( get_default_page_size, ¶ms ); + if (status != STATUS_BUFFER_OVERFLOW) break; + if (params.name != buffer) heap_free( params.name ); + params.name = heap_alloc( params.name_size ); + if (!params.name) break; + } + if (!status) SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)params.name, params.name_size ); + if (params.name != buffer) heap_free( params.name ); } static BOOL update_driver( HANDLE printer ) diff --git a/dlls/winspool.drv/wspool.h b/dlls/winspool.drv/wspool.h index e66e08bfee0..578ed39733d 100644 --- a/dlls/winspool.drv/wspool.h +++ b/dlls/winspool.drv/wspool.h @@ -52,6 +52,12 @@ struct enum_printers_params unsigned int num; }; +struct get_default_page_size_params +{ + WCHAR *name; + unsigned int name_size; +}; + struct get_ppd_params { const WCHAR *printer; /* set to NULL to unlink */ @@ -62,4 +68,5 @@ struct get_ppd_params NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN; NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN; +NTSTATUS unix_get_default_page_size( void * ) DECLSPEC_HIDDEN; NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
1
0
0
0
Huw Davies : winspool: Move ppd retrieval to cups.c.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: f519535879a7a28956f4e0ed17b238ca7e20db3e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f519535879a7a28956f4e0ed…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:11 2021 +0100 winspool: Move ppd retrieval to cups.c. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/cups.c | 125 +++++++++++++++++++++++++++++++++++++++++++++ dlls/winspool.drv/info.c | 107 ++++---------------------------------- dlls/winspool.drv/wspool.h | 7 +++ 3 files changed, 142 insertions(+), 97 deletions(-) diff --git a/dlls/winspool.drv/cups.c b/dlls/winspool.drv/cups.c index 7aeb68d4f8d..2ce5f43fa8f 100644 --- a/dlls/winspool.drv/cups.c +++ b/dlls/winspool.drv/cups.c @@ -22,6 +22,9 @@ #include <stdarg.h> #include <string.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> #ifdef HAVE_CUPS_CUPS_H #include <cups/cups.h> #endif @@ -56,6 +59,11 @@ static DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD d { return MultiByteToWideChar( CP_UNIXCP, 0, src, srclen, dst, dstlen ); } +static int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) +{ + /* FIXME: strict */ + return WideCharToMultiByte( CP_UNIXCP, 0, src, srclen, dst, dstlen, NULL, NULL ); +} #ifdef SONAME_LIBCUPS @@ -111,6 +119,56 @@ NTSTATUS unix_process_attach( void *arg ) #endif /* SONAME_LIBCUPS */ } +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; +} + +static char *get_unix_file_name( LPCWSTR path ) +{ + UNICODE_STRING nt_name; + OBJECT_ATTRIBUTES attr; + NTSTATUS status; + ULONG size = 256; + char *buffer; + + nt_name.Buffer = (WCHAR *)path; + nt_name.MaximumLength = nt_name.Length = lstrlenW( path ) * sizeof(WCHAR); + InitializeObjectAttributes( &attr, &nt_name, 0, 0, NULL ); + for (;;) + { + if (!(buffer = malloc( size ))) return NULL; + status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN_IF ); + if (status != STATUS_BUFFER_TOO_SMALL) break; + free( buffer ); + } + if (status && status != STATUS_NO_SUCH_FILE) + { + free( buffer ); + return NULL; + } + return buffer; +} + + #ifdef SONAME_LIBCUPS static WCHAR *cups_get_optionW( const char *opt_name, int num_options, cups_option_t *options ) { @@ -145,6 +203,32 @@ static BOOL cups_is_scanner( cups_dest_t *dest ) { return cups_get_printer_type( dest ) & 0x2000000 /* CUPS_PRINTER_SCANNER */; } + +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 ); + if (!pcupsGetPPD) return HTTP_NOT_FOUND; + + 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; +} #endif /* SONAME_LIBCUPS */ NTSTATUS unix_enum_printers( void *args ) @@ -216,3 +300,44 @@ NTSTATUS unix_enum_printers( void *args ) return STATUS_NOT_SUPPORTED; #endif /* SONAME_LIBCUPS */ } + +NTSTATUS unix_get_ppd( void *args ) +{ + struct get_ppd_params *params = args; + char *unix_ppd = get_unix_file_name( params->ppd ); + NTSTATUS status = STATUS_SUCCESS; + + TRACE( "(%s, %s)\n", debugstr_w( params->printer ), debugstr_w( params->ppd ) ); + + if (!unix_ppd) return STATUS_NO_SUCH_FILE; + + if (!params->printer) /* unlink */ + { + unlink( unix_ppd ); + } + else + { +#ifdef SONAME_LIBCUPS + http_status_t http_status; + time_t modtime = 0; + char *printer_name; + int len; + + len = strlenW( params->printer ); + printer_name = malloc( len * 3 + 1 ); + ntdll_wcstoumbs( params->printer, len + 1, printer_name, len * 3 + 1, FALSE ); + + http_status = cupsGetPPD3_wrapper( 0, printer_name, &modtime, unix_ppd, strlen( unix_ppd ) + 1 ); + if (http_status != HTTP_OK) + { + unlink( unix_ppd ); + status = STATUS_DEVICE_UNREACHABLE; + } + free( printer_name ); +#else + status = STATUS_NOT_SUPPORTED; +#endif + } + free( unix_ppd ); + return status; +} diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index a3fcb32641a..5deab0083d3 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -752,29 +752,6 @@ static DWORD WINSPOOL_GetOpenedPrinterRegKey(HANDLE hPrinter, HKEY *phkey) return open_printer_reg_key( name, phkey ); } -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; -} - static BOOL get_internal_fallback_ppd( const WCHAR *ppd ) { static const WCHAR typeW[] = {'P','P','D','F','I','L','E',0}; @@ -817,31 +794,22 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name ) return ppd; } -static char *get_dest_name( const WCHAR *printer ) -{ - int len = WideCharToMultiByte( CP_UNIXCP, 0, printer, -1, NULL, 0, NULL, NULL ); - char *dest = heap_alloc( len ); - - if (dest) WideCharToMultiByte( CP_UNIXCP, 0, printer, -1, dest, len, NULL, NULL ); - return dest; -} - -static BOOL get_cups_ppd( const char *printer_name, const WCHAR *ppd ); -static void unlink_ppd( const WCHAR *ppd ); - static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir ) { WCHAR *ppd = get_ppd_filename( ppd_dir, name ); - char *dest_name; + struct get_ppd_params ppd_params; + UNICODE_STRING nt_ppd; DRIVER_INFO_3W di3; unsigned int i; BOOL res = FALSE; if (!ppd) return FALSE; - dest_name = get_dest_name( name ); - if (!dest_name) goto end; + RtlInitUnicodeString( &nt_ppd, NULL ); + if (!RtlDosPathNameToNtPathName_U( ppd, &nt_ppd, NULL, NULL )) goto end; - res = get_cups_ppd( dest_name, ppd ) || get_internal_fallback_ppd( ppd ); + ppd_params.printer = name; + ppd_params.ppd = nt_ppd.Buffer; + res = !UNIX_CALL( get_ppd, &ppd_params ) || get_internal_fallback_ppd( ppd ); if (!res) goto end; memset( &di3, 0, sizeof(DRIVER_INFO_3W) ); @@ -872,10 +840,11 @@ static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir ) } res = TRUE; } - unlink_ppd( ppd ); + ppd_params.printer = NULL; /* unlink the ppd */ + UNIX_CALL( get_ppd, &ppd_params ); end: - heap_free( dest_name ); + RtlFreeUnicodeString( &nt_ppd ); heap_free( ppd ); return res; } @@ -904,13 +873,6 @@ static WCHAR *get_ppd_dir( void ) 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 ); -} - #ifdef SONAME_LIBCUPS extern void *libcups_handle; @@ -932,56 +894,7 @@ extern void *libcups_handle; CUPS_FUNCS; #undef DO_FUNC extern cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *); -extern const char * (*pcupsGetPPD)(const char *); -extern http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t); extern const char * (*pcupsLastErrorString)(void); - -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 ); - - if (!pcupsGetPPD) return HTTP_NOT_FOUND; - - 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 ); - - if (http_status != HTTP_OK) unlink( unix_name ); - HeapFree( GetProcessHeap(), 0, unix_name ); - - return http_status == HTTP_OK; -} #endif static BOOL init_unix_printers( void ) diff --git a/dlls/winspool.drv/wspool.h b/dlls/winspool.drv/wspool.h index 5a1f1038995..e66e08bfee0 100644 --- a/dlls/winspool.drv/wspool.h +++ b/dlls/winspool.drv/wspool.h @@ -52,7 +52,14 @@ struct enum_printers_params unsigned int num; }; +struct get_ppd_params +{ + const WCHAR *printer; /* set to NULL to unlink */ + const WCHAR *ppd; +}; + #define UNIX_CALL( func, params ) unix_ ## func( params ) NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN; NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN; +NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
1
0
0
0
Huw Davies : winspool: Move CUPS printer enumeration to cups.c.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 5a163d55373d7c6cf1aa8ce3fe44c55c0dbe7d22 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5a163d55373d7c6cf1aa8ce3…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:10 2021 +0100 winspool: Move CUPS printer enumeration to cups.c. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/cups.c | 117 +++++++++++++++++++++++++++++++++++ dlls/winspool.drv/info.c | 148 ++++++++++++++++----------------------------- dlls/winspool.drv/wspool.h | 16 +++++ 3 files changed, 185 insertions(+), 96 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=5a163d55373d7c6cf1aa…
1
0
0
0
Huw Davies : winspool: Call the ppd retrieval function from add_printer_driver().
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 9d8bf3bf9678cbcd20e26c6ae94dd1d0af2c054f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9d8bf3bf9678cbcd20e26c6a…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:09 2021 +0100 winspool: Call the ppd retrieval function from add_printer_driver(). Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/info.c | 197 ++++++++++++++++++----------------------------- 1 file changed, 77 insertions(+), 120 deletions(-) diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index badde6ea5ae..9d2af8cec94 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -750,43 +750,6 @@ static DWORD WINSPOOL_GetOpenedPrinterRegKey(HANDLE hPrinter, HKEY *phkey) return open_printer_reg_key( name, phkey ); } -static BOOL add_printer_driver(const WCHAR *name, WCHAR *ppd) -{ - DRIVER_INFO_3W di3; - unsigned int i; - BOOL res; - - ZeroMemory(&di3, sizeof(DRIVER_INFO_3W)); - di3.cVersion = 3; - di3.pName = (WCHAR*)name; - di3.pDriverPath = driver_nt; - di3.pDataFile = ppd; - di3.pConfigFile = driver_nt; - di3.pDefaultDataType = rawW; - - for (i = 0; i < ARRAY_SIZE(all_printenv); i++) - { - di3.pEnvironment = (WCHAR *) all_printenv[i]->envname; - if (all_printenv[i]->envname == envname_win40W) - { - /* We use wineps16.drv as driver for 16 bit */ - di3.pDriverPath = driver_9x; - di3.pConfigFile = driver_9x; - } - res = AddPrinterDriverExW( NULL, 3, (LPBYTE)&di3, APD_COPY_NEW_FILES | APD_COPY_FROM_DIRECTORY ); - TRACE("got %d and %d for %s (%s)\n", res, GetLastError(), debugstr_w(name), debugstr_w(di3.pEnvironment)); - - if (!res && (GetLastError() != ERROR_PRINTER_DRIVER_ALREADY_INSTALLED)) - { - ERR("failed with %u for %s (%s) %s\n", GetLastError(), debugstr_w(name), - debugstr_w(di3.pEnvironment), debugstr_w(di3.pDriverPath)); - return FALSE; - } - } - - return TRUE; -} - static BOOL copy_file( const char *src, const char *dst ) { int fds[2] = {-1, -1}, num; @@ -852,6 +815,69 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name ) return ppd; } +static char *get_dest_name( const WCHAR *printer ) +{ + int len = WideCharToMultiByte( CP_UNIXCP, 0, printer, -1, NULL, 0, NULL, NULL ); + char *dest = heap_alloc( len ); + + if (dest) WideCharToMultiByte( CP_UNIXCP, 0, printer, -1, dest, len, NULL, NULL ); + return dest; +} + +static BOOL get_cups_ppd( const char *printer_name, const WCHAR *ppd ); +static void unlink_ppd( const WCHAR *ppd ); + +static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir ) +{ + WCHAR *ppd = get_ppd_filename( ppd_dir, name ); + char *dest_name; + DRIVER_INFO_3W di3; + unsigned int i; + BOOL res = FALSE; + + if (!ppd) return FALSE; + dest_name = get_dest_name( name ); + if (!dest_name) goto end; + + res = get_cups_ppd( dest_name, ppd ) || get_internal_fallback_ppd( ppd ); + if (!res) goto end; + + memset( &di3, 0, sizeof(DRIVER_INFO_3W) ); + di3.cVersion = 3; + di3.pName = (WCHAR *)name; + di3.pDriverPath = driver_nt; + di3.pDataFile = ppd; + di3.pConfigFile = driver_nt; + di3.pDefaultDataType = rawW; + + for (i = 0; i < ARRAY_SIZE(all_printenv); i++) + { + di3.pEnvironment = (WCHAR *)all_printenv[i]->envname; + if (all_printenv[i]->envname == envname_win40W) + { + /* We use wineps16.drv as driver for 16 bit */ + di3.pDriverPath = driver_9x; + di3.pConfigFile = driver_9x; + } + res = AddPrinterDriverExW( NULL, 3, (BYTE *)&di3, APD_COPY_NEW_FILES | APD_COPY_FROM_DIRECTORY ); + TRACE( "got %d and %d for %s (%s)\n", res, GetLastError(), debugstr_w( name ), debugstr_w( di3.pEnvironment ) ); + + if (!res && (GetLastError() != ERROR_PRINTER_DRIVER_ALREADY_INSTALLED)) + { + ERR( "failed with %u for %s (%s) %s\n", GetLastError(), debugstr_w( name ), + debugstr_w( di3.pEnvironment ), debugstr_w( di3.pDriverPath ) ); + break; + } + res = TRUE; + } + unlink_ppd( ppd ); + +end: + heap_free( dest_name ); + heap_free( ppd ); + return res; +} + static WCHAR *get_ppd_dir( void ) { static const WCHAR wine_ppds[] = {'w','i','n','e','_','p','p','d','s','\\',0}; @@ -953,11 +979,7 @@ static BOOL get_cups_ppd( const char *printer_name, const WCHAR *ppd ) if (http_status != HTTP_OK) unlink( unix_name ); HeapFree( GetProcessHeap(), 0, unix_name ); - if (http_status == HTTP_OK) return TRUE; - - TRACE( "failed to get ppd for printer %s from cups (status %d), calling fallback\n", - debugstr_a(printer_name), http_status ); - return get_internal_fallback_ppd( ppd ); + return http_status == HTTP_OK; } static WCHAR *get_cups_option( const char *name, int num_options, cups_option_t *options ) @@ -996,7 +1018,7 @@ static BOOL CUPS_LoadPrinters(void) BOOL hadprinter = FALSE, haddefault = FALSE; cups_dest_t *dests; PRINTER_INFO_2W pi2; - WCHAR *port, *ppd_dir = NULL, *ppd; + WCHAR *port, *ppd_dir = NULL; HKEY hkeyPrinter, hkeyPrinters; WCHAR nameW[MAX_PATH]; HANDLE added_printer; @@ -1024,7 +1046,8 @@ static BOOL CUPS_LoadPrinters(void) continue; } - if(RegOpenKeyW(hkeyPrinters, nameW, &hkeyPrinter) == ERROR_SUCCESS) { + if (RegOpenKeyW( hkeyPrinters, nameW, &hkeyPrinter ) == ERROR_SUCCESS) + { DWORD status = get_dword_from_reg( hkeyPrinter, StatusW ); /* Printer already in registry, delete the tag added in WINSPOOL_LoadSystemPrinters and continue */ @@ -1033,19 +1056,11 @@ static BOOL CUPS_LoadPrinters(void) /* flag that the PPD file should be checked for an update */ set_reg_DWORD( hkeyPrinter, StatusW, status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED ); RegCloseKey(hkeyPrinter); - } else { - BOOL added_driver = FALSE; - + } + else + { if (!ppd_dir && !(ppd_dir = get_ppd_dir())) break; - - 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 ); - if (!added_driver) continue; + if (!add_printer_driver( nameW, ppd_dir )) continue; port = heap_alloc( sizeof(CUPS_Port) + lstrlenW( nameW ) * sizeof(WCHAR) ); lstrcpyW( port, CUPS_Port ); @@ -1097,43 +1112,6 @@ static BOOL CUPS_LoadPrinters(void) #endif -static char *get_queue_name( HANDLE printer, BOOL *cups ) -{ - WCHAR *port, *name = NULL; - DWORD err, needed, type; - char *ret = NULL; - HKEY key; - - *cups = FALSE; - - err = WINSPOOL_GetOpenedPrinterRegKey( printer, &key ); - if (err) return NULL; - err = RegQueryValueExW( key, PortW, 0, &type, NULL, &needed ); - if (err) goto end; - port = HeapAlloc( GetProcessHeap(), 0, needed ); - if (!port) goto end; - RegQueryValueExW( key, PortW, 0, &type, (BYTE*)port, &needed ); - - if (!strncmpW( port, CUPS_Port, ARRAY_SIZE( CUPS_Port ) -1 )) - { - name = port + ARRAY_SIZE( CUPS_Port ) - 1; - *cups = TRUE; - } - else if (!strncmpW( port, LPR_Port, ARRAY_SIZE( LPR_Port ) -1 )) - name = port + ARRAY_SIZE( LPR_Port ) - 1; - if (name) - { - 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; -} - - static void set_ppd_overrides( HANDLE printer ) { WCHAR *wstr = NULL; @@ -1180,38 +1158,17 @@ end: static BOOL update_driver( HANDLE printer ) { - BOOL ret, is_cups; + BOOL ret; const WCHAR *name = get_opened_printer_name( printer ); - WCHAR *ppd_dir, *ppd; - char *queue_name; + WCHAR *ppd_dir; if (!name) return FALSE; - queue_name = get_queue_name( printer, &is_cups ); - if (!queue_name) return FALSE; - - if (!(ppd_dir = get_ppd_dir())) - { - HeapFree( GetProcessHeap(), 0, queue_name ); - return FALSE; - } - ppd = get_ppd_filename( ppd_dir, name ); + if (!(ppd_dir = get_ppd_dir())) return FALSE; -#ifdef SONAME_LIBCUPS - if (is_cups) - ret = get_cups_ppd( queue_name, ppd ); - else -#endif - ret = get_internal_fallback_ppd( ppd ); + TRACE( "updating driver %s\n", debugstr_w( name ) ); + ret = add_printer_driver( name, ppd_dir ); - if (ret) - { - 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 ); - HeapFree( GetProcessHeap(), 0, queue_name ); + heap_free( ppd_dir ); set_ppd_overrides( printer );
1
0
0
0
Huw Davies : winspool: Remove support for parsing /etc/printcap.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: e432c1cd307ae6fbebd352b5cb6fb0f3aafbba3b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e432c1cd307ae6fbebd352b5…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:08 2021 +0100 winspool: Remove support for parsing /etc/printcap. This is extremely obsolete and doesn't provide the location of the ppd file anyway. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/info.c | 310 ++--------------------------------------------- 1 file changed, 11 insertions(+), 299 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=e432c1cd307ae6fbebd3…
1
0
0
0
Huw Davies : winspool: Move loading of libcups to cups.c.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 4bb4d90c7022883b8e14ba7ad1c65dad27b0cd5b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4bb4d90c7022883b8e14ba7a…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 11:18:07 2021 +0100 winspool: Move loading of libcups to cups.c. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winspool.drv/Makefile.in | 1 + dlls/winspool.drv/cups.c | 101 ++++++++++++++++++++++++++++++++++++++++++ dlls/winspool.drv/info.c | 40 +++-------------- dlls/winspool.drv/wspool.c | 31 ++++++------- dlls/winspool.drv/wspool.h | 5 +++ 5 files changed, 130 insertions(+), 48 deletions(-) diff --git a/dlls/winspool.drv/Makefile.in b/dlls/winspool.drv/Makefile.in index a0d0f9504f2..d40813d649c 100644 --- a/dlls/winspool.drv/Makefile.in +++ b/dlls/winspool.drv/Makefile.in @@ -8,6 +8,7 @@ EXTRALIBS = $(APPLICATIONSERVICES_LIBS) EXTRADLLFLAGS = -mcygwin C_SRCS = \ + cups.c \ info.c \ wspool.c diff --git a/dlls/winspool.drv/cups.c b/dlls/winspool.drv/cups.c new file mode 100644 index 00000000000..207c95c568a --- /dev/null +++ b/dlls/winspool.drv/cups.c @@ -0,0 +1,101 @@ +/* + * CUPS functions + * + * Copyright 2021 Huw Davies + * + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ +#include "config.h" +#include "wine/port.h" + +#include <stdarg.h> +#include <string.h> +#ifdef HAVE_CUPS_CUPS_H +#include <cups/cups.h> +#endif +#ifdef HAVE_CUPS_PPD_H +#include <cups/ppd.h> +#endif + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "winuser.h" +#include "winerror.h" +#include "winreg.h" +#include "wingdi.h" +#include "winspool.h" +#include "ddk/winsplp.h" +#include "wine/debug.h" + +#include "wspool.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winspool); + +#ifdef SONAME_LIBCUPS + +void *libcups_handle = NULL; + +#define CUPS_FUNCS \ + DO_FUNC(cupsAddOption); \ + DO_FUNC(cupsFreeDests); \ + DO_FUNC(cupsFreeOptions); \ + DO_FUNC(cupsGetDests); \ + DO_FUNC(cupsGetOption); \ + DO_FUNC(cupsParseOptions); \ + DO_FUNC(cupsPrintFile) +#define CUPS_OPT_FUNCS \ + DO_FUNC(cupsGetNamedDest); \ + DO_FUNC(cupsGetPPD); \ + DO_FUNC(cupsGetPPD3); \ + DO_FUNC(cupsLastErrorString) + +#define DO_FUNC(f) typeof(f) *p##f = NULL +CUPS_FUNCS; +#undef DO_FUNC +cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *) = NULL; +const char * (*pcupsGetPPD)(const char *) = NULL; +http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t) = NULL; +const char * (*pcupsLastErrorString)(void) = NULL; + +#endif /* SONAME_LIBCUPS */ + +NTSTATUS unix_process_attach( void *arg ) +{ +#ifdef SONAME_LIBCUPS + libcups_handle = dlopen( SONAME_LIBCUPS, RTLD_NOW ); + TRACE( "%p: %s loaded\n", libcups_handle, SONAME_LIBCUPS ); + if (!libcups_handle) return STATUS_DLL_NOT_FOUND; + +#define DO_FUNC(x) \ + p##x = dlsym( libcups_handle, #x ); \ + if (!p##x) \ + { \ + ERR( "failed to load symbol %s\n", #x ); \ + libcups_handle = NULL; \ + return STATUS_ENTRYPOINT_NOT_FOUND; \ + } + CUPS_FUNCS; +#undef DO_FUNC +#define DO_FUNC(x) p##x = dlsym( libcups_handle, #x ) + CUPS_OPT_FUNCS; +#undef DO_FUNC + return STATUS_SUCCESS; +#else /* SONAME_LIBCUPS */ + return STATUS_NOT_SUPPORTED; +#endif /* SONAME_LIBCUPS */ +} diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index 660a5afe74d..fd02d2b2b3e 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -967,7 +967,7 @@ static void unlink_ppd( const WCHAR *ppd ) #ifdef SONAME_LIBCUPS -static void *cupshandle; +extern void *libcups_handle; #define CUPS_FUNCS \ DO_FUNC(cupsAddOption); \ @@ -983,13 +983,13 @@ static void *cupshandle; DO_FUNC(cupsGetPPD3); \ DO_FUNC(cupsLastErrorString) -#define DO_FUNC(f) static typeof(f) *p##f +#define DO_FUNC(f) extern typeof(f) *p##f CUPS_FUNCS; #undef DO_FUNC -static cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *); -static const char * (*pcupsGetPPD)(const char *); -static http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t); -static const char * (*pcupsLastErrorString)(void); +extern cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *); +extern const char * (*pcupsGetPPD)(const char *); +extern http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t); +extern const char * (*pcupsLastErrorString)(void); static http_status_t cupsGetPPD3_wrapper( http_t *http, const char *name, time_t *modtime, char *buffer, @@ -1072,28 +1072,6 @@ static cups_ptype_t get_cups_printer_type( const cups_dest_t *dest ) return ret; } -static void load_cups(void) -{ - cupshandle = dlopen( SONAME_LIBCUPS, RTLD_NOW ); - if (!cupshandle) return; - - TRACE("%p: %s loaded\n", cupshandle, SONAME_LIBCUPS); - -#define DO_FUNC(x) \ - p##x = dlsym( cupshandle, #x ); \ - 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 = dlsym( cupshandle, #x ) - CUPS_OPT_FUNCS; -#undef DO_FUNC -} - static BOOL CUPS_LoadPrinters(void) { int i, nrofdests; @@ -1106,7 +1084,7 @@ static BOOL CUPS_LoadPrinters(void) HANDLE added_printer; cups_ptype_t printer_type; - if (!cupshandle) return FALSE; + if (!libcups_handle) return FALSE; if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) != ERROR_SUCCESS) { @@ -1807,10 +1785,6 @@ void WINSPOOL_LoadSystemPrinters(void) WCHAR PrinterName[256]; BOOL done = FALSE; -#ifdef SONAME_LIBCUPS - load_cups(); -#endif - /* FIXME: The init code should be moved to spoolsv.exe */ init_mutex = CreateMutexW( NULL, TRUE, winspool_mutex_name ); if (!init_mutex) diff --git a/dlls/winspool.drv/wspool.c b/dlls/winspool.drv/wspool.c index bbfb0fb0f42..90d35bee73e 100644 --- a/dlls/winspool.drv/wspool.c +++ b/dlls/winspool.drv/wspool.c @@ -110,22 +110,23 @@ BOOL load_backend(void) * Winspool entry point. * */ -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID lpReserved) +BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) { - switch (reason) - { - case DLL_PROCESS_ATTACH: { - WINSPOOL_hInstance = hInstance; - DisableThreadLibraryCalls(hInstance); - WINSPOOL_LoadSystemPrinters(); - break; - } + switch (reason) + { + case DLL_PROCESS_ATTACH: + WINSPOOL_hInstance = instance; + DisableThreadLibraryCalls( instance ); + UNIX_CALL( process_attach, NULL ); + WINSPOOL_LoadSystemPrinters(); + break; + case DLL_PROCESS_DETACH: - if (lpReserved) break; - DeleteCriticalSection(&backend_cs); - FreeLibrary(hlocalspl); - break; - } + if (reserved) break; + DeleteCriticalSection(&backend_cs); + FreeLibrary(hlocalspl); + break; + } - return TRUE; + return TRUE; } diff --git a/dlls/winspool.drv/wspool.h b/dlls/winspool.drv/wspool.h index 06c28231330..bca4a5ea02d 100644 --- a/dlls/winspool.drv/wspool.h +++ b/dlls/winspool.drv/wspool.h @@ -21,6 +21,7 @@ #include <windef.h> #include <winuser.h> +#include <winternl.h> extern HINSTANCE WINSPOOL_hInstance DECLSPEC_HIDDEN; @@ -35,3 +36,7 @@ extern void WINSPOOL_LoadSystemPrinters(void) DECLSPEC_HIDDEN; #define FILENAME_DIALOG 100 #define EDITBOX 201 + +#define UNIX_CALL( func, params ) unix_ ## func( params ) + +NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN;
1
0
0
0
Alexandre Julliard : ntdll: Remove math functions from the unixlib interface.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 1b9ada6cabd04ccb02c4ddcc82a53e62ea477948 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1b9ada6cabd04ccb02c4ddcc…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:34:11 2021 +0200 ntdll: Remove math functions from the unixlib interface. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/Makefile.in | 2 +- dlls/ntdll/unix/loader.c | 24 ------------------------ dlls/ntdll/unixlib.h | 14 +------------- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index ba23e397545..c40e7ba8242 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -4,7 +4,7 @@ UNIXLIB = ntdll.so IMPORTLIB = ntdll IMPORTS = winecrt0 EXTRAINCL = $(UNWIND_CFLAGS) -EXTRALIBS = $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS) $(PROCSTAT_LIBS) -lm +EXTRALIBS = $(IOKIT_LIBS) $(COREFOUNDATION_LIBS) $(CORESERVICES_LIBS) $(RT_LIBS) $(PTHREAD_LIBS) $(UNWIND_LIBS) $(I386_LIBS) $(PROCSTAT_LIBS) EXTRADLLFLAGS = -nodefaultlibs -Wl,--image-base,0x7bc00000 diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 0542d2bc865..ea7f18602da 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -30,7 +30,6 @@ #include <stdarg.h> #include <stdio.h> #include <signal.h> -#include <math.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> @@ -2137,19 +2136,6 @@ static ULONG_PTR get_image_address(void) } -/* math function wrappers */ -static double CDECL ntdll_atan( double d ) { return atan( d ); } -static double CDECL ntdll_ceil( double d ) { return ceil( d ); } -static double CDECL ntdll_cos( double d ) { return cos( d ); } -static double CDECL ntdll_fabs( double d ) { return fabs( d ); } -static double CDECL ntdll_floor( double d ) { return floor( d ); } -static double CDECL ntdll_log( double d ) { return log( d ); } -static double CDECL ntdll_pow( double x, double y ) { return pow( x, y ); } -static double CDECL ntdll_sin( double d ) { return sin( d ); } -static double CDECL ntdll_sqrt( double d ) { return sqrt( d ); } -static double CDECL ntdll_tan( double d ) { return tan( d ); } - - /*********************************************************************** * unix_funcs */ @@ -2174,16 +2160,6 @@ static struct unix_funcs unix_funcs = fast_RtlReleaseSRWLockShared, fast_RtlWakeConditionVariable, fast_wait_cv, - ntdll_atan, - ntdll_ceil, - ntdll_cos, - ntdll_fabs, - ntdll_floor, - ntdll_log, - ntdll_pow, - ntdll_sin, - ntdll_sqrt, - ntdll_tan, load_so_dll, init_builtin_dll, init_unix_lib, diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 4b7c8b45be7..d56259deff2 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -26,7 +26,7 @@ struct _DISPATCHER_CONTEXT; /* increment this when you change the function table */ -#define NTDLL_UNIXLIB_VERSION 126 +#define NTDLL_UNIXLIB_VERSION 127 struct unix_funcs { @@ -57,18 +57,6 @@ struct unix_funcs NTSTATUS (CDECL *fast_wait_cv)( RTL_CONDITION_VARIABLE *variable, const void *value, const LARGE_INTEGER *timeout ); - /* math functions */ - double (CDECL *atan)( double d ); - double (CDECL *ceil)( double d ); - double (CDECL *cos)( double d ); - double (CDECL *fabs)( double d ); - double (CDECL *floor)( double d ); - double (CDECL *log)( double d ); - double (CDECL *pow)( double x, double y ); - double (CDECL *sin)( double d ); - double (CDECL *sqrt)( double d ); - double (CDECL *tan)( double d ); - /* loader functions */ NTSTATUS (CDECL *load_so_dll)( UNICODE_STRING *nt_name, void **module ); void (CDECL *init_builtin_dll)( void *module );
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
117
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Results per page:
10
25
50
100
200