| 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 | void glkio_printf(char *fmt, ...) |
| 16 | { |
| 17 | va_list argp; |
| 18 | va_start(argp, fmt); |
| 19 | if (NULL == glkMainWin) |
| 20 | /* assume stdio is available in this case only */ |
| 21 | vprintf(fmt, argp); |
| 22 | else |
| 23 | { |
| 24 | char buf[1024]; /* FIXME: buf size should be foolproof */ |
| 25 | vsprintf(buf, fmt, argp); |
| 26 | glk_put_string(buf); |
| 27 | } |
| 28 | va_end(argp); |
| 29 | } |
| 30 |