- Documentation
- Reference manual
- Packages
SIO_NL_DETECT
- This mode may be enabled on an input stream. It causes the stream to read up to the first newline to set the newline mode accordingly.
SIO_NL_POSIX
- Do not do any translation on input or output.
SIO_NL_DOS
- Emit a newline (
\n
) as\r\n
. Discard\r
from the input.237The current implementation does not check that the character is followed by
n.\
12.9.7 Foreign stream position information
The IOSTREAM
has a field position
that
points at a structure of type IOPOS
. This structure is
defined as below.
typedef struct io_position { int64_t byteno; /* byte-position in file */ int64_t charno; /* character position in file */ int lineno; /* lineno in file */ int linepos; /* position in line */ intptr_t reserved[2]; /* future extensions */ } IOPOS;
If a stream is created using the flag SIO_RECORDPOS
the
IO functions maintain the position information. Note that, supporting
the ISO stream position data (see stream_property/2),
both the byte and character position is maintained. These may differ if
the stream uses a multibyte encoding.
The linepos
is updated as follows: \n
and \r
reset the position to 0 (zero). The backspace (\b
)
decrements the position if it is positive. The tab (\t
)
tabs to the next multiple of 8. Any other character increments the line
position by one. Future versions may change that, notably the tab width
might no longer be hard coded.
12.9.8 Support functions for blob save/load
The functions in this sections are intended to support blobs
to define save() and load() functions so they can be part of a saved
state or .qlf
file. The matching pair of functions is
guaranteed to give the same result, regardless of byte ordering (big or
little endian). The user must not make any assumptions on the exact data
format used for storing the data. The atom read/write functions can only
be used from the blob callback functions.
For saving an uninterpreted array of bytes, it is suggested that the
length is output as a size_t
value using PL_qlf_put_uint32()
followed by the bytes using Sfwrite();
and for loading, the length is read using PL_qlf_get_uint32(),
a buffer is allocated, and the bytes are read using Sfread().
- int PL_qlf_put_int64(int64_t i, IOSTREAM *s)
- int PL_qlf_put_int32(int32_t i, IOSTREAM *s)
- int PL_qlf_put_uint32(uint32 i, IOSTREAM *s)
- Write integers of several sizes. Signed integers are written in zigzag encoding. For unsigned integers we only write the non-zero bytes. The result is compact and the same for big or little endian.
- int PL_qlf_put_double(double f, IOSTREAM *s)
- Write double as 8 byte big endian.
- int PL_qlf_put_atom(atom_t a, IOSTREAM *s)
- Write an atom. The atom may be a blob. Note that this function may only be used from a blob save() function. Calling from another context results in a fatal error.
- int PL_qlf_get_int64(IOSTREAM *s, int64_t *ip)
- int PL_qlf_get_int32(IOSTREAM *s, int32_t *ip)
- int PL_qlf_get_uint32(IOSTREAM *s, uint32_t *ip)
- int PL_qlf_get_double(IOSTREAM *s, double *fp)
- Counterparts of corresponding PL_qlf_put_*() functions.
- int PL_qlf_get_atom(IOSTREAM *s, atom_t *ap)
- Counterpart of PL_qlf_put_atom(). Again, this may only be used in the context of a blob load() function.