2008-02-14 03:20:20 -05:00
|
|
|
! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
|
2007-11-21 01:18:46 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-12-14 21:03:00 -05:00
|
|
|
USING: alien alien.c-types arrays destructors io io.backend.windows libc
|
2008-09-05 20:29:14 -04:00
|
|
|
windows.types math.bitwise windows.kernel32 windows namespaces
|
2008-09-11 02:27:23 -04:00
|
|
|
make kernel sequences windows.errors assocs math.parser system
|
|
|
|
random combinators accessors io.pipes io.ports ;
|
2008-12-14 21:03:00 -05:00
|
|
|
IN: io.pipes.windows.nt
|
2007-11-21 01:18:46 -05:00
|
|
|
|
2007-11-21 03:18:28 -05:00
|
|
|
! This code is based on
|
|
|
|
! http://twistedmatrix.com/trac/browser/trunk/twisted/internet/iocpreactor/process.py
|
|
|
|
|
2008-05-06 03:10:17 -04:00
|
|
|
: create-named-pipe ( name -- handle )
|
|
|
|
{ PIPE_ACCESS_INBOUND FILE_FLAG_OVERLAPPED } flags
|
2007-11-21 01:18:46 -05:00
|
|
|
PIPE_TYPE_BYTE
|
|
|
|
1
|
|
|
|
4096
|
|
|
|
4096
|
|
|
|
0
|
2008-06-27 20:26:36 -04:00
|
|
|
default-security-attributes
|
2008-05-15 06:20:42 -04:00
|
|
|
CreateNamedPipe opened-file ;
|
2007-11-21 01:18:46 -05:00
|
|
|
|
2008-05-06 03:10:17 -04:00
|
|
|
: open-other-end ( name -- handle )
|
|
|
|
GENERIC_WRITE
|
|
|
|
{ FILE_SHARE_READ FILE_SHARE_WRITE } flags
|
2008-06-27 20:26:36 -04:00
|
|
|
default-security-attributes
|
2007-11-21 01:18:46 -05:00
|
|
|
OPEN_EXISTING
|
|
|
|
FILE_FLAG_OVERLAPPED
|
|
|
|
f
|
2008-05-15 06:20:42 -04:00
|
|
|
CreateFile opened-file ;
|
2007-11-21 01:18:46 -05:00
|
|
|
|
|
|
|
: unique-pipe-name ( -- string )
|
|
|
|
[
|
|
|
|
"\\\\.\\pipe\\factor-" %
|
|
|
|
pipe counter #
|
|
|
|
"-" %
|
2008-03-19 22:41:39 -04:00
|
|
|
32 random-bits #
|
2007-11-21 01:18:46 -05:00
|
|
|
"-" %
|
2009-11-18 21:04:37 -05:00
|
|
|
nano-count #
|
2007-11-21 01:18:46 -05:00
|
|
|
] "" make ;
|
|
|
|
|
2008-05-06 03:10:17 -04:00
|
|
|
M: winnt (pipe) ( -- pipe )
|
|
|
|
[
|
|
|
|
unique-pipe-name
|
2008-05-15 02:45:32 -04:00
|
|
|
[ create-named-pipe ] [ open-other-end ] bi
|
|
|
|
pipe boa
|
2008-05-06 03:10:17 -04:00
|
|
|
] with-destructors ;
|