diff options
author | Gary Houston <ghouston@arglist.com> | 2000-11-07 21:34:45 +0000 |
---|---|---|
committer | Gary Houston <ghouston@arglist.com> | 2000-11-07 21:34:45 +0000 |
commit | c2ca44933f8b2b43ec3efa541a6824537c45a560 (patch) | |
tree | b93f926b2a7b6410cf36252c58f82e37979f5fdc /libguile/ioext.c | |
parent | b100f5eed22720eed9a8c2caa5dd46b0f712bae8 (diff) | |
download | guile-c2ca44933f8b2b43ec3efa541a6824537c45a560.tar.gz |
2000-11-07 Gary Houston <ghouston@arglist.com>
* ports.c (scm_port_for_each): new proc. implements port-for-each,
which applies a procedure to each port in the port table.
ports.h: declare scm_port_for_each.
* ioext.c (scm_dup2): new proc. implements "dup2" which is a simple
wrapper for the dup2 system call (unlike dup->fdes or
primitive-move->fdes).
* ioext.h: declare scm_dup2.
* filesys.c (scm_close_fdes): new proc. implements "close-fdes"
which is a simple wrapper for close system call (unlike scm_close).
* filesys.h: declare for scm_close_fdes.
Diffstat (limited to 'libguile/ioext.c')
-rw-r--r-- | libguile/ioext.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libguile/ioext.c b/libguile/ioext.c index 9cb84560e..439a7d7a0 100644 --- a/libguile/ioext.c +++ b/libguile/ioext.c @@ -412,6 +412,31 @@ SCM_DEFINE (scm_dup_to_fdes, "dup->fdes", 1, 1, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_dup2, "dup2", 2, 0, 0, + (SCM oldfd, SCM newfd), + "A simple wrapper for the @code{dup2} system call.\n" + "Copies the file descriptor @var{oldfd} to descriptor\n" + "number @var{newfd}, replacing the previous meaning\n" + "of @var{newfd}. Both @var{oldfd} and @var{newfd} must\n" + "be integers.\n" + "Unlike for dup->fdes or primitive-move->fdes, no attempt\n" + "is made to move away ports which are using @var{newfd}\n". + "The return value is unspecified.") +#define FUNC_NAME s_scm_dup2 +{ + int c_oldfd; + int c_newfd; + int rv; + + SCM_VALIDATE_INUM_COPY (1, oldfd, c_oldfd); + SCM_VALIDATE_INUM_COPY (2, newfd, c_newfd); + rv = dup2 (c_oldfd, c_newfd); + if (rv == -1) + SCM_SYSERROR; + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME + SCM_DEFINE (scm_fileno, "fileno", 1, 0, 0, (SCM port), "Returns the integer file descriptor underlying @var{port}.\n" |