HPUX getut[3c]






 getut(3C)                                                         getut(3C)





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

 SYNOPSIS
      #include <utmp.h>

      struct utmp *getutent(void);

      struct utmp *getutid(struct utmp *id);

      struct utmp *getutline(struct utmp *line);

      struct utmp *_pututline(const struct utmp *utmp);

      void pututline(const struct utmp *utmp);

      void setutent(void);

      void endutent(void);

      void utmpname(const 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) */
               pid_t 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. */
               unsigned short ut_reserved1;  /* Reserved for future use */
               time_t ut_time;           /* time entry was made */
               char ut_host[16];         /* host name, if remote; NOT SUPPORTED */
               unsigned long ut_addr;    /* Internet addr of host, if remote */
           };

      getutent()          Reads in the next entry from a utmp-like file.  If
                          the file is not already open, getutent() opens it.
                          If it reaches the end of the file, getutent()
                          fails.

      getutid()           Searches forward from the current point in the
                          utmp file until it finds an entry with a ut_type



 Hewlett-Packard Company            - 1 -     HP-UX Release 9.0: August 1992






 getut(3C)                                                         getut(3C)





                          matching id->ut_type if the type specified is
                          RUN_LVL, BOOT_TIME, OLD_TIME, or NEW_TIME.  If the
                          type specified in id is INIT_PROCESS,
                          LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS,
                          getutid() returns a pointer to the first entry
                          whose type is one of these four, and whose ut_id
                          field matches id->ut_id.  If end-of-file is
                          reached without a match, getutid() fails.

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

      pututline()         Writes out the supplied utmp structure into the
                          utmp file.  pututline() uses getutid() to search
                          forward for the proper location if it is not
                          already there.  It is normally expected that the
                          application program has already searched for the
                          proper entry by using one of the getut() routines
                          before calling pututline().  If the search as
                          already been made, pututline() does not repeat it.
                          If pututline() does not find a matching slot for
                          the new entry, it adds a new entry to the end of
                          the file.

      _pututline()        Performs the same actions as pututline(), except
                          that it returns a value useful for error checking.

      setutent()          Resets the input stream to the beginning of the
                          file.  This should be done before each search for
                          a new entry if it is desired that the entire file
                          be examined.

      endutent()          Closes the currently open file.

      utmpname()          Allows the user to change the name of the file
                          being examined from /etc/utmp to any other file.
                          The other file is usually /etc/wtmp.  If the file
                          does not exist, its absence is not discovered
                          until the first subsequent attempt to reference
                          the file.  utmpname() does not open the file - it
                          merely closes the old file if it is currently
                          open, and saves the new file name.

      The most current entry is saved in a static structure.  Multiple
      accesses require that the structure be copied before further accesses
      are made.  During each call to either getutid() or getutline(), the
      static structure is examined before performing more I/O.  If the



 Hewlett-Packard Company            - 2 -     HP-UX Release 9.0: August 1992






 getut(3C)                                                         getut(3C)





      contents of the static structure match what the routine is searching
      for, no additional searching is done.  Therefore, if using getutline()
      to search for multiple occurrences, it is necessary to zero out the
      static structure after each success; otherwise getutline() simply
      returns the same pointer over and over again.  There is one exception
      to the rule about removing the structure before a new read: The
      implicit read done by pututline() (if it finds that it is not already
      at the correct place in the file) does not alter the contents of the
      static structure returned by getutent(), getutid(), or getutline() if
      the user has just modified those contents and passed the pointer back
      to pututline().

 RETURN VALUE
      These functions return a NULL pointer upon failure to read (whether
      for permissions or having reached end-of-file), or upon failure to
      write.  They also return a NULL pointer if the size of the file is not
      an integral multiple of sizeof(struct utmp).

      _pututline() behaves the same as pututline(), except that it returns a
      pointer to a static location containing the most current utmp entry if
      the _pututline() call succeeds.  The contents of this structure is
      identical to the contents of the supplied utmp structure if
      successful.  If _pututline() fails, it returns a NULL pointer.

 WARNINGS
      Some vendors' versions of getutent() erase the utmp file if the file
      exists but is not an integral multiple of sizeof(struct utmp).  Given
      the possiblity of user error in providing a name to utmpname (such as
      giving improper arguments to who(1)), HP-UX does not do this, but
      instead returns an error indication.

 FILES
      /etc/utmp
      /etc/wtmp

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

 STANDARDS CONFORMANCE
      endutent(): SVID2, XPG2

      getutent(): SVID2, XPG2

      getutid(): SVID2, XPG2

      getutline(): SVID2, XPG2

      pututline(): SVID2, XPG2

      setutent(): SVID2, XPG2




 Hewlett-Packard Company            - 3 -     HP-UX Release 9.0: August 1992






 getut(3C)                                                         getut(3C)





      utmpname(): SVID2, XPG2





















































 Hewlett-Packard Company            - 4 -     HP-UX Release 9.0: August 1992