! Copyright (C) 2004, 2005 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: io-internals USING: errors kernel kernel-internals namespaces io strings ; ! Simple wrappers for ANSI C I/O functions, used for ! bootstrapping only. ! More elaborate platform-specific I/O code is used on Unix and ! Windows; see library/unix and library/win32. TUPLE: c-stream in out ; M: c-stream stream-write1 >r ch>string r> stream-write ; M: c-stream stream-write c-stream-out fwrite ; M: c-stream stream-read1 c-stream-in dup [ fgetc ] when ; M: c-stream stream-flush c-stream-out [ fflush ] when* ; M: c-stream stream-close dup c-stream-in [ fclose ] when* c-stream-out [ fclose ] when* ; : ( in out -- stream ) >r f f r> ; : init-io ( -- ) 13 getenv 14 getenv stdio set ; : io-multiplex ( ms -- ) drop ; IN: io : ( path -- stream ) "rb" fopen f ; : ( path -- stream ) "wb" fopen f swap ; TUPLE: client-stream host port ; TUPLE: c-stream-error ; : c-stream-error ( -- * ) throw ; : c-stream-error ; : c-stream-error ; : accept c-stream-error ;