ldopen(3) CLIX ldopen(3)
NAME
ldopen, ldaopen - Opens a common object file for reading
LIBRARY
COFF Object File Manipulation Library (libld.a)
SYNOPSIS
#include <stdio.h>
#include <filehdr.h>
#include <ldfcn.h>
#include "INCDIR/filehdr.h"
#include "INCDIR/ldfcn.h"
LDFILE *ldopen(
char *filename ,
LDFILE *ldptr );
LDFILE *ldaopen(
char *filename ,
LDFILE *oldptr );
DESCRIPTION
The functions ldopen() and ldclose() provide uniform access to both simple
object files and object files that are members of archive files. Thus an
archive of common object files can be processed as a series of simple
common object files.
If ldptr has the value NULL, then ldopen() opens filename and allocates
and initializes the LDFILE structure to the calling program.
If ldptr is valid and if TYPE(ldptr) is the archive magic number, ldopen()
reinitializes the LDFILE structure for the next archive member of
filename.
The functions ldopen() and ldclose() work together. The ldclose() returns
FAILURE when TYPE(ldptr) is the archive magic number and there is another
file in the archive to be processed. Only then should ldopen() be called
with the current value of ldptr. In all other cases, in particular
whenever a new filename is opened, ldopen() should be called with a ldptr
argument.
The following is a prototype for the use of ldopen() and ldclose().
2/94 - Intergraph Corporation 1
ldopen(3) CLIX ldopen(3)
/* for each filename to be processed */
ldptr = NULL;
do
{
if ((ldptr = ldopen(filename, ldptr)) != NULL)
{
/* check magic number */
/* process the file */
}
} while (ldclose(ldptr) == FAILURE);
If the value of oldptr is not NULL, ldaopen() will open filename anew and
allocate and initialize a new LDFILE TYPE, OFFSET, and HEADER fields from
oldptr. The ldaopen() returns a pointer to the new LDFILE structure.
This new pointer is independent of the old pointer, oldptr. The two
pointers may be used concurrently to read separate parts of the object
file. For example, one pointer may be used to step sequentially through
the relocation information, while the other is used to read indexed symbol
table entries.
Both ldopen() and ldaopen() open filename for reading. Both functions
return if filename cannot be opened, or if memory for the LDFILE structure
cannot be allocated. A successful open does not insure that the given
file is a common object file or an archived object file.
The program must be loaded with the object file access function library
libld.a.
INCDIR is the standard directory list for #include files, usually
/usr/include. LIBDIR is the set of standard library files, usually /lib.
RELATED INFORMATION
Functions: fopen(3), ldclose(3)
Files: ldfcn(0)
2 Intergraph Corporation - 2/94