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" "a string or a group id" } { "quot" quotation } }
69 { $description "Sets the effective group name and calls the quotation. Restors the effective group name on success or on error after the call." } ;
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" "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." } ;
81 ARTICLE: "unix.groups" "Unix groups"
82 "The " { $vocab-link "unix.groups" } " vocabulary contains words that return information about Unix groups."
85 { $subsection all-groups }
86 "Returning a passwd tuple:"
88 { $subsection real-group-name }
89 { $subsection real-group-id }
90 { $subsection set-real-group }
92 { $subsection effective-group-name }
93 { $subsection effective-group-id }
94 { $subsection set-effective-group }
95 "Combinators to change groups:"
96 { $subsection with-real-group }
97 { $subsection with-effective-group } ;