Module: wine Branch: master Commit: 90149034efa232679adafa26febf00bf0c32225f URL: https://gitlab.winehq.org/wine/wine/-/commit/90149034efa232679adafa26febf00b...
Author: Piotr Caban piotr@codeweavers.com Date: Mon Nov 28 13:33:15 2022 +0100
localspl: Add lpr port extension.
---
dlls/localspl/cups.c | 16 ++++++++++++++++ dlls/localspl/localmon.c | 9 ++++++--- 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/localspl/cups.c b/dlls/localspl/cups.c index fa685e26289..47362c1f138 100644 --- a/dlls/localspl/cups.c +++ b/dlls/localspl/cups.c @@ -164,6 +164,20 @@ static BOOL unixname_start_doc(doc_t *doc, const WCHAR *output) return doc->unixname.fd != -1; }
+static BOOL lpr_start_doc(doc_t *doc, const WCHAR *printer_name) +{ + static const WCHAR lpr[] = { 'l','p','r',' ','-','P',''' }; + static const WCHAR quote[] = { ''',0 }; + int printer_len = wcslen(printer_name); + WCHAR *cmd; + + cmd = malloc(printer_len * sizeof(WCHAR) + sizeof(lpr) + sizeof(quote)); + memcpy(cmd, lpr, sizeof(lpr)); + memcpy(cmd + ARRAY_SIZE(lpr), printer_name, printer_len * sizeof(WCHAR)); + memcpy(cmd + ARRAY_SIZE(lpr) + printer_len, quote, sizeof(quote)); + return pipe_start_doc(doc, cmd); +} + static NTSTATUS start_doc(void *args) { const struct start_doc_params *params = args; @@ -176,6 +190,8 @@ static NTSTATUS start_doc(void *args) ret = pipe_start_doc(doc, params->port + 1 /* strlen("|") */); else if (params->type == PORT_IS_UNIXNAME) ret = unixname_start_doc(doc, params->port); + else if (params->type == PORT_IS_LPR) + ret = lpr_start_doc(doc, params->port + 4 /* strlen("lpr:") */);
if (ret) *params->doc = (size_t)doc; diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c index d2712cde995..8cef23787e7 100644 --- a/dlls/localspl/localmon.c +++ b/dlls/localspl/localmon.c @@ -506,7 +506,8 @@ static BOOL WINAPI localmon_StartDocPort(HANDLE hport, WCHAR *printer_name, TRACE("(%p %s %ld %ld %p)\n", hport, debugstr_w(printer_name), job_id, level, doc_info);
- if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME) + if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME || + port->type == PORT_IS_LPR) { struct start_doc_params params;
@@ -546,7 +547,8 @@ static BOOL WINAPI localmon_WritePort(HANDLE hport, BYTE *buf, DWORD size,
TRACE("(%p %p %lu %p)\n", hport, buf, size, written);
- if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME) + if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME || + port->type == PORT_IS_LPR) { struct write_doc_params params; BOOL ret; @@ -568,7 +570,8 @@ static BOOL WINAPI localmon_EndDocPort(HANDLE hport)
TRACE("(%p)\n", hport);
- if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME) + if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME || + port->type == PORT_IS_LPR) { struct end_doc_params params;