Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
052cfad0
Commit
052cfad0
authored
Dec 07, 2010
by
Huw Davies
Committed by
Alexandre Julliard
Dec 07, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool.drv: Rewrite the lpr scheduler to use the pipe scheduler.
parent
5bdcd79c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
77 deletions
+66
-77
info.c
dlls/winspool.drv/info.c
+66
-77
No files found.
dlls/winspool.drv/info.c
View file @
052cfad0
...
...
@@ -7361,32 +7361,83 @@ BOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob,
}
/*****************************************************************************
* schedule_
lpr
* schedule_
pipe
*/
static
BOOL
schedule_
lpr
(
LPCWSTR
printer_name
,
LPCWSTR
filename
)
static
BOOL
schedule_
pipe
(
LPCWSTR
cmd
,
LPCWSTR
filename
)
{
char
*
unixname
,
*
queue
,
*
cmd
;
char
fmt
[]
=
"lpr -P'%s' '%s'"
;
#ifdef HAVE_FORK
char
*
unixname
,
*
cmdA
;
DWORD
len
;
int
r
;
int
fds
[
2
]
=
{
-
1
,
-
1
},
file_fd
=
-
1
,
no_read
;
BOOL
ret
=
FALSE
;
char
buf
[
1024
];
if
(
!
(
unixname
=
wine_get_unix_file_name
(
filename
)))
return
FALSE
;
len
=
WideCharToMultiByte
(
CP_
ACP
,
0
,
printer_name
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
queue
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
WideCharToMultiByte
(
CP_
ACP
,
0
,
printer_name
,
-
1
,
queue
,
len
,
NULL
,
NULL
);
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
);
cmd
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
unixname
)
+
len
+
sizeof
(
fmt
)
-
5
);
sprintf
(
cmd
,
fmt
,
queue
,
unixname
);
TRACE
(
"printing with: %s
\n
"
,
cmdA
);
TRACE
(
"printing with: %s
\n
"
,
cmd
);
r
=
system
(
cmd
)
;
if
((
file_fd
=
open
(
unixname
,
O_RDONLY
))
==
-
1
)
goto
end
;
HeapFree
(
GetProcessHeap
(),
0
,
cmd
);
HeapFree
(
GetProcessHeap
(),
0
,
queue
);
if
(
pipe
(
fds
))
{
ERR
(
"pipe() failed!
\n
"
);
goto
end
;
}
if
(
fork
()
==
0
)
{
close
(
0
);
dup2
(
fds
[
0
],
0
);
close
(
fds
[
1
]);
/* reset signals that we previously set to SIG_IGN */
signal
(
SIGPIPE
,
SIG_DFL
);
signal
(
SIGCHLD
,
SIG_DFL
);
execl
(
"/bin/sh"
,
"/bin/sh"
,
"-c"
,
cmdA
,
NULL
);
_exit
(
1
);
}
while
((
no_read
=
read
(
file_fd
,
buf
,
sizeof
(
buf
)))
>
0
)
write
(
fds
[
1
],
buf
,
no_read
);
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
);
HeapFree
(
GetProcessHeap
(),
0
,
unixname
);
return
(
r
==
0
);
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
;
}
/*****************************************************************************
...
...
@@ -7519,68 +7570,6 @@ static BOOL schedule_file(LPCWSTR filename)
}
/*****************************************************************************
* schedule_pipe
*/
static
BOOL
schedule_pipe
(
LPCWSTR
cmd
,
LPCWSTR
filename
)
{
#ifdef HAVE_FORK
char
*
unixname
,
*
cmdA
;
DWORD
len
;
int
fds
[
2
]
=
{
-
1
,
-
1
},
file_fd
=
-
1
,
no_read
;
BOOL
ret
=
FALSE
;
char
buf
[
1024
];
if
(
!
(
unixname
=
wine_get_unix_file_name
(
filename
)))
return
FALSE
;
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
);
TRACE
(
"printing with: %s
\n
"
,
cmdA
);
if
((
file_fd
=
open
(
unixname
,
O_RDONLY
))
==
-
1
)
goto
end
;
if
(
pipe
(
fds
))
{
ERR
(
"pipe() failed!
\n
"
);
goto
end
;
}
if
(
fork
()
==
0
)
{
close
(
0
);
dup2
(
fds
[
0
],
0
);
close
(
fds
[
1
]);
/* reset signals that we previously set to SIG_IGN */
signal
(
SIGPIPE
,
SIG_DFL
);
signal
(
SIGCHLD
,
SIG_DFL
);
execl
(
"/bin/sh"
,
"/bin/sh"
,
"-c"
,
cmdA
,
NULL
);
_exit
(
1
);
}
while
((
no_read
=
read
(
file_fd
,
buf
,
sizeof
(
buf
)))
>
0
)
write
(
fds
[
1
],
buf
,
no_read
);
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
);
HeapFree
(
GetProcessHeap
(),
0
,
unixname
);
return
ret
;
#else
return
FALSE
;
#endif
}
/*****************************************************************************
* schedule_unixfile
*/
static
BOOL
schedule_unixfile
(
LPCWSTR
output
,
LPCWSTR
filename
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment