summaryrefslogtreecommitdiff
path: root/libc/misc/utmp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/utmp')
-rw-r--r--libc/misc/utmp/Makefile.in4
-rw-r--r--libc/misc/utmp/utent.c5
-rw-r--r--libc/misc/utmp/utxent.c105
-rw-r--r--libc/misc/utmp/wtent.c1
4 files changed, 115 insertions, 0 deletions
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index b209a4587..49ae5a503 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/Makefile.in
@@ -9,6 +9,10 @@ subdirs += libc/misc/utmp
CSRC := utent.c wtent.c
+ifeq ($(UCLIBC_HAS_UTMPX),y)
+CSRC += utxent.c
+endif
+
MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp
MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index a678130a3..bf265c2a3 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -98,6 +98,7 @@ struct utmp *getutent(void)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return ret;
}
+libc_hidden_def(getutent)
#endif
void endutent(void)
@@ -108,6 +109,7 @@ void endutent(void)
static_fd = -1;
__UCLIBC_MUTEX_UNLOCK(utmplock);
}
+libc_hidden_def(endutent)
/* This function must be called with the LOCK held */
static_if_threaded struct utmp *__getutid(const struct utmp *utmp_entry)
@@ -160,6 +162,7 @@ struct utmp *getutline(const struct utmp *utmp_entry)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return lutmp;
}
+libc_hidden_def(getutline)
struct utmp *pututline(const struct utmp *utmp_entry)
{
@@ -178,6 +181,7 @@ struct utmp *pututline(const struct utmp *utmp_entry)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return (struct utmp *)utmp_entry;
}
+libc_hidden_def(pututline)
int utmpname(const char *new_ut_name)
{
@@ -200,3 +204,4 @@ int utmpname(const char *new_ut_name)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return 0; /* or maybe return -(static_ut_name != new_ut_name)? */
}
+libc_hidden_def(utmpname)
diff --git a/libc/misc/utmp/utxent.c b/libc/misc/utmp/utxent.c
new file mode 100644
index 000000000..3c59f1c48
--- /dev/null
+++ b/libc/misc/utmp/utxent.c
@@ -0,0 +1,105 @@
+/*
+ * utexent.c : Support for accessing user accounting database.
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ *
+ * Author: Salvatore Cro <salvatore.cro@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <features.h>
+#include <string.h>
+#include <utmpx.h>
+#include <utmp.h>
+
+void setutxent(void)
+{
+ setutent ();
+}
+
+void endutxent(void)
+{
+ endutent ();
+}
+
+struct utmpx *getutxent(void)
+{
+ return (struct utmpx *) getutent ();
+}
+
+struct utmpx *getutxid(const struct utmpx *utmp_entry)
+{
+ return (struct utmpx *) getutid ((const struct utmp *) utmp_entry);
+}
+
+struct utmpx *getutxline(const struct utmpx *utmp_entry)
+{
+ return (struct utmpx *) getutline ((const struct utmp *) utmp_entry);
+}
+
+struct utmpx *pututxline (const struct utmpx *utmp_entry)
+{
+ return (struct utmpx *) pututline ((const struct utmp *) utmp_entry);
+}
+
+int utmpxname (const char *new_ut_name)
+{
+ return utmpname (new_ut_name);
+}
+
+void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
+{
+ updwtmp (wtmpx_file, (const struct utmp *) utmpx);
+}
+
+/* Copy the information in UTMPX to UTMP. */
+void getutmp (const struct utmpx *utmpx, struct utmp *utmp)
+{
+#if _HAVE_UT_TYPE - 0
+ utmp->ut_type = utmpx->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+ utmp->ut_pid = utmpx->ut_pid;
+#endif
+ memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
+ memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
+#if _HAVE_UT_ID - 0
+ memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
+#endif
+#if _HAVE_UT_HOST - 0
+ memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
+#endif
+#if _HAVE_UT_TV - 0
+ utmp->ut_tv = utmpx->ut_tv;
+#else
+ utmp->ut_time = utmpx->ut_time;
+#endif
+}
+
+/* Copy the information in UTMP to UTMPX. */
+void getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
+{
+ memset (utmpx, 0, sizeof (struct utmpx));
+
+#if _HAVE_UT_TYPE - 0
+ utmpx->ut_type = utmp->ut_type;
+#endif
+#if _HAVE_UT_PID - 0
+ utmpx->ut_pid = utmp->ut_pid;
+#endif
+ memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
+ memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
+#if _HAVE_UT_ID - 0
+ memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
+#endif
+#if _HAVE_UT_HOST - 0
+ memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
+#endif
+#if _HAVE_UT_TV - 0
+ utmpx->ut_tv = utmp->ut_tv;
+#else
+ utmpx->ut_time = utmp->ut_time;
+#endif
+}
+
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index 5ab743d9b..c97f89cff 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -46,3 +46,4 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
}
}
}
+libc_hidden_def(updwtmp)