summaryrefslogtreecommitdiff
path: root/include/internal/utmp.h
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-25 23:59:45 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-25 23:59:45 +0100
commit6ff9c31abc14f207265ab214370982ecb3bfe428 (patch)
treeafdaf5624e71c939c39abe8ef3aba5980aa4d911 /include/internal/utmp.h
parent2b33716c08cc506e57115e34b5fe11d8d5477398 (diff)
utmp: favour POSIX utmpx over SVID utmp
Note: _PATH_UTMPX == _PATH_UTMP and the utmp struct is identical to the utmpx struct so this only changes the external API entrypoints and NOT the underlying data source. This saves about 500b (~1300b from previously ~1950) while at it. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'include/internal/utmp.h')
-rw-r--r--include/internal/utmp.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/include/internal/utmp.h b/include/internal/utmp.h
new file mode 100644
index 000000000..49f96b4d8
--- /dev/null
+++ b/include/internal/utmp.h
@@ -0,0 +1,92 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * internal helper for utmp and utmpx handling
+ *
+ * Copyright (C) 2015 by Bernhard Reutner-Fischer
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+#ifndef __INTERNAL_UTMP_H
+#define __INTERNAL_UTMP_H
+
+#include <utmpx.h>
+#include <utmp.h>
+
+/* Note: _PATH_UTMPX == _PATH_UTMP */
+
+#if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+/* implement the X and alias the non-X */
+# define __set_unlocked __setutxent_unlocked
+# define set setutxent
+# define __get_unlocked __getutxent_unlocked
+# define get getutxent
+# define end endutxent
+# define __getid_unlocked __getutxid_unlocked
+# define getid getutxid
+# define getline getutxline
+# define putline pututxline
+# define name utmpxname
+# define updw updwtmpx
+# define UT utmpx
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMPX
+# endif
+# if defined __UCLIBC_HAS_UTMP__
+# define other(n,a) strong_alias_untyped(n,a)
+# else
+# define other(n,a) /* nothing */
+# endif
+#elif defined __UCLIBC_HAS_UTMP__
+# define __set_unlocked __setutent_unlocked
+# define set setutent
+# define __get_unlocked __getutent_unlocked
+# define get getutent
+# define end endutent
+# define __getid_unlocked __getutid_unlocked
+# define getid getutid
+# define getline getutline
+# define putline pututline
+# define name utmpname
+# define updw updwtmp
+# define UT utmp
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMP
+# endif
+# define other(n,a) /* nothing */
+#else
+#error You are supposed to either have UTMP or UTMPX or both here
+#endif
+
+/* not used in libc_hidden_proto(setutxent) */
+/* not used in libc_hidden_proto(endutxent) */
+/* not used in libc_hidden_proto(getutxent) */
+/* not used in libc_hidden_proto(getutxid) */
+/* not used in libc_hidden_proto(getutxline) */
+/* not used in libc_hidden_proto(pututxline) */
+/* not used in libc_hidden_proto(utmpxname) */
+/* not used in libc_hidden_proto(updwtmpx) */
+
+/* not used in libc_hidden_proto(setutent) */
+/* not used in libc_hidden_proto(endutent) */
+/* not used in libc_hidden_proto(getutent) */
+/* not used in libc_hidden_proto(getutid) */
+/* not used in libc_hidden_proto(getutline) */
+/* not used in libc_hidden_proto(pututline) */
+/* not used in libc_hidden_proto(utmpname) */
+/* not used in libc_hidden_proto(updwtmp) */
+
+#ifdef IS_IN_libutil
+# if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+ /* monkey-patch to use the POSIX interface */
+# define setutent setutxent
+# define getutline getutxline
+# define pututline pututxline
+# define endutent endutxent
+# define updwtmp updwtmpx
+# endif
+#endif /* IS_IN_libutil */
+
+#endif /* __INTERNAL_UTMP_H */
+