| /* Common utmpx implementation |
| Copyright 2015-2023 Rivoreo |
| |
| Permission is hereby granted, free of charge, to any person obtaining |
| a copy of this software and associated documentation files (the |
| "Software"), to deal in the Software without restriction, including |
| without limitation the rights to use, copy, modify, merge, publish, |
| distribute, sublicense, and/or sell copies of the Software, and to |
| permit persons to whom the Software is furnished to do so, subject to |
| the following conditions: |
| |
| The above copyright notice and this permission notice shall be |
| included in all copies or substantial portions of the Software. |
| |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
| THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| */ |
| |
| |
| #ifndef _UTMPX_H |
| #define _UTMPX_H |
| |
| #include <sys/types.h> |
| #include <sys/time.h> |
| |
| #define EMPTY 0 |
| |
| #define RUN_LVL 1 |
| #define BOOT_TIME 2 |
| #define NEW_TIME 3 |
| #define OLD_TIME 4 |
| |
| #define INIT_PROCESS 5 |
| #define LOGIN_PROCESS 6 |
| #define USER_PROCESS 7 |
| #define DEAD_PROCESS 8 |
| |
| // FreeBSD extension |
| #define UTXDB_ACTIVE 0 |
| #if 0 |
| #define UTXDB_LASTLOGIN 1 |
| #define UTXDB_LOG 2 |
| #endif |
| |
| #define UTMPX_FILE "/var/run/utmpx" |
| #define WTMPX_FILE "/var/log/wtmpx" |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| struct utmpx { |
| short int ut_type; |
| pid_t ut_pid; |
| char ut_line[16]; |
| char ut_id[8]; |
| char ut_user[16]; |
| char ut_host[256]; |
| long int ut_addr; |
| struct timeval ut_tv; |
| }; |
| |
| #define ut_name ut_user |
| #define ut_xtime ut_tv.tv_sec |
| |
| #ifdef _ALL_SOURCE |
| extern int _sun_utmpxname(const char *); |
| #elif !defined _GNU_SOURCE |
| #define utmpxname _sun_utmpxname |
| #endif |
| extern int utmpxname(const char *); |
| extern int setutxdb(int, const char *); |
| extern void setutxent(void); |
| extern void endutxent(void); |
| extern struct utmpx *getutxent(void); |
| extern struct utmpx *getutxid(const struct utmpx *); |
| extern struct utmpx *getutxline(const struct utmpx *); |
| extern struct utmpx *pututxline(const struct utmpx *); |
| extern void updwtmpx(const char *, const struct utmpx *); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif |