Inspired by #17, compared our Nitfol source to the source from its last
[projects/chimara/chimara.git] / interpreters / frotz / glkio.h
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2006-2009 by Tor Andersson.                                  *
4  *                                                                            *
5  * This file is part of Gargoyle.                                             *
6  *                                                                            *
7  * Gargoyle is free software; you can redistribute it and/or modify           *
8  * it under the terms of the GNU General Public License as published by       *
9  * the Free Software Foundation; either version 2 of the License, or          *
10  * (at your option) any later version.                                        *
11  *                                                                            *
12  * Gargoyle is distributed in the hope that it will be useful,                *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
15  * GNU General Public License for more details.                               *
16  *                                                                            *
17  * You should have received a copy of the GNU General Public License          *
18  * along with Gargoyle; if not, write to the Free Software                    *
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
20  *                                                                            *
21  *****************************************************************************/
22
23 /* glkio.h -- make stdio calls use glk i/o instead */
24
25 #undef FILE
26 typedef struct glk_stream_struct FILE;
27
28 #undef EOF
29 #define EOF                             (-1)
30
31 #undef ungetc
32 #define ungetc(f,c)
33
34 #undef fclose
35 #define fclose(f)       (glk_stream_close(f, NULL), 0)
36 #undef ferror
37 #define ferror(f)       (0)     /* No ferror() equivalent */
38 #undef fgetc
39 #define fgetc(f)        (glk_get_char_stream(f))
40 #undef fgets
41 #define fgets(a, n, f)  (glk_get_line_stream(f, a, n))
42 #undef fread
43 #define fread(a,s,n,f)  (glk_get_buffer_stream(f, (char *)a, s*n))
44 #undef fwrite
45 #define fwrite(a,s,n,f)  (glk_put_buffer_stream(f, (char *)a, s*n), 0)
46 #undef fprintf
47 #define fprintf(f,s,a)  (glk_put_string_stream(f, a), 0)
48 #undef fputc
49 #define fputc(c, f)     (glk_put_char_stream(f, (unsigned char)(c)), 0)
50 #undef fputs
51 #define fputs(s, f)     (glk_put_buffer_stream(f, s, strlen(s)), 0)
52 #undef ftell
53 #define ftell(f)        (glk_stream_get_position(f))
54 #undef fseek
55 #define fseek(f, p, m)  (glk_stream_set_position(f, p, m), 0)
56
57 #undef SEEK_SET
58 #define SEEK_SET        seekmode_Start
59 #undef SEEK_CUR
60 #define SEEK_CUR                seekmode_Current
61 #undef SEEK_END
62 #define SEEK_END        seekmode_End
63
64 FILE *frotzopenprompt(int flag);
65 FILE *frotzopen(char *filename, int flag);
66