]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
c2f1db8f | 2 | #pragma once |
e537352b | 3 | |
a8fbdf54 TA |
4 | #include <stdbool.h> |
5 | #include <sys/types.h> | |
6 | ||
7 | #include "time-util.h" | |
e537352b | 8 | |
3211da4b | 9 | #if ENABLE_UTMP |
c2a99093 ZJS |
10 | #include <utmpx.h> |
11 | ||
e537352b LP |
12 | int utmp_get_runlevel(int *runlevel, int *previous); |
13 | ||
0ad26e09 | 14 | int utmp_put_shutdown(void); |
e537352b | 15 | int utmp_put_reboot(usec_t timestamp); |
0ad26e09 | 16 | int utmp_put_runlevel(int runlevel, int previous); |
e537352b | 17 | |
169c1bda | 18 | int utmp_put_dead_process(const char *id, pid_t pid, int code, int status); |
023a4f67 | 19 | int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user); |
169c1bda | 20 | |
c2a99093 ZJS |
21 | static inline bool utxent_start(void) { |
22 | setutxent(); | |
23 | return true; | |
24 | } | |
25 | static inline void utxent_cleanup(bool *initialized) { | |
22a8f002 MY |
26 | assert(initialized); |
27 | if (*initialized) | |
c2a99093 ZJS |
28 | endutxent(); |
29 | } | |
30 | ||
3211da4b | 31 | #else /* ENABLE_UTMP */ |
37161c51 ERB |
32 | |
33 | static inline int utmp_get_runlevel(int *runlevel, int *previous) { | |
34 | return -ESRCH; | |
35 | } | |
36 | static inline int utmp_put_shutdown(void) { | |
37 | return 0; | |
38 | } | |
39 | static inline int utmp_put_reboot(usec_t timestamp) { | |
40 | return 0; | |
41 | } | |
42 | static inline int utmp_put_runlevel(int runlevel, int previous) { | |
43 | return 0; | |
44 | } | |
45 | static inline int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) { | |
46 | return 0; | |
47 | } | |
023a4f67 | 48 | static inline int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user) { |
37161c51 ERB |
49 | return 0; |
50 | } | |
37161c51 | 51 | |
3211da4b | 52 | #endif /* ENABLE_UTMP */ |