This library defines a Prolog stream that realises its low-level I/O
with callbacks to Prolog. The library was developed to bind normal
Prolog I/O to Pengines I/O. This type of I/O redirection is probably the
primary use case.
- open_prolog_stream(+Module,
+Mode, -Stream, +Options)
- Create a new stream that implements its I/O by calling predicates in Module.
The called predicates are:
- Module
:
stream_write(+Stream,
+String)
- Called for a
Mode = write
stream if data is available.
String contains the (textual) data that is written to Stream.
The callback is called if the buffer of
Stream overflows, the user calls flush_output(Stream)
or Stream is closed and there is buffered data.
- Module
:
stream_read(+Stream,
-Term)
- Called for a
Mode == read
stream to get new data. On
success the stream extracts text from the provided Term.
Term is typically a string, atom, code or character list. If
term is not one of the above, it is handed to writeq/1.
To signal end-of-file, unify stream with an empty text, e.g., stream_read(Stream, "")
.
- Module
:
stream_close(+Stream)
- Called when the stream is closed. This predicate must succeed. The
callback can be used to cleanup associated resources.
The current implementation only deals with text streams. The stream
uses the wchar_t
encoding. The buffer size must be a
multiple of wchar_t
, i.e., a multiple of four for
portability. The newline mode of the stream is posix
on all platforms, disabling the translation "\n" --> "\r\n"
.
Options | is currently ignored. |
- bug
- Futher versions might require additional callbacks. As we demand all
callbacks to be defined, existing code needs to implement the new
callbacks.
NetBSD Crypt license
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Tom Truscott.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- ?
- add_stream_to_pool/2
- 7
- alarm/3
- alarm/4
- alarm_at/3
- alarm_at/4
- atom_to_memory_file/2
- atom_to_term/3
- 15
- call_with_time_limit/2
- call_with_time_limit/3
- catch/3
- 18
- cgi_get_form/1
- 9.1
- chmod/2
- close/1
- 15
- close_stream_pool/0
- 7
- closelog/0
- copy_directory/2
- copy_file/2
- crypt/2
- 10 10 10
- crypto_password_hash/2
- 10
- current_alarm/4
- delete_directory_and_contents/1
- delete_directory_contents/1
- delete_memory_file/3
- delete_stream_from_pool/1
- directory_file_path/3
- directory_member/3
- dispatch_stream_pool/1
- 7
- dup/2
- ensure_directory/1
- exec/1
- fork/1
- fork_exec/1
- format/2
- 9.1
- format/3
- 15
- free_memory_file/1
- 15
- getegid/1
- geteuid/1
- getgid/1
- getgroups/1
- gethostname/1
- getuid/1
- group_data/3
- group_info/2
- hash_atom/2
- 12
- hmac_sha/4
- host_address/3
- initgroups/2
- insert_memory_file/3
- install_alarm/1
- install_alarm/2
- ip_name/2
- iri_normalized/2
- iri_normalized/3
- is_process/1
- kill/2
- link_file/3
- make_directory_path/1
- md5_hash/3
- memory_file_line_position/4
- memory_file_substring/5
- memory_file_to_atom/2
- memory_file_to_atom/3
- memory_file_to_codes/2
- memory_file_to_codes/3
- memory_file_to_string/2
- memory_file_to_string/3
- negotiate_socks_connection/2
- new_memory_file/1
- on_signal/3
- 18
- open/4
- 15
- open_chars_stream/2
- 15
- open_codes_stream/3
- 15
- open_hash_stream/3
- open_memory_file/3
- 15
- open_memory_file/4
- open_prolog_stream/4
- openlog/3
- pipe/2
- prctl/1
- process_create/3
- process_group_kill/1
- process_group_kill/2
- process_id/1
- process_id/2
- process_kill/1
- process_kill/2
- process_release/1
- process_set_method/1
- process_wait/2
- process_wait/3
- prolog:debug_print_hook/3
- proxy_for_url/3
- relative_file_name/3
- remove_alarm/1
- rewrite_host/3
- rlimit/3
- seek/4
- 15
- set_stream_position/2
- 15
- set_time_file/3
- set_user_and_group/1
- set_user_and_group/2
- setegid/1
- seteuid/1
- setgid/1
- setgroups/1
- setuid/1
- sha_hash/3
- 12
- size_memory_file/2
- size_memory_file/3
- socket_create/2
- stream_hash/2
- stream_pool_main_loop/0
- sub_atom/5
- 15
- sub_string/5
- 15 15
- sysconf/1
- syslog/2
- syslog/3
- tcp_accept/3
- tcp_bind/2
- tcp_close_socket/1
- tcp_connect/2
- tcp_connect/3
- tcp_connect/4
- tcp_fcntl/3
- tcp_getopt/2
- tcp_host_to_address/2
- tcp_listen/2
- tcp_open_socket/2
- tcp_open_socket/3
- tcp_select/3
- tcp_setopt/2
- tcp_socket/1
- term_string/2
- 15
- term_to_atom/2
- 15
- try_proxy/4
- udp_broadcast_close/1
- udp_broadcast_initialize/2
- udp_peer/2
- udp_peer_add/2
- udp_peer_del/2
- udp_receive/4
- udp_send/4
- udp_socket/1
- udp_term_string_hook/3
- udp_unicast_join_hook/3
- uninstall_alarm/1
- unix_domain_socket/1
- uri_authority_components/2
- uri_authority_data/3
- uri_components/2
- uri_data/3
- uri_data/4
- uri_edit/3
- uri_encoded/3
- uri_file_name/2
- uri_iri/2
- uri_is_global/1
- uri_normalized/2
- uri_normalized/3
- uri_normalized_iri/2
- uri_normalized_iri/3
- uri_query_components/2
- uri_resolve/3
- user_data/3
- user_info/2
- uuid/1
- uuid/2
- uuid_property/2
- wait/2
- wait_for_input/3
- 7 7
- writeq/1
- 15
- detach_IO/0
- detach_IO/1