# endutxent

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           endutxent, getutxent, getutxid, getutxline, pututxline, setutxent
           — user accounting database functions
    


## SYNOPSIS



           #include <utmpx.h>
    
           void endutxent(void);
           struct utmpx *getutxent(void);
           struct utmpx *getutxid(const struct utmpx *_id_);
           struct utmpx *getutxline(const struct utmpx *_line_);
           struct utmpx *pututxline(const struct utmpx *_utmpx_);
           void setutxent(void);
    


## DESCRIPTION



           These functions shall provide access to the user accounting
           database.
    
           The _getutxent_() function shall read the next entry from the user
           accounting database.  If the database is not already open, it
           shall open it. If it reaches the end of the database, it shall
           fail.
    
           The _getutxid_() function shall search forward from the current
           point in the database.  If the _ut_type_ value of the **utmpx**
           structure pointed to by _id_ is BOOT_TIME, OLD_TIME, or NEW_TIME,
           then it shall stop when it finds an entry with a matching _ut_type_
           value. If the _ut_type_ value is INIT_PROCESS, LOGIN_PROCESS,
           USER_PROCESS, or DEAD_PROCESS, then it shall stop when it finds an
           entry whose type is one of these four and whose _ut_id_ member
           matches the _ut_id_ member of the **utmpx** structure pointed to by _id_.
           If the end of the database is reached without a match, _getutxid_()
           shall fail.
    
           The _getutxline_() function shall search forward from the current
           point in the database until it finds an entry of the type
           LOGIN_PROCESS or USER_PROCESS which also has a _ut_line_ value
           matching that in the **utmpx** structure pointed to by _line_.  If the
           end of the database is reached without a match, _getutxline_() shall
           fail.
    
           The _getutxid_() or _getutxline_() function may cache data. For this
           reason, to use _getutxline_() to search for multiple occurrences,
           the application shall zero out the static data after each success,
           or _getutxline_() may return a pointer to the same **utmpx** structure.
    
           There is one exception to the rule about clearing the structure
           before further reads are done. The implicit read done by
           _pututxline_() (if it finds that it is not already at the correct
           place in the user accounting database) shall not modify the static
           structure returned by _getutxent_(), _getutxid_(), or _getutxline_(), if
           the application has modified this structure and passed the pointer
           back to _pututxline_().
    
           For all entries that match a request, the _ut_type_ member indicates
           the type of the entry. Other members of the entry shall contain
           meaningful data based on the value of the _ut_type_ member as
           follows:
    ┌────────────────┬─────────────────────────────────────────────────────────────────┐
    │ **ut_type Member** │               **Other Members with Meaningful Data** │
    ├────────────────┼─────────────────────────────────────────────────────────────────┤
    │ EMPTY          │ No others                                                       │
    │ BOOT_TIME      │ _ut_tv_                                                           │
    │ OLD_TIME       │ _ut_tv_                                                           │
    │ NEW_TIME       │ _ut_tv_                                                           │
    │ USER_PROCESS   │ _ut_id_ , _ut_user_ (login name of the user), _ut_line_ , _ut_pid_ , _ut_tv_ │
    │ INIT_PROCESS   │ _ut_id_ , _ut_pid_ , _ut_tv_                                            │
    │ LOGIN_PROCESS  │ _ut_id_ , _ut_user_ (implementation-defined name of the login        │
    │                │ process), _ut_line_ , _ut_pid_ , _ut_tv_                                │
    │ DEAD_PROCESS   │ _ut_id_ , _ut_pid_ , _ut_tv_                                            │
    └────────────────┴─────────────────────────────────────────────────────────────────┘
    
           An implementation that provides extended security controls may
           impose implementation-defined restrictions on accessing the user
           accounting database. In particular, the system may deny the
           existence of some or all of the user accounting database entries
           associated with users other than the caller.
    
           If the process has appropriate privileges, the _pututxline_()
           function shall write out the structure into the user accounting
           database. It shall search for a record as if by _getutxid_() that
           satisfies the request. If this search succeeds, then the entry
           shall be replaced. Otherwise, a new entry shall be made at the end
           of the user accounting database.
    
           The _endutxent_() function shall close the user accounting database.
    
           The _setutxent_() function shall reset the input to the beginning of
           the database. This should be done before each search for a new
           entry if it is desired that the entire database be examined.
    
           These functions need not be thread-safe.
    


## RETURN VALUE



           Upon successful completion, _getutxent_(), _getutxid_(), and
           _getutxline_() shall return a pointer to a **utmpx** structure
           containing a copy of the requested entry in the user accounting
           database. Otherwise, a null pointer shall be returned.
    
           The return value may point to a static area which is overwritten
           by a subsequent call to _getutxid_() or _getutxline_().
    
           Upon successful completion, _pututxline_() shall return a pointer to
           a **utmpx** structure containing a copy of the entry added to the user
           accounting database. Otherwise, a null pointer shall be returned.
    
           The _endutxent_() and _setutxent_() functions shall not return a
           value.
    


## ERRORS



           No errors are defined for the _endutxent_(), _getutxent_(),
           _getutxid_(), _getutxline_(), and _setutxent_() functions.
    
           The _pututxline_() function may fail if:
    
           **EPERM** The process does not have appropriate privileges.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           The sizes of the arrays in the structure can be found using the
           _sizeof_ operator.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *