b580d759a7aef4162f04ab5d385844ad0f5a2a25
[projects/chimara/chimara.git] / interpreters / frotz / glkio.h
1 /* glkio.h -- make stdio calls use glk i/o instead */
2
3 #undef FILE
4 typedef struct glk_stream_struct FILE;
5
6 #undef EOF
7 #define EOF                             (-1)
8
9 #undef ungetc
10 #define ungetc(f,c)
11
12 #undef fclose
13 #define fclose(f)       (glk_stream_close(f, NULL), 0)
14 #undef ferror
15 #define ferror(f)       (0)     /* No ferror() equivalent */
16 #undef fgetc
17 #define fgetc(f)        (glk_get_char_stream(f))
18 #undef fgets
19 #define fgets(a, n, f)  (glk_get_line_stream(f, a, n))
20 #undef fread
21 #define fread(a,s,n,f)  (glk_get_buffer_stream(f, (char *)a, s*n))
22 #undef fwrite
23 #define fwrite(a,s,n,f)  (glk_put_buffer_stream(f, (char *)a, s*n), 0)
24 #undef fprintf
25 #define fprintf(f,s,a)  (glk_put_string_stream(f, a), 0)
26 #undef fputc
27 #define fputc(c, f)     (glk_put_char_stream(f, (unsigned char)(c)), 0)
28 #undef fputs
29 #define fputs(s, f)     (glk_put_buffer_stream(f, s, strlen(s)), 0)
30 #undef ftell
31 #define ftell(f)        (glk_stream_get_position(f))
32 #undef fseek
33 #define fseek(f, p, m)  (glk_stream_set_position(f, p, m), 0)
34
35 #undef SEEK_SET
36 #define SEEK_SET        seekmode_Start
37 #undef SEEK_CUR
38 #define SEEK_CUR                seekmode_Current
39 #undef SEEK_END
40 #define SEEK_END        seekmode_End
41
42 FILE *frotzopenprompt(int flag);
43 FILE *frotzopen(char *filename, int flag);
44