1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of Mes.
7 * Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Mes. If not, see <http://www.gnu.org/licenses/>.
24 return ungetc (c, g_stdin);
38 return MAKE_NUMBER (peekchar ());
44 return MAKE_NUMBER (getchar ());
50 ungetchar (VALUE (i));
55 write_byte (SCM x) ///((arity . n))
60 if (TYPE (p) == TPAIR && TYPE (car (p)) == TNUMBER) fd = VALUE (car (p));
62 write (fd, (char*)&cc, 1);
64 assert (TYPE (c) == TNUMBER || TYPE (c) == TCHAR);
69 char string_to_cstring_buf[1024];
71 string_to_cstring (SCM s)
73 //static char buf[1024];
75 char *p = string_to_cstring_buf;
79 *p++ = VALUE (car (s));
84 return string_to_cstring_buf;
88 getenv_ (SCM s) ///((name . "getenv"))
91 p = getenv (string_to_cstring (s));
92 return p ? MAKE_STRING (cstring_to_list (p)) : cell_f;
96 open_input_file (SCM file_name)
98 return MAKE_NUMBER (open (string_to_cstring (file_name), O_RDONLY));
102 access_p (SCM file_name, SCM mode)
104 return access (string_to_cstring (file_name), VALUE (mode)) == 0 ? cell_t : cell_f;
108 current_input_port ()
110 return MAKE_NUMBER (g_stdin);
114 set_current_input_port (SCM port)
116 g_stdin = VALUE (port) ? VALUE (port) : STDIN;
117 return current_input_port ();
121 force_output (SCM p) ///((arity . n))
123 return cell_unspecified;