1 /***********************************************************************/
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
12 /***********************************************************************/
14 /* $Id: getgr.c 4144 2001-12-07 13:41:02Z xleroy $ */
20 #include "unixsupport.h"
24 static value alloc_group_entry(struct group *entry)
27 value name = Val_unit, pass = Val_unit, mem = Val_unit;
29 Begin_roots3 (name, pass, mem);
30 name = copy_string(entry->gr_name);
31 pass = copy_string(entry->gr_passwd);
32 mem = copy_string_array((const char**)entry->gr_mem);
33 res = alloc_small(4, 0);
36 Field(res,2) = Val_int(entry->gr_gid);
42 CAMLprim value unix_getgrnam(value name)
45 entry = getgrnam(String_val(name));
46 if (entry == NULL) raise_not_found();
47 return alloc_group_entry(entry);
50 CAMLprim value unix_getgrgid(value gid)
53 entry = getgrgid(Int_val(gid));
54 if (entry == NULL) raise_not_found();
55 return alloc_group_entry(entry);