]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/misc/utmp/utxent.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / misc / utmp / utxent.c
1 /*
2  * utexent.c : Support for accessing user accounting database.
3  * Copyright (C) 2010 STMicroelectronics Ltd.
4  *
5  * Author: Salvatore Cro <salvatore.cro@st.com>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  *
9  */
10
11 #include <features.h>
12 #include <string.h>
13 #include <utmpx.h>
14 #include <utmp.h>
15
16 #if 0 /* moved to utent.c */
17 void setutxent(void)
18 {
19         setutent ();
20 }
21
22 void endutxent(void)
23 {
24         endutent ();
25 }
26
27 struct utmpx *getutxent(void)
28 {
29         return (struct utmpx *) getutent ();
30 }
31
32 struct utmpx *getutxid(const struct utmpx *utmp_entry)
33 {
34         return (struct utmpx *) getutid ((const struct utmp *) utmp_entry);
35 }
36
37 struct utmpx *getutxline(const struct utmpx *utmp_entry)
38 {
39         return (struct utmpx *) getutline ((const struct utmp *) utmp_entry);
40 }
41
42 struct utmpx *pututxline (const struct utmpx *utmp_entry)
43 {
44         return (struct utmpx *) pututline ((const struct utmp *) utmp_entry);
45 }
46
47 int utmpxname (const char *new_ut_name)
48 {
49         return utmpname (new_ut_name);
50 }
51
52 /* moved to wtent.c */
53 void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
54 {
55         updwtmp (wtmpx_file, (const struct utmp *) utmpx);
56 }
57 #endif
58
59 /* Copy the information in UTMPX to UTMP. */
60 void getutmp (const struct utmpx *utmpx, struct utmp *utmp)
61 {
62 #if _HAVE_UT_TYPE - 0
63         utmp->ut_type = utmpx->ut_type;
64 #endif
65 #if _HAVE_UT_PID - 0
66         utmp->ut_pid = utmpx->ut_pid;
67 #endif
68         memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
69         memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
70 #if _HAVE_UT_ID - 0
71         memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
72 #endif
73 #if _HAVE_UT_HOST - 0
74         memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
75 #endif
76 #if _HAVE_UT_TV - 0
77         utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec;
78         utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec;
79 #else
80         utmp->ut_time = utmpx->ut_time;
81 #endif
82 }
83
84 /* Copy the information in UTMP to UTMPX. */
85 void getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
86 {
87         memset (utmpx, 0, sizeof (struct utmpx));
88
89 #if _HAVE_UT_TYPE - 0
90         utmpx->ut_type = utmp->ut_type;
91 #endif
92 #if _HAVE_UT_PID - 0
93         utmpx->ut_pid = utmp->ut_pid;
94 #endif
95         memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
96         memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
97 #if _HAVE_UT_ID - 0
98         memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
99 #endif
100 #if _HAVE_UT_HOST - 0
101         memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
102 #endif
103 #if _HAVE_UT_TV - 0
104         utmpx->ut_tv.tv_sec = utmp->ut_tv.tv_sec;
105         utmpx->ut_tv.tv_usec = utmp->ut_tv.tv_usec;
106 #else
107         utmpx->ut_time = utmp->ut_time;
108 #endif
109 }