1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1995-1996 Sun Microsystems, Inc.
|
3 |
|
|
'\"
|
4 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
5 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
6 |
|
|
'\"
|
7 |
|
|
'\" RCS: @(#) $Id: fconfigure.n,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
|
8 |
|
|
'\"
|
9 |
|
|
.so man.macros
|
10 |
|
|
.TH fconfigure n 7.5 Tcl "Tcl Built-In Commands"
|
11 |
|
|
.BS
|
12 |
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
13 |
|
|
.SH NAME
|
14 |
|
|
fconfigure \- Set and get options on a channel
|
15 |
|
|
.SH SYNOPSIS
|
16 |
|
|
.nf
|
17 |
|
|
\fBfconfigure \fIchannelId\fR
|
18 |
|
|
\fBfconfigure \fIchannelId\fR \fIname\fR
|
19 |
|
|
\fBfconfigure \fIchannelId\fR \fIname value \fR?\fIname value ...\fR?
|
20 |
|
|
.fi
|
21 |
|
|
.BE
|
22 |
|
|
|
23 |
|
|
.SH DESCRIPTION
|
24 |
|
|
.PP
|
25 |
|
|
The \fBfconfigure\fR command sets and retrieves options for channels.
|
26 |
|
|
\fIChannelId\fR identifies the channel for which to set or query an option.
|
27 |
|
|
If no \fIname\fR or \fIvalue\fR arguments are supplied, the command
|
28 |
|
|
returns a list containing alternating option names and values for the channel.
|
29 |
|
|
If \fIname\fR is supplied but no \fIvalue\fR then the command returns
|
30 |
|
|
the current value of the given option.
|
31 |
|
|
If one or more pairs of \fIname\fR and \fIvalue\fR are supplied, the
|
32 |
|
|
command sets each of the named options to the corresponding \fIvalue\fR;
|
33 |
|
|
in this case the return value is an empty string.
|
34 |
|
|
.PP
|
35 |
|
|
The options described below are supported for all channels. In addition,
|
36 |
|
|
each channel type may add options that only it supports. See the manual
|
37 |
|
|
entry for the command that creates each type of channels for the options
|
38 |
|
|
that that specific type of channel supports. For example, see the manual
|
39 |
|
|
entry for the \fBsocket\fR command for its additional options.
|
40 |
|
|
.TP
|
41 |
|
|
\fB\-blocking\fR \fIboolean\fR
|
42 |
|
|
The \fB\-blocking\fR option determines whether I/O operations on the
|
43 |
|
|
channel can cause the process to block indefinitely.
|
44 |
|
|
The value of the option must be a proper boolean value.
|
45 |
|
|
Channels are normally in blocking mode; if a channel is placed into
|
46 |
|
|
nonblocking mode it will affect the operation of the \fBgets\fR,
|
47 |
|
|
\fBread\fR, \fBputs\fR, \fBflush\fR, and \fBclose\fR commands;
|
48 |
|
|
see the documentation for those commands for details.
|
49 |
|
|
For nonblocking mode to work correctly, the application must be
|
50 |
|
|
using the Tcl event loop (e.g. by calling \fBTcl_DoOneEvent\fR or
|
51 |
|
|
invoking the \fBvwait\fR command).
|
52 |
|
|
.TP
|
53 |
|
|
\fB\-buffering\fR \fInewValue\fR
|
54 |
|
|
If \fInewValue\fR is \fBfull\fR then the I/O system will buffer output
|
55 |
|
|
until its internal buffer is full or until the \fBflush\fR command is
|
56 |
|
|
invoked. If \fInewValue\fR is \fBline\fR, then the I/O system will
|
57 |
|
|
automatically flush output for the channel whenever a newline character
|
58 |
|
|
is output. If \fInewValue\fR is \fBnone\fR, the I/O system will flush
|
59 |
|
|
automatically after every output operation.
|
60 |
|
|
The default is for \fB\-buffering\fR to be set to \fBfull\fR except for
|
61 |
|
|
channels that connect to terminal-like devices; for these channels the
|
62 |
|
|
initial setting is \fBline\fR.
|
63 |
|
|
.TP
|
64 |
|
|
\fB\-buffersize\fR \fInewSize\fR
|
65 |
|
|
\fINewvalue\fR must be an integer; its value is used to set the size of
|
66 |
|
|
buffers, in bytes, subsequently allocated for this channel to store input
|
67 |
|
|
or output. \fINewvalue\fR must be between ten and one million, allowing
|
68 |
|
|
buffers of ten to one million bytes in size.
|
69 |
|
|
.TP
|
70 |
|
|
\fB\-eofchar\fR \fIchar\fR
|
71 |
|
|
.TP
|
72 |
|
|
\fB\-eofchar\fR \fB{\fIinChar outChar\fB}\fR
|
73 |
|
|
This option supports DOS file systems that use Control-z (\ex1a) as
|
74 |
|
|
an end of file marker.
|
75 |
|
|
If \fIchar\fR is not an empty string, then this character signals
|
76 |
|
|
end of file when it is encountered during input.
|
77 |
|
|
For output, the end of file character is output when
|
78 |
|
|
the channel is closed.
|
79 |
|
|
If \fIchar\fR is the empty string, then there is no special
|
80 |
|
|
end of file character marker.
|
81 |
|
|
For read-write channels, a two-element list specifies
|
82 |
|
|
the end of file marker for input and output, respectively.
|
83 |
|
|
As a convenience, when setting the end-of-file character
|
84 |
|
|
for a read-write channel
|
85 |
|
|
you can specify a single value that will apply to both reading and writing.
|
86 |
|
|
When querying the end-of-file character of a read-write channel,
|
87 |
|
|
a two-element list will always be returned.
|
88 |
|
|
The default value for \fB\-eofchar\fR is the empty string in all
|
89 |
|
|
cases except for files under Windows. In that case the \fB\-eofchar\fR
|
90 |
|
|
is Control-z (\ex1a) for reading and the empty string for writing.
|
91 |
|
|
.TP
|
92 |
|
|
\fB\-translation\fR \fImode\fR
|
93 |
|
|
.TP
|
94 |
|
|
\fB\-translation\fR \fB{\fIinMode outMode\fB}\fR
|
95 |
|
|
In Tcl scripts the end of a line is always represented using a
|
96 |
|
|
single newline character (\en).
|
97 |
|
|
However, in actual files and devices the end of a line may be
|
98 |
|
|
represented differently on different platforms, or even for
|
99 |
|
|
different devices on the same platform. For example, under UNIX
|
100 |
|
|
newlines are used in files, whereas carriage-return-linefeed
|
101 |
|
|
sequences are normally used in network connections.
|
102 |
|
|
On input (i.e., with \fBgets\fP and \fBread\fP)
|
103 |
|
|
the Tcl I/O system automatically translates the external end-of-line
|
104 |
|
|
representation into newline characters.
|
105 |
|
|
Upon output (i.e., with \fBputs\fP),
|
106 |
|
|
the I/O system translates newlines to the external
|
107 |
|
|
end-of-line representation.
|
108 |
|
|
The default translation mode, \fBauto\fP, handles all the common
|
109 |
|
|
cases automatically, but the \fB\-translation\fR option provides
|
110 |
|
|
explicit control over the end of line translations.
|
111 |
|
|
.RS
|
112 |
|
|
.PP
|
113 |
|
|
The value associated with \fB\-translation\fR is a single item for
|
114 |
|
|
read-only and write-only channels.
|
115 |
|
|
The value is a two-element list for read-write channels;
|
116 |
|
|
the read translation mode is the first element of the list,
|
117 |
|
|
and the write translation mode is the second element.
|
118 |
|
|
As a convenience, when setting the translation mode for a read-write channel
|
119 |
|
|
you can specify a single value that will apply to both reading and writing.
|
120 |
|
|
When querying the translation mode of a read-write channel,
|
121 |
|
|
a two-element list will always be returned.
|
122 |
|
|
The following values are currently supported:
|
123 |
|
|
.TP
|
124 |
|
|
\fBauto\fR
|
125 |
|
|
As the input translation mode, \fBauto\fR treats any of newline (\fBlf\fP),
|
126 |
|
|
carriage return (\fBcr\fP), or carriage return followed by a newline (\fBcrlf\fP)
|
127 |
|
|
as the end of line representation. The end of line representation can
|
128 |
|
|
even change from line-to-line, and all cases are translated to a newline.
|
129 |
|
|
As the output translation mode, \fBauto\fR chooses a platform specific
|
130 |
|
|
representation; for sockets on all platforms Tcl
|
131 |
|
|
chooses \fBcrlf\fR, for all Unix flavors, it chooses \fBlf\fR, for the
|
132 |
|
|
Macintosh platform it chooses \fBcr\fR and for the various flavors of
|
133 |
|
|
Windows it chooses \fBcrlf\fR.
|
134 |
|
|
The default setting for \fB\-translation\fR is \fBauto\fR for both
|
135 |
|
|
input and output.
|
136 |
|
|
.TP
|
137 |
|
|
\fBbinary\fR
|
138 |
|
|
No end-of-line translations are performed. This is nearly identical to
|
139 |
|
|
\fBlf\fP mode, except that in addition \fBbinary\fP mode also sets the
|
140 |
|
|
end of file character to the empty string, which disables it.
|
141 |
|
|
See the description of
|
142 |
|
|
\fB\-eofchar\fP for more information.
|
143 |
|
|
.TP
|
144 |
|
|
\fBcr\fR
|
145 |
|
|
The end of a line in the underlying file or device is represented
|
146 |
|
|
by a single carriage return character.
|
147 |
|
|
As the input translation mode, \fBcr\fP mode converts carriage returns
|
148 |
|
|
to newline characters.
|
149 |
|
|
As the output translation mode, \fBcr\fP mode
|
150 |
|
|
translates newline characters to carriage returns.
|
151 |
|
|
This mode is typically used on Macintosh platforms.
|
152 |
|
|
.TP
|
153 |
|
|
\fBcrlf\fR
|
154 |
|
|
The end of a line in the underlying file or device is represented
|
155 |
|
|
by a carriage return character followed by a linefeed character.
|
156 |
|
|
As the input translation mode, \fBcrlf\fP mode converts
|
157 |
|
|
carriage-return-linefeed sequences
|
158 |
|
|
to newline characters.
|
159 |
|
|
As the output translation mode, \fBcrlf\fP mode
|
160 |
|
|
translates newline characters to
|
161 |
|
|
carriage-return-linefeed sequences.
|
162 |
|
|
This mode is typically used on Windows platforms and for network
|
163 |
|
|
connections.
|
164 |
|
|
.TP
|
165 |
|
|
\fBlf\fR
|
166 |
|
|
The end of a line in the underlying file or device is represented
|
167 |
|
|
by a single newline (linefeed) character.
|
168 |
|
|
In this mode no translations occur during either input or output.
|
169 |
|
|
This mode is typically used on UNIX platforms.
|
170 |
|
|
.RE
|
171 |
|
|
.PP
|
172 |
|
|
|
173 |
|
|
.SH "SEE ALSO"
|
174 |
|
|
close(n), flush(n), gets(n), puts(n), read(n), socket(n)
|
175 |
|
|
|
176 |
|
|
.SH KEYWORDS
|
177 |
|
|
blocking, buffering, carriage return, end of line, flushing, linemode,
|
178 |
|
|
newline, nonblocking, platform, translation
|