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, David 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 ***************************************************************/
24 /***************************************************************
25 ** Initialize I/O system.
29 /* System dependant terminal initialization. */
37 /***************************************************************
38 ** Send single character to output stream.
44 Result = sdTerminalOut(c);
45 if( Result < 0 ) EXIT(1);
51 gCurrentTask->td_OUT = 0;
56 gCurrentTask->td_OUT++;
61 /***************************************************************
62 ** Send an entire string..
64 void ioType( const char *s, cell_t n )
74 /***************************************************************
75 ** Return single character from input device, always keyboard.
86 /**************************************************************
87 ** Receive line from keyboard.
88 ** Return number of characters enterred.
91 #define BACKSPACE (0x08)
93 cell_t ioAccept( char *buffer, cell_t maxChars )
99 DBUGX(("ioAccept(0x%x, 0x%x)\n", buffer, len ));
105 while(len < maxChars)
118 if( len > 0 ) /* Don't go beyond beginning of line. */
129 sdTerminalEcho( (char) c );
139 sdTerminalEcho( SPACE );
141 /* NUL terminate line to simplify printing when debugging. */
142 if( len < maxChars ) p[len] = '\0';
147 #define UNIMPLEMENTED(name) { MSG(name); MSG("is unimplemented!\n"); }
150 /***********************************************************************************/
151 /*********** File I/O **************************************************************/
152 /***********************************************************************************/
155 /* Provide stubs for standard file I/O */
157 FileStream *PF_STDIN;
158 FileStream *PF_STDOUT;
160 cell_t sdInputChar( FileStream *stream )
162 UNIMPLEMENTED("sdInputChar");
167 FileStream *sdOpenFile( const char *FileName, const char *Mode )
169 UNIMPLEMENTED("sdOpenFile");
174 cell_t sdFlushFile( FileStream * Stream )
179 cell_t sdReadFile( void *ptr, cell_t Size, int32_t nItems, FileStream * Stream )
181 UNIMPLEMENTED("sdReadFile");
188 cell_t sdWriteFile( void *ptr, cell_t Size, int32_t nItems, FileStream * Stream )
190 UNIMPLEMENTED("sdWriteFile");
197 cell_t sdSeekFile( FileStream * Stream, file_offset_t Position, int32_t Mode )
199 UNIMPLEMENTED("sdSeekFile");
205 cell_t sdTellFile( FileStream * Stream )
207 UNIMPLEMENTED("sdTellFile");
211 cell_t sdCloseFile( FileStream * Stream )
213 UNIMPLEMENTED("sdCloseFile");
218 cell_t sdDeleteFile( const char *FileName )
220 UNIMPLEMENTED("sdDeleteFile");
225 cell_t sdRenameFile( const char *OldName, const char *NewName )
227 UNIMPLEMENTED("sdRenameFile");
233 ThrowCode sdResizeFile( FileStream * File, uint64_t NewSize )
235 UNIMPLEMENTED("sdResizeFile");
237 return THROW_RESIZE_FILE;