Cygwin: dirent.h: fix a comment
[newlib-cygwin.git] / libgloss / mep / read.c
blob3cf5f7b785171dc7342234ddfb06af38cd6c80a0
1 /* read.c -- read characters from file, with hook.
2 *
3 * Copyright (c) 2003 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use, modify,
6 * copy, or redistribute it subject to the terms and conditions of the BSD
7 * License. This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY expressed or implied, including the implied
9 * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy
10 * of this license is available at http://www.opensource.org/licenses. Any
11 * Red Hat trademarks that are incorporated in the source code or documentation
12 * are not subject to the BSD License and may only be used or replicated with
13 * the express permission of Red Hat, Inc.
16 extern int __mep_read(int, unsigned char *, int);
17 extern int _ioIn(void) __attribute__((weak));
19 int
20 read(int fd, unsigned char *buf, int count)
22 if (fd == 0 && &_ioIn)
24 int c = 0;
25 while (c < count)
27 int ch = _ioIn();
28 *buf++ = ch;
29 if (ch == -1)
30 break;
31 c ++;
33 return c;
35 return __mep_read(fd, buf, count);