gp_stdin.c 1.5 KB

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