xref: /plan9/sys/src/cmd/gs/src/gp_stdin.c (revision ff8c3af2f44d95267f67219afa20ba82ff6cf7e4)
1 /* Copyright (C) 2001 artofcode LLC.  All rights reserved.
2 
3   This file is part of AFPL Ghostscript.
4 
5   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
6   distributor accepts any responsibility for the consequences of using it, or
7   for whether it serves any particular purpose or works at all, unless he or
8   she says so in writing.  Refer to the Aladdin Free Public License (the
9   "License") for full details.
10 
11   Every copy of AFPL Ghostscript must include a copy of the License, normally
12   in a plain ASCII text file named PUBLIC.  The License grants you the right
13   to copy, modify and redistribute AFPL Ghostscript, but only under certain
14   conditions described in the License.  Among other things, the License
15   requires that the copyright notice and this notice be preserved on all
16   copies.
17 */
18 
19 /*$Id: gp_stdin.c,v 1.2 2001/10/12 21:37:08 ghostgum Exp $ */
20 /* Read stdin on platforms that do not support unbuffered read.
21  * This is the most portable implementation, but it is very slow
22  * when reading stdin because it will read one byte at a time.
23  * Platforms that support unbuffered read should use gp_stdia.c
24  * or provide their own implementation
25  */
26 
27 #include "stdio_.h"
28 #include "gx.h"
29 #include "gp.h"
30 
31 /* Read bytes from stdin, using unbuffered if possible.
32  * This implementation doesn't do unbuffered, so if
33  * interactive read one byte at a time.
34  */
35 int gp_stdin_read(char *buf, int len, int interactive, FILE *f)
36 {
37     return fread(buf, 1, interactive ? 1 : len, f);
38 }
39 
40