]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/utmp-wtmp.h
Merge pull request #30513 from rpigott/resolved-ede
[thirdparty/systemd.git] / src / shared / utmp-wtmp.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <sys/types.h>
6
7 #include "time-util.h"
8
9 #if ENABLE_UTMP
10 #include <utmpx.h>
11
12 int utmp_get_runlevel(int *runlevel, int *previous);
13
14 int utmp_put_shutdown(void);
15 int utmp_put_reboot(usec_t timestamp);
16 int utmp_put_runlevel(int runlevel, int previous);
17
18 int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
19 int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user);
20
21 static inline bool utxent_start(void) {
22 setutxent();
23 return true;
24 }
25 static inline void utxent_cleanup(bool *initialized) {
26 assert(initialized);
27 if (*initialized)
28 endutxent();
29 }
30
31 #else /* ENABLE_UTMP */
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 }
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) {
49 return 0;
50 }
51
52 #endif /* ENABLE_UTMP */