Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ defopen(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(S)


 defopen(S)                     6 January 1993                     defopen(S)


 Name

    defopen, defread - reads default entries

 Syntax


    cc  . . .  -lc


    int defopen(filename)
    char *filename;

    char *defread(pattern)
    char *pattern;


 Description

    defopen and defread are a pair of routines designed to allow easy access
    to default definition files.  The UNIX operating system is normally dis-
    tributed in binary form; the use of default files allows OEMs or site
    administrators to customize utility defaults without having the source
    code.

    defopen opens the default file named by the pathname in filename.
    defopen returns null if it is successful in opening the file, or the
    fopen failure code (errno) if the open fails.

    defread reads the previously opened file from the beginning until it
    encounters a line beginning with pattern.  defread then returns a pointer
    to the first character in the line after the initial pattern.  If a
    trailing newline character is read it is replaced by a null byte.

    When all items of interest have been extracted from the opened file the
    program may call defopen with the name of another file to be searched, or
    it may call defopen with NULL, which closes the default file without
    opening another.

 Files

    The UNIX style convention is for a system program xyz to store its
    defaults (if any) in the file /etc/default/xyz.

 Diagnostics

    defopen returns zero on success and nonzero if the open fails. The return
    value is the errno value set by fopen(S).

    defread returns NULL if a default file is not open, if the indicated pat-
    tern could not be found, or if it encounters any line in the file greater
    than the maximum length of 128 characters.

 Notes

    The return value points to static data, whose contents are overwritten by
    each call.

 See also

    fopen(S)

 Standards conformance

    defopen and defread are extensions of AT&T System V provided by the Santa
    Cruz Operation.


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