From 4d0a448a4457ff6a223698f1edade728c9fbc827 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 16 Jan 2014 18:35:22 +0900 Subject: [PATCH] impl char/string IO functions --- src/port.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/port.c b/src/port.c index 8d0e5af7..11e835e7 100644 --- a/src/port.c +++ b/src/port.c @@ -108,6 +108,38 @@ pic_fclose(pic_file *file) return 0; } +int +pic_fgetc(pic_file *file) +{ + char buf[1]; + + pic_fread(buf, 1, 1, file); + + return buf[0]; +} + +int +pic_fputc(int c, pic_file *file) +{ + char buf[1]; + + buf[0] = c; + pic_fwrite(buf, 1, 1, file); + + return buf[0]; +} + +int +pic_fputs(const char *str, pic_file *file) +{ + int len; + + len = strlen(str); + pic_fwrite(str, len, 1, file); + + return 0; +} + static void write_pair(pic_state *pic, struct pic_pair *pair); static void write_str(pic_state *pic, struct pic_string *str);