chibi-scheme/lib/chibi/posix.stub

40 lines
1.2 KiB
Text

(c-system-include "sys/types.h")
(c-system-include "sys/wait.h")
(c-system-include "time.h")
(c-system-include "unistd.h")
(c-system-include "dirent.h")
(define-c-struct DIR
finalizer: closedir)
(define-c-struct dirent
(string d_name dirent-name))
(define-c input-port (open-input-fd "fdopen") (int (value "r" string)))
(define-c output-port (open-output-fd "fdopen") (int (value "w" string)))
(define-c errno (delete-file "unlink") (string))
(define-c errno (link-file "link") (string string))
(define-c errno (symbolic-link-file "symlink") (string string))
(define-c errno (rename-file "rename") (string string))
(define-c non-null-string (current-directory "getcwd")
((result (array char (auto-expand arg1))) (value 256 int)))
(define-c errno (create-directory "mkdir") (string int))
(define-c errno (delete-directory "rmdir") (string))
(define-c (free DIR) opendir (string))
(define-c dirent readdir ((link DIR)))
(define-c int (duplicate-fd "dup") (int))
(define-c pid_t fork ())
(define-c pid_t waitpid (int (result int) int))
(define-c void exit (int))
(define-c int (execute execvp) (string (array string)))
(define-c errno pipe ((result (array int 2))))
(define-c time_t (current-seconds "time") ((value NULL)))