1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax io.streams.string kernel quotations sequences strings math ;
7 { $values { "seq" sequence } }
8 { $description "Returns a sequence of " { $link group } " tuples that are platform-dependent and field for field complete with the Unix " { $link group } " structure." } ;
10 HELP: effective-group-id
11 { $values { "string" string } }
12 { $description "Returns the effective group id for the current user." } ;
14 HELP: effective-group-name
15 { $values { "string" string } }
16 { $description "Returns the effective group name for the current user." } ;
19 { $description "A platform-specific tuple corresponding to every field from the Unix group struct including the group name, the group id, the group passwd, and a list of users in each group." } ;
22 { $description "A symbol containing a cache of groups returned from " { $link all-groups } " and indexed by group id. Can be more efficient than using the system call words for many group lookups." } ;
27 { "id/f" "an integer or f" } }
28 { $description "Returns the group id given a group name. Returns " { $link f } " if the group does not exist." } ;
34 { $description "Returns the group name given a group id." } ;
39 { "group/f" "a group struct or f" } }
40 { $description "Returns an alien group struct to be turned into a group tuple by calling subsequent words." } ;
43 { $values { "id" integer } }
44 { $description "Returns the real group id for the current user." } ;
47 { $values { "string" string } }
48 { $description "Returns the real group name for the current user." } ;
50 HELP: set-effective-group
53 { $description "Sets the effective group id for the current user." } ;
58 { $description "Sets the real group id for the current user." } ;
62 { "string/id" "a string or a group id" }
64 { $description "Returns the sequence of groups to which the user belongs." } ;
66 HELP: with-effective-group
68 { "string/id/f" "a string, a group id, or f" } { "quot" quotation } }
69 { $description "Sets the effective group name and calls the quotation. Restores the effective group name on success or on error after the call. If the first parameter is " { $link f } ", the quotation is called as the current user." } ;
71 HELP: with-group-cache
73 { "quot" quotation } }
74 { $description "Iterates over the group file using library calls and creates a cache in the " { $link group-cache } " symbol. The cache is a hashtable indexed by group id. When looking up many groups, this approach is much faster than calling system calls." } ;
78 { "string/id/f" "a string or a group id" } { "quot" quotation } }
79 { $description "Sets the real group name and calls the quotation. Restores the current group name on success or on error after the call. If the first parameter is " { $link f } ", the quotation is called as the current user." } ;
86 { $description "Returns a group id or throws an exception." } ;
93 { $description "Returns a sequence of group names as strings." } ;
97 { "name/id" "a name or a group id" }
100 { $description "Returns a boolean representing the group's existence." } ;
102 ARTICLE: "unix.groups" "Unix groups"
103 "The " { $vocab-link "unix.groups" } " vocabulary contains words that return information about Unix groups."
105 "Listing all group structures:"
106 { $subsections all-groups }
107 "Listing all group names:"
108 { $subsections all-group-names }
109 "Checking if a group exists:"
110 { $subsections group-exists? }
111 "Querying/setting the current real group:"
117 "Querying/setting the current effective group:"
123 "Getting a group id from a group name or id:"
127 "Combinators to change groups:"