ENDUTXENT(3)               POSIX Programmer's Manual              ENDUTXENT(3)



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


NNAAMMEE
       endutxent, getutxent, getutxid, getutxline, pututxline, setutxent --
       user accounting database functions

SSYYNNOOPPSSIISS
       #include <utmpx.h>

       void endutxent(void);
       struct utmpx *getutxent(void);
       struct utmpx *getutxid(const struct utmpx *_i_d);
       struct utmpx *getutxline(const struct utmpx *_l_i_n_e);
       struct utmpx *pututxline(const struct utmpx *_u_t_m_p_x);
       void setutxent(void);

DDEESSCCRRIIPPTTIIOONN
       These functions shall provide access to the user accounting database.

       The _g_e_t_u_t_x_e_n_t() 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 _g_e_t_u_t_x_i_d() function shall search forward from the current point in
       the database.  If the _u_t___t_y_p_e value of the uuttmmppxx structure pointed to
       by _i_d is BOOT_TIME, OLD_TIME, or NEW_TIME, then it shall stop when it
       finds an entry with a matching _u_t___t_y_p_e value. If the _u_t___t_y_p_e 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 _u_t___i_d member matches the _u_t___i_d member of the uuttmmppxx structure
       pointed to by _i_d.  If the end of the database is reached without a
       match, _g_e_t_u_t_x_i_d() shall fail.

       The _g_e_t_u_t_x_l_i_n_e() 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 _u_t___l_i_n_e value matching that in the uuttmmppxx
       structure pointed to by _l_i_n_e.  If the end of the database is reached
       without a match, _g_e_t_u_t_x_l_i_n_e() shall fail.

       The _g_e_t_u_t_x_i_d() or _g_e_t_u_t_x_l_i_n_e() function may cache data. For this
       reason, to use _g_e_t_u_t_x_l_i_n_e() to search for multiple occurrences, the
       application shall zero out the static data after each success, or
       _g_e_t_u_t_x_l_i_n_e() may return a pointer to the same uuttmmppxx structure.

       There is one exception to the rule about clearing the structure before
       further reads are done. The implicit read done by _p_u_t_u_t_x_l_i_n_e() (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
       _g_e_t_u_t_x_e_n_t(), _g_e_t_u_t_x_i_d(), or _g_e_t_u_t_x_l_i_n_e(), if the application has
       modified this structure and passed the pointer back to _p_u_t_u_t_x_l_i_n_e().

       For all entries that match a request, the _u_t___t_y_p_e member indicates the
       type of the entry. Other members of the entry shall contain meaningful
       data based on the value of the _u_t___t_y_p_e member as follows:

  +---------------+-----------------------------------------------------------------+
  |uutt__ttyyppee MMeemmbbeerr |               OOtthheerr MMeemmbbeerrss wwiitthh MMeeaanniinnggffuull DDaattaa                |
  +---------------+-----------------------------------------------------------------+
  |EMPTY          | No others                                                       |
  |BOOT_TIME      | _u_t___t_v                                                           |
  |OLD_TIME       | _u_t___t_v                                                           |
  |NEW_TIME       | _u_t___t_v                                                           |
  |USER_PROCESS   | _u_t___i_d, _u_t___u_s_e_r (login name of the user), _u_t___l_i_n_e, _u_t___p_i_d, _u_t___t_v |
  |INIT_PROCESS   | _u_t___i_d, _u_t___p_i_d, _u_t___t_v                                            |
  |LOGIN_PROCESS  | _u_t___i_d, _u_t___u_s_e_r (implementation-defined name of the login        |
  |               | process), _u_t___l_i_n_e, _u_t___p_i_d, _u_t___t_v                                |
  |DEAD_PROCESS   | _u_t___i_d, _u_t___p_i_d, _u_t___t_v                                            |
  +---------------+-----------------------------------------------------------------+
       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 _p_u_t_u_t_x_l_i_n_e() function
       shall write out the structure into the user accounting database. It
       shall search for a record as if by _g_e_t_u_t_x_i_d() 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 _e_n_d_u_t_x_e_n_t() function shall close the user accounting database.

       The _s_e_t_u_t_x_e_n_t() 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.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _g_e_t_u_t_x_e_n_t(), _g_e_t_u_t_x_i_d(), and _g_e_t_u_t_x_l_i_n_e()
       shall return a pointer to a uuttmmppxx 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 _g_e_t_u_t_x_i_d() or _g_e_t_u_t_x_l_i_n_e().

       Upon successful completion, _p_u_t_u_t_x_l_i_n_e() shall return a pointer to a
       uuttmmppxx structure containing a copy of the entry added to the user
       accounting database. Otherwise, a null pointer shall be returned.

       The _e_n_d_u_t_x_e_n_t() and _s_e_t_u_t_x_e_n_t() functions shall not return a value.

EERRRROORRSS
       No errors are defined for the _e_n_d_u_t_x_e_n_t(), _g_e_t_u_t_x_e_n_t(), _g_e_t_u_t_x_i_d(),
       _g_e_t_u_t_x_l_i_n_e(), and _s_e_t_u_t_x_e_n_t() functions.

       The _p_u_t_u_t_x_l_i_n_e() function may fail if:

       EEPPEERRMM  The process does not have appropriate privileges.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The sizes of the arrays in the structure can be found using the _s_i_z_e_o_f
       operator.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       The Base Definitions volume of POSIX.1-2008, <<uuttmmppxx..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                         ENDUTXENT(3)
