summaryrefslogtreecommitdiffstats
path: root/posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix.c')
-rw-r--r--posix.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/posix.c b/posix.c
index 8af5c0b..229384a 100644
--- a/posix.c
+++ b/posix.c
@@ -57,14 +57,15 @@
#else /* added by Denys Duchier */
# ifdef SVR4
# include <unistd.h>
-# else
-# ifdef linux
-# include <unistd.h>
-# else
-# ifdef __OpenBSD__
-# include <unistd.h>
-# endif
-# endif
+# endif
+# ifdef linux
+# include <unistd.h>
+# endif
+# ifdef __OpenBSD__
+# include <unistd.h>
+# endif
+# ifdef __NetBSD__
+# include <unistd.h>
# endif
#endif
@@ -73,9 +74,9 @@ SCM l_chown(path, owner, group)
SCM path, owner, group;
{
int val;
- ASSERT(NIMP(path) && STRINGP(path), path, ARG1, s_chown);
- ASSERT(INUMP(owner), owner, ARG2, s_chown);
- ASSERT(INUMP(group), group, ARG3, s_chown);
+ ASRTER(NIMP(path) && STRINGP(path), path, ARG1, s_chown);
+ ASRTER(INUMP(owner), owner, ARG2, s_chown);
+ ASRTER(INUMP(group), group, ARG3, s_chown);
SYSCALL(val = chown(CHARS(path), INUM(owner), INUM(group)););
return val ? BOOL_F : BOOL_T;
}
@@ -85,8 +86,8 @@ SCM l_link(oldpath, newpath)
SCM oldpath, newpath;
{
int val;
- ASSERT(NIMP(oldpath) && STRINGP(oldpath), oldpath, ARG1, s_link);
- ASSERT(NIMP(newpath) && STRINGP(newpath), newpath, ARG2, s_link);
+ ASRTER(NIMP(oldpath) && STRINGP(oldpath), oldpath, ARG1, s_link);
+ ASRTER(NIMP(newpath) && STRINGP(newpath), newpath, ARG2, s_link);
SYSCALL(val = link(CHARS(oldpath), CHARS(newpath)););
return val ? BOOL_F : BOOL_T;
}
@@ -124,8 +125,8 @@ SCM open_pipe(pipestr, modes)
{
FILE *f;
register SCM z;
- ASSERT(NIMP(pipestr) && STRINGP(pipestr), pipestr, ARG1, s_op_pipe);
- ASSERT(NIMP(modes) && (STRINGP(modes) || SYMBOLP(modes)), modes, ARG2, s_op_pipe);
+ ASRTER(NIMP(pipestr) && STRINGP(pipestr), pipestr, ARG1, s_op_pipe);
+ ASRTER(NIMP(modes) && (STRINGP(modes) || SYMBOLP(modes)), modes, ARG2, s_op_pipe);
NEWCELL(z);
/* DEFER_INTS, SYSCALL, and ALLOW_INTS are probably paranoid here*/
DEFER_INTS;
@@ -180,7 +181,7 @@ SCM l_pwinfo(user)
if UNBNDP(user) SYSCALL(entry = getpwent(););
else if INUMP(user) SYSCALL(entry = getpwuid(INUM(user)););
else {
- ASSERT(NIMP(user) && STRINGP(user), user, ARG1, s_pwinfo);
+ ASRTER(NIMP(user) && STRINGP(user), user, ARG1, s_pwinfo);
SYSCALL(entry = getpwnam(CHARS(user)););
}
ALLOW_INTS;
@@ -206,7 +207,7 @@ SCM l_grinfo(name)
if UNBNDP(name) SYSCALL(entry = getgrent(););
else if INUMP(name) SYSCALL(entry = getgrgid(INUM(name)););
else {
- ASSERT(NIMP(name) && STRINGP(name), name, ARG1, s_grinfo);
+ ASRTER(NIMP(name) && STRINGP(name), name, ARG1, s_grinfo);
SYSCALL(entry = getgrnam(CHARS(name)););
}
ALLOW_INTS;
@@ -237,8 +238,8 @@ SCM l_kill(pid, sig)
SCM pid, sig;
{
int i;
- ASSERT(INUMP(pid), pid, ARG1, s_kill);
- ASSERT(INUMP(sig), sig, ARG2, s_kill);
+ ASRTER(INUMP(pid), pid, ARG1, s_kill);
+ ASRTER(INUMP(sig), sig, ARG2, s_kill);
SYSCALL(i = kill((int)INUM(pid), (int)INUM(sig)););
return MAKINUM(0L+i);
}
@@ -247,8 +248,8 @@ SCM l_waitpid(pid, options)
SCM pid, options;
{
int i, status;
- ASSERT(INUMP(pid), pid, ARG1, s_waitpid);
- ASSERT(INUMP(options), options, ARG2, s_waitpid);
+ ASRTER(INUMP(pid), pid, ARG1, s_waitpid);
+ ASRTER(INUMP(options), options, ARG2, s_waitpid);
SYSCALL(i = waitpid(INUM(pid), &status, INUM(options)););
return i < 0 ? BOOL_F : MAKINUM(0L+status);
}
@@ -258,10 +259,6 @@ SCM l_getppid()
return MAKINUM(0L+getppid());
}
-SCM scm_getlogin()
-{
- return makfrom0str(getlogin());
-}
SCM l_getuid()
{
return MAKINUM(0L+getuid());
@@ -285,14 +282,14 @@ static char s_setuid[] = "setuid";
SCM l_setuid(id)
SCM id;
{
- ASSERT(INUMP(id), id, ARG1, s_setuid);
+ ASRTER(INUMP(id), id, ARG1, s_setuid);
return setuid(INUM(id)) ? BOOL_F : BOOL_T;
}
static char s_setgid[] = "setgid";
SCM l_setgid(id)
SCM id;
{
- ASSERT(INUMP(id), id, ARG1, s_setgid);
+ ASRTER(INUMP(id), id, ARG1, s_setgid);
return setgid(INUM(id)) ? BOOL_F : BOOL_T;
}
@@ -301,14 +298,14 @@ static char s_seteuid[] = "seteuid";
SCM l_seteuid(id)
SCM id;
{
- ASSERT(INUMP(id), id, ARG1, s_seteuid);
+ ASRTER(INUMP(id), id, ARG1, s_seteuid);
return seteuid(INUM(id)) ? BOOL_F : BOOL_T;
}
static char s_setegid[] = "setegid";
SCM l_setegid(id)
SCM id;
{
- ASSERT(INUMP(id), id, ARG1, s_setegid);
+ ASRTER(INUMP(id), id, ARG1, s_setegid);
return setegid(INUM(id)) ? BOOL_F : BOOL_T;
}
#endif
@@ -318,7 +315,7 @@ SCM l_ttyname(port)
SCM port;
{
char *ans;
- ASSERT(NIMP(port) && OPPORTP(port), port, ARG1, s_ttyname);
+ ASRTER(NIMP(port) && OPPORTP(port), port, ARG1, s_ttyname);
if (tc16_fport != TYP16(port)) return BOOL_F;
SYSCALL(ans = ttyname(fileno(STREAM(port))););
/* ans could be overwritten by another call to ttyname */
@@ -351,7 +348,6 @@ static iproc subr0s[] = {
{"pipe", l_pipe},
{scm_s_getgroups, scm_getgroups},
{"getppid", l_getppid},
- {"getlogin", scm_getlogin},
{"getuid", l_getuid},
{"getgid", l_getgid},
#ifndef LACK_E_IDs
@@ -405,8 +401,11 @@ void init_posix()
scm_ldstr("\n\
(define (open-input-pipe cmd) (open-pipe cmd \"r\"))\n\
(define (open-output-pipe cmd) (open-pipe cmd \"w\"))\n\
-(define getlogin\n\
- (let ((getlogin getlogin))\n\
- (lambda () (or (getlogin) (getenv \"USER\") (getenv \"LOGNAME\")))))\n\
+(define (system->line command . tmp)\n\
+ (define line\n\
+ (call-with-open-ports\n\
+ read-line\n\
+ (open-input-pipe command)))\n\
+ (if (eof-object? line) \"\" line))\n\
");
}