xref: /plan9/sys/src/cmd/gs/src/gp_stdin.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 2001 artofcode LLC.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gp_stdin.c,v 1.4 2002/02/21 22:24:52 giles Exp $ */
18 /* Read stdin on platforms that do not support unbuffered read.
19  * This is the most portable implementation, but it is very slow
20  * when reading stdin because it will read one byte at a time.
21  * Platforms that support unbuffered read should use gp_stdia.c
22  * or provide their own implementation
23  */
24 
25 #include "stdio_.h"
26 #include "gx.h"
27 #include "gp.h"
28 
29 /* Read bytes from stdin, using unbuffered if possible.
30  * This implementation doesn't do unbuffered, so if
31  * interactive read one byte at a time.
32  */
gp_stdin_read(char * buf,int len,int interactive,FILE * f)33 int gp_stdin_read(char *buf, int len, int interactive, FILE *f)
34 {
35     return fread(buf, 1, interactive ? 1 : len, f);
36 }
37 
38