1 /* @(#) pf_io.h 98/01/26 1.2 */
5 /***************************************************************
6 ** Include file for PForth IO
9 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
11 ** The pForth software code is dedicated to the public domain,
12 ** and any third party may reproduce, distribute and modify
13 ** the pForth software code or any derivative works thereof
14 ** without any compensation or license. The pForth software
15 ** code is provided on an "as is" basis without any warranty
16 ** of any kind, including, without limitation, the implied
17 ** warranties of merchantability and fitness for a particular
18 ** purpose and their equivalents under the laws of any jurisdiction.
20 ***************************************************************/
23 int sdTerminalOut( char c );
24 int sdTerminalFlush( void );
25 int sdTerminalIn( void );
26 int sdQueryTerminal( void );
27 #else /* PF_NO_CHARIO */
29 /* Get user prototypes or macros from include file.
30 ** API must match that defined above for the stubs.
32 /* If your sdTerminalIn echos, define PF_KEY_ECHOS. */
33 #include PF_USER_CHARIO
35 #define sdTerminalOut(c) putchar(c)
36 #define sdTerminalIn getchar
37 /* Since getchar() echos, define PF_KEY_ECHOS. */
40 * If you know a way to implement ?TERMINAL in STANDARD ANSI 'C',
41 * please let me know. ?TERMINAL ( -- charAvailable? )
43 #define sdQueryTerminal() (0)
45 #define sdTerminalFlush() /* fflush(PF_STDOUT) */
47 #define sdTerminalFlush() fflush(PF_STDOUT)
50 #endif /* PF_NO_CHARIO */
53 /* Define file access modes. */
54 /* User can #undef and re#define using PF_USER_FILEIO if needed. */
55 #define PF_FAM_READ_ONLY (0)
56 #define PF_FAM_READ_WRITE (1)
58 #define PF_FAM_CREATE ("w+")
59 #define PF_FAM_OPEN_RO ("r")
60 #define PF_FAM_OPEN_RW ("r+")
64 typedef void FileStream;
66 extern FileStream *PF_STDIN;
67 extern FileStream *PF_STDOUT;
73 /* Prototypes for stubs. */
74 FileStream *sdOpenFile( const char *FileName, const char *Mode );
75 int32 sdFlushFile( FileStream * Stream );
76 int32 sdReadFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream );
77 int32 sdWriteFile( void *ptr, int32 Size, int32 nItems, FileStream * Stream );
78 int32 sdSeekFile( FileStream * Stream, int32 Position, int32 Mode );
79 int32 sdTellFile( FileStream * Stream );
80 int32 sdCloseFile( FileStream * Stream );
81 int32 sdInputChar( FileStream *stream );
87 #define PF_SEEK_SET (0)
88 #define PF_SEEK_CUR (1)
89 #define PF_SEEK_END (2)
91 ** printf() is only used for debugging purposes.
92 ** It is not required for normal operation.
94 #define PRT(x) /* No printf(). */
99 /* Get user prototypes or macros from include file.
100 ** API must match that defined above for the stubs.
102 #include PF_USER_FILEIO
105 typedef FILE FileStream;
107 #define sdOpenFile fopen
108 #define sdFlushFile fflush
109 #define sdReadFile fread
110 #define sdWriteFile fwrite
111 #define sdSeekFile fseek
112 #define sdTellFile ftell
113 #define sdCloseFile fclose
114 #define sdInputChar fgetc
116 #define PF_STDIN ((FileStream *) stdin)
117 #define PF_STDOUT ((FileStream *) stdout)
119 #define PF_SEEK_SET (0)
120 #define PF_SEEK_CUR (1)
121 #define PF_SEEK_END (2)
124 ** printf() is only used for debugging purposes.
125 ** It is not required for normal operation.
127 #define PRT(x) { printf x; sdFlushFile(PF_STDOUT); }
130 #endif /* PF_NO_FILEIO */
137 cell ioAccept( char *Target, cell n1, FileStream *Stream );
139 void ioEmit( char c );
140 void ioType( const char *s, int32 n);
146 #endif /* _pf_io_h */