Commit 6372a61e authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

localspl: Add unixname port extension.

parent fca258ef
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment