## posix-etc.pkg
#
# 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/psx/posixlib.pkg# Compiled by:
#
src/lib/std/src/standard-core.sublib### "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.pkg package fs = posix_file; # posix_file is from
src/lib/std/src/psx/posix-file.pkg package hu = host_unt; # host_unt is from
src/lib/std/types-only/bind-largest32.pkg #
fun cfun fun_name # For background see Note[1] in
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg =
ci::find_c_function'' { lib_name => "posix_passwd_db", fun_name };
herein
# This package appears to implement
#
#
src/lib/std/src/psx/posix-etc.api #
package posix_etc { # Posix_Etc is from
src/lib/std/src/psx/posix-etc.api #
Unt = hu::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 p) = p.name;
fun uid (PWD p) = p.uid;
fun gid (PWD p) = p.gid;
fun home (PWD p) = p.home;
fun shell (PWD p) = p.shell;
};
package group
=
package {
Group = GROUP { # extensible
name: String,
gid: Group_Id,
members: List( String )
};
fun name (GROUP g) = g.name;
fun gid (GROUP g) = g.gid;
fun members (GROUP g) = g.members;
};
(cfun "getgrgid") # getgrgid def in src/c/lib/posix-passwd/getgrgid.c
->
( getgrgid__syscall: Unt -> (String, Unt, List( String )),
getgrgid__ref,
set__getgrgid__ref
);
(cfun "getgrnam") # getgrnam def in src/c/lib/posix-passwd/getgrnam.c
->
( getgrnam__syscall: String -> (String, Unt, List( String )),
getgrnam__ref,
set__getgrnam__ref
);
fun getgrgid gid
=
{ (*getgrgid__ref gid)
->
(name, gid, members);
group::GROUP
{
name,
gid,
members
};
};
fun getgrnam gname
=
{ (*getgrnam__ref gname)
->
(name, gid, members);
group::GROUP { name, gid, members };
};
(cfun "getpwuid") # getpwuid def in src/c/lib/posix-passwd/getpwuid.c
->
( getpwuid__syscall: Unt -> (String, Unt, Unt, String, String),
getpwuid__ref,
set__getpwuid__ref
);
(cfun "getpwnam") # getpwnam def in src/c/lib/posix-passwd/getpwnam.c
->
( getpwnam__syscall: String -> (String, Unt, Unt, String, String),
getpwnam__ref,
set__getpwnam__ref
);
fun getpwuid uid
=
{ (*getpwuid__ref uid)
->
(name, uid, gid, dir, shell);
passwd::PWD { name, uid, gid, home => dir, shell };
};
fun getpwnam name
=
{ (*getpwnam__ref name)
->
(name, uid, gid, dir, shell);
passwd::PWD { name, uid, gid, home => dir, shell };
};
}; # package posix_etc
end;