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