| 1 | /*----------------------------------------------------------------------*\ |
| 2 | |
| 3 | glkio.c |
| 4 | |
| 5 | Glk output for Alan interpreter |
| 6 | |
| 7 | \*----------------------------------------------------------------------*/ |
| 8 | |
| 9 | #include <stdarg.h> |
| 10 | #include <stdio.h> |
| 11 | |
| 12 | #include "glk.h" |
| 13 | #include "glkio.h" |
| 14 | |
| 15 | winid_t glkMainWin; |
| 16 | winid_t glkStatusWin; |
| 17 | |
| 18 | void glkio_printf(char *fmt, ...) |
| 19 | { |
| 20 | va_list argp; |
| 21 | va_start(argp, fmt); |
| 22 | if (glkMainWin == NULL) |
| 23 | /* assume stdio is available in this case only */ |
| 24 | vprintf(fmt, argp); |
| 25 | else |
| 26 | { |
| 27 | char buf[1024]; /* FIXME: buf size should be foolproof */ |
| 28 | vsprintf(buf, fmt, argp); |
| 29 | glk_put_string(buf); |
| 30 | } |
| 31 | va_end(argp); |
| 32 | } |