OSDN Git Service

expression.c, stream.c, textfile.txt, token.cの追加
[gleam-language/alpha.git] / stream.c
1 #include "common.h"
2
3 /*
4 * stream.c      --manage stream
5
6 * Copyright(C) 2013(Heisei 25) ttwilb All rights reserved.
7
8 * This source code is released on the BSD licensing.
9
10 */
11
12 struct StreamInfo open_stream_file(char fname[FILENAME_MAX])
13 {
14         struct StreamInfo res;
15         strcpy(res.file.filename, fname);
16         res.file.fp = fopen(fname, "r");
17         res.type = STREAM_FILE;
18         return res;
19 }
20
21 void close_stream(struct StreamInfo info)
22 {
23         if(info.type == STREAM_FILE)
24                 fclose(info.file.fp);
25 }
26
27 char stream_nextchar(struct StreamInfo info)
28 {
29         if(info.type == STREAM_FILE)
30                 return (getc(info.file.fp));
31 }