33 |
ports} are two interesting and powerful examples of this technique. |
ports} are two interesting and powerful examples of this technique. |
34 |
|
|
35 |
@rnindex input-port? |
@rnindex input-port? |
36 |
@deffn primitive input-port? x |
@deffn {Scheme Procedure} input-port? x |
37 |
|
@deffnx {C Function} scm_input_port_p (x) |
38 |
Return @code{#t} if @var{x} is an input port, otherwise return |
Return @code{#t} if @var{x} is an input port, otherwise return |
39 |
@code{#f}. Any object satisfying this predicate also satisfies |
@code{#f}. Any object satisfying this predicate also satisfies |
40 |
@code{port?}. |
@code{port?}. |
41 |
@end deffn |
@end deffn |
42 |
|
|
43 |
@rnindex output-port? |
@rnindex output-port? |
44 |
@deffn primitive output-port? x |
@deffn {Scheme Procedure} output-port? x |
45 |
|
@deffnx {C Function} scm_output_port_p (x) |
46 |
Return @code{#t} if @var{x} is an output port, otherwise return |
Return @code{#t} if @var{x} is an output port, otherwise return |
47 |
@code{#f}. Any object satisfying this predicate also satisfies |
@code{#f}. Any object satisfying this predicate also satisfies |
48 |
@code{port?}. |
@code{port?}. |
49 |
@end deffn |
@end deffn |
50 |
|
|
51 |
@deffn primitive port? x |
@deffn {Scheme Procedure} port? x |
52 |
|
@deffnx {C Function} scm_port_p (x) |
53 |
Return a boolean indicating whether @var{x} is a port. |
Return a boolean indicating whether @var{x} is a port. |
54 |
Equivalent to @code{(or (input-port? @var{x}) (output-port? |
Equivalent to @code{(or (input-port? @var{x}) (output-port? |
55 |
@var{x}))}. |
@var{x}))}. |
62 |
[Generic procedures for reading from ports.] |
[Generic procedures for reading from ports.] |
63 |
|
|
64 |
@rnindex eof-object? |
@rnindex eof-object? |
65 |
@deffn primitive eof-object? x |
@deffn {Scheme Procedure} eof-object? x |
66 |
|
@deffnx {C Function} scm_eof_object_p (x) |
67 |
Return @code{#t} if @var{x} is an end-of-file object; otherwise |
Return @code{#t} if @var{x} is an end-of-file object; otherwise |
68 |
return @code{#f}. |
return @code{#f}. |
69 |
@end deffn |
@end deffn |
70 |
|
|
71 |
@rnindex char-ready? |
@rnindex char-ready? |
72 |
@deffn primitive char-ready? [port] |
@deffn {Scheme Procedure} char-ready? [port] |
73 |
|
@deffnx {C Function} scm_char_ready_p (port) |
74 |
Return @code{#t} if a character is ready on input @var{port} |
Return @code{#t} if a character is ready on input @var{port} |
75 |
and return @code{#f} otherwise. If @code{char-ready?} returns |
and return @code{#f} otherwise. If @code{char-ready?} returns |
76 |
@code{#t} then the next @code{read-char} operation on |
@code{#t} then the next @code{read-char} operation on |
87 |
@end deffn |
@end deffn |
88 |
|
|
89 |
@rnindex read-char? |
@rnindex read-char? |
90 |
@deffn primitive read-char [port] |
@deffn {Scheme Procedure} read-char [port] |
91 |
|
@deffnx {C Function} scm_read_char (port) |
92 |
Return the next character available from @var{port}, updating |
Return the next character available from @var{port}, updating |
93 |
@var{port} to point to the following character. If no more |
@var{port} to point to the following character. If no more |
94 |
characters are available, the end-of-file object is returned. |
characters are available, the end-of-file object is returned. |
95 |
@end deffn |
@end deffn |
96 |
|
|
97 |
@rnindex peek-char? |
@rnindex peek-char? |
98 |
@deffn primitive peek-char [port] |
@deffn {Scheme Procedure} peek-char [port] |
99 |
|
@deffnx {C Function} scm_peek_char (port) |
100 |
Return the next character available from @var{port}, |
Return the next character available from @var{port}, |
101 |
@emph{without} updating @var{port} to point to the following |
@emph{without} updating @var{port} to point to the following |
102 |
character. If no more characters are available, the |
character. If no more characters are available, the |
111 |
to @code{read-char} would have hung.} |
to @code{read-char} would have hung.} |
112 |
@end deffn |
@end deffn |
113 |
|
|
114 |
@deffn primitive unread-char cobj port |
@deffn {Scheme Procedure} unread-char cobj port |
115 |
Place @var{char} in @var{port} so that it will be read by the |
Place @var{char} in @var{port} so that it will be read by the |
116 |
next read operation. If called multiple times, the unread characters |
next read operation. If called multiple times, the unread characters |
117 |
will be read again in last-in first-out order. If @var{port} is |
will be read again in last-in first-out order. If @var{port} is |
118 |
not supplied, the current input port is used. |
not supplied, the current input port is used. |
119 |
@end deffn |
@end deffn |
120 |
|
|
121 |
@deffn primitive unread-string str port |
@deffn {Scheme Procedure} unread-string str port |
122 |
|
@deffnx {C Function} scm_unread_string (str, port) |
123 |
Place the string @var{str} in @var{port} so that its characters will be |
Place the string @var{str} in @var{port} so that its characters will be |
124 |
read in subsequent read operations. If called multiple times, the |
read in subsequent read operations. If called multiple times, the |
125 |
unread characters will be read again in last-in first-out order. If |
unread characters will be read again in last-in first-out order. If |
126 |
@var{port} is not supplied, the current-input-port is used. |
@var{port} is not supplied, the current-input-port is used. |
127 |
@end deffn |
@end deffn |
128 |
|
|
129 |
@deffn primitive drain-input port |
@deffn {Scheme Procedure} drain-input port |
130 |
|
@deffnx {C Function} scm_drain_input (port) |
131 |
This procedure clears a port's input buffers, similar |
This procedure clears a port's input buffers, similar |
132 |
to the way that force-output clears the output buffer. The |
to the way that force-output clears the output buffer. The |
133 |
contents of the buffers are returned as a single string, e.g., |
contents of the buffers are returned as a single string, e.g., |
144 |
for further input. |
for further input. |
145 |
@end deffn |
@end deffn |
146 |
|
|
147 |
@deffn primitive port-column port |
@deffn {Scheme Procedure} port-column port |
148 |
@deffnx primitive port-line port |
@deffnx {Scheme Procedure} port-line port |
149 |
|
@deffnx {C Function} scm_port_column (port) |
150 |
|
@deffnx {C Function} scm_port_line (port) |
151 |
Return the current column number or line number of @var{port}, |
Return the current column number or line number of @var{port}, |
152 |
using the current input port if none is specified. If the number is |
using the current input port if none is specified. If the number is |
153 |
unknown, the result is #f. Otherwise, the result is a 0-origin integer |
unknown, the result is #f. Otherwise, the result is a 0-origin integer |
158 |
what non-programmers will find most natural.) |
what non-programmers will find most natural.) |
159 |
@end deffn |
@end deffn |
160 |
|
|
161 |
@deffn primitive set-port-column! port column |
@deffn {Scheme Procedure} set-port-column! port column |
162 |
@deffnx primitive set-port-line! port line |
@deffnx {Scheme Procedure} set-port-line! port line |
163 |
|
@deffnx {C Function} scm_set_port_column_x (port, column) |
164 |
|
@deffnx {C Function} scm_set_port_line_x (port, line) |
165 |
Set the current column or line number of @var{port}, using the |
Set the current column or line number of @var{port}, using the |
166 |
current input port if none is specified. |
current input port if none is specified. |
167 |
@end deffn |
@end deffn |
171 |
|
|
172 |
[Generic procedures for writing to ports.] |
[Generic procedures for writing to ports.] |
173 |
|
|
174 |
@deffn primitive get-print-state port |
@deffn {Scheme Procedure} get-print-state port |
175 |
|
@deffnx {C Function} scm_get_print_state (port) |
176 |
Return the print state of the port @var{port}. If @var{port} |
Return the print state of the port @var{port}. If @var{port} |
177 |
has no associated print state, @code{#f} is returned. |
has no associated print state, @code{#f} is returned. |
178 |
@end deffn |
@end deffn |
179 |
|
|
180 |
@rnindex display |
@rnindex display |
181 |
@deffn primitive display obj [port] |
@deffn {Scheme Procedure} display obj [port] |
182 |
Send a representation of @var{obj} to @var{current-output-port}. |
Send a representation of @var{obj} to @var{current-output-port}. |
183 |
Optional second arg @var{port} specifies an alternative output port. |
Optional second arg @var{port} specifies an alternative output port. |
184 |
The representation is similar to that produced by @code{write} (REFFIXME), |
The representation is similar to that produced by @code{write} (REFFIXME), |
187 |
@end deffn |
@end deffn |
188 |
|
|
189 |
@rnindex newline |
@rnindex newline |
190 |
@deffn primitive newline [port] |
@deffn {Scheme Procedure} newline [port] |
191 |
|
@deffnx {C Function} scm_newline (port) |
192 |
Send a newline to @var{port} (default @var{current-output-port} if omitted). |
Send a newline to @var{port} (default @var{current-output-port} if omitted). |
193 |
@end deffn |
@end deffn |
194 |
|
|
195 |
@deffn primitive port-with-print-state port pstate |
@deffn {Scheme Procedure} port-with-print-state port pstate |
196 |
|
@deffnx {C Function} scm_port_with_print_state (port, pstate) |
197 |
Create a new port which behaves like @var{port}, but with an |
Create a new port which behaves like @var{port}, but with an |
198 |
included print state @var{pstate}. |
included print state @var{pstate}. |
199 |
@end deffn |
@end deffn |
200 |
|
|
201 |
@deffn primitive print-options-interface [setting] |
@deffn {Scheme Procedure} print-options-interface [setting] |
202 |
|
@deffnx {C Function} scm_print_options (setting) |
203 |
Option interface for the print options. Instead of using |
Option interface for the print options. Instead of using |
204 |
this procedure directly, use the procedures |
this procedure directly, use the procedures |
205 |
@code{print-enable}, @code{print-disable}, @code{print-set!} |
@code{print-enable}, @code{print-disable}, @code{print-set!} |
206 |
and @code{print-options}. |
and @code{print-options}. |
207 |
@end deffn |
@end deffn |
208 |
|
|
209 |
@deffn primitive simple-format destination message . args |
@deffn {Scheme Procedure} simple-format destination message . args |
210 |
|
@deffnx {C Function} scm_simple_format (destination, message, args) |
211 |
Write @var{message} to @var{destination}, defaulting to |
Write @var{message} to @var{destination}, defaulting to |
212 |
the current output port. |
the current output port. |
213 |
@var{message} can contain @code{~A} (was @code{%s}) and |
@var{message} can contain @code{~A} (was @code{%s}) and |
222 |
@end deffn |
@end deffn |
223 |
|
|
224 |
@rnindex write-char |
@rnindex write-char |
225 |
@deffn primitive write-char chr [port] |
@deffn {Scheme Procedure} write-char chr [port] |
226 |
|
@deffnx {C Function} scm_write_char (chr, port) |
227 |
Send character @var{chr} to @var{port}. |
Send character @var{chr} to @var{port}. |
228 |
@end deffn |
@end deffn |
229 |
|
|
230 |
@findex fflush |
@findex fflush |
231 |
@deffn primitive force-output [port] |
@deffn {Scheme Procedure} force-output [port] |
232 |
|
@deffnx {C Function} scm_force_output (port) |
233 |
Flush the specified output port, or the current output port if @var{port} |
Flush the specified output port, or the current output port if @var{port} |
234 |
is omitted. The current output buffer contents are passed to the |
is omitted. The current output buffer contents are passed to the |
235 |
underlying port implementation (e.g., in the case of fports, the |
underlying port implementation (e.g., in the case of fports, the |
239 |
The return value is unspecified. |
The return value is unspecified. |
240 |
@end deffn |
@end deffn |
241 |
|
|
242 |
@deffn primitive flush-all-ports |
@deffn {Scheme Procedure} flush-all-ports |
243 |
|
@deffnx {C Function} scm_flush_all_ports () |
244 |
Equivalent to calling @code{force-output} on |
Equivalent to calling @code{force-output} on |
245 |
all open output ports. The return value is unspecified. |
all open output ports. The return value is unspecified. |
246 |
@end deffn |
@end deffn |
249 |
@node Closing |
@node Closing |
250 |
@section Closing |
@section Closing |
251 |
|
|
252 |
@deffn primitive close-port port |
@deffn {Scheme Procedure} close-port port |
253 |
|
@deffnx {C Function} scm_close_port (port) |
254 |
Close the specified port object. Return @code{#t} if it |
Close the specified port object. Return @code{#t} if it |
255 |
successfully closes a port or @code{#f} if it was already |
successfully closes a port or @code{#f} if it was already |
256 |
closed. An exception may be raised if an error occurs, for |
closed. An exception may be raised if an error occurs, for |
260 |
@end deffn |
@end deffn |
261 |
|
|
262 |
@rnindex close-input-port |
@rnindex close-input-port |
263 |
@deffn primitive close-input-port port |
@deffn {Scheme Procedure} close-input-port port |
264 |
|
@deffnx {C Function} scm_close_input_port (port) |
265 |
Close the specified input port object. The routine has no effect if |
Close the specified input port object. The routine has no effect if |
266 |
the file has already been closed. An exception may be raised if an |
the file has already been closed. An exception may be raised if an |
267 |
error occurs. The value returned is unspecified. |
error occurs. The value returned is unspecified. |
271 |
@end deffn |
@end deffn |
272 |
|
|
273 |
@rnindex close-output-port |
@rnindex close-output-port |
274 |
@deffn primitive close-output-port port |
@deffn {Scheme Procedure} close-output-port port |
275 |
|
@deffnx {C Function} scm_close_output_port (port) |
276 |
Close the specified output port object. The routine has no effect if |
Close the specified output port object. The routine has no effect if |
277 |
the file has already been closed. An exception may be raised if an |
the file has already been closed. An exception may be raised if an |
278 |
error occurs. The value returned is unspecified. |
error occurs. The value returned is unspecified. |
281 |
which can close file descriptors. |
which can close file descriptors. |
282 |
@end deffn |
@end deffn |
283 |
|
|
284 |
@deffn primitive port-closed? port |
@deffn {Scheme Procedure} port-closed? port |
285 |
|
@deffnx {C Function} scm_port_closed_p (port) |
286 |
Return @code{#t} if @var{port} is closed or @code{#f} if it is |
Return @code{#t} if @var{port} is closed or @code{#f} if it is |
287 |
open. |
open. |
288 |
@end deffn |
@end deffn |
291 |
@node Random Access |
@node Random Access |
292 |
@section Random Access |
@section Random Access |
293 |
|
|
294 |
@deffn primitive seek fd_port offset whence |
@deffn {Scheme Procedure} seek fd_port offset whence |
295 |
|
@deffnx {C Function} scm_seek (fd_port, offset, whence) |
296 |
Sets the current position of @var{fd/port} to the integer |
Sets the current position of @var{fd/port} to the integer |
297 |
@var{offset}, which is interpreted according to the value of |
@var{offset}, which is interpreted according to the value of |
298 |
@var{whence}. |
@var{whence}. |
318 |
@end lisp |
@end lisp |
319 |
@end deffn |
@end deffn |
320 |
|
|
321 |
@deffn primitive ftell fd_port |
@deffn {Scheme Procedure} ftell fd_port |
322 |
|
@deffnx {C Function} scm_ftell (fd_port) |
323 |
Return an integer representing the current position of |
Return an integer representing the current position of |
324 |
@var{fd/port}, measured from the beginning. Equivalent to: |
@var{fd/port}, measured from the beginning. Equivalent to: |
325 |
|
|
330 |
|
|
331 |
@findex truncate |
@findex truncate |
332 |
@findex ftruncate |
@findex ftruncate |
333 |
@deffn primitive truncate-file object [length] |
@deffn {Scheme Procedure} truncate-file object [length] |
334 |
|
@deffnx {C Function} scm_truncate_file (object, length) |
335 |
Truncates the object referred to by @var{object} to at most |
Truncates the object referred to by @var{object} to at most |
336 |
@var{length} bytes. @var{object} can be a string containing a |
@var{length} bytes. @var{object} can be a string containing a |
337 |
file name or an integer file descriptor or a port. |
file name or an integer file descriptor or a port. |
355 |
sets and has an extra procedure @code{write-line}. |
sets and has an extra procedure @code{write-line}. |
356 |
|
|
357 |
@c begin (scm-doc-string "rdelim.scm" "read-line") |
@c begin (scm-doc-string "rdelim.scm" "read-line") |
358 |
@deffn procedure read-line [port] [handle-delim] |
@deffn {Scheme Procedure} read-line [port] [handle-delim] |
359 |
Return a line of text from @var{port} if specified, otherwise from the |
Return a line of text from @var{port} if specified, otherwise from the |
360 |
value returned by @code{(current-input-port)}. Under Unix, a line of text |
value returned by @code{(current-input-port)}. Under Unix, a line of text |
361 |
is terminated by the first end-of-line character or by end-of-file. |
is terminated by the first end-of-line character or by end-of-file. |
378 |
@end deffn |
@end deffn |
379 |
|
|
380 |
@c begin (scm-doc-string "rdelim.scm" "read-line!") |
@c begin (scm-doc-string "rdelim.scm" "read-line!") |
381 |
@deffn procedure read-line! buf [port] |
@deffn {Scheme Procedure} read-line! buf [port] |
382 |
Read a line of text into the supplied string @var{buf} and return the |
Read a line of text into the supplied string @var{buf} and return the |
383 |
number of characters added to @var{buf}. If @var{buf} is filled, then |
number of characters added to @var{buf}. If @var{buf} is filled, then |
384 |
@code{#f} is returned. |
@code{#f} is returned. |
387 |
@end deffn |
@end deffn |
388 |
|
|
389 |
@c begin (scm-doc-string "rdelim.scm" "read-delimited") |
@c begin (scm-doc-string "rdelim.scm" "read-delimited") |
390 |
@deffn procedure read-delimited delims [port] [handle-delim] |
@deffn {Scheme Procedure} read-delimited delims [port] [handle-delim] |
391 |
Read text until one of the characters in the string @var{delims} is found |
Read text until one of the characters in the string @var{delims} is found |
392 |
or end-of-file is reached. Read from @var{port} if supplied, otherwise |
or end-of-file is reached. Read from @var{port} if supplied, otherwise |
393 |
from the value returned by @code{(current-input-port)}. |
from the value returned by @code{(current-input-port)}. |
395 |
@end deffn |
@end deffn |
396 |
|
|
397 |
@c begin (scm-doc-string "rdelim.scm" "read-delimited!") |
@c begin (scm-doc-string "rdelim.scm" "read-delimited!") |
398 |
@deffn procedure read-delimited! delims buf [port] [handle-delim] [start] [end] |
@deffn {Scheme Procedure} read-delimited! delims buf [port] [handle-delim] [start] [end] |
399 |
Read text into the supplied string @var{buf} and return the number of |
Read text into the supplied string @var{buf} and return the number of |
400 |
characters added to @var{buf} (subject to @var{handle-delim}, which takes |
characters added to @var{buf} (subject to @var{handle-delim}, which takes |
401 |
the same values specified for @code{read-line}. If @var{buf} is filled, |
the same values specified for @code{read-line}. If @var{buf} is filled, |
406 |
from the value returned by @code{(current-input-port)}. |
from the value returned by @code{(current-input-port)}. |
407 |
@end deffn |
@end deffn |
408 |
|
|
409 |
@deffn primitive write-line obj [port] |
@deffn {Scheme Procedure} write-line obj [port] |
410 |
|
@deffnx {C Function} scm_write_line (obj, port) |
411 |
Display @var{obj} and a newline character to @var{port}. If |
Display @var{obj} and a newline character to @var{port}. If |
412 |
@var{port} is not specified, @code{(current-output-port)} is |
@var{port} is not specified, @code{(current-output-port)} is |
413 |
used. This function is equivalent to: |
used. This function is equivalent to: |
421 |
primitives. These will mainly be of interest to people hacking Guile |
primitives. These will mainly be of interest to people hacking Guile |
422 |
internals. |
internals. |
423 |
|
|
424 |
@deffn primitive %read-delimited! delims str gobble [port [start [end]]] |
@deffn {Scheme Procedure} %read-delimited! delims str gobble [port [start [end]]] |
425 |
|
@deffnx {C Function} scm_read_delimited_x (delims, str, gobble, port, start, end) |
426 |
Read characters from @var{port} into @var{str} until one of the |
Read characters from @var{port} into @var{str} until one of the |
427 |
characters in the @var{delims} string is encountered. If |
characters in the @var{delims} string is encountered. If |
428 |
@var{gobble} is true, discard the delimiter character; |
@var{gobble} is true, discard the delimiter character; |
440 |
a delimiter, this value is @code{#f}. |
a delimiter, this value is @code{#f}. |
441 |
@end deffn |
@end deffn |
442 |
|
|
443 |
@deffn primitive %read-line [port] |
@deffn {Scheme Procedure} %read-line [port] |
444 |
|
@deffnx {C Function} scm_read_line (port) |
445 |
Read a newline-terminated line from @var{port}, allocating storage as |
Read a newline-terminated line from @var{port}, allocating storage as |
446 |
necessary. The newline terminator (if any) is removed from the string, |
necessary. The newline terminator (if any) is removed from the string, |
447 |
and a pair consisting of the line and its delimiter is returned. The |
and a pair consisting of the line and its delimiter is returned. The |
462 |
It currently contains procedures that help to implement the |
It currently contains procedures that help to implement the |
463 |
@code{(scsh rw)} module in guile-scsh. |
@code{(scsh rw)} module in guile-scsh. |
464 |
|
|
465 |
@deffn primitive read-string!/partial str [port_or_fdes [start [end]]] |
@deffn {Scheme Procedure} read-string!/partial str [port_or_fdes [start [end]]] |
466 |
|
@deffnx {C Function} scm_read_string_x_partial (str, port_or_fdes, start, end) |
467 |
Read characters from a port or file descriptor into a |
Read characters from a port or file descriptor into a |
468 |
string @var{str}. A port must have an underlying file |
string @var{str}. A port must have an underlying file |
469 |
descriptor --- a so-called fport. This procedure is |
descriptor --- a so-called fport. This procedure is |
503 |
@end itemize |
@end itemize |
504 |
@end deffn |
@end deffn |
505 |
|
|
506 |
@deffn primitive write-string/partial str [port_or_fdes start end] |
@deffn {Scheme Procedure} write-string/partial str [port_or_fdes [start [end]]] |
507 |
|
@deffnx {C Function} scm_write_string_partial (str, port_or_fdes, start, end) |
508 |
Write characters from a string @var{str} to a port or file |
Write characters from a string @var{str} to a port or file |
509 |
descriptor. A port must have an underlying file descriptor |
descriptor. A port must have an underlying file descriptor |
510 |
--- a so-called fport. This procedure is |
--- a so-called fport. This procedure is |
552 |
@section Default Ports for Input, Output and Errors |
@section Default Ports for Input, Output and Errors |
553 |
|
|
554 |
@rnindex current-input-port |
@rnindex current-input-port |
555 |
@deffn primitive current-input-port |
@deffn {Scheme Procedure} current-input-port |
556 |
|
@deffnx {C Function} scm_current_input_port () |
557 |
Return the current input port. This is the default port used |
Return the current input port. This is the default port used |
558 |
by many input procedures. Initially, @code{current-input-port} |
by many input procedures. Initially, @code{current-input-port} |
559 |
returns the @dfn{standard input} in Unix and C terminology. |
returns the @dfn{standard input} in Unix and C terminology. |
560 |
@end deffn |
@end deffn |
561 |
|
|
562 |
@rnindex current-output-port |
@rnindex current-output-port |
563 |
@deffn primitive current-output-port |
@deffn {Scheme Procedure} current-output-port |
564 |
|
@deffnx {C Function} scm_current_output_port () |
565 |
Return the current output port. This is the default port used |
Return the current output port. This is the default port used |
566 |
by many output procedures. Initially, |
by many output procedures. Initially, |
567 |
@code{current-output-port} returns the @dfn{standard output} in |
@code{current-output-port} returns the @dfn{standard output} in |
568 |
Unix and C terminology. |
Unix and C terminology. |
569 |
@end deffn |
@end deffn |
570 |
|
|
571 |
@deffn primitive current-error-port |
@deffn {Scheme Procedure} current-error-port |
572 |
|
@deffnx {C Function} scm_current_error_port () |
573 |
Return the port to which errors and warnings should be sent (the |
Return the port to which errors and warnings should be sent (the |
574 |
@dfn{standard error} in Unix and C terminology). |
@dfn{standard error} in Unix and C terminology). |
575 |
@end deffn |
@end deffn |
576 |
|
|
577 |
@deffn primitive set-current-input-port port |
@deffn {Scheme Procedure} set-current-input-port port |
578 |
@deffnx primitive set-current-output-port port |
@deffnx {Scheme Procedure} set-current-output-port port |
579 |
@deffnx primitive set-current-error-port port |
@deffnx {Scheme Procedure} set-current-error-port port |
580 |
|
@deffnx {C Function} scm_set_current_input_port (port) |
581 |
Change the ports returned by @code{current-input-port}, |
Change the ports returned by @code{current-input-port}, |
582 |
@code{current-output-port} and @code{current-error-port}, respectively, |
@code{current-output-port} and @code{current-error-port}, respectively, |
583 |
so that they use the supplied @var{port} for input or output. |
so that they use the supplied @var{port} for input or output. |
584 |
@end deffn |
@end deffn |
585 |
|
|
586 |
@deffn primitive set-current-output-port port |
@deffn {Scheme Procedure} set-current-output-port port |
587 |
Set the current default output port to PORT. |
Set the current default output port to PORT. |
588 |
@end deffn |
@end deffn |
589 |
|
|
590 |
@deffn primitive set-current-error-port port |
@deffn {Scheme Procedure} set-current-error-port port |
591 |
Set the current default error port to PORT. |
Set the current default error port to PORT. |
592 |
@end deffn |
@end deffn |
593 |
|
|
612 |
See also @ref{Ports and File Descriptors, open}, for an interface |
See also @ref{Ports and File Descriptors, open}, for an interface |
613 |
to the Unix @code{open} system call. |
to the Unix @code{open} system call. |
614 |
|
|
615 |
@deffn primitive open-file filename mode |
@deffn {Scheme Procedure} open-file filename mode |
616 |
|
@deffnx {C Function} scm_open_file (filename, mode) |
617 |
Open the file whose name is @var{filename}, and return a port |
Open the file whose name is @var{filename}, and return a port |
618 |
representing that file. The attributes of the port are |
representing that file. The attributes of the port are |
619 |
determined by the @var{mode} string. The way in which this is |
determined by the @var{mode} string. The way in which this is |
654 |
@end deffn |
@end deffn |
655 |
|
|
656 |
@rnindex open-input-file |
@rnindex open-input-file |
657 |
@deffn procedure open-input-file filename |
@deffn {Scheme Procedure} open-input-file filename |
658 |
Open @var{filename} for input. Equivalent to |
Open @var{filename} for input. Equivalent to |
659 |
@smalllisp |
@smalllisp |
660 |
(open-file @var{filename} "r") |
(open-file @var{filename} "r") |
662 |
@end deffn |
@end deffn |
663 |
|
|
664 |
@rnindex open-output-file |
@rnindex open-output-file |
665 |
@deffn procedure open-output-file filename |
@deffn {Scheme Procedure} open-output-file filename |
666 |
Open @var{filename} for output. Equivalent to |
Open @var{filename} for output. Equivalent to |
667 |
@smalllisp |
@smalllisp |
668 |
(open-file @var{filename} "w") |
(open-file @var{filename} "w") |
670 |
@end deffn |
@end deffn |
671 |
|
|
672 |
@rnindex call-with-input-file |
@rnindex call-with-input-file |
673 |
@deffn procedure call-with-input-file file proc |
@deffn {Scheme Procedure} call-with-input-file file proc |
674 |
@var{proc} should be a procedure of one argument, and @var{file} should |
@var{proc} should be a procedure of one argument, and @var{file} should |
675 |
be a string naming a file. The file must already exist. These |
be a string naming a file. The file must already exist. These |
676 |
procedures call @var{proc} with one argument: the port obtained by |
procedures call @var{proc} with one argument: the port obtained by |
683 |
@end deffn |
@end deffn |
684 |
|
|
685 |
@rnindex call-with-output-file |
@rnindex call-with-output-file |
686 |
@deffn procedure call-with-output-file file proc |
@deffn {Scheme Procedure} call-with-output-file file proc |
687 |
@var{proc} should be a procedure of one argument, and @var{file} should |
@var{proc} should be a procedure of one argument, and @var{file} should |
688 |
be a string naming a file. The behaviour is unspecified if the file |
be a string naming a file. The behaviour is unspecified if the file |
689 |
already exists. These procedures call @var{proc} with one argument: the |
already exists. These procedures call @var{proc} with one argument: the |
696 |
@end deffn |
@end deffn |
697 |
|
|
698 |
@rnindex with-input-from-file |
@rnindex with-input-from-file |
699 |
@deffn procedure with-input-from-file file thunk |
@deffn {Scheme Procedure} with-input-from-file file thunk |
700 |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
701 |
a string naming a file. The file must already exist. The file is opened |
a string naming a file. The file must already exist. The file is opened |
702 |
for input, an input port connected to it is made the default value |
for input, an input port connected to it is made the default value |
709 |
@end deffn |
@end deffn |
710 |
|
|
711 |
@rnindex with-output-to-file |
@rnindex with-output-to-file |
712 |
@deffn procedure with-output-to-file file thunk |
@deffn {Scheme Procedure} with-output-to-file file thunk |
713 |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
714 |
a string naming a file. The effect is unspecified if the file already |
a string naming a file. The effect is unspecified if the file already |
715 |
exists. The file is opened for output, an output port connected to it |
exists. The file is opened for output, an output port connected to it |
721 |
is implementation dependent. |
is implementation dependent. |
722 |
@end deffn |
@end deffn |
723 |
|
|
724 |
@deffn procedure with-error-to-file file thunk |
@deffn {Scheme Procedure} with-error-to-file file thunk |
725 |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
@var{thunk} must be a procedure of no arguments, and @var{file} must be |
726 |
a string naming a file. The effect is unspecified if the file already |
a string naming a file. The effect is unspecified if the file already |
727 |
exists. The file is opened for output, an output port connected to it |
exists. The file is opened for output, an output port connected to it |
733 |
implementation dependent. |
implementation dependent. |
734 |
@end deffn |
@end deffn |
735 |
|
|
736 |
@deffn primitive port-mode port |
@deffn {Scheme Procedure} port-mode port |
737 |
Return the port modes associated with the open port @var{port}. These |
@deffnx {C Function} scm_port_mode (port) |
738 |
will not necessarily be identical to the modes used when the port was |
Return the port modes associated with the open port @var{port}. |
739 |
opened, since modes such as "append" which are used only during |
These will not necessarily be identical to the modes used when |
740 |
port creation are not retained. |
the port was opened, since modes such as "append" which are |
741 |
|
used only during port creation are not retained. |
742 |
@end deffn |
@end deffn |
743 |
|
|
744 |
@deffn primitive port-filename port |
@deffn {Scheme Procedure} port-filename port |
745 |
|
@deffnx {C Function} scm_port_filename (port) |
746 |
Return the filename associated with @var{port}. This function returns |
Return the filename associated with @var{port}. This function returns |
747 |
the strings "standard input", "standard output" and "standard error" |
the strings "standard input", "standard output" and "standard error" |
748 |
when called on the current input, output and error ports respectively. |
when called on the current input, output and error ports respectively. |
749 |
@end deffn |
@end deffn |
750 |
|
|
751 |
@deffn primitive set-port-filename! port filename |
@deffn {Scheme Procedure} set-port-filename! port filename |
752 |
|
@deffnx {C Function} scm_set_port_filename_x (port, filename) |
753 |
Change the filename associated with @var{port}, using the current input |
Change the filename associated with @var{port}, using the current input |
754 |
port if none is specified. Note that this does not change the port's |
port if none is specified. Note that this does not change the port's |
755 |
source of data, but only the value that is returned by |
source of data, but only the value that is returned by |
756 |
@code{port-filename} and reported in diagnostic output. |
@code{port-filename} and reported in diagnostic output. |
757 |
@end deffn |
@end deffn |
758 |
|
|
759 |
@deffn primitive file-port? obj |
@deffn {Scheme Procedure} file-port? obj |
760 |
|
@deffnx {C Function} scm_file_port_p (obj) |
761 |
Determine whether @var{obj} is a port that is related to a file. |
Determine whether @var{obj} is a port that is related to a file. |
762 |
@end deffn |
@end deffn |
763 |
|
|
768 |
The following allow string ports to be opened by analogy to R4R* |
The following allow string ports to be opened by analogy to R4R* |
769 |
file port facilities: |
file port facilities: |
770 |
|
|
771 |
@deffn primitive call-with-output-string proc |
@deffn {Scheme Procedure} call-with-output-string proc |
772 |
|
@deffnx {C Function} scm_call_with_output_string (proc) |
773 |
Calls the one-argument procedure @var{proc} with a newly created output |
Calls the one-argument procedure @var{proc} with a newly created output |
774 |
port. When the function returns, the string composed of the characters |
port. When the function returns, the string composed of the characters |
775 |
written into the port is returned. |
written into the port is returned. |
776 |
@end deffn |
@end deffn |
777 |
|
|
778 |
@deffn primitive call-with-input-string string proc |
@deffn {Scheme Procedure} call-with-input-string string proc |
779 |
|
@deffnx {C Function} scm_call_with_input_string (string, proc) |
780 |
Calls the one-argument procedure @var{proc} with a newly |
Calls the one-argument procedure @var{proc} with a newly |
781 |
created input port from which @var{string}'s contents may be |
created input port from which @var{string}'s contents may be |
782 |
read. The value yielded by the @var{proc} is returned. |
read. The value yielded by the @var{proc} is returned. |
783 |
@end deffn |
@end deffn |
784 |
|
|
785 |
@deffn procedure with-output-to-string thunk |
@deffn {Scheme Procedure} with-output-to-string thunk |
786 |
Calls the zero-argument procedure @var{thunk} with the current output |
Calls the zero-argument procedure @var{thunk} with the current output |
787 |
port set temporarily to a new string port. It returns a string |
port set temporarily to a new string port. It returns a string |
788 |
composed of the characters written to the current output. |
composed of the characters written to the current output. |
789 |
@end deffn |
@end deffn |
790 |
|
|
791 |
@deffn procedure with-input-from-string string thunk |
@deffn {Scheme Procedure} with-input-from-string string thunk |
792 |
Calls the zero-argument procedure @var{thunk} with the current input |
Calls the zero-argument procedure @var{thunk} with the current input |
793 |
port set temporarily to a string port opened on the specified |
port set temporarily to a string port opened on the specified |
794 |
@var{string}. The value yielded by @var{thunk} is returned. |
@var{string}. The value yielded by @var{thunk} is returned. |
795 |
@end deffn |
@end deffn |
796 |
|
|
797 |
@deffn primitive open-input-string str |
@deffn {Scheme Procedure} open-input-string str |
798 |
|
@deffnx {C Function} scm_open_input_string (str) |
799 |
Take a string and return an input port that delivers characters |
Take a string and return an input port that delivers characters |
800 |
from the string. The port can be closed by |
from the string. The port can be closed by |
801 |
@code{close-input-port}, though its storage will be reclaimed |
@code{close-input-port}, though its storage will be reclaimed |
802 |
by the garbage collector if it becomes inaccessible. |
by the garbage collector if it becomes inaccessible. |
803 |
@end deffn |
@end deffn |
804 |
|
|
805 |
@deffn primitive open-output-string |
@deffn {Scheme Procedure} open-output-string |
806 |
|
@deffnx {C Function} scm_open_output_string () |
807 |
Return an output port that will accumulate characters for |
Return an output port that will accumulate characters for |
808 |
retrieval by @code{get-output-string}. The port can be closed |
retrieval by @code{get-output-string}. The port can be closed |
809 |
by the procedure @code{close-output-port}, though its storage |
by the procedure @code{close-output-port}, though its storage |
811 |
inaccessible. |
inaccessible. |
812 |
@end deffn |
@end deffn |
813 |
|
|
814 |
@deffn primitive get-output-string port |
@deffn {Scheme Procedure} get-output-string port |
815 |
|
@deffnx {C Function} scm_get_output_string (port) |
816 |
Given an output port created by @code{open-output-string}, |
Given an output port created by @code{open-output-string}, |
817 |
return a string consisting of the characters that have been |
return a string consisting of the characters that have been |
818 |
output to the port so far. |
output to the port so far. |
830 |
A @dfn{soft-port} is a port based on a vector of procedures capable of |
A @dfn{soft-port} is a port based on a vector of procedures capable of |
831 |
accepting or delivering characters. It allows emulation of I/O ports. |
accepting or delivering characters. It allows emulation of I/O ports. |
832 |
|
|
833 |
@deffn primitive make-soft-port pv modes |
@deffn {Scheme Procedure} make-soft-port pv modes |
834 |
|
@deffnx {C Function} scm_make_soft_port (pv, modes) |
835 |
Return a port capable of receiving or delivering characters as |
Return a port capable of receiving or delivering characters as |
836 |
specified by the @var{modes} string (@pxref{File Ports, |
specified by the @var{modes} string (@pxref{File Ports, |
837 |
open-file}). @var{pv} must be a vector of length 5. Its |
open-file}). @var{pv} must be a vector of length 5. Its |
882 |
This kind of port causes any data to be discarded when written to, and |
This kind of port causes any data to be discarded when written to, and |
883 |
always returns the end-of-file object when read from. |
always returns the end-of-file object when read from. |
884 |
|
|
885 |
@deffn primitive %make-void-port mode |
@deffn {Scheme Procedure} %make-void-port mode |
886 |
|
@deffnx {C Function} scm_sys_make_void_port (mode) |
887 |
Create and return a new void port. A void port acts like |
Create and return a new void port. A void port acts like |
888 |
@code{/dev/null}. The @var{mode} argument specifies the input/output |
@file{/dev/null}. The @var{mode} argument |
889 |
modes for this port: see the documentation for @code{open-file} in |
specifies the input/output modes for this port: see the |
890 |
@ref{File Ports}. |
documentation for @code{open-file} in @ref{File Ports}. |
891 |
@end deffn |
@end deffn |
892 |
|
|
893 |
|
|