localspl: Add unixname port extension.

This commit is contained in:
Piotr Caban 2022-11-28 13:05:22 +01:00 committed by Alexandre Julliard
parent fca258ef89
commit 6372a61eb5
3 changed files with 39 additions and 4 deletions

View file

@ -52,6 +52,10 @@ typedef struct _doc_t
pid_t pid;
int fd;
} pipe;
struct
{
int fd;
} unixname;
};
} doc_t;
@ -131,6 +135,35 @@ static BOOL pipe_start_doc(doc_t *doc, const WCHAR *cmd)
return TRUE;
}
static BOOL unixname_write_doc(doc_t *doc, const BYTE *buf, unsigned int size)
{
return write(doc->unixname.fd, buf, size) == size;
}
static BOOL unixname_end_doc(doc_t *doc)
{
close(doc->unixname.fd);
return TRUE;
}
static BOOL unixname_start_doc(doc_t *doc, const WCHAR *output)
{
char *outputA;
DWORD len;
doc->write_doc = unixname_write_doc;
doc->end_doc = unixname_end_doc;
len = wcslen(output);
outputA = malloc(len * 3 + 1);
ntdll_wcstoumbs(output, len + 1, outputA, len * 3 + 1, FALSE);
doc->unixname.fd = open(outputA, O_CREAT | O_TRUNC | O_WRONLY, 0666);
free(outputA);
return doc->unixname.fd != -1;
}
static NTSTATUS start_doc(void *args)
{
const struct start_doc_params *params = args;
@ -141,6 +174,8 @@ static NTSTATUS start_doc(void *args)
if (params->type == PORT_IS_PIPE)
ret = pipe_start_doc(doc, params->port + 1 /* strlen("|") */);
else if (params->type == PORT_IS_UNIXNAME)
ret = unixname_start_doc(doc, params->port);
if (ret)
*params->doc = (size_t)doc;

View file

@ -506,7 +506,7 @@ 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)
if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME)
{
struct start_doc_params params;
@ -546,7 +546,7 @@ 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)
if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME)
{
struct write_doc_params params;
BOOL ret;
@ -568,7 +568,7 @@ static BOOL WINAPI localmon_EndDocPort(HANDLE hport)
TRACE("(%p)\n", hport);
if (port->type == PORT_IS_PIPE)
if (port->type == PORT_IS_PIPE || port->type == PORT_IS_UNIXNAME)
{
struct end_doc_params params;

View file

@ -988,7 +988,7 @@ static monitor_t * monitor_load_by_port(LPCWSTR portname)
TRACE("(%s)\n", debugstr_w(portname));
/* wine specific ports */
if (portname[0] == '|')
if (portname[0] == '|' || portname[0] == '/')
return monitor_load(L"Local Port", NULL);
/* Try the Local Monitor first */