ldopen(3x)
_________________________________________________________________
ldopen, ldaopen Subroutine
open an executable file for reading in DG/UX
_________________________________________________________________
SYNTAX
#include <stdio.h>
#include <sys/types.h>
#include <filehdr.h>
#include <ldfcn.h>
LDFILE *ldopen (filename, ldptr)
char *filename;
LDFILE *ldptr;
LDFILE *ldaopen (filename, oldptr)
char *filename;
LDFILE *oldptr;
DESCRIPTION
Ldopen and ldclose(3X) provide uniform access to both simple
executable files and executable files that are members of archive
files. Thus an archive of executable files can be processed as
if it were a series of simple executable files.
If ldptr has the value NULL, then ldopen will open filename and
allocate and initialize the LDFILE structure, and return a
pointer to the structure to the calling program.
If ldptr is valid and if TYPE(ldptr) is the archive magic number,
ldopen will re-initialize the LDFILE structure for the next
archive member of filename.
Ldopen and ldclose(3X) work in concert. Ldclose will return
FAILURE only when TYPE(ldptr) is the archive magic number and
when another file in the archive is to be processed. Only then
should ldopen be called with the current value of ldptr. In all
other cases, and particularly whenever a new filename is opened,
ldopen should be called with a NULL ldptr argument.
The following is a model for the use of ldopen and ldclose(3X).
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
ldopen(3x)
/* 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 re-open filename
and allocate and initialize a new LDFILE structure, copying the
TYPE, OFFSET, and HEADER fields from oldptr. 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 executable file.
Both ldopen and ldaopen open filename for reading. Both
functions return NULL if:
a) filename cannot be opened
b) memory for the LDFILE structure cannot be allocated
c) filename is too small to be an executable file or an
archived executable file. The functions try to read the
header of executable files, so a file smaller than a
header will cause the functions to return NULL.
Note that a successful open does not ensure that the given file
is an executable file or an archived executable file.
The program must be loaded with the executable file access
routine library libld.a.
SEE ALSO
fopen(3S), ldclose(3X), ldfcn(4).
CAVEATS
The executable file format is used only for executable files
(load modules), not for object files.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)