1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21: #include <bits/libc-lock.h>
22: #include <stdlib.h>
23: #include <utmp.h>
24:
25: #include "utmp-private.h"
26:
27:
28:
29: static int setutent_unknown (void);
30: static int getutent_r_unknown (struct utmp *buffer, struct utmp **result);
31: static int getutid_r_unknown (const struct utmp *line, struct utmp *buffer,
32: struct utmp **result);
33: static int getutline_r_unknown (const struct utmp *id, struct utmp *buffer,
34: struct utmp **result);
35: static struct utmp *pututline_unknown (const struct utmp *data);
36: static void endutent_unknown (void);
37:
38:
39: const struct utfuncs __libc_utmp_unknown_functions =
40: {
41: setutent_unknown,
42: getutent_r_unknown,
43: getutid_r_unknown,
44: getutline_r_unknown,
45: pututline_unknown,
46: endutent_unknown,
47: NULL
48: };
49:
50:
51: const struct utfuncs *__libc_utmp_jump_table = &__libc_utmp_unknown_functions;
52:
53:
54: __libc_lock_define_initialized (, __libc_utmp_lock attribute_hidden)
55:
56:
57: static int
58: setutent_unknown (void)
59: {
60: int result;
61:
62: result = (*__libc_utmp_file_functions.setutent) ();
63: if (result)
64: __libc_utmp_jump_table = &__libc_utmp_file_functions;
65:
66: return result;
67: }
68:
69:
70: static int
71: getutent_r_unknown (struct utmp *buffer, struct utmp **result)
72: {
73:
74: if (setutent_unknown ())
75: return (*__libc_utmp_jump_table->getutent_r) (buffer, result);
76:
77:
78: *result = NULL;
79: return -1;
80: }
81:
82:
83: static int
84: getutid_r_unknown (const struct utmp *id, struct utmp *buffer,
85: struct utmp **result)
86: {
87:
88: if (setutent_unknown ())
89: return (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
90:
91:
92: *result = NULL;
93: return -1;
94: }
95:
96:
97: static int
98: getutline_r_unknown (const struct utmp *line, struct utmp *buffer,
99: struct utmp **result)
100: {
101:
102: if (setutent_unknown ())
103: return (*__libc_utmp_jump_table->getutline_r) (line, buffer, result);
104:
105:
106: *result = NULL;
107: return -1;
108: }
109:
110:
111: static struct utmp *
112: pututline_unknown (const struct utmp *data)
113: {
114:
115: if (setutent_unknown ())
116: return (*__libc_utmp_jump_table->pututline) (data);
117:
118:
119: return NULL;
120: }
121:
122:
123: static void
124: endutent_unknown (void)
125: {
126:
127: }
128:
129:
130: void
131: __setutent (void)
132: {
133: __libc_lock_lock (__libc_utmp_lock);
134:
135: (*__libc_utmp_jump_table->setutent) ();
136:
137: __libc_lock_unlock (__libc_utmp_lock);
138: }
139: weak_alias (__setutent, setutent)
140:
141:
142: int
143: __getutent_r (struct utmp *buffer, struct utmp **result)
144: {
145: int retval;
146:
147: __libc_lock_lock (__libc_utmp_lock);
148:
149: retval = (*__libc_utmp_jump_table->getutent_r) (buffer, result);
150:
151: __libc_lock_unlock (__libc_utmp_lock);
152:
153: return retval;
154: }
155: weak_alias (__getutent_r, getutent_r)
156:
157:
158: struct utmp *
159: __pututline (const struct utmp *data)
160: {
161: struct utmp *buffer;
162:
163: __libc_lock_lock (__libc_utmp_lock);
164:
165: buffer = (*__libc_utmp_jump_table->pututline) (data);
166:
167: __libc_lock_unlock (__libc_utmp_lock);
168:
169: return buffer;
170: }
171: weak_alias (__pututline, pututline)
172:
173:
174: void
175: __endutent (void)
176: {
177: __libc_lock_lock (__libc_utmp_lock);
178:
179: (*__libc_utmp_jump_table->endutent) ();
180: __libc_utmp_jump_table = &__libc_utmp_unknown_functions;
181:
182: __libc_lock_unlock (__libc_utmp_lock);
183: }
184: weak_alias (__endutent, endutent)