aboutsummaryrefslogtreecommitdiffstats
path: root/doc/gawktexi.in
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gawktexi.in')
-rw-r--r--doc/gawktexi.in99
1 files changed, 56 insertions, 43 deletions
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index eda9fc9d..7aa427aa 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -7715,7 +7715,7 @@ it encounters the end of the file. If there is some error in getting
a record, such as a file that cannot be opened, then @code{getline}
returns @minus{}1. In this case, @command{gawk} sets the variable
@code{ERRNO} to a string describing the error that occurred.
-If the @code{errno} variable indicates that the I/O operation may be
+If @code{ERRNO} indicates that the I/O operation may be
retried, and @code{PROCINFO["input", "RETRY"]} is set, then @minus{}2
will be returned instead of @minus{}1, and further calls to @code{getline}
may be attemped. @DBXREF{Retrying Input} for further information about
@@ -8393,26 +8393,26 @@ indefinitely until some other process opens it for writing.
@cindex differences in @command{awk} and @command{gawk}, retrying input
This @value{SECTION} describes a feature that is specific to @command{gawk}.
-When @command{gawk} encounters an error while reading input, it will by default
-return @minus{}1 from getline, and subsequent attempts to read from that file
-will result in an end-of-file indication. However, you may optionally instruct
-@command{gawk} to allow I/O to be retried when certain errors are encountered
-by setting setting a special element
-in the @code{PROCINFO} array (@pxref{Auto-set}):
+When @command{gawk} encounters an error while reading input, by
+default @code{getline} returns @minus{}1, and subsequent attempts to
+read from that file result in an end-of-file indication. However, you
+may optionally instruct @command{gawk} to allow I/O to be retried when
+certain errors are encountered by setting setting a special element in
+the @code{PROCINFO} array (@pxref{Auto-set}):
@example
-PROCINFO["input_name", "RETRY"]
+PROCINFO["@var{input_name}", "RETRY"] = 1
@end example
-When set, this causes @command{gawk} to check the value of the system
+When this element exists, @command{gawk} checks the value of the system
@code{errno} variable when an I/O error occurs. If @code{errno} indicates
-a subsequent I/O attempt may succeed, @code{getline} will instead return
+a subsequent I/O attempt may succeed, @code{getline} instead returns
@minus{}2 and
further calls to @code{getline} may succeed. This applies to @code{errno}
-values EAGAIN, EWOULDBLOCK, EINTR, or ETIMEDOUT.
+values @code{EAGAIN}, @code{EWOULDBLOCK}, @code{EINTR}, or @code{ETIMEDOUT}.
This feature is useful in conjunction with
-@code{PROCINFO["input_name", "READ_TIMEOUT"]} or situations where a file
+@code{PROCINFO["@var{input_name}", "READ_TIMEOUT"]} or situations where a file
descriptor has been configured to behave in a non-blocking fashion.
@node Command-line directories
@@ -32776,45 +32776,58 @@ The following function allows extensions to access and manipulate redirections.
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ int fd,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_input_buf_t **ibufp,
@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ const awk_output_buf_t **obufp);
-Look up a file in @command{gawk}'s internal redirection table. If @code{name} is NULL or @code{name_len} is 0, it returns
-data for the currently open input file corresponding to @code{FILENAME}
-(and it will not access the @code{filetype} argument, so that may be
-undefined).
-If the file is not already open, it tries to open it.
-The @code{filetype} argument must be NUL-terminated and should be one of:
+Look up a file in @command{gawk}'s internal redirection table.
+If @code{name} is @code{NULL} or @code{name_len} is zero, return
+data for the currently open input file corresponding to @code{FILENAME}.
+(This does not access the @code{filetype} argument, so that may be undefined).
+If the file is not already open, attempt to open it.
+The @code{filetype} argument must be zero-terminated and should be one of:
+
@table @code
-@item >
+@item ">"
A file opened for output.
-@item >>
+
+@item ">>"
A file opened for append.
-@item <
+
+@item "<"
A file opened for input.
-@item |>
+
+@item "|>"
A pipe opened for output.
-@item |<
+
+@item "|<"
A pipe opened for input.
-@item |&
+
+@item "|&"
A two-way coprocess.
@end table
-On error, a @code{false} value is returned. Otherwise, the return status
-is @code{true}, and additional information about the redirection is
-returned in the @code{ibufp} and @code{obufp} pointers. For input redirections,
-the @code{*ibufp} value should be non-NULL, and @code{*obufp} should be NULL.
-For output redirections,
-the @code{*obufp} value should be non-NULL, and @code{*ibufp} should be NULL.
-For two-way coprocesses, both values should be non-NULL. In the usual case,
-the extension is interested in @code{(*ibufp)->fd} and/or @code{fileno((*obufp)->fp)}.
-If the file is not already open, and the fd argument is non-negative,
-@command{gawk} will use that file descriptor instead of opening the file
-in the usual way. If the fd is non-negative, but the file exists
-already, @command{gawk} ignores the fd and returns the existing file. It is
-the caller's responsibility to notice that neither the fd in the returned
-@code{awk_input_buf_t} nor the fd in the returned @code{awk_output_buf_t} matches the requested value. Note that
-supplying a file descriptor is currently NOT supported for pipes.
-It should work for input, output, append, and two-way (coprocess)
-sockets. If @code{filetype} is two-way, we assume that it is a socket!
-Note that in the two-way case, the input and output file descriptors
-may differ. To check for success, one must check whether either matches.
+
+On error, return a @code{false} value. Otherwise, return
+@code{true}, and return additional information about the redirection
+in the @code{ibufp} and @code{obufp} pointers. For input
+redirections, the @code{*ibufp} value should be non-@code{NULL},
+and @code{*obufp} should be @code{NULL}. For output redirections,
+the @code{*obufp} value should be non-@code{NULL}, and @code{*ibufp}
+should be @code{NULL}. For two-way coprocesses, both values should
+be non-@code{NULL}.
+
+In the usual case, the extension is interested in @code{(*ibufp)->fd}
+and/or @code{fileno((*obufp)->fp)}. If the file is not already
+open, and the @code{fd} argument is non-negative, @command{gawk}
+will use that file descriptor instead of opening the file in the
+usual way. If @code{fd} is non-negative, but the file exists already,
+@command{gawk} ignores @code{fd} and returns the existing file. It is
+the caller's responsibility to notice that neither the @code{fd} in
+the returned @code{awk_input_buf_t} nor the @code{fd} in the returned
+@code{awk_output_buf_t} matches the requested value.
+
+Note that supplying a file descriptor is currently @emph{not} supported
+for pipes. However, supplying a file descriptor should work for input,
+output, append, and two-way (coprocess) sockets. If @code{filetype}
+is two-way, @command{gawk} assumes that it is a socket! Note that in
+the two-way case, the input and output file descriptors may differ.
+To check for success, you must check whether either matches.
@end table
It is anticipated that this API function will be used to implement I/O