]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/ce/backend/backend.factor
Fix http tests and io.server.connection docs
[factor.git] / unmaintained / ce / backend / backend.factor
1 USING: io.ports io.windows threads.private kernel
2 io.backend windows.winsock windows.kernel32 windows
3 io.streams.duplex io namespaces alien.syntax system combinators
4 io.buffers io.encodings io.encodings.utf8 combinators.lib ;
5 IN: io.windows.ce.backend
6
7 : port-errored ( port -- )
8     win32-error-string swap set-port-error ;
9
10 M: wince io-multiplex ( ms -- )
11     60 60 * 1000 * or (sleep) ;
12
13 M: wince add-completion ( handle -- ) drop ;
14
15 GENERIC: wince-read ( port port-handle -- )
16
17 M: input-port (wait-to-read) ( port -- )
18     dup dup port-handle wince-read pending-error ;
19
20 GENERIC: wince-write ( port port-handle -- )
21
22 M: port port-flush
23     dup buffer-empty? over port-error or [
24         drop
25     ] [
26         dup dup port-handle wince-write port-flush
27     ] if ;
28
29 M: wince init-io ( -- )
30     init-winsock ;
31
32 LIBRARY: libc
33 FUNCTION: void* _getstdfilex int fd ;
34 FUNCTION: void* _fileno void* file ;
35
36 M: wince (init-stdio) ( -- )
37     #! We support Windows NT too, to make this I/O backend
38     #! easier to debug.
39     512 default-buffer-size [
40         os winnt? [
41             STD_INPUT_HANDLE GetStdHandle
42             STD_OUTPUT_HANDLE GetStdHandle
43             STD_ERROR_HANDLE GetStdHandle
44         ] [
45             0 _getstdfilex _fileno
46             1 _getstdfilex _fileno
47             2 _getstdfilex _fileno
48         ] if [ f <win32-file> ] 3apply
49         [ <input-port> ] [ <output-port> ] [ <output-port> ] tri*
50     ] with-variable ;