


## posix-etc.pkg
# Compiled by:
# src/lib/std/src/standard-core.sublib# Access to info from /etc/passwd /etc/group etc --
# POSIX 1003.1 system data-base operations
# This is a subpackage of the POSIX 1003.1 based
# 'Posix' package
#
# src/lib/std/src/posix-1003.1b/posix-1003-1b.pkg### "UNIX is basically a simple operating system, but you
### have to be a genius to understand the simplicity."
###
### -- Dennis Ritchie
stipulate
package ci = mythryl_callable_c_library_interface; # mythryl_callable_c_library_interface is from src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkgherein
package posix_etc {
#
package fs
=
posix_file; # posix_file is from src/lib/std/src/posix-1003.1b/posix-file.pkg fun cfun fun_name
=
ci::find_c_function { lib_name => "posix_passwd_db", fun_name };
Unt = host_unt::Unt;
User_Id = fs::User_Id;
Group_Id = fs::Group_Id;
package passwd
=
package {
Passwd
=
PWD { # extensible
name: String,
uid: User_Id,
gid: Group_Id,
home: String,
shell: String
};
fun name (PWD { name, ... } ) = name;
fun uid (PWD { uid, ... } ) = uid;
fun gid (PWD { gid, ... } ) = gid;
fun home (PWD { home, ... } ) = home;
fun shell (PWD { shell, ... } ) = shell;
};
package group
=
package {
Group = GROUP { # extensible
name: String,
gid: Group_Id,
members: List( String )
};
fun name (GROUP { name, ... } ) = name;
fun gid (GROUP { gid, ... } ) = gid;
fun members (GROUP { members, ... } ) = members;
};
my getgrgid' : Unt -> (String, Unt, List( String )) = cfun "getgrgid"; # getgrgid def in src/c/lib/posix-passwd/getgrgid.c
my getgrnam' : String -> (String, Unt, List( String )) = cfun "getgrnam"; # getgrnam def in src/c/lib/posix-passwd/getgrnam.c
fun getgrgid gid
=
{ my (name, gid, members)
=
getgrgid' gid;
group::GROUP
{
name,
gid,
members
};
};
fun getgrnam gname
=
{ my (name, gid, members)
=
getgrnam' gname;
group::GROUP { name, gid, members };
};
my getpwuid' : Unt -> (String, Unt, Unt, String, String) = cfun "getpwuid"; # getpwuid def in src/c/lib/posix-passwd/getpwuid.c
my getpwnam' : String -> (String, Unt, Unt, String, String) = cfun "getpwnam"; # getpwnam def in src/c/lib/posix-passwd/getpwnam.c
fun getpwuid uid
=
{ my (name, uid, gid, dir, shell)
=
getpwuid' uid;
passwd::PWD { name, uid, gid, home => dir, shell };
};
fun getpwnam name
=
{ my (name, uid, gid, dir, shell)
=
getpwnam' name;
passwd::PWD { name, uid, gid, home => dir, shell };
};
}; # package posix_etc
end;


