/[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.106 by mvo, Wed Jul 10 19:40:43 2002 UTC revision 1.107 by xxhanwen, Sat Jul 20 14:08:34 2002 UTC
# Line 236  SCM_DEFINE (scm_getgroups, "getgroups", Line 236  SCM_DEFINE (scm_getgroups, "getgroups",
236    getgroups (ngroups, groups);    getgroups (ngroups, groups);
237    
238    ans = scm_c_make_vector (ngroups, SCM_UNDEFINED);    ans = scm_c_make_vector (ngroups, SCM_UNDEFINED);
   while (--ngroups >= 0)  
     SCM_VELTS (ans) [ngroups] = SCM_MAKINUM (groups [ngroups]);  
239    
240      {
241        SCM * ve = SCM_WRITABLE_VELTS(ans);
242        
243        while (--ngroups >= 0)
244          ve[ngroups] = SCM_MAKINUM (groups [ngroups]);
245      }
246    free (groups);    free (groups);
247    return ans;    return ans;
248  }  }
# Line 253  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, Line 257  SCM_DEFINE (scm_getpwuid, "getpw", 0, 1,
257              "or getpwent respectively.")              "or getpwent respectively.")
258  #define FUNC_NAME s_scm_getpwuid  #define FUNC_NAME s_scm_getpwuid
259  {  {
   SCM result;  
260    struct passwd *entry;    struct passwd *entry;
   SCM *ve;  
261    
262    result = scm_c_make_vector (7, SCM_UNSPECIFIED);    SCM ans = scm_c_make_vector (7, SCM_UNSPECIFIED);
   ve = SCM_VELTS (result);  
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 279  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    ve[0] = scm_makfrom0str (entry->pw_name);    SCM_VECTOR_SET(ans, 0, scm_makfrom0str (entry->pw_name));
284    ve[1] = scm_makfrom0str (entry->pw_passwd);    SCM_VECTOR_SET(ans, 1, scm_makfrom0str (entry->pw_passwd));
285    ve[2] = scm_ulong2num ((unsigned long) entry->pw_uid);    SCM_VECTOR_SET(ans, 2, scm_ulong2num ((unsigned long) entry->pw_uid));
286    ve[3] = scm_ulong2num ((unsigned long) entry->pw_gid);    SCM_VECTOR_SET(ans, 3, scm_ulong2num ((unsigned long) entry->pw_gid));
287    ve[4] = scm_makfrom0str (entry->pw_gecos);    SCM_VECTOR_SET(ans, 4, scm_makfrom0str (entry->pw_gecos));
288    if (!entry->pw_dir)    if (!entry->pw_dir)
289      ve[5] = scm_makfrom0str ("");      SCM_VECTOR_SET(ans, 5, scm_makfrom0str (""));
290    else    else
291      ve[5] = scm_makfrom0str (entry->pw_dir);      SCM_VECTOR_SET(ans, 5, scm_makfrom0str (entry->pw_dir));
292    if (!entry->pw_shell)    if (!entry->pw_shell)
293      ve[6] = scm_makfrom0str ("");      SCM_VECTOR_SET(ans, 6, scm_makfrom0str (""));
294    else    else
295      ve[6] = scm_makfrom0str (entry->pw_shell);      SCM_VECTOR_SET(ans, 6, scm_makfrom0str (entry->pw_shell));
296    return result;    return ans;
297  }  }
298  #undef FUNC_NAME  #undef FUNC_NAME
299  #endif /* HAVE_GETPWENT */  #endif /* HAVE_GETPWENT */
# Line 325  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1, Line 326  SCM_DEFINE (scm_getgrgid, "getgr", 0, 1,
326              "or getgrent respectively.")              "or getgrent respectively.")
327  #define FUNC_NAME s_scm_getgrgid  #define FUNC_NAME s_scm_getgrgid
328  {  {
   SCM result;  
329    struct group *entry;    struct group *entry;
330    SCM *ve;    SCM ans = scm_c_make_vector (4, SCM_UNSPECIFIED);
331    result = scm_c_make_vector (4, SCM_UNSPECIFIED);  
   ve = SCM_VELTS (result);  
332    if (SCM_UNBNDP (name) || SCM_FALSEP (name))    if (SCM_UNBNDP (name) || SCM_FALSEP (name))
333      {      {
334        SCM_SYSCALL (entry = getgrent ());        SCM_SYSCALL (entry = getgrent ());
# Line 348  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    ve[0] = scm_makfrom0str (entry->gr_name);    SCM_VECTOR_SET(ans, 0, scm_makfrom0str (entry->gr_name));
351    ve[1] = scm_makfrom0str (entry->gr_passwd);    SCM_VECTOR_SET(ans, 1, scm_makfrom0str (entry->gr_passwd));
352    ve[2] = scm_ulong2num ((unsigned long) entry->gr_gid);    SCM_VECTOR_SET(ans, 2, scm_ulong2num ((unsigned long) entry->gr_gid));
353    ve[3] = scm_makfromstrs (-1, entry->gr_mem);    SCM_VECTOR_SET(ans, 3, scm_makfromstrs (-1, entry->gr_mem));
354    return result;    return ans;
355  }  }
356  #undef FUNC_NAME  #undef FUNC_NAME
357    
# Line 401  SCM_DEFINE (scm_kill, "kill", 2, 0, 0, Line 400  SCM_DEFINE (scm_kill, "kill", 2, 0, 0,
400              "@end defvar")              "@end defvar")
401  #define FUNC_NAME s_scm_kill  #define FUNC_NAME s_scm_kill
402  {  {
403    SCM_VALIDATE_INUM (1,pid);    SCM_VALIDATE_INUM (1, pid);
404    SCM_VALIDATE_INUM (2,sig);    SCM_VALIDATE_INUM (2, sig);
405    /* Signal values are interned in scm_init_posix().  */    /* Signal values are interned in scm_init_posix().  */
406  #ifdef HAVE_KILL  #ifdef HAVE_KILL
407    if (kill ((int) SCM_INUM (pid), (int) SCM_INUM (sig)) != 0)    if (kill ((int) SCM_INUM (pid), (int) SCM_INUM (sig)) != 0)
# Line 457  SCM_DEFINE (scm_waitpid, "waitpid", 1, 1 Line 456  SCM_DEFINE (scm_waitpid, "waitpid", 1, 1
456    int i;    int i;
457    int status;    int status;
458    int ioptions;    int ioptions;
459    SCM_VALIDATE_INUM (1,pid);    SCM_VALIDATE_INUM (1, pid);
460    if (SCM_UNBNDP (options))    if (SCM_UNBNDP (options))
461      ioptions = 0;      ioptions = 0;
462    else    else
463      {      {
464        SCM_VALIDATE_INUM (2,options);        SCM_VALIDATE_INUM (2, options);
465        /* Flags are interned in scm_init_posix.  */        /* Flags are interned in scm_init_posix.  */
466        ioptions = SCM_INUM (options);        ioptions = SCM_INUM (options);
467      }      }
# Line 484  SCM_DEFINE (scm_status_exit_val, "status Line 483  SCM_DEFINE (scm_status_exit_val, "status
483  {  {
484    int lstatus;    int lstatus;
485    
486    SCM_VALIDATE_INUM (1,status);    SCM_VALIDATE_INUM (1, status);
487    
488    /* On Ultrix, the WIF... macros assume their argument is an lvalue;    /* On Ultrix, the WIF... macros assume their argument is an lvalue;
489       go figure.  SCM_INUM does not yield an lvalue.  */       go figure.  SCM_INUM does not yield an lvalue.  */
# Line 504  SCM_DEFINE (scm_status_term_sig, "status Line 503  SCM_DEFINE (scm_status_term_sig, "status
503  {  {
504    int lstatus;    int lstatus;
505    
506    SCM_VALIDATE_INUM (1,status);    SCM_VALIDATE_INUM (1, status);
507    
508    lstatus = SCM_INUM (status);    lstatus = SCM_INUM (status);
509    if (WIFSIGNALED (lstatus))    if (WIFSIGNALED (lstatus))
# Line 522  SCM_DEFINE (scm_status_stop_sig, "status Line 521  SCM_DEFINE (scm_status_stop_sig, "status
521  {  {
522    int lstatus;    int lstatus;
523    
524    SCM_VALIDATE_INUM (1,status);    SCM_VALIDATE_INUM (1, status);
525    
526    lstatus = SCM_INUM (status);    lstatus = SCM_INUM (status);
527    if (WIFSTOPPED (lstatus))    if (WIFSTOPPED (lstatus))
# Line 610  SCM_DEFINE (scm_setuid, "setuid", 1, 0, Line 609  SCM_DEFINE (scm_setuid, "setuid", 1, 0,
609              "The return value is unspecified.")              "The return value is unspecified.")
610  #define FUNC_NAME s_scm_setuid  #define FUNC_NAME s_scm_setuid
611  {  {
612    SCM_VALIDATE_INUM (1,id);    SCM_VALIDATE_INUM (1, id);
613    if (setuid (SCM_INUM (id)) != 0)    if (setuid (SCM_INUM (id)) != 0)
614      SCM_SYSERROR;      SCM_SYSERROR;
615    return SCM_UNSPECIFIED;    return SCM_UNSPECIFIED;
# Line 624  SCM_DEFINE (scm_setgid, "setgid", 1, 0, Line 623  SCM_DEFINE (scm_setgid, "setgid", 1, 0,
623              "The return value is unspecified.")              "The return value is unspecified.")
624  #define FUNC_NAME s_scm_setgid  #define FUNC_NAME s_scm_setgid
625  {  {
626    SCM_VALIDATE_INUM (1,id);    SCM_VALIDATE_INUM (1, id);
627    if (setgid (SCM_INUM (id)) != 0)    if (setgid (SCM_INUM (id)) != 0)
628      SCM_SYSERROR;      SCM_SYSERROR;
629    return SCM_UNSPECIFIED;    return SCM_UNSPECIFIED;
# Line 642  SCM_DEFINE (scm_seteuid, "seteuid", 1, 0 Line 641  SCM_DEFINE (scm_seteuid, "seteuid", 1, 0
641  {  {
642    int rv;    int rv;
643    
644    SCM_VALIDATE_INUM (1,id);    SCM_VALIDATE_INUM (1, id);
645  #ifdef HAVE_SETEUID  #ifdef HAVE_SETEUID
646    rv = seteuid (SCM_INUM (id));    rv = seteuid (SCM_INUM (id));
647  #else  #else
# Line 668  SCM_DEFINE (scm_setegid, "setegid", 1, 0 Line 667  SCM_DEFINE (scm_setegid, "setegid", 1, 0
667  {  {
668    int rv;    int rv;
669    
670    SCM_VALIDATE_INUM (1,id);    SCM_VALIDATE_INUM (1, id);
671  #ifdef HAVE_SETEUID  #ifdef HAVE_SETEUID
672    rv = setegid (SCM_INUM (id));    rv = setegid (SCM_INUM (id));
673  #else  #else
# Line 708  SCM_DEFINE (scm_setpgid, "setpgid", 2, 0 Line 707  SCM_DEFINE (scm_setpgid, "setpgid", 2, 0
707              "The return value is unspecified.")              "The return value is unspecified.")
708  #define FUNC_NAME s_scm_setpgid  #define FUNC_NAME s_scm_setpgid
709  {  {
710    SCM_VALIDATE_INUM (1,pid);    SCM_VALIDATE_INUM (1, pid);
711    SCM_VALIDATE_INUM (2,pgid);    SCM_VALIDATE_INUM (2, pgid);
712    /* FIXME(?): may be known as setpgrp.  */    /* FIXME(?): may be known as setpgrp.  */
713    if (setpgid (SCM_INUM (pid), SCM_INUM (pgid)) != 0)    if (setpgid (SCM_INUM (pid), SCM_INUM (pgid)) != 0)
714      SCM_SYSERROR;      SCM_SYSERROR;
# Line 746  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0 Line 745  SCM_DEFINE (scm_ttyname, "ttyname", 1, 0
745    int fd;    int fd;
746    
747    port = SCM_COERCE_OUTPORT (port);    port = SCM_COERCE_OUTPORT (port);
748    SCM_VALIDATE_OPPORT (1,port);    SCM_VALIDATE_OPPORT (1, 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);
# Line 794  SCM_DEFINE (scm_tcgetpgrp, "tcgetpgrp", Line 793  SCM_DEFINE (scm_tcgetpgrp, "tcgetpgrp",
793    
794    port = SCM_COERCE_OUTPORT (port);    port = SCM_COERCE_OUTPORT (port);
795    
796    SCM_VALIDATE_OPFPORT (1,port);    SCM_VALIDATE_OPFPORT (1, port);
797    fd = SCM_FPORT_FDES (port);    fd = SCM_FPORT_FDES (port);
798    if ((pgid = tcgetpgrp (fd)) == -1)    if ((pgid = tcgetpgrp (fd)) == -1)
799      SCM_SYSERROR;      SCM_SYSERROR;
# Line 817  SCM_DEFINE (scm_tcsetpgrp, "tcsetpgrp", Line 816  SCM_DEFINE (scm_tcsetpgrp, "tcsetpgrp",
816    
817    port = SCM_COERCE_OUTPORT (port);    port = SCM_COERCE_OUTPORT (port);
818    
819    SCM_VALIDATE_OPFPORT (1,port);    SCM_VALIDATE_OPFPORT (1, port);
820    SCM_VALIDATE_INUM (2,pgid);    SCM_VALIDATE_INUM (2, pgid);
821    fd = SCM_FPORT_FDES (port);    fd = SCM_FPORT_FDES (port);
822    if (tcsetpgrp (fd, SCM_INUM (pgid)) == -1)    if (tcsetpgrp (fd, SCM_INUM (pgid)) == -1)
823      SCM_SYSERROR;      SCM_SYSERROR;
# Line 984  SCM_DEFINE (scm_uname, "uname", 0, 0, 0, Line 983  SCM_DEFINE (scm_uname, "uname", 0, 0, 0,
983  {  {
984    struct utsname buf;    struct utsname buf;
985    SCM ans = scm_c_make_vector (5, SCM_UNSPECIFIED);    SCM ans = scm_c_make_vector (5, SCM_UNSPECIFIED);
   SCM *ve = SCM_VELTS (ans);  
986    if (uname (&buf) < 0)    if (uname (&buf) < 0)
987      SCM_SYSERROR;      SCM_SYSERROR;
988    ve[0] = scm_makfrom0str (buf.sysname);    SCM_VECTOR_SET(ans, 0, scm_makfrom0str (buf.sysname));
989    ve[1] = scm_makfrom0str (buf.nodename);    SCM_VECTOR_SET(ans, 1, scm_makfrom0str (buf.nodename));
990    ve[2] = scm_makfrom0str (buf.release);    SCM_VECTOR_SET(ans, 2, scm_makfrom0str (buf.release));
991    ve[3] = scm_makfrom0str (buf.version);    SCM_VECTOR_SET(ans, 3, scm_makfrom0str (buf.version));
992    ve[4] = scm_makfrom0str (buf.machine);    SCM_VECTOR_SET(ans, 4, scm_makfrom0str (buf.machine));
993  /*  /*
994     a linux special?     a linux special?
995    ve[5] = scm_makfrom0str (buf.domainname);    SCM_VECTOR_SET(ans, 5, scm_makfrom0str (buf.domainname));
996  */  */
997    return ans;    return ans;
998  }  }
# Line 1225  SCM_DEFINE (scm_setlocale, "setlocale", Line 1223  SCM_DEFINE (scm_setlocale, "setlocale",
1223    char *clocale;    char *clocale;
1224    char *rv;    char *rv;
1225    
1226    SCM_VALIDATE_INUM (1,category);    SCM_VALIDATE_INUM (1, category);
1227    if (SCM_UNBNDP (locale))    if (SCM_UNBNDP (locale))
1228      {      {
1229        clocale = NULL;        clocale = NULL;
# Line 1267  SCM_DEFINE (scm_mknod, "mknod", 4, 0, 0, Line 1265  SCM_DEFINE (scm_mknod, "mknod", 4, 0, 0,
1265    int ctype = 0;    int ctype = 0;
1266    
1267    SCM_VALIDATE_STRING (1, path);    SCM_VALIDATE_STRING (1, path);
1268    SCM_VALIDATE_SYMBOL (2,type);    SCM_VALIDATE_SYMBOL (2, type);
1269    SCM_VALIDATE_INUM (3,perms);    SCM_VALIDATE_INUM (3, perms);
1270    SCM_VALIDATE_INUM (4,dev);    SCM_VALIDATE_INUM (4, dev);
1271    
1272    p = SCM_SYMBOL_CHARS (type);    p = SCM_SYMBOL_CHARS (type);
1273    if (strcmp (p, "regular") == 0)    if (strcmp (p, "regular") == 0)
# Line 1289  SCM_DEFINE (scm_mknod, "mknod", 4, 0, 0, Line 1287  SCM_DEFINE (scm_mknod, "mknod", 4, 0, 0,
1287      ctype = S_IFSOCK;      ctype = S_IFSOCK;
1288  #endif  #endif
1289    else    else
1290      SCM_OUT_OF_RANGE (2,type);      SCM_OUT_OF_RANGE (2, type);
1291    
1292    SCM_SYSCALL (val = mknod (SCM_STRING_CHARS (path), ctype | SCM_INUM (perms),    SCM_SYSCALL (val = mknod (SCM_STRING_CHARS (path), ctype | SCM_INUM (perms),
1293                              SCM_INUM (dev)));                              SCM_INUM (dev)));
# Line 1308  SCM_DEFINE (scm_nice, "nice", 1, 0, 0, Line 1306  SCM_DEFINE (scm_nice, "nice", 1, 0, 0,
1306              "The return value is unspecified.")              "The return value is unspecified.")
1307  #define FUNC_NAME s_scm_nice  #define FUNC_NAME s_scm_nice
1308  {  {
1309    SCM_VALIDATE_INUM (1,incr);    SCM_VALIDATE_INUM (1, incr);
1310    if (nice(SCM_INUM(incr)) != 0)    if (nice(SCM_INUM(incr)) != 0)
1311      SCM_SYSERROR;      SCM_SYSERROR;
1312    return SCM_UNSPECIFIED;    return SCM_UNSPECIFIED;

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

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