gxclio.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* Copyright (C) 1995, 1997, 1998 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gxclio.h,v 1.5 2002/06/16 08:45:43 lpd Exp $ */
  14. /* I/O interface for command lists */
  15. #ifndef gxclio_INCLUDED
  16. # define gxclio_INCLUDED
  17. #include "gp.h" /* for gp_file_name_sizeof */
  18. /*
  19. * There are two implementations of the I/O interface for command lists --
  20. * one suitable for embedded systems, which stores the "files" in RAM, and
  21. * one suitable for other systems, which uses an external file system --
  22. * with the choice made at compile/link time. This header file defines the
  23. * API between the command list code proper and its I/O interface.
  24. */
  25. typedef void *clist_file_ptr; /* We can't do any better than this. */
  26. /* ---------------- Open/close/unlink ---------------- */
  27. /*
  28. * If *fname = 0, generate and store a new scratch file name; otherwise,
  29. * open an existing file. Only modes "r" and "w+" are supported,
  30. * and only binary data (but the caller must append the "b" if needed).
  31. * Mode "r" with *fname = 0 is an error.
  32. */
  33. int clist_fopen(char fname[gp_file_name_sizeof], const char *fmode,
  34. clist_file_ptr * pcf,
  35. gs_memory_t * mem, gs_memory_t *data_mem,
  36. bool ok_to_compress);
  37. /*
  38. * Close a file, optionally deleting it.
  39. */
  40. int clist_fclose(clist_file_ptr cf, const char *fname, bool delete);
  41. /*
  42. * Delete a file.
  43. */
  44. int clist_unlink(const char *fname);
  45. /* ---------------- Writing ---------------- */
  46. /* clist_space_available returns min(requested, available). */
  47. long clist_space_available(long requested);
  48. int clist_fwrite_chars(const void *data, uint len, clist_file_ptr cf);
  49. /* ---------------- Reading ---------------- */
  50. int clist_fread_chars(void *data, uint len, clist_file_ptr cf);
  51. /* ---------------- Position/status ---------------- */
  52. /*
  53. * Set the low-memory warning threshold. clist_ferror_code will return 1
  54. * if fewer than this many bytes of memory are left for storing band data.
  55. */
  56. int clist_set_memory_warning(clist_file_ptr cf, int bytes_left);
  57. /*
  58. * clist_ferror_code returns a negative error code per gserrors.h, not a
  59. * Boolean; 0 means no error, 1 means low-memory warning.
  60. */
  61. int clist_ferror_code(clist_file_ptr cf);
  62. long clist_ftell(clist_file_ptr cf);
  63. /*
  64. * We pass the file name to clist_rewind and clist_fseek in case the
  65. * implementation has to close and reopen the file. (clist_fseek with
  66. * offset = 0 and mode = SEEK_END indicates we are about to append.)
  67. */
  68. void clist_rewind(clist_file_ptr cf, bool discard_data, const char *fname);
  69. int clist_fseek(clist_file_ptr cf, long offset, int mode, const char *fname);
  70. #endif /* gxclio_INCLUDED */