-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.h
46 lines (37 loc) · 1.34 KB
/
io.h
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
// mind -- a Forth interpreter
// Copyright 2011-2014 Markus Redeker <[email protected]>
//
// Published under the GNU General Public License version 2 or any
// later version, at your choice. There is NO WARRANY, not at all. See
// the file "copying" for details.
#ifndef IO_H
#define IO_H
#include "types.h"
typedef struct {
cell get; // Forth word ( stream -- )
cell i; // Forth word ( stream -- char )
cell iq; // Forth word ( stream -- flag )
} stream_t;
typedef struct {
stream_t stream;
cell input; // (FILE*) Input file
cell name; // (char*) File name
cell current; // Character at input position (or EOF)
cell lineno; // integer: line number
} textfile_t;
// Structure to iterate over the lines in a file.
typedef struct {
stream_t stream;
cell file; // (FILE*) Input file, or NULL
cell path; // (char*) File path
cell line; // (char*) Line at input position (or NULL)
cell lineno; // integer: line number
} lines_t;
char *mind_relative(char *mind_file, char *filename);
void file_open(textfile_t *inf, char* name);
void file_close(textfile_t *inf);
void file_get(textfile_t *inf);
void lines_open(lines_t *seq, char* path);
void lines_close(lines_t *seq);
void lines_get(lines_t *seq);
#endif