Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ldopen(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ldclose(S)

ldfcn(FP)


 ldopen(S)                      6 January 1993                      ldopen(S)


 Name

    ldopen, ldaopen - open a common object file for reading

 Syntax


    cc  . . .  -lld


    #include <filehdr.h>
    #include <ldfcn.h>

    LDFILE *ldopen (filename, ldptr)
    char *filename;
    LDFILE *ldptr;

    LDFILE *ldaopen (filename, oldptr)
    char *filename;
    LDFILE *oldptr;


 Description

    The ldopen and ldclose functions 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 if it were a series of
    simple common object files.

    If ldptr has the value NULL then ldopen opens filename and allocates and
    initializes the LDFILE structure, and returns a pointer to the 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 ldopen and ldclose(S) functions work in concert.  ldclose returns
    FAILURE only 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 particu-
    lar whenever a new filename is opened, ldopen should be called with a
    NULL ldptr argument.

    If the value of oldptr is not NULL, ldaopen opens filename anew and allo-
    cates and initializes 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 object file.  For example, one pointer may be used to step sequen-
    tially 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
    NULL if filename cannot be opened, or if memory for the LDFILE structure
    cannot be allocated.  A successful open does not ensure that the given
    file is a common object file or an archived object file.

 Example

    The following is an example for the use of ldopen and ldclose(S).

       /* 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 );


 See also

    ldclose(S), ldfcn(FP)

 Standards conformance

    ldopen and ldaopen are not part of any currently supported standard; they
    are an extension of AT&T System V provided by the Santa Cruz Operation.


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