120 lines
4.4 KiB
Modula-2
120 lines
4.4 KiB
Modula-2
(*$Foreign language module *)
|
|
DEFINITION MODULE Unix;
|
|
(*
|
|
Module: interface to some Unix systemcalls
|
|
Author: Ceriel J.H. Jacobs
|
|
Version: $Header$
|
|
*)
|
|
FROM SYSTEM IMPORT WORD, ADDRESS;
|
|
|
|
(* Type needed for Signal *)
|
|
TYPE SignalPrc = PROCEDURE(INTEGER);
|
|
CONST
|
|
SIGDFL = SignalPrc(NIL);
|
|
SIGIGN = SignalPrc(NIL+1);
|
|
ILLBREAK = ADDRESS(NIL-1);
|
|
|
|
VAR errno: INTEGER;
|
|
(* Possible values of errno: *)
|
|
CONST
|
|
EPERM = 1; (* Not owner *)
|
|
ENOENT = 2; (* No such file or directory *)
|
|
ESRCH = 3; (* No such process *)
|
|
EINTR = 4; (* Interrupted system call *)
|
|
EIO = 5; (* I/O error *)
|
|
ENXIO = 6; (* No such device or address *)
|
|
E2BIG = 7; (* Arg list too long *)
|
|
ENOEXEC = 8; (* Exec format error *)
|
|
EBADF = 9; (* Bad file number *)
|
|
ECHILD = 10; (* No child processes *)
|
|
EAGAIN = 11; (* No more processes *)
|
|
ENOMEM = 12; (* Not enough space *)
|
|
EACCES = 13; (* Permission denied *)
|
|
EFAULT = 14; (* Bad address *)
|
|
ENOTBLK = 15; (* Block device required *)
|
|
EBUSY = 16; (* Mount device busy *)
|
|
EEXIST = 17; (* File exists *)
|
|
EXDEV = 18; (* Cross-device link *)
|
|
ENODEV = 19; (* No such device *)
|
|
ENOTDIR = 20; (* Not a directory *)
|
|
EISDIR = 21; (* Is a directory *)
|
|
EINVAL = 22; (* Invalid argument *)
|
|
ENFILE = 23; (* File table overflow *)
|
|
EMFILE = 24; (* Too many open files *)
|
|
ENOTTY = 25; (* Not a typewriter *)
|
|
ETXTBSY = 26; (* Text file busy *)
|
|
EFBIG = 27; (* File too large *)
|
|
ENOSPC = 28; (* No space left on device *)
|
|
ESPIPE = 29; (* Illegal seek *)
|
|
EROFS = 30; (* Read-only file system *)
|
|
EMLINK = 31; (* Too many links *)
|
|
EPIPE = 32; (* Broken pipe *)
|
|
EDOM = 33; (* Math argument *)
|
|
ERANGE = 34; (* Result too large *)
|
|
|
|
PROCEDURE access(path: ADDRESS; amode : INTEGER) : INTEGER;
|
|
PROCEDURE acct(path: ADDRESS) : INTEGER;
|
|
PROCEDURE alarm(sec: CARDINAL) : CARDINAL;
|
|
PROCEDURE brk(endds: ADDRESS) : INTEGER;
|
|
PROCEDURE sbrk(incr: INTEGER) : ADDRESS;
|
|
PROCEDURE chdir(path: ADDRESS) : INTEGER;
|
|
PROCEDURE chmod(path: ADDRESS; mode: INTEGER) : INTEGER;
|
|
PROCEDURE chown(path: ADDRESS; owner, group: INTEGER) : INTEGER;
|
|
PROCEDURE chroot(path: ADDRESS) : INTEGER;
|
|
PROCEDURE close(fildes: INTEGER) : INTEGER;
|
|
PROCEDURE creat(path: ADDRESS;
|
|
mode: INTEGER) : INTEGER;
|
|
PROCEDURE dup(fildes: INTEGER) : INTEGER;
|
|
PROCEDURE execve(path: ADDRESS;
|
|
argv: ADDRESS;
|
|
envp: ADDRESS) : INTEGER;
|
|
PROCEDURE exit(status: INTEGER);
|
|
(* Sys5 *) PROCEDURE fcntl(fildes, request, arg: INTEGER) : INTEGER;
|
|
PROCEDURE ftime(bufp:ADDRESS) : INTEGER;
|
|
PROCEDURE fork() : INTEGER;
|
|
PROCEDURE getpid() : INTEGER;
|
|
PROCEDURE getppid() : INTEGER;
|
|
PROCEDURE getuid() : INTEGER;
|
|
PROCEDURE geteuid() : INTEGER;
|
|
PROCEDURE getgid() : INTEGER;
|
|
PROCEDURE getegid() : INTEGER;
|
|
PROCEDURE ioctl(fildes, request: INTEGER; arg: ADDRESS) : INTEGER;
|
|
PROCEDURE stty(fildes: INTEGER; buf: ADDRESS) : INTEGER;
|
|
PROCEDURE gtty(fildes: INTEGER; buf: ADDRESS) : INTEGER;
|
|
PROCEDURE kill(pid, sig: INTEGER) : INTEGER;
|
|
PROCEDURE link(path1, path2: ADDRESS) : INTEGER;
|
|
PROCEDURE lseek(fildes: INTEGER; offset: LONGINT; whence: INTEGER) : LONGINT;
|
|
PROCEDURE mknod(path: ADDRESS; mode, dev: INTEGER) : INTEGER;
|
|
PROCEDURE mount(spec, dir: ADDRESS; rwflag: INTEGER) : INTEGER;
|
|
PROCEDURE nice(incr: INTEGER) : INTEGER;
|
|
PROCEDURE open(path: ADDRESS; oflag: INTEGER) : INTEGER;
|
|
PROCEDURE pause();
|
|
PROCEDURE pipe(fildes: ADDRESS) : INTEGER;
|
|
PROCEDURE profil(buff: ADDRESS;
|
|
bufsiz, offset, scale: INTEGER);
|
|
PROCEDURE ptrace(request, pid, addr, data: WORD) : INTEGER;
|
|
PROCEDURE read(fildes: INTEGER;
|
|
buf: ADDRESS;
|
|
nbyte: CARDINAL) : INTEGER;
|
|
PROCEDURE setuid(uid: INTEGER) : INTEGER;
|
|
PROCEDURE setgid(gid: INTEGER) : INTEGER;
|
|
PROCEDURE signal(sig: INTEGER;
|
|
func: SignalPrc) : SignalPrc;
|
|
PROCEDURE sigtrp(trapno, signo: INTEGER) : INTEGER;
|
|
(* Let Unix signal signo cause EM trap trapno to occur *)
|
|
PROCEDURE stat(path: ADDRESS; statbuf: ADDRESS) : INTEGER;
|
|
PROCEDURE fstat(fildes: INTEGER; statbuf: ADDRESS) : INTEGER;
|
|
PROCEDURE stime(t: LONGINT) : INTEGER;
|
|
PROCEDURE sync();
|
|
PROCEDURE time(tloc: ADDRESS) : LONGINT;
|
|
PROCEDURE times(buffer: ADDRESS) : LONGINT;
|
|
PROCEDURE umask(cmask: INTEGER) : INTEGER;
|
|
PROCEDURE umount(spec: ADDRESS) : INTEGER;
|
|
PROCEDURE unlink(path: ADDRESS) : INTEGER;
|
|
PROCEDURE utime(path: ADDRESS; times: ADDRESS) : INTEGER;
|
|
PROCEDURE wait(VAR statloc: INTEGER): INTEGER;
|
|
PROCEDURE write(fildes: INTEGER;
|
|
buf: ADDRESS;
|
|
nbyte: CARDINAL) : INTEGER;
|
|
END Unix.
|