// Support code for Imp I/O

#ifndef __INTERNALFILE_H__
#define __INTERNALFILE_H__ 1

#include <stdio.h>

#include "imptypes.h"

typedef struct _imp_filedata {
  int streamno;
  FILE *f;
  _imp_string fname;
  int lastchar, nextchar;
  // Do I want a mode flag here?  (to mark binary input and output files)
  union {
    int inpos;
    int outpos;
  };
} _imp_filedata;

extern char *_imp_Progname;
extern int _imp_global_argc;
extern char **_imp_global_argv;

// Used for error reporting only:
extern char *_imp_current_file;
extern int   _imp_current_line;

extern void _imp_init_files(void);
extern void _imp_initialise(int argc, char **argv);
extern void _imp_issue_prompt(void);
extern void check_instream(const char *fn);
extern void check_outstream(const char *fn);

extern int     _imp_InStream,  _imp_OutStream;
extern FILE   *_imp_INFILE,   *_imp_OUTFILE;

// Note that in Imp we can have two stream 1's: open input and open output are
// effectively separate namespaces.  Stream 0 in tty on output and keyboard on input.

extern _imp_filedata _imp_infile[256];
extern _imp_filedata _imp_outfile[256];

extern _imp_string   _imp_promptstr;

#endif // __INTERNALFILE_H__
