1 /* @(#) pf_io.c 96/12/23 1.12 */
2 /***************************************************************
3 ** I/O subsystem for PForth based on 'C'
6 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
8 ** The pForth software code is dedicated to the public domain,
9 ** and any third party may reproduce, distribute and modify
10 ** the pForth software code or any derivative works thereof
11 ** without any compensation or license. The pForth software
12 ** code is provided on an "as is" basis without any warranty
13 ** of any kind, including, without limitation, the implied
14 ** warranties of merchantability and fitness for a particular
15 ** purpose and their equivalents under the laws of any jurisdiction.
17 ****************************************************************
18 ** 941004 PLB Extracted IO calls from pforth_main.c
19 ***************************************************************/
23 /***************************************************************
24 ** Send single character to output stream.
29 Result = sdTerminalOut(c);
31 if( Result < 0 ) EXIT(1);
34 gCurrentTask->td_OUT = 0;
39 gCurrentTask->td_OUT++;
43 void ioType( const char *s, int32 n )
53 /***************************************************************
54 ** Return single character from input device, always keyboard.
58 return sdTerminalIn();
61 /**************************************************************
62 ** Receive line from input stream.
63 ** Return length, or -1 for EOF.
66 cell ioAccept( char *Target, cell MaxLen, FileStream *stream )
72 DBUGX(("ioAccept(0x%x, 0x%x, 0x%x)\n", Target, Len, stream ));
77 if( stream == PF_STDIN )
80 /* If KEY does not echo, then echo here. If using getchar(), KEY will echo. */
83 if( c == '\r') ioEmit('\n'); /* Send LF after CR */
88 c = sdInputChar(stream);
105 if( Len < MaxLen ) /* Don't go beyond beginning of line. */
124 return pfCStringLength( Target );
127 #define UNIMPLEMENTED(name) { MSG(name); MSG("is unimplemented!\n"); }
130 int sdTerminalOut( char c )
135 int sdTerminalIn( void )
139 int sdTerminalFlush( void )
145 /***********************************************************************************/
148 /* Provide stubs for standard file I/O */
150 FileStream *PF_STDIN;
151 FileStream *PF_STDOUT;
153 int32 sdInputChar( FileStream *stream )
155 UNIMPLEMENTED("sdInputChar");
160 FileStream *sdOpenFile( const char *FileName, const char *Mode )
162 UNIMPLEMENTED("sdOpenFile");
167 int32 sdFlushFile( FileStream * Stream )
172 int32 sdReadFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream )
174 UNIMPLEMENTED("sdReadFile");
181 int32 sdWriteFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream )
183 UNIMPLEMENTED("sdWriteFile");
190 int32 sdSeekFile( FileStream * Stream, int32 Position, int32 Mode )
192 UNIMPLEMENTED("sdSeekFile");
198 int32 sdTellFile( FileStream * Stream )
200 UNIMPLEMENTED("sdTellFile");
204 int32 sdCloseFile( FileStream * Stream )
206 UNIMPLEMENTED("sdCloseFile");