Lines Matching refs:ut
40 #define UTOF_STRING(ut, fu, field) do { \
41 strncpy((fu)->fu_ ## field, (ut)->ut_ ## field, \
42 MIN(sizeof (fu)->fu_ ## field, sizeof (ut)->ut_ ## field)); \
44 #define UTOF_ID(ut, fu) do { \
45 memcpy((fu)->fu_id, (ut)->ut_id, \
46 MIN(sizeof (fu)->fu_id, sizeof (ut)->ut_id)); \
48 #define UTOF_PID(ut, fu) do { \
49 (fu)->fu_pid = htobe32((ut)->ut_pid); \
51 #define UTOF_TYPE(ut, fu) do { \
52 (fu)->fu_type = (ut)->ut_type; \
62 utx_to_futx(const struct utmpx *ut, struct futx *fu)
67 switch (ut->ut_type) {
75 UTOF_ID(ut, fu);
76 UTOF_STRING(ut, fu, user);
77 UTOF_STRING(ut, fu, line);
79 UTOF_STRING(ut, fu, host);
80 UTOF_PID(ut, fu);
83 UTOF_ID(ut, fu);
84 UTOF_PID(ut, fu);
87 UTOF_ID(ut, fu);
88 UTOF_STRING(ut, fu, user);
89 UTOF_STRING(ut, fu, line);
90 UTOF_PID(ut, fu);
93 UTOF_ID(ut, fu);
94 UTOF_PID(ut, fu);
101 UTOF_TYPE(ut, fu);
105 #define FTOU_STRING(fu, ut, field) do { \
106 strncpy((ut)->ut_ ## field, (fu)->fu_ ## field, \
107 MIN(sizeof (ut)->ut_ ## field - 1, sizeof (fu)->fu_ ## field)); \
109 #define FTOU_ID(fu, ut) do { \
110 memcpy((ut)->ut_id, (fu)->fu_id, \
111 MIN(sizeof (ut)->ut_id, sizeof (fu)->fu_id)); \
113 #define FTOU_PID(fu, ut) do { \
114 (ut)->ut_pid = be32toh((fu)->fu_pid); \
116 #define FTOU_TYPE(fu, ut) do { \
117 (ut)->ut_type = (fu)->fu_type; \
119 #define FTOU_TV(fu, ut) do { \
122 (ut)->ut_tv.tv_sec = t / 1000000; \
123 (ut)->ut_tv.tv_usec = t % 1000000; \
130 static struct utmpx *ut;
132 static _Thread_local struct utmpx *ut;
135 if (ut == NULL) {
136 ut = calloc(1, sizeof *ut);
137 if (ut == NULL)
140 memset(ut, 0, sizeof *ut);
150 FTOU_ID(fu, ut);
151 FTOU_STRING(fu, ut, user);
152 FTOU_STRING(fu, ut, line);
154 FTOU_STRING(fu, ut, host);
155 FTOU_PID(fu, ut);
158 FTOU_ID(fu, ut);
159 FTOU_PID(fu, ut);
162 FTOU_ID(fu, ut);
163 FTOU_STRING(fu, ut, user);
164 FTOU_STRING(fu, ut, line);
165 FTOU_PID(fu, ut);
168 FTOU_ID(fu, ut);
169 FTOU_PID(fu, ut);
172 ut->ut_type = EMPTY;
173 return (ut);
176 FTOU_TYPE(fu, ut);
177 FTOU_TV(fu, ut);
178 return (ut);