(cond-expand
 ((or macosx openbsd netbsd) (c-system-include "util.h"))
 ((or freebsd dragonfly) (c-system-include "libutil.h"))
 (else (c-system-include "pty.h")))
(cond-expand
 ((not bsd) (c-system-include "utmp.h")))

(c-link "util")

(declare-c-struct termios)
(declare-c-struct winsize)

(define-c errno openpty
  ((result fileno) (result fileno) (result (array char 256)) (maybe-null default NULL termios) (maybe-null default NULL winsize)))
(define-c pid_t forkpty
  ((result fileno)  (result (array char 256)) (maybe-null default NULL termios) (maybe-null default NULL winsize)))
(define-c int (login-tty "login_tty") (fileno))