111 lines
6 KiB
HTML
111 lines
6 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<!-- This manual documents Guile version 3.0.10.
|
||
|
|
||
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
||
|
Inc.
|
||
|
|
||
|
Copyright (C) 2021 Maxime Devos
|
||
|
|
||
|
Copyright (C) 2024 Tomas Volf
|
||
|
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with no
|
||
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
||
|
copy of the license is included in the section entitled "GNU Free
|
||
|
Documentation License." -->
|
||
|
<title>Bytevector Ports (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="Bytevector Ports (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="Bytevector Ports (Guile Reference Manual)">
|
||
|
<meta name="resource-type" content="document">
|
||
|
<meta name="distribution" content="global">
|
||
|
<meta name="Generator" content=".texi2any-real">
|
||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
|
|
||
|
<link href="index.html" rel="start" title="Top">
|
||
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
||
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
||
|
<link href="Port-Types.html" rel="up" title="Port Types">
|
||
|
<link href="String-Ports.html" rel="next" title="String Ports">
|
||
|
<link href="File-Ports.html" rel="prev" title="File Ports">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
span:hover a.copiable-link {visibility: visible}
|
||
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
||
|
-->
|
||
|
</style>
|
||
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
||
|
|
||
|
|
||
|
</head>
|
||
|
|
||
|
<body lang="en">
|
||
|
<div class="subsubsection-level-extent" id="Bytevector-Ports">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="String-Ports.html" accesskey="n" rel="next">String Ports</a>, Previous: <a href="File-Ports.html" accesskey="p" rel="prev">File Ports</a>, Up: <a href="Port-Types.html" accesskey="u" rel="up">Types of Port</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<h4 class="subsubsection" id="Bytevector-Ports-1"><span>6.12.10.2 Bytevector Ports<a class="copiable-link" href="#Bytevector-Ports-1"> ¶</a></span></h4>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-open_002dbytevector_002dinput_002dport"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">open-bytevector-input-port</strong> <var class="def-var-arguments">bv [transcoder]</var><a class="copiable-link" href="#index-open_002dbytevector_002dinput_002dport"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fopen_005fbytevector_005finput_005fport"><span class="category-def">C Function: </span><span><strong class="def-name">scm_open_bytevector_input_port</strong> <var class="def-var-arguments">(bv, transcoder)</var><a class="copiable-link" href="#index-scm_005fopen_005fbytevector_005finput_005fport"> ¶</a></span></dt>
|
||
|
<dd><p>Return an input port whose contents are drawn from bytevector <var class="var">bv</var>
|
||
|
(see <a class="pxref" href="Bytevectors.html">Bytevectors</a>).
|
||
|
</p>
|
||
|
<p>The <var class="var">transcoder</var> argument is currently not supported.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-open_002dbytevector_002doutput_002dport"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">open-bytevector-output-port</strong> <var class="def-var-arguments">[transcoder]</var><a class="copiable-link" href="#index-open_002dbytevector_002doutput_002dport"> ¶</a></span></dt>
|
||
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fopen_005fbytevector_005foutput_005fport"><span class="category-def">C Function: </span><span><strong class="def-name">scm_open_bytevector_output_port</strong> <var class="def-var-arguments">(transcoder)</var><a class="copiable-link" href="#index-scm_005fopen_005fbytevector_005foutput_005fport"> ¶</a></span></dt>
|
||
|
<dd><p>Return two values: a binary output port and a procedure. The latter
|
||
|
should be called with zero arguments to obtain a bytevector containing
|
||
|
the data accumulated by the port, as illustrated below.
|
||
|
</p>
|
||
|
<div class="example lisp">
|
||
|
<pre class="lisp-preformatted">(call-with-values
|
||
|
(lambda ()
|
||
|
(open-bytevector-output-port))
|
||
|
(lambda (port get-bytevector)
|
||
|
(display "hello" port)
|
||
|
(get-bytevector)))
|
||
|
|
||
|
⇒ #vu8(104 101 108 108 111)
|
||
|
</pre></div>
|
||
|
|
||
|
<p>The <var class="var">transcoder</var> argument is currently not supported.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-call_002dwith_002doutput_002dbytevector"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">call-with-output-bytevector</strong> <var class="def-var-arguments">proc</var><a class="copiable-link" href="#index-call_002dwith_002doutput_002dbytevector"> ¶</a></span></dt>
|
||
|
<dd><p>Call the one-argument procedure <var class="var">proc</var> with a newly created
|
||
|
bytevector output port. When the function returns, the bytevector
|
||
|
composed of the characters written into the port is returned.
|
||
|
<var class="var">proc</var> should not close the port.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
<dl class="first-deffn">
|
||
|
<dt class="deffn" id="index-call_002dwith_002dinput_002dbytevector"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">call-with-input-bytevector</strong> <var class="def-var-arguments">bytevector proc</var><a class="copiable-link" href="#index-call_002dwith_002dinput_002dbytevector"> ¶</a></span></dt>
|
||
|
<dd><p>Call the one-argument procedure <var class="var">proc</var> with a newly created input
|
||
|
port from which <var class="var">bytevector</var>’s contents may be read. The values
|
||
|
yielded by the <var class="var">proc</var> is returned.
|
||
|
</p></dd></dl>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|