/src/ghostpdl/base/gp_stdib.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2024 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Read stdin on platforms that support unbuffered read */ |
18 | | /* and require the user to restart interrupted system calls. */ |
19 | | /* We also want unbuffered for console input and pipes. */ |
20 | | |
21 | | #include "stdio_.h" |
22 | | #include "time_.h" |
23 | | #include "unistd_.h" |
24 | | #include "errno_.h" |
25 | | #include "gx.h" |
26 | | #include "gp.h" |
27 | | |
28 | | /* Read bytes from stdin, unbuffered if possible. */ |
29 | | int gp_stdin_read(char *buf, int len, int interactive, FILE *f) |
30 | 0 | { |
31 | 0 | int code; |
32 | | |
33 | | /* Retry if interrupted, bug 706858. */ |
34 | 0 | do { |
35 | 0 | code = read(fileno(f), buf, len); |
36 | 0 | } while (code < 0 && errno == EINTR); |
37 | 0 | return code; |
38 | 0 | } |