2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <sys/types.h>
25 static llist_t pwd_list
= NULL
;
26 static size_t pwd_idx
= 0;
28 static void pwd_init() {
30 //FILE *fd = fopen("/etc/passwd","r");
31 /// @todo Read from file and do some scanf or regex stuff
35 struct passwd
*getpwnam(const char *name
) {
36 if (pwd_list
==NULL
) pwd_init();
40 for (i
=0;(pwd
= llist_get(pwd_list
,i
));i
++) {
41 if (strcmp(pwd
->pw_name
,name
)==0) return pwd
;
46 struct passwd
*getpwuid(uid_t uid
) {
47 if (pwd_list
==NULL
) pwd_init();
51 for (i
=0;(pwd
= llist_get(pwd_list
,i
));i
++) {
52 if (pwd
->pw_uid
==uid
) return pwd
;
57 struct passwd
*getpwent() {
58 return llist_get(pwd_list
,pwd_idx
++);