(include "sys/types.h" "sys/socket.h" "errno.h" "unistd.h" "fcntl.h" "poll.h" "netinet/in.h" "arpa/inet.h" "sys/un.h" "limits.h" "sys/param.h" "dirent.h" "sys/stat.h" "grp.h" "pwd.h") (in-package #:unixint) (ctype :size :unsigned "size_t") (ctype :ssize :signed "ssize_t") (ctype :time :unsigned "time_t") (ctype :pid :unsigned "pid_t") (ctype :uid :unsigned "uid_t") (ctype :gid :unsigned "gid_t") (ctype :mode :unsigned "mode_t") (ctype :socklen :unsigned "socklen_t") (constantenum address-family ((:af-inet "AF_INET" "PF_INET") :documentation "IPv4 Protocol family") ((:af-local "AF_UNIX" "AF_LOCAL" "PF_UNIX" "PF_LOCAL") :documentation "File domain sockets") ((:af-inet6 "AF_INET6" "PF_INET6") :documentation "IPv6 Protocol family") ((:af-packet "AF_PACKET" "PF_PACKET") :documentation "Raw packet access" :optional t)) (constantenum socket-protocol ((:sock-stream "SOCK_STREAM") :documentation "TCP") ((:sock-dgram "SOCK_DGRAM") :documentation "UDP") ((:sock-seqpacket "SOCK_SEQPACKET") :documentation "Reliable Sequenced Datagram Protocol" :optional t) ((:sock-raw "SOCK_RAW") :documentation "Raw protocol access" :optional t) ((:sock-rdm "SOCK_RDM") :documentation "Reliable Unordered Datagram Protocol" :optional t)) (constant (sol-socket "SOL_SOCKET") :documentation "get/setsockopt socket level constant.") ;; FIXME missing a bunch in here (constantenum socket-options ((:so-keepalive "SO_KEEPALIVE")) ((:so-oobinline "SO_OOBINLINE")) ((:so-passcred "SO_PASSCRED") :optional t) ((:so-peercred "SO_PEERCRED") :optional t) ((:so-reuseaddr "SO_REUSEADDR")) ((:so-type "SO_TYPE")) ((:so-acceptconn "SO_ACCEPTCONN")) ((:so-dontroute "SO_DONTROUTE")) ((:so-broadcast "SO_BROADCAST")) ((:so-sndbuf "SO_SNDBUF")) ((:so-rcvbuf "SO_RCVBUF")) ((:so-linger "SO_LINGER")) ((:so-error "SO_ERROR"))) ;; FIXME missing a lot of critical stuff in here (constantenum errno-values ((:EADDRINUSE "EADDRINUSE")) ((:EAGAIN "EAGAIN" "EWOULDBLOCK")) ((:EBADF "EBADF")) ((:ECONNREFUSED "ECONNREFUSED")) ((:ETIMEDOUT "ETIMEDOUT")) ((:EINTR "EINTR")) ((:EINVAL "EINVAL")) ((:ENOBUFS "ENOBUFS")) ((:ENOMEM "ENOMEM")) ((:EOPNOTSUPP "EOPNOTSUPP")) ((:EPERM "EPERM")) ((:EPROTONOSUPPORT "EPROTONOSUPPORT")) ((:ESOCKTNOSUPPORT "ESOCKTNOSUPPORT")) ((:ENETUNREACH "ENETUNREACH")) ((:ENOTCONN "ENOTCONN")) ((:EFAULT "EFAULT")) ((:ENOLCK "ENOLCK")) ((:EACCES "EACCES")) ((:EDEADLOCK "EDEADLOCK" "EDEADLK")) ((:EMFILE "EMFILE")) ((:ENOENT "ENOENT")) ((:ERANGE "ERANGE")) ((:EIO "EIO")) ((:ELOOP "ELOOP")) ((:ENAMETOOLONG "ENAMETOOLONG")) ((:ENOTDIR "ENOTDIR")) ((:EOVERFLOR "EOVERFLOW"))) (constantenum fcntl-options ((:f-dupfd "F_DUPFD")) ((:f-getfd "F_GETFD")) ((:f-setfd "F_SETFD")) ((:f-getfl "F_GETFL")) ((:f-setfl "F_SETFL")) ((:f-getlk "F_GETLK")) ((:f-setlk "F_SETLK")) ((:f-setlkw "F_SETLKW"))) (constantenum fcntl-lock-options ((:f-rdlck "F_RDLCK")) ((:f-wrlck "F_WRLCK")) ((:f-unlck "F_UNLCK"))) (constantenum seek-options ((:seek-set "SEEK_SET")) ((:seek-cur "SEEK_CUR")) ((:seek-end "SEEK_END"))) (constant (somaxconn "SOMAXCONN") :documentation "Maximum listen() queue length") ;; msg-oob and friends go here (constant (scm-rights "SCM_RIGHTS")) (constant (scm-credentials "SCM_CREDENTIALS") :optional t) (constant (path-max "PATH_MAX" "MAXPATHLEN")) (cstruct pollfd "struct pollfd" "Poll file descriptor activity specification structure." (fd "fd") (events "events") (revents "revents")) (cstruct timeval "struct timeval" "UNIX time specification in seconds and microseconds." (tv-sec "tv_sec" :type :time) (tv-usec "tv_usec" :type :time)) (cstruct sockaddr-in "struct sockaddr_in" "An IPv4 socket address." (family "sin_family" :type address-family) (port "sin_port" :signed nil) (address "sin_addr" :type :uint8 :count 4)) (cstruct sockaddr-un "struct sockaddr_un" "A UNIX-domain socket address." (family "sun_family") (path "sun_path" :type :char :count :auto)) (cstruct sockaddr-in6 "struct sockaddr_in6" "An IPv6 socket address." (family "sin6_family") (port "sin6_port" :signed nil) (flow-info "sin6_flowinfo") (address "sin6_addr" :type :uint8 :count 16) (scope-id "sin6_scope_id")) #+linux (cstruct ucred "struct ucred" "Socket credential messages." (pid "pid" :type :pid) (uid "uid" :type :uid) (gid "gid" :type :gid)) (cstruct linger "struct linger" "SO_LINGER manipulation record." (l-onoff "l_onoff") (l-linger "l_linger")) (cvar ("errno" errno) errno-values) (constant (stat-irwxu "S_IRWXU") :documentation "read, write, execute/search by owner") (constant (stat-irusr "S_IRUSR") :documentation "read permission, owner") (constant (stat-iwusr "S_IWUSR") :documentation "write permission, owner") (constant (stat-ixusr "S_IXUSR") :documentation "execute/search permission, owner") (constant (stat-irwxg "S_IRWXG") :documentation "read, write, execute/search by group") (constant (stat-irgrp "S_IRGRP") :documentation "read permission, group") (constant (stat-iwgrp "S_IWGRP") :documentation "write permission, group") (constant (stat-ixgrp "S_IXGRP") :documentation "execute/search permission, group") (constant (stat-irwxo "S_IRWXO") :documentation "read, write, execute/search by others") (constant (stat-iroth "S_IROTH") :documentation "read permission, others") (constant (stat-iwoth "S_IWOTH") :documentation "write permission, others") (constant (stat-ixoth "S_IXOTH") :documentation "execute/search permission, others") (constant (stat-isuid "S_ISUID") :documentation "set-user-ID on execution") (constant (stat-isgid "S_ISGID") :documentation "set-group-ID on execution") (constant (stat-isvtx "S_ISVTX") :documentation "'sticky' bit, many meanings, nonportable") (constant (stat-ifmt "S_IFMT") :documentation "bitmask for type of entry") (constant (stat-ififo "S_IFIFO") :documentation "named pipe, aka fifo") (constant (stat-ifchr "S_IFCHR") :documentation "special character-device") (constant (stat-ifdir "S_IFDIR") :documentation "directory") (constant (stat-ifblk "S_IFBLK") :documentation "special block-device") (constant (stat-ifreg "S_IFREG") :documentation "regular file") (constant (stat-iflnk "S_IFLNK") :documentation "symbolic link") (constant (stat-ifsock "S_IFSOCK") :documentation "socket") (constant (stat-ifwht "S_IFWHT") :documentation "whiteout" :optional t) (cstruct-and-class stat "struct stat" (device "st_dev" :signed nil) (inode "st_ino" :signed nil) (mode "st_mode" :type :mode) (link-count "st_nlink" :signed nil) (uid "st_uid" :type :uid) (gid "st_gid" :type :gid) (special-device-type "st_rdev" :signed nil) (atime "st_atime" :signed nil) ; (atime-nano "st_atimespec.tv_nsec" :signed nil) (mtime "st_mtime" :signed nil) ; (mtime-nano "st_mtimespec.tv_nsec" :signed nil) (ctime "st_ctime" :signed nil) ; (ctime-nano "st_ctimespec.tv_nsec" :signed nil) (size "st_size" :signed nil) (block-count "st_blocks" :signed nil) (block-size "st_blksize" :signed nil)) (cstruct-and-class password-entry "struct passwd" (username "pw_name" :type :string) (password "pw_passwd" :type :string) (uid "pw_uid" :signed nil) (gid "pw_gid" :signed nil) (full-name "pw_gecos" :type :string) (home-directory "pw_dir" :type :string) (shell "pw_shell" :type :string)) (cstruct-and-class group-entry "struct group" (name "gr_name" :type :string) (password "gr_passwd" :type :string) (gid "gr_gid" :signed nil)) ; FIXME What about gr_mem? Kinda the whole point? ;; Apparently POSIX 1003.1-2001 (according linux manpages) only ;; requires d_name. Sigh. I guess we should assemble some decent ;; wrapper functions. No, struct-members can't be optional at this ;; point. (cstruct-and-class directory-entry "struct dirent" (name "d_name" :type :char :count :auto))