nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
metrics/mendel: add missing comments
[nit.git]
/
lib
/
standard
/
posix.nit
diff --git
a/lib/standard/posix.nit
b/lib/standard/posix.nit
index
4ac70a1
..
1fe850d
100644
(file)
--- a/
lib/standard/posix.nit
+++ b/
lib/standard/posix.nit
@@
-19,7
+19,7
@@
module posix
import string
import string
-`{
+in "C Header" `{
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
@@
-27,39
+27,76
@@
import string
`}
redef class Sys
`}
redef class Sys
+ # Set the real current user id of this process
fun uid=(uid: Int): Bool `{ return setuid(uid); `}
fun uid=(uid: Int): Bool `{ return setuid(uid); `}
+
+ # Current real user id of this process
fun uid: Int `{ return getuid(); `}
fun uid: Int `{ return getuid(); `}
+ # Set the current real group id of this process
fun gid=(gid: Int): Bool `{ return setgid(gid); `}
fun gid=(gid: Int): Bool `{ return setgid(gid); `}
+
+ # Current real group id of this process
fun gid: Int `{ return getgid(); `}
fun gid: Int `{ return getgid(); `}
+ # Set the effective user id of this process
fun euid=(uid: Int): Bool `{ return seteuid(uid); `}
fun euid=(uid: Int): Bool `{ return seteuid(uid); `}
+
+ # The effective user id of this process
fun euid: Int `{ return geteuid(); `}
fun euid: Int `{ return geteuid(); `}
+ # Set the effective group id of this process
fun egid=(gid: Int): Bool `{ return setegid(gid); `}
fun egid=(gid: Int): Bool `{ return setegid(gid); `}
+
+ # The effective group id of this process
fun egid: Int `{ return getegid(); `}
end
fun egid: Int `{ return getegid(); `}
end
+# Information on a user account
extern class Passwd `{struct passwd*`}
extern class Passwd `{struct passwd*`}
+ # Get the `Passwd` of the user with the `uid`
new from_uid(uid: Int) `{ return getpwuid(uid); `}
new from_uid(uid: Int) `{ return getpwuid(uid); `}
+
+ # Get the `Passwd` of the user with the `name`
new from_name(name: String) import String.to_cstring `{ return getpwnam( String_to_cstring(name) ); `}
new from_name(name: String) import String.to_cstring `{ return getpwnam( String_to_cstring(name) ); `}
+ # Username
fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_name); `}
fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_name); `}
+
+ # User password
fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_passwd); `}
fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_passwd); `}
+
+ # User ID
fun uid: Int `{ return recv->pw_uid; `}
fun uid: Int `{ return recv->pw_uid; `}
+
+ # Group ID
fun gid: Int `{ return recv->pw_gid; `}
fun gid: Int `{ return recv->pw_gid; `}
- fun gecos: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_gecos); `}
+
+ # Home directory
fun dir: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_dir); `}
fun dir: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_dir); `}
+
+ # Shell program
fun shell: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_shell); `}
end
fun shell: String import NativeString.to_s `{ return NativeString_to_s(recv->pw_shell); `}
end
+# Information on a user group
extern class Group `{struct group*`}
extern class Group `{struct group*`}
+ # Get a group from its id
new from_gid(gid: Int) `{ return getgrgid(gid); `}
new from_gid(gid: Int) `{ return getgrgid(gid); `}
+
+ # Get a group from its name
new from_name(name: String) import String.to_cstring `{ return getgrnam( String_to_cstring(name) ); `}
new from_name(name: String) import String.to_cstring `{ return getgrnam( String_to_cstring(name) ); `}
+ # Name of this ground
fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_name); `}
fun name: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_name); `}
+
+ # Encrypted password of this group
fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_passwd); `}
fun passwd: String import NativeString.to_s `{ return NativeString_to_s(recv->gr_passwd); `}
+
+ # Id of this group
fun gid: Int `{ return recv->gr_gid; `}
fun gid: Int `{ return recv->gr_gid; `}
+
+ # List of the members of the group
fun mem: Array[String] import Array[String], Array[String].add, NativeString.to_s `{
char **mem;
int m;
fun mem: Array[String] import Array[String], Array[String].add, NativeString.to_s `{
char **mem;
int m;