elf_rand(S-osr5)
elf_rand --
random archive member access
Syntax
cc [flag . . . ] file . . . -lelf [library] . . .
#include <libelf.h>
size_t elf_rand(Elf *elf, size_t offset);
Description
elf_rand(S-osr5),
elf_next(S-osr5),
and
elf_begin(S-osr5)
manipulate simple object files and archives.
elf
is an
ELF
descriptor previously returned from
elf_begin( ).
elf_rand( )
provides random archive processing, preparing
elf
to access an arbitrary archive member.
elf
must be a descriptor for the archive itself,
not for a member within the archive.
offset
gives the byte offset from the beginning of
the archive to the archive header of the desired member.
See
elf_getarsym(S-osr5)
for more information about archive member offsets.
When
elf_rand( )
works, it returns
offset.
Otherwise it returns 0, because an error occurred,
elf
was null, or the file was not an archive
(no archive member can have a zero offset).
A program may mix random and sequential archive processing.
Diagnostics
Error conditions are identified through the routine
elf_error(S-osr5).
Examples
An archive starts with a ``magic string'' that has
SARMAG
bytes; the initial archive member follows immediately.
An application could thus provide the following function
to rewind an archive (the function returns -1 for errors
and 0 otherwise).
#include <ar.h>
#include <libelf.h>
int
rewindelf(Elf *elf)
{
if (elf_rand(elf, (size_t)SARMAG) == SARMAG)
return 0;
return -1;
}
See also
ar(FP),
elf(S-osr5),
elf_begin(S-osr5),
elf_getarsym(S-osr5),
elf_next(S-osr5)
Standards conformance
elf_rand(S-osr5)
is not part of any currently supported standard;
it was developed by UNIX System Laboratories, Inc.
and is maintained by The SCO Group.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005