ports-internal.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * ports-internal.h - internal-only declarations for ports.
  3. *
  4. * Copyright (C) 2013 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #ifndef SCM_PORTS_INTERNAL
  22. #define SCM_PORTS_INTERNAL
  23. #include "libguile/_scm.h"
  24. #include "libguile/ports.h"
  25. enum scm_port_encoding_mode {
  26. SCM_PORT_ENCODING_MODE_UTF8,
  27. SCM_PORT_ENCODING_MODE_LATIN1,
  28. SCM_PORT_ENCODING_MODE_ICONV
  29. };
  30. typedef enum scm_port_encoding_mode scm_t_port_encoding_mode;
  31. /* This is a separate object so that only those ports that use iconv
  32. cause finalizers to be registered. */
  33. struct scm_iconv_descriptors
  34. {
  35. /* input/output iconv conversion descriptors */
  36. void *input_cd;
  37. void *output_cd;
  38. };
  39. typedef struct scm_iconv_descriptors scm_t_iconv_descriptors;
  40. struct scm_port_internal
  41. {
  42. unsigned at_stream_start_for_bom_read : 1;
  43. unsigned at_stream_start_for_bom_write : 1;
  44. scm_t_port_encoding_mode encoding_mode;
  45. scm_t_iconv_descriptors *iconv_descriptors;
  46. int pending_eof;
  47. SCM alist;
  48. };
  49. typedef struct scm_port_internal scm_t_port_internal;
  50. #define SCM_UNICODE_BOM 0xFEFFUL /* Unicode byte-order mark */
  51. #define SCM_PORT_GET_INTERNAL(x) (SCM_PTAB_ENTRY(x)->internal)
  52. SCM_INTERNAL scm_t_iconv_descriptors *
  53. scm_i_port_iconv_descriptors (SCM port, scm_t_port_rw_active mode);
  54. #endif