1 /* @(#) pf_io.c 96/12/23 1.12 */
\r
2 /***************************************************************
\r
3 ** I/O subsystem for PForth based on 'C'
\r
6 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
\r
8 ** The pForth software code is dedicated to the public domain,
\r
9 ** and any third party may reproduce, distribute and modify
\r
10 ** the pForth software code or any derivative works thereof
\r
11 ** without any compensation or license. The pForth software
\r
12 ** code is provided on an "as is" basis without any warranty
\r
13 ** of any kind, including, without limitation, the implied
\r
14 ** warranties of merchantability and fitness for a particular
\r
15 ** purpose and their equivalents under the laws of any jurisdiction.
\r
17 ****************************************************************
\r
18 ** 941004 PLB Extracted IO calls from pforth_main.c
\r
19 ***************************************************************/
\r
24 /***************************************************************
\r
25 ** Initialize I/O system.
\r
29 /* System dependant terminal initialization. */
\r
37 /***************************************************************
\r
38 ** Send single character to output stream.
\r
40 void ioEmit( char c )
\r
44 Result = sdTerminalOut(c);
\r
45 if( Result < 0 ) EXIT(1);
\r
51 gCurrentTask->td_OUT = 0;
\r
56 gCurrentTask->td_OUT++;
\r
61 /***************************************************************
\r
62 ** Send an entire string..
\r
64 void ioType( const char *s, int32 n )
\r
74 /***************************************************************
\r
75 ** Return single character from input device, always keyboard.
\r
86 /**************************************************************
\r
87 ** Receive line from keyboard.
\r
88 ** Return number of characters enterred.
\r
90 #define BACKSPACE (8)
\r
91 #define DELETE (0x7F)
\r
92 cell ioAccept( char *buffer, cell maxChars )
\r
98 DBUGX(("ioAccept(0x%x, 0x%x)\n", buffer, len ));
\r
104 while(len < maxChars)
\r
106 c = sdTerminalIn();
\r
117 if( len > 0 ) /* Don't go beyond beginning of line. */
\r
128 sdTerminalEcho( (char) c );
\r
139 /* NUL terminate line to simplify printing when debugging. */
\r
140 if( len < maxChars ) p[len] = '\0';
\r
145 #define UNIMPLEMENTED(name) { MSG(name); MSG("is unimplemented!\n"); }
\r
148 /***********************************************************************************/
\r
149 /*********** File I/O **************************************************************/
\r
150 /***********************************************************************************/
\r
151 #ifdef PF_NO_FILEIO
\r
153 /* Provide stubs for standard file I/O */
\r
155 FileStream *PF_STDIN;
\r
156 FileStream *PF_STDOUT;
\r
158 int32 sdInputChar( FileStream *stream )
\r
160 UNIMPLEMENTED("sdInputChar");
\r
165 FileStream *sdOpenFile( const char *FileName, const char *Mode )
\r
167 UNIMPLEMENTED("sdOpenFile");
\r
172 int32 sdFlushFile( FileStream * Stream )
\r
177 int32 sdReadFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream )
\r
179 UNIMPLEMENTED("sdReadFile");
\r
186 int32 sdWriteFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream )
\r
188 UNIMPLEMENTED("sdWriteFile");
\r
195 int32 sdSeekFile( FileStream * Stream, int32 Position, int32 Mode )
\r
197 UNIMPLEMENTED("sdSeekFile");
\r
203 int32 sdTellFile( FileStream * Stream )
\r
205 UNIMPLEMENTED("sdTellFile");
\r
209 int32 sdCloseFile( FileStream * Stream )
\r
211 UNIMPLEMENTED("sdCloseFile");
\r