gxclio.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 1995, 1997, 1998 Aladdin Enterprises. 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: gxclio.h,v 1.2 2000/09/19 19:00:34 lpd Exp $ */
  16. /* I/O interface for command lists */
  17. #ifndef gxclio_INCLUDED
  18. # define gxclio_INCLUDED
  19. #include "gp.h" /* for gp_file_name_sizeof */
  20. /*
  21. * There are two implementations of the I/O interface for command lists --
  22. * one suitable for embedded systems, which stores the "files" in RAM, and
  23. * one suitable for other systems, which uses an external file system --
  24. * with the choice made at compile/link time. This header file defines the
  25. * API between the command list code proper and its I/O interface.
  26. */
  27. typedef void *clist_file_ptr; /* We can't do any better than this. */
  28. /* ---------------- Open/close/unlink ---------------- */
  29. /*
  30. * If *fname = 0, generate and store a new scratch file name; otherwise,
  31. * open an existing file. Only modes "r" and "w+" are supported,
  32. * and only binary data (but the caller must append the "b" if needed).
  33. * Mode "r" with *fname = 0 is an error.
  34. */
  35. int clist_fopen(P6(char fname[gp_file_name_sizeof], const char *fmode,
  36. clist_file_ptr * pcf,
  37. gs_memory_t * mem, gs_memory_t *data_mem,
  38. bool ok_to_compress));
  39. /*
  40. * Close a file, optionally deleting it.
  41. */
  42. int clist_fclose(P3(clist_file_ptr cf, const char *fname, bool delete));
  43. /*
  44. * Delete a file.
  45. */
  46. int clist_unlink(P1(const char *fname));
  47. /* ---------------- Writing ---------------- */
  48. /* clist_space_available returns min(requested, available). */
  49. long clist_space_available(P1(long requested));
  50. int clist_fwrite_chars(P3(const void *data, uint len, clist_file_ptr cf));
  51. /* ---------------- Reading ---------------- */
  52. int clist_fread_chars(P3(void *data, uint len, clist_file_ptr cf));
  53. /* ---------------- Position/status ---------------- */
  54. /*
  55. * Set the low-memory warning threshold. clist_ferror_code will return 1
  56. * if fewer than this many bytes of memory are left for storing band data.
  57. */
  58. int clist_set_memory_warning(P2(clist_file_ptr cf, int bytes_left));
  59. /*
  60. * clist_ferror_code returns a negative error code per gserrors.h, not a
  61. * Boolean; 0 means no error, 1 means low-memory warning.
  62. */
  63. int clist_ferror_code(P1(clist_file_ptr cf));
  64. long clist_ftell(P1(clist_file_ptr cf));
  65. /*
  66. * We pass the file name to clist_rewind and clist_fseek in case the
  67. * implementation has to close and reopen the file. (clist_fseek with
  68. * offset = 0 and mode = SEEK_END indicates we are about to append.)
  69. */
  70. void clist_rewind(P3(clist_file_ptr cf, bool discard_data,
  71. const char *fname));
  72. int clist_fseek(P4(clist_file_ptr cf, long offset, int mode,
  73. const char *fname));
  74. #endif /* gxclio_INCLUDED */