Lisp objects and C structures - SBCL 1.0.31 User Manual
Description: SBCL 1.0.31 User Manual

Next: Functions with idiosyncratic bindings, Previous: Function Return Values, Up: sb-posix

#### 16.3.5 Lisp objects and C structures

Sb-posix provides various Lisp object types to stand in for C structures in the POSIX library. Lisp bindings to C functions that accept, manipulate, or return C structures accept, manipulate, or return instances of these Lisp types instead of instances of alien types.

The names of the Lisp types are chosen according to the general rules described above. For example Lisp objects of type `STAT` stand in for C structures of type `struct stat`.

Accessors are provided for each standard field in the structure. These are named structure-name`-`field-name where the two components are chosen according to the general name conversion rules, with the exception that in cases where all fields in a given structure have a common prefix, that prefix is omitted. For example, `stat.st_dev` in C becomes `STAT-DEV` in Lisp.

Because sb-posix might not support all semi-standard or implementation-dependent members of all structure types on your system (patches welcome), here is an enumeration of all supported Lisp objects corresponding to supported POSIX structures, and the supported slots for those structures.

- flock
  — Class: sb-posix:flock

  > Class precedence list: `flock, standard-object, t`

  > Slots:

  > - `type` — initarg: `:type`; reader: `sb-posix:flock-type`; writer: `(setf sb-posix:flock-type)`

  >   Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.

  > - `whence` — initarg: `:whence`; reader: `sb-posix:flock-whence`; writer: `(setf sb-posix:flock-whence)`

  >   Flag for starting offset.

  > - `start` — initarg: `:start`; reader: `sb-posix:flock-start`; writer: `(setf sb-posix:flock-start)`

  >   Relative offset in bytes.

  > - `len` — initarg: `:len`; reader: `sb-posix:flock-len`; writer: `(setf sb-posix:flock-len)`

  >   Size; if 0 then until `eof`.

  > - `pid` — reader: `sb-posix:flock-pid`

  >   Process `id` of the process holding the lock; returned with F_GETLK.

  > Class representing locks used in fcntl(2).

- passwd
  — Class: sb-posix:passwd

  > Class precedence list: `passwd, standard-object, t`

  > Slots:

  > - `name` — initarg: `:name`; reader: `sb-posix:passwd-name`; writer: `(setf sb-posix:passwd-name)`

  >   User's login name.

  > - `passwd` — initarg: `:passwd`; reader: `sb-posix:passwd-passwd`; writer: `(setf sb-posix:passwd-passwd)`

  >   The account's encrypted password.

  > - `uid` — initarg: `:uid`; reader: `sb-posix:passwd-uid`; writer: `(setf sb-posix:passwd-uid)`

  >   Numerical user `id`.

  > - `gid` — initarg: `:gid`; reader: `sb-posix:passwd-gid`; writer: `(setf sb-posix:passwd-gid)`

  >   Numerical group `id`.

  > - `gecos` — initarg: `:gecos`; reader: `sb-posix:passwd-gecos`; writer: `(setf sb-posix:passwd-gecos)`

  >   User's name or comment field.

  > - `dir` — initarg: `:dir`; reader: `sb-posix:passwd-dir`; writer: `(setf sb-posix:passwd-dir)`

  >   Initial working directory.

  > - `shell` — initarg: `:shell`; reader: `sb-posix:passwd-shell`; writer: `(setf sb-posix:passwd-shell)`

  >   Program to use as shell.

  > Instances of this class represent entries in the system's user database.

- stat
  — Class: sb-posix:stat

  > Class precedence list: `stat, standard-object, t`

  > Slots:

  > - `mode` — initarg: `:mode`; reader: `sb-posix:stat-mode`

  >   Mode of file.

  > - `ino` — initarg: `:ino`; reader: `sb-posix:stat-ino`

  >   File serial number.

  > - `dev` — initarg: `:dev`; reader: `sb-posix:stat-dev`

  >   Device `id` of device containing file.

  > - `nlink` — initarg: `:nlink`; reader: `sb-posix:stat-nlink`

  >   Number of hard links to the file.

  > - `uid` — initarg: `:uid`; reader: `sb-posix:stat-uid`

  >   User `id` of file.

  > - `gid` — initarg: `:gid`; reader: `sb-posix:stat-gid`

  >   Group `id` of file.

  > - `size` — initarg: `:size`; reader: `sb-posix:stat-size`

  >   For regular files, the file size in bytes. For symbolic links, the length in bytes of the filename contained in the symbolic link.

  > - `atime` — initarg: `:atime`; reader: `sb-posix:stat-atime`

  >   Time of last access.

  > - `mtime` — initarg: `:mtime`; reader: `sb-posix:stat-mtime`

  >   Time of last data modification.

  > - `ctime` — initarg: `:ctime`; reader: `sb-posix:stat-ctime`

  >   Time of last status change

  > Instances of this class represent Posix file metadata.

- termios
  — Class: sb-posix:termios

  > Class precedence list: `termios, standard-object, t`

  > Slots:

  > - `iflag` — initarg: `:iflag`; reader: `sb-posix:termios-iflag`; writer: `(setf sb-posix:termios-iflag)`

  >   Input modes.

  > - `oflag` — initarg: `:oflag`; reader: `sb-posix:termios-oflag`; writer: `(setf sb-posix:termios-oflag)`

  >   Output modes.

  > - `cflag` — initarg: `:cflag`; reader: `sb-posix:termios-cflag`; writer: `(setf sb-posix:termios-cflag)`

  >   Control modes.

  > - `lflag` — initarg: `:lflag`; reader: `sb-posix:termios-lflag`; writer: `(setf sb-posix:termios-lflag)`

  >   Local modes.

  > Instances of this class represent I/O characteristics of the terminal.

- timeval
  — Class: sb-posix:timeval

  > Class precedence list: `timeval, standard-object, t`

  > Slots:

  > - `sec` — initarg: `:tv-sec`; reader: `sb-posix:timeval-sec`; writer: `(setf sb-posix:timeval-sec)`

  >   Seconds.

  > - `usec` — initarg: `:tv-usec`; reader: `sb-posix:timeval-usec`; writer: `(setf sb-posix:timeval-usec)`

  >   Microseconds.

  > Instances of this class represent time values.