/[guile]/guile/guile-core/libguile/posix.c
ViewVC logotype

Diff of /guile/guile-core/libguile/posix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.107 by xxhanwen, Sat Jul 20 14:08:34 2002 UTC revision 1.108 by xxhanwen, Sun Jul 21 17:46:23 2002 UTC
# Line 222  SCM_DEFINE (scm_getgroups, "getgroups", Line 222  SCM_DEFINE (scm_getgroups, "getgroups",
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;
# Line 235  SCM_DEFINE (scm_getgroups, "getgroups", Line 235  SCM_DEFINE (scm_getgroups, "getgroups",
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
# Line 259  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, Line 259  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1,
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 ());
# Line 280  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, Line 280  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1,
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 */
# Line 327  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, Line 327  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1,
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      {      {
# Line 347  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, Line 347  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1,
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    
# Line 741  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0 Line 741  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0
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);
# Line 749  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0 Line 749  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0
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 */
# Line 982  SCM_DEFINE (scm_uname, "uname", 0, 0, 0, Line 982  SCM_DEFINE (scm_uname, "uname", 0, 0, 0,
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 */

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.108

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26