| /* Common utmpx implementation |
| * Copyright 2015-2016 Rivoreo |
| * |
| * This program is free software; you can redistribute it and/or modify it |
| * under the terms of the GNU General Public License as published by the |
| * Free Software Foundation; either version 2 of the License, or (at your |
| * option) any later version. |
| * |
| * This program is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| * more details. |
| */ |
| |
| #ifndef _UTMPX_H |
| #define _UTMPX_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 |
| |
| #define UTMPX_FILE "/var/run/utmpx" |
| #define WTMPX_FILE "/var/log/wtmpx" |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| #define _UTX_LINE_SIZE 16 |
| #define _UTX_NAME_SIZE 16 |
| #define _UTX_HOST_SIZE 256 |
| #define _UTX_ID_SIZE 2 |
| |
| struct utmpx { |
| short int ut_type; |
| pid_t ut_pid; |
| char ut_line[_UTX_LINE_SIZE]; |
| char ut_id[_UTX_ID_SIZE]; |
| int ut_session; |
| char ut_user[_UTX_NAME_SIZE]; |
| char ut_host[_UTX_HOST_SIZE]; |
| long ut_addr; |
| struct timeval ut_tv; |
| }; |
| |
| #ifndef ut_name |
| #define ut_name ut_user |
| #endif |
| #ifndef ut_time |
| #define ut_time ut_tv.tv_sec |
| #endif |
| |
| extern void endutxent(void); |
| extern struct utmpx *getutxent(void); |
| extern struct utmpx *getutxid(const struct utmpx *id); |
| extern struct utmpx *getutxline(const struct utmpx *line); |
| extern struct utmpx *pututxline(const struct utmpx *utmpx); |
| extern void setutxent(void); |
| extern int utmpxname(const char *file); |
| extern void updwtmpx(const char *file, const struct utmpx *utmpx); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif |