=head1 NAME

gbatch_getredir - extract a redirection structure from a job structure

=head1 SYNOPSIS

=for man
\&\fB#include <gbatch.h>\fR
.PP

=for html
<STRONG>#include &lt;gbatch.h&gt;</STRONG>
<br>

B<const apiMredir *gbatch_getredir(const apiBtjob *>I<jobp>B<, const
unsigned>
I<indx>B<)>

=head1 DESCRIPTION

The function B<gbatch_getredir> is used to extract a redirection structure
from a job structure.

I<jobp> is a pointer to a structure containing the details of the job.

I<indx> is the redirection number required. This should be between 0
and 1 less than the number of redirections as given by the field
C<jobp->h.bj_nredirs>.

=head2 Redirection Structure

The format of the redirection structure is as follows:

 typedef struct {
         unsigned char fd;
         unsigned char action;
         union  {
                  unsigned short arg;
                  const char *buffer;
         }  un;
 } apiMredir;

In this structure C<fd> represents the file descriptor, and C<action>
gives the action required as follows:

=over 8

=item RD_ACT_RD

Open file name given in C<un.buffer> for reading.

=item RD_ACT_WRT

Open file name given in C<un.buffer> for writing.

=item RD_ACT_APPEND

Append to file name given in C<un.buffer>, opened for writing.

=item RD_ACT_RDWR

Open file name given in C<un.buffer> for read/write.

=item RD_ACT_RDWRAPP

Open file name given in C<un.buffer> for read/write and append.

=item RD_ACT_PIPEO

Open pipe to shell command given in C<un.buffer> for output.

=item RD_ACT_PIPEI

Open pipe from shell command given in C<un.buffer> for input.

=item RD_ACT_CLOSE

Close file descriptor.

=item RD_ACT_DUP

Duplicate file descriptor given in C<un.arg>.

=back

=head1 RETURN VALUES

The result is a pointer to a static structure containing the required
redirection of the job C<NULL> if the redirection number is invalid.

Note that the structure used will be overwritten by a further call to
B<gbatch_getredir> with different arguments, hence it should be copied if
required.

=head1 SEE ALSO

gbatch_delarg(3),
gbatch_delenv(3),
gbatch_delredir(3),
gbatch_getarg(3),
gbatch_getdirect(3),
gbatch_getenv(3),
gbatch_getenvlist(3),
gbatch_gethenv(3),
gbatch_gettitle(3),
gbatch_putarg(3),
gbatch_putarglist(3),
gbatch_putdirect(3),
gbatch_putenv(3),
gbatch_putenvlist(3),
gbatch_putredir(3),
gbatch_putredirlist(3),
gbatch_puttitle(3),
gbatch_setqueue(3).

=head1 COPYRIGHT

Copyright (c) 2009 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the
terms of the GNU General Public License
<http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

=head1 AUTHOR

John M Collins, Xi Software Ltd.

=cut

## Local Variables:
## mode: nroff
## End:
