'\"macro stdmacro
.if n .pH g3e.elf_cntl @(#)elf_cntl	40.10 of 10/27/89
.\" Copyright 1989 AT&T
.\"#ident	"@(#)ci5-doc:req/libelf/cntl.man	1.2"
.nr X
.if \nX=0 .ds x} elf_cntl 3E "ELF Library" "\&"
.if \nX=1 .ds x} elf_cntl 3E "ELF Library"
.if \nX=2 .ds x} elf_cntl 3E "" "\&"
.if \nX=3 .ds x} elf_cntl "" "" "\&"
.TH \*(x}
.SH NAME
\f4elf_cntl\f1 \- control a file descriptor
.SH SYNOPSIS
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lelf\f1
[\f2library\fP \|.\|.\|.]
.PP
.nf
.na
.ft 4
#include <libelf.h>
.sp 0.5
int elf_cntl(Elf \(**elf, Elf_Cmd cmd);
.ft 1
.ad
.fi
.SH DESCRIPTION
\f4elf_cntl\fP
instructs the library to modify its behavior with respect to an
.SM ELF
descriptor,
.IR elf .
As
\f4elf_begin\fP(3E)
describes, an
.SM ELF
descriptor can have multiple activations,
and multiple
.SM ELF
descriptors may share a single file descriptor.
Generally,
\f4elf_cntl\fP
commands apply to all activations of
.IR elf .
Moreover, if the
.SM ELF
descriptor is associated
with an archive file, descriptors for members within
the archive will also be affected as described below.
Unless stated otherwise, operations on archive members
do not affect the descriptor for the containing archive.
.P
The
.I cmd
argument tells what actions to take and may have the following values.
.TP 10
\f4ELF_C_FDDONE\f1
This value tells the library not to use the file descriptor
associated with
.IR elf .
A program should use this command when it has requested all the
information it cares to use and wishes to avoid the overhead
of reading the rest of the file.
The memory for all completed operations remains valid, but later
file operations, such as the initial
\f4elf_getdata\fP
for a section, will fail if the data are not in memory already.
.TP
\f4ELF_C_FDREAD\f1
This command is similar to
\f4ELF_C_FDDONE\f1,
except it forces the library to read the rest of the file.
A program should use this command when it must close the file
descriptor but has not yet read everything it needs from the file.
After
\f4elf_cntl\fP
completes the
\f4ELF_C_FDREAD\f1
command, future operations, such as
\f4elf_getdata\fP,
will use the memory version of the file without needing
to use the file descriptor.
.P
If
\f4elf_cntl\fP
succeeds, it returns zero.
Otherwise
.I elf
was null or an error occurred, and the function returns \-1.
.SH "SEE ALSO"
.na
\f4elf\fP(3E),
\f4elf_begin\fP(3E),
\f4elf_getdata\fP(3E),
\f4elf_rawfile\fP(3E).
.SH NOTE
If the program wishes to use the ``raw'' operations [see
\f4elf_rawdata\fP,
which
\f4elf_getdata\fP(3E)
describes, and
\f4elf_rawfile\fP(3E)]
after
disabling the file descriptor with
\f4ELF_C_FDDONE\f1 or \f4ELF_C_FDREAD\f1,
it must execute the raw operations explicitly beforehand.
Otherwise, the raw file operations will fail.
Calling
\f4elf_rawfile\fP
makes the entire image available, thus supporting subsequent
\f4elf_rawdata\fP
calls.
