Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ldaopen(3X) — DG/UX 5.4R3.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3S)

ldclose(3X)

ldfcn(4)



ldopen(3X)                     DG/UX 5.4R3.00                     ldopen(3X)


NAME
       ldopen, ldaopen - open an object file for reading

SYNOPSIS
       #include <stdio.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 common
       object (COFF) files and object files that are members of archive
       files.  Thus an archive of object files can be processed as if it
       were a series of simple object 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 reinitialize 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).

              /* 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 reopen filename and
       allocate and initialize a new LDFILE structure, copying the TYPE,
       OFFSET, and HEADER fields from oldptr.  Ldaopen returns a pointer to



Licensed material--property of copyright holder(s)                         1




ldopen(3X)                     DG/UX 5.4R3.00                     ldopen(3X)


       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.

       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 object file or an archive of
                 object files.  The functions try to read the header of
                 object 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
       object file or an archive of object files.

       The program must be loaded with the object file access routine
       library libld.a.

SEE ALSO
       fopen(3S), ldclose(3X), ldfcn(4).

































Licensed material--property of copyright holder(s)                         2


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026