build: Don't include <config.h> in native programs when cross-compiling.
[bpt/guile.git] / libguile / ports-internal.h
CommitLineData
e4598559
MW
1/*
2 * ports-internal.h - internal-only declarations for ports.
3 *
122f24cc 4 * Copyright (C) 2013, 2014 Free Software Foundation, Inc.
e4598559
MW
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
22#ifndef SCM_PORTS_INTERNAL
23#define SCM_PORTS_INTERNAL
24
25#include "libguile/_scm.h"
26#include "libguile/ports.h"
27
337edc59
MW
28enum scm_port_encoding_mode {
29 SCM_PORT_ENCODING_MODE_UTF8,
30 SCM_PORT_ENCODING_MODE_ICONV
31};
32
33typedef enum scm_port_encoding_mode scm_t_port_encoding_mode;
34
35/* This is a separate object so that only those ports that use iconv
36 cause finalizers to be registered (FIXME: although currently in 2.0
37 finalizers are always registered for ports anyway). */
38struct scm_iconv_descriptors
e4598559
MW
39{
40 /* input/output iconv conversion descriptors */
41 void *input_cd;
42 void *output_cd;
43};
44
337edc59
MW
45typedef struct scm_iconv_descriptors scm_t_iconv_descriptors;
46
47struct scm_port_internal
48{
cdd3d6c9
MW
49 unsigned at_stream_start_for_bom_read : 1;
50 unsigned at_stream_start_for_bom_write : 1;
337edc59
MW
51 scm_t_port_encoding_mode encoding_mode;
52 scm_t_iconv_descriptors *iconv_descriptors;
122f24cc
LC
53 unsigned char pending_eof: 1;
54
55 /* When non-NULL, this is the method called by 'setvbuf' for this port.
56 It must create read and write buffers for PORT with the specified
57 sizes (a size of 0 is for unbuffered ports, which should use the
58 'shortbuf' field.) Size -1 means to use the port's preferred buffer
59 size. */
60 /* XXX: In 2.2 make this a property of the 'scm_t_ptob_descriptor'. */
61 void (*setvbuf) (SCM port, long read_size, long write_size);
62
63 /* Key-value properties. */
05d7f762 64 SCM alist;
337edc59
MW
65};
66
e4598559
MW
67typedef struct scm_port_internal scm_t_port_internal;
68
cdd3d6c9
MW
69#define SCM_UNICODE_BOM 0xFEFFUL /* Unicode byte-order mark */
70
e4598559
MW
71#define SCM_PORT_GET_INTERNAL(x) \
72 ((scm_t_port_internal *) (SCM_PTAB_ENTRY(x)->input_cd))
73
cdd3d6c9
MW
74SCM_INTERNAL scm_t_iconv_descriptors *
75scm_i_port_iconv_descriptors (SCM port, scm_t_port_rw_active mode);
337edc59 76
e4598559 77#endif