Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ endutent(3) — DG/UX 4.30

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ttyslot(3C)

utmp(4)



     getut(3)                   DG/UX 4.30                    getut(3)



     NAME
          getutent, getutid, getutline, pututline, setutent, endutent,
          utmpname - access utmp file entry

     SYNOPSIS
          #include <utmp.h>

          struct utmp *getutent ()

          struct utmp *getutid (id)
          struct utmp *id;

          struct utmp *getutline (line)
          struct utmp *line;

          void pututline (utmp)
          struct utmp *utmp;

          void setutent ()

          void endutent ()

          void utmpname (file)
          char *file;

     DESCRIPTION
          Getutent, getutid and getutline each return a pointer to a
          structure of the following type:

          struct utmp {
                 char       ut_user[8];        /* User login name */
                 char       ut_id[4];          /* /etc/inittab id
                                                * (usually line #) */
                 char       ut_line[12];       /* device name (console,
                                                * lnxx) */
                 short      ut_pid;            /* process id */
                 short      ut_type;           /* type of entry */
                 struct     exit_status {
                     short      e_termination; /* Process termination status */
                     short      e_exit;        /* Process exit status */
                 } ut_exit;                    /* The exit status of a process
                                                * marked as DEAD_PROCESS. */
                 time_t     ut_time;           /* time entry was made */
          };

          Getutent reads in the next entry from a utmp-like file.  If
          the file is not already open, it opens it.  If it reaches
          the end of the file, it fails.

          Getutid searches forward from the current point in the utmp
          file until it finds an entry with a ut_type matching
          id->ut_type if the type specified is RUN_LVL, BOOT_TIME,



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





     getut(3)                   DG/UX 4.30                    getut(3)



          OLD_TIME or NEW_TIME.  If the type specified in id is
          INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS,
          then getutid will return a pointer to the first entry whose
          type is one of these four and whose ut_id field matches
          id->ut_id.  If the end of file is reached without a match,
          it fails.

          Getutline searches forward from the current point in the
          utmp file until it finds an entry of the type LOGIN_PROCESS
          or USER_PROCESS that also has a ut_line string matching the
          line->ut_line string.  If the end of file is reached without
          a match, it fails.

          Pututline writes out the supplied utmp structure into the
          utmp file.  It uses getutid to search forward for the proper
          place in the file if it is not already there.  It is
          expected that the user of pututline will have searched for
          the proper entry using one of the getut routines.  If so,
          pututline will not search.  If pututline does not find a
          matching slot for the new entry, it will add a new entry to
          the end of the file.

          Setutent resets the input stream to the beginning of the
          file.  This should be done before each search for a new
          entry if you want to examine the entire file.

          Endutent closes the currently open file.

          Utmpname lets you change the name of the file examined to
          something other than /etc/utmp.  This other file will
          usually be /etc/wtmp.  Bad filenames go undetected  until
          the first attempt to reference the file.  Utmpname does not
          open the file.  It just closes the old file if it is open
          and saves the new filename.

     FILES
          /etc/utmp
          /etc/wtmp

     SEE ALSO
          ttyslot(3C), utmp(4).

     DIAGNOSTICS
          A NULL pointer is returned upon failure to read (bad
          permissions, end of file, failure to write).

     COMMENTS
          The most current entry is saved in a static structure.
          Multiple accesses require that it be copied before further
          accesses are made.  Each call to either getutid or getutline
          sees the routine examine the static structure before
          performing more I/O.  If the contents of the static



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





     getut(3)                   DG/UX 4.30                    getut(3)



          structure match what it is searching for, it looks no
          further.

          Therefore, to use getutline to search for multiple
          occurrences, you must zero out the static structure after
          each success, or getutline will just return the same pointer
          over and over again.

          There is one exception to the rule about removing the
          structure before further reads are done.  The implicit read
          done by pututline (if it finds that it is not already at the
          correct place in the file) will not hurt the contents of the
          static structure returned by the getutent, getutid or
          getutline routines, if you have just modified those contents
          and passed the pointer back to pututline.

          These routines use buffered standard I/O for input, but
          pututline uses an unbuffered non-standard write to avoid
          race conditions between processes trying to modify the utmp
          and wtmp files.



































     Licensed material--property of copyright holder(s)         Page 3



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