First NIT release and new clean mercurial repository
[nit.git] / lib / standard / stream_nit.c
1 /* This file is part of NIT ( http://www.nitlanguage.org ).
2 *
3 * Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 *
5 * This file is free software, which comes along with NIT. This software is
6 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8 * PARTICULAR PURPOSE. You can modify it is you want, provided this header
9 * is kept unaltered, and a notification of the changes is added.
10 * You are allowed to redistribute it and sell it, alone or is a part of
11 * another product.
12 */
13
14 #include <unistd.h>
15
16 int stream_FDStream_FDStream_native_read_char_1(void *s, int fd) {
17 int result;
18 char buf;
19 ssize_t r = read(fd, &buf, 1);
20 if (r == 0)
21 result = -1;
22 else
23 result = buf;
24 return result;
25 }
26
27 void stream_FDStream_FDStream_write_char_1(void *s, int fd, int c) {
28 write(fd, &c, 1);
29 }
30