222 |
"supplementary group IDs.") |
"supplementary group IDs.") |
223 |
#define FUNC_NAME s_scm_getgroups |
#define FUNC_NAME s_scm_getgroups |
224 |
{ |
{ |
225 |
SCM ans; |
SCM result; |
226 |
int ngroups; |
int ngroups; |
227 |
size_t size; |
size_t size; |
228 |
GETGROUPS_T *groups; |
GETGROUPS_T *groups; |
235 |
groups = scm_malloc (size); |
groups = scm_malloc (size); |
236 |
getgroups (ngroups, groups); |
getgroups (ngroups, groups); |
237 |
|
|
238 |
ans = scm_c_make_vector (ngroups, SCM_UNDEFINED); |
result = scm_c_make_vector (ngroups, SCM_UNDEFINED); |
239 |
|
|
240 |
{ |
{ |
241 |
SCM * ve = SCM_WRITABLE_VELTS(ans); |
SCM * ve = SCM_WRITABLE_VELTS(result); |
242 |
|
|
243 |
while (--ngroups >= 0) |
while (--ngroups >= 0) |
244 |
ve[ngroups] = SCM_MAKINUM (groups [ngroups]); |
ve[ngroups] = SCM_MAKINUM (groups [ngroups]); |
245 |
} |
} |
246 |
free (groups); |
free (groups); |
247 |
return ans; |
return result; |
248 |
} |
} |
249 |
#undef FUNC_NAME |
#undef FUNC_NAME |
250 |
#endif |
#endif |
259 |
{ |
{ |
260 |
struct passwd *entry; |
struct passwd *entry; |
261 |
|
|
262 |
SCM ans = scm_c_make_vector (7, SCM_UNSPECIFIED); |
SCM result = scm_c_make_vector (7, SCM_UNSPECIFIED); |
263 |
if (SCM_UNBNDP (user) || SCM_FALSEP (user)) |
if (SCM_UNBNDP (user) || SCM_FALSEP (user)) |
264 |
{ |
{ |
265 |
SCM_SYSCALL (entry = getpwent ()); |
SCM_SYSCALL (entry = getpwent ()); |
280 |
if (!entry) |
if (!entry) |
281 |
SCM_MISC_ERROR ("entry not found", SCM_EOL); |
SCM_MISC_ERROR ("entry not found", SCM_EOL); |
282 |
|
|
283 |
SCM_VECTOR_SET(ans, 0, scm_makfrom0str (entry->pw_name)); |
SCM_VECTOR_SET(result, 0, scm_makfrom0str (entry->pw_name)); |
284 |
SCM_VECTOR_SET(ans, 1, scm_makfrom0str (entry->pw_passwd)); |
SCM_VECTOR_SET(result, 1, scm_makfrom0str (entry->pw_passwd)); |
285 |
SCM_VECTOR_SET(ans, 2, scm_ulong2num ((unsigned long) entry->pw_uid)); |
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) entry->pw_uid)); |
286 |
SCM_VECTOR_SET(ans, 3, scm_ulong2num ((unsigned long) entry->pw_gid)); |
SCM_VECTOR_SET(result, 3, scm_ulong2num ((unsigned long) entry->pw_gid)); |
287 |
SCM_VECTOR_SET(ans, 4, scm_makfrom0str (entry->pw_gecos)); |
SCM_VECTOR_SET(result, 4, scm_makfrom0str (entry->pw_gecos)); |
288 |
if (!entry->pw_dir) |
if (!entry->pw_dir) |
289 |
SCM_VECTOR_SET(ans, 5, scm_makfrom0str ("")); |
SCM_VECTOR_SET(result, 5, scm_makfrom0str ("")); |
290 |
else |
else |
291 |
SCM_VECTOR_SET(ans, 5, scm_makfrom0str (entry->pw_dir)); |
SCM_VECTOR_SET(result, 5, scm_makfrom0str (entry->pw_dir)); |
292 |
if (!entry->pw_shell) |
if (!entry->pw_shell) |
293 |
SCM_VECTOR_SET(ans, 6, scm_makfrom0str ("")); |
SCM_VECTOR_SET(result, 6, scm_makfrom0str ("")); |
294 |
else |
else |
295 |
SCM_VECTOR_SET(ans, 6, scm_makfrom0str (entry->pw_shell)); |
SCM_VECTOR_SET(result, 6, scm_makfrom0str (entry->pw_shell)); |
296 |
return ans; |
return result; |
297 |
} |
} |
298 |
#undef FUNC_NAME |
#undef FUNC_NAME |
299 |
#endif /* HAVE_GETPWENT */ |
#endif /* HAVE_GETPWENT */ |
327 |
#define FUNC_NAME s_scm_getgrgid |
#define FUNC_NAME s_scm_getgrgid |
328 |
{ |
{ |
329 |
struct group *entry; |
struct group *entry; |
330 |
SCM ans = scm_c_make_vector (4, SCM_UNSPECIFIED); |
SCM result = scm_c_make_vector (4, SCM_UNSPECIFIED); |
331 |
|
|
332 |
if (SCM_UNBNDP (name) || SCM_FALSEP (name)) |
if (SCM_UNBNDP (name) || SCM_FALSEP (name)) |
333 |
{ |
{ |
347 |
if (!entry) |
if (!entry) |
348 |
SCM_SYSERROR; |
SCM_SYSERROR; |
349 |
|
|
350 |
SCM_VECTOR_SET(ans, 0, scm_makfrom0str (entry->gr_name)); |
SCM_VECTOR_SET(result, 0, scm_makfrom0str (entry->gr_name)); |
351 |
SCM_VECTOR_SET(ans, 1, scm_makfrom0str (entry->gr_passwd)); |
SCM_VECTOR_SET(result, 1, scm_makfrom0str (entry->gr_passwd)); |
352 |
SCM_VECTOR_SET(ans, 2, scm_ulong2num ((unsigned long) entry->gr_gid)); |
SCM_VECTOR_SET(result, 2, scm_ulong2num ((unsigned long) entry->gr_gid)); |
353 |
SCM_VECTOR_SET(ans, 3, scm_makfromstrs (-1, entry->gr_mem)); |
SCM_VECTOR_SET(result, 3, scm_makfromstrs (-1, entry->gr_mem)); |
354 |
return ans; |
return result; |
355 |
} |
} |
356 |
#undef FUNC_NAME |
#undef FUNC_NAME |
357 |
|
|
741 |
"underlying @var{port}.") |
"underlying @var{port}.") |
742 |
#define FUNC_NAME s_scm_ttyname |
#define FUNC_NAME s_scm_ttyname |
743 |
{ |
{ |
744 |
char *ans; |
char *result; |
745 |
int fd; |
int fd; |
746 |
|
|
747 |
port = SCM_COERCE_OUTPORT (port); |
port = SCM_COERCE_OUTPORT (port); |
749 |
if (!SCM_FPORTP (port)) |
if (!SCM_FPORTP (port)) |
750 |
return SCM_BOOL_F; |
return SCM_BOOL_F; |
751 |
fd = SCM_FPORT_FDES (port); |
fd = SCM_FPORT_FDES (port); |
752 |
SCM_SYSCALL (ans = ttyname (fd)); |
SCM_SYSCALL (result = ttyname (fd)); |
753 |
if (!ans) |
if (!result) |
754 |
SCM_SYSERROR; |
SCM_SYSERROR; |
755 |
/* ans could be overwritten by another call to ttyname */ |
/* result could be overwritten by another call to ttyname */ |
756 |
return (scm_makfrom0str (ans)); |
return (scm_makfrom0str (result)); |
757 |
} |
} |
758 |
#undef FUNC_NAME |
#undef FUNC_NAME |
759 |
#endif /* HAVE_TTYNAME */ |
#endif /* HAVE_TTYNAME */ |
982 |
#define FUNC_NAME s_scm_uname |
#define FUNC_NAME s_scm_uname |
983 |
{ |
{ |
984 |
struct utsname buf; |
struct utsname buf; |
985 |
SCM ans = scm_c_make_vector (5, SCM_UNSPECIFIED); |
SCM result = scm_c_make_vector (5, SCM_UNSPECIFIED); |
986 |
if (uname (&buf) < 0) |
if (uname (&buf) < 0) |
987 |
SCM_SYSERROR; |
SCM_SYSERROR; |
988 |
SCM_VECTOR_SET(ans, 0, scm_makfrom0str (buf.sysname)); |
SCM_VECTOR_SET(result, 0, scm_makfrom0str (buf.sysname)); |
989 |
SCM_VECTOR_SET(ans, 1, scm_makfrom0str (buf.nodename)); |
SCM_VECTOR_SET(result, 1, scm_makfrom0str (buf.nodename)); |
990 |
SCM_VECTOR_SET(ans, 2, scm_makfrom0str (buf.release)); |
SCM_VECTOR_SET(result, 2, scm_makfrom0str (buf.release)); |
991 |
SCM_VECTOR_SET(ans, 3, scm_makfrom0str (buf.version)); |
SCM_VECTOR_SET(result, 3, scm_makfrom0str (buf.version)); |
992 |
SCM_VECTOR_SET(ans, 4, scm_makfrom0str (buf.machine)); |
SCM_VECTOR_SET(result, 4, scm_makfrom0str (buf.machine)); |
993 |
/* |
/* |
994 |
a linux special? |
a linux special? |
995 |
SCM_VECTOR_SET(ans, 5, scm_makfrom0str (buf.domainname)); |
SCM_VECTOR_SET(result, 5, scm_makfrom0str (buf.domainname)); |
996 |
*/ |
*/ |
997 |
return ans; |
return result; |
998 |
} |
} |
999 |
#undef FUNC_NAME |
#undef FUNC_NAME |
1000 |
#endif /* HAVE_UNAME */ |
#endif /* HAVE_UNAME */ |