cl-posix-dirent

Common-Lisp-POSIX API - SUSv3 - dirent

Fetch an implementation of the dirent API for CLISP (using the LINUX package): cl-posix-dirent-susv3-lisp

Common-Lisp Specific Definitions

Type SUSV3:BOUND-STRING

[***SEE***: Find a better name!]

[***Suggestion***: What about SUSV3:LIMITED-STRING ?]


(DEFTYPE BOUND-STRING (MIN MAX)
  "A TYPE REPRESENTING STRINGS OF MINIMUM SIZE MIN AND MAXIMUM SIZE MAX."
  (IF (= (EVAL MIN) (EVAL MAX))
    `(STRING ,(EVAL MIN))
    `STRING) ;; TODO: (OR (STRING MIN) (STRING (1+ MIN)) ... (STRING MAX))
  );;BOUND-STRING

Condition SYSV3:SYSCALL-ERROR

(DEFINE-CONDITION SYSCALL-ERROR ()
  (
   (ERRNO :INITARG :ERRNO
          :ACCESSOR SYSCALL-ERRNO
          :TYPE (SIGNED-BYTE 32))
   ));;SYSCALL-ERROR

SUSv3 Definitions

sys/types.h

Type SUSV3:BLKCNT-T

   (DEFTYPE SUSV3:BLKCNT-T ()
     "Used for file block counts."
     ;; implementation dependent
    );;SUSV3:BLKCNT-T

   (ASSERT (SUBTYPEP 'SUSV3:BLKCNT-T 'INTEGER)

Type SUSV3:BLKSIZE-T

   (DEFTYPE SUSV3:BLKSIZE-T ()
     "Used for block sizes."
     ;; implementation dependent
    );;SUSV3:BLKSIZE-T

   (ASSERT (SUBTYPEP 'SUSV3:BLKSIZE-T 'INTEGER)

Type SUSV3-XSI:CLOCK-T

   (DEFTYPE SUSV3-XSI:CLOCK-T ()
     "Used for system times in clock ticks or CLOCKS_PER_SEC; see <time.h> ."
     ;; implementation dependent
    );;SUSV3-XSI:CLOCK-T

   (ASSERT (SUBTYPEP 'SUSV3-XSI:CLOCK-T '(OR INTEGER FLOAT))

Type SUSV3-TMR:CLOCKID-T

   (DEFTYPE SUSV3-TMR:CLOCKID-T ()
     "Used for clock ID type in the clock and timer functions."
     ;; implementation dependent
    );;SUSV3-TMR:CLOCKID-T

Type SUSV3:DEV-T

   (DEFTYPE SUSV3:DEV-T ()
     "Used for device IDs."
     ;; implementation dependent
    );;SUSV3:DEV-T

Type SUSV3-XSI:FSBLKCNT-T

   (DEFTYPE SUSV3-XSI:FSBLKCNT-T ()
     "Used for file system block counts."
     ;; implementation dependent
    );;SUSV3-XSI:FSBLKCNT-T

   (ASSERT (SUBTYPEP 'SUSV3-XSI:FSBLKCNT-T '(INTEGER 0))

Type SUSV3-XSI:FSFILCNT-T

   (DEFTYPE SUSV3-XSI:FSFILCNT-T ()
     "Used for file system file counts."
     ;; implementation dependent
    );;SUSV3-XSI:FSFILCNT-T

   (ASSERT (SUBTYPEP 'SUSV3-XSI:FSFILCNT-T '(INTEGER 0))

Type SUSV3:GID-T

   (DEFTYPE SUSV3:GID-T ()
     "Used for group IDs."
     ;; implementation dependent
    );;SUSV3:GID-T

   (ASSERT (SUBTYPEP 'SUSV3:GID-T 'INTEGER)

Type SUSV3-XSI:ID-T

   (DEFTYPE SUSV3-XSI:ID-T ()
     "Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t."
     ;; implementation dependent
    );;SUSV3-XSI:ID-T

   (ASSERT (AND (SUBTYPEP 'SUSV3-XSI:ID-T 'INTEGER)
                (SUBTYPEP 'SUSV3-XSI:ID-T 'SUSV3:PID-T)
                (SUBTYPEP 'SUSV3-XSI:ID-T 'SUSV3:UID-T)
                (SUBTYPEP 'SUSV3-XSI:ID-T 'SUSV3:GID-T)))
)

Type SUSV3:INO-T

   (DEFTYPE SUSV3:INO-T ()
     "Used for file serial numbers."
     ;; implementation dependent
    );;SUSV3:INO-T

   (ASSERT (SUBTYPEP 'SUSV3:INO-T '(INTEGER 0))

Type SUSV3-XSI:KEY-T

   (DEFTYPE SUSV3-XSI:KEY-T ()
     "Used for XSI interprocess communication."
     ;; implementation dependent
    );;SUSV3-XSI:KEY-T

Type SUSV3:MODE-T

   (DEFTYPE SUSV3:MODE-T ()
     "Used for some file attributes."
     ;; implementation dependent
    );;SUSV3:MODE-T

   (ASSERT (SUBTYPEP 'SUSV3:MODE-T 'INTEGER)

Type SUSV3:NLINK-T

   (DEFTYPE SUSV3:NLINK-T ()
     "Used for link counts."
     ;; implementation dependent
    );;SUSV3:NLINK-T

   (ASSERT (SUBTYPEP 'SUSV3:NLINK-T 'INTEGER)

Type SUSV3:OFF-T

   (DEFTYPE SUSV3:OFF-T ()
     "Used for file sizes."
     ;; implementation dependent
    );;SUSV3:OFF-T

   (ASSERT (SUBTYPEP 'SUSV3:OFF-T 'INTEGER)

Type SUSV3:PID-T

   (DEFTYPE SUSV3:PID-T ()
     "Used for process IDs and process group IDs."
     ;; implementation dependent
    );;SUSV3:PID-T

   (ASSERT (SUBTYPEP 'SUSV3:PID-T 'INTEGER)

Type SUSV3-THR:PTHREAD-ATTR-T

   (DEFTYPE SUSV3-THR:PTHREAD-ATTR-T ()
     "Used to identify a thread attribute object."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-ATTR-T

Type SUSV3-BAR:PTHREAD-BARRIER-T

   (DEFTYPE SUSV3-BAR:PTHREAD-BARRIER-T ()
     "Used to identify a barrier."
     ;; implementation dependent
    );;SUSV3-BAR:PTHREAD-BARRIER-T

Type SUSV3-BAR:PTHREAD-BARRIERATTR-T

   (DEFTYPE SUSV3-BAR:PTHREAD-BARRIERATTR-T ()
     "Used to define a barrier attributes object."
     ;; implementation dependent
    );;SUSV3-BAR:PTHREAD-BARRIERATTR-T

Type SUSV3-THR:PTHREAD-COND-T

   (DEFTYPE SUSV3-THR:PTHREAD-COND-T ()
     "Used for condition variables."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-COND-T

Type SUSV3-THR:PTHREAD-CONDATTR-T

   (DEFTYPE SUSV3-THR:PTHREAD-CONDATTR-T ()
     "Used to identify a condition attribute object."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-CONDATTR-T

Type SUSV3-THR:PTHREAD-KEY-T

   (DEFTYPE SUSV3-THR:PTHREAD-KEY-T ()
     "Used for thread-specific data keys."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-KEY-T

Type SUSV3-THR:PTHREAD-MUTEX-T

   (DEFTYPE SUSV3-THR:PTHREAD-MUTEX-T ()
     "Used for mutexes."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-MUTEX-T

Type SUSV3-THR:PTHREAD-MUTEXATTR-T

   (DEFTYPE SUSV3-THR:PTHREAD-MUTEXATTR-T ()
     "Used to identify a mutex attribute object."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-MUTEXATTR-T

Type SUSV3-THR:PTHREAD-ONCE-T

   (DEFTYPE SUSV3-THR:PTHREAD-ONCE-T ()
     "Used for dynamic package initialization."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-ONCE-T

Type SUSV3-THR:PTHREAD-RWLOCK-T

   (DEFTYPE SUSV3-THR:PTHREAD-RWLOCK-T ()
     "Used for read-write locks."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-RWLOCK-T

Type SUSV3-THR:PTHREAD-RWLOCKATTR-T

   (DEFTYPE SUSV3-THR:PTHREAD-RWLOCKATTR-T ()
     "Used for read-write lock attributes."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-RWLOCKATTR-T

Type SUSV3-SPI:PTHREAD-SPINLOCK-T

   (DEFTYPE SUSV3-SPI:PTHREAD-SPINLOCK-T ()
     "Used to identify a spin lock."
     ;; implementation dependent
    );;SUSV3-SPI:PTHREAD-SPINLOCK-T

Type SUSV3-THR:PTHREAD-T

   (DEFTYPE SUSV3-THR:PTHREAD-T ()
     "Used to identify a thread."
     ;; implementation dependent
    );;SUSV3-THR:PTHREAD-T

Type SUSV3:SIZE-T

   (DEFTYPE SUSV3:SIZE-T ()
     "Used for sizes of objects."
     ;; implementation dependent
    );;SUSV3:SIZE-T

   (ASSERT (SUBTYPEP 'SUSV3:SIZE-T '(INTEGER 0))

Type SUSV3:SSIZE-T

   (DEFTYPE SUSV3:SSIZE-T ()
     "Used for a count of bytes or an error indication."
     ;; implementation dependent
    );;SUSV3:SSIZE-T

   (ASSERT (AND (SUBTYPEP 'SUSV3:SSIZE-T 'INTEGER)
                (SUBTYPEP (INTEGER -1 SUSV3:SSIZE-MAX) SUSV3:SSIZE-T)))
)

Type SUSV3-XSI:SUSECONDS-T

   (DEFTYPE SUSV3-XSI:SUSECONDS-T ()
     "Used for time in microseconds."
     ;; implementation dependent
    );;SUSV3-XSI:SUSECONDS-T

Type SUSV3:TIME-T

   (DEFTYPE SUSV3:TIME-T ()
     "Used for time in seconds."
     ;; implementation dependent
    );;SUSV3:TIME-T

   (ASSERT (SUBTYPEP 'SUSV3:TIME-T '(OR INTEGER FLOAT))

Type SUSV3-TMR:TIMER-T

   (DEFTYPE SUSV3-TMR:TIMER-T ()
     "Used for timer ID returned by timer_create()."
     ;; implementation dependent
    );;SUSV3-TMR:TIMER-T

Type SUSV3-TRC:TRACE-ATTR-T

   (DEFTYPE SUSV3-TRC:TRACE-ATTR-T ()
     "Used to identify a trace stream attributes object."
     ;; implementation dependent
    );;SUSV3-TRC:TRACE-ATTR-T

Type SUSV3-TRC:TRACE-EVENT-ID-T

   (DEFTYPE SUSV3-TRC:TRACE-EVENT-ID-T ()
     "Used to identify a trace event type."
     ;; implementation dependent
    );;SUSV3-TRC:TRACE-EVENT-ID-T

Type SUSV3-TRC-TEF:TRACE-EVENT-SET-T

   (DEFTYPE SUSV3-TRC-TEF:TRACE-EVENT-SET-T ()
     "Used to identify a trace event type set."
     ;; implementation dependent
    );;SUSV3-TRC-TEF:TRACE-EVENT-SET-T

Type SUSV3-TRC:TRACE-ID-T

   (DEFTYPE SUSV3-TRC:TRACE-ID-T ()
     "Used to identify a trace stream."
     ;; implementation dependent
    );;SUSV3-TRC:TRACE-ID-T

Type SUSV3:UID-T

   (DEFTYPE SUSV3:UID-T ()
     "Used for user IDs."
     ;; implementation dependent
    );;SUSV3:UID-T

   (ASSERT (SUBTYPEP 'SUSV3:UID-T 'INTEGER)

Type SUSV3-XSI:USECONDS-T

   (DEFTYPE SUSV3-XSI:USECONDS-T ()
     "Used for time in microseconds."
     ;; implementation dependent
    );;SUSV3-XSI:USECONDS-T

limits.h

Constant SUSV3:+NAME-MAX+

   (DEFCONSTANT SUSV3:+NAME-MAX+
     "Maximum number of bytes in a filename (not including terminating null)."
     ;; implementation dependent.
    )

   (ASSERT (<= SUSV3:+POSIX-NAME-MAX+ SUSV3:+NAME-MAX+))
   ;; [XSI]:
   (ASSERT (<= SUSV3:+XOPEN-NAME-MAX+ SUSV3:+NAME-MAX+))

dirent.h

Type SUSV3:DIR

   (DEFTYPE SUSV3:DIR ()
     "A type representing a directory stream.
      Note: this is NOT a Common-Lisp stream."
     ;; opaque
    );;SUSV3:DIR

Type SUSV3:DIRENT

   (DEFSTRUCT SUSV3:DIRENT 
     (INO  0  :TYPE SUSV3:INO-T) ;; [XSI] File serial number
     (NAME "" :TYPE (SUSV3:BOUND-STRING 0 SUSV3:+NAME-MAX+)) ;; Name of entry
    );;SUSV3:DIRENT

Function SUSV3:OPENDIR

   (DECLAIM (FTYPE (FUNCTION (STRING) (OR NULL DIR)) SUSV3:OPENDIR))
   (DEFUN SUSV3:OPENDIR (PATH)
     ;; implementation dependent
     )

Function SUSV3:READDIR

   (DECLAIM (FTYPE (FUNCTION (DIR) (OR NULL DIRENT)) SUSV3:READDIR))
   (DEFUN SUSV3:READDIR (DIR-STREAM)
     ;; implementation dependent
     )

Function SUSV3:REWINDDIR

   (DECLAIM (FTYPE (FUNCTION (DIR) NIL) SUSV3:REWINDDIR))
   (DEFUN SUSV3:REWINDDIR (DIR-STREAM)
     ;; implementation dependent
     (VALUES)
     )

Function SUSV3:CLOSEDIR

   (DECLAIM (FTYPE (FUNCTION (DIR) NIL) SUSV3:CLOSEDIR))
   (DEFUN SUSV3:CLOSEDIR (DIR-STREAM)
     ;; implementation dependent
     (VALUES)
     )

Function SUSV3-TSF:READDIR-R

[***SEE***: Must we implement this function? Or is it C-specific API?

Function SUSV3-XSI:SEEKDIR

   (DECLAIM (FTYPE (FUNCTION (DIR INTEGER) NIL) SUSV3-XSI:SEEKDIR))
   (DEFUN SUSV3-XSI:SEEKDIR (DIR-STREAM POSITION)
     ;; implementation dependent
     (VALUES)
     )

Function SUSV3-XSI:TELLDIR

   (DECLAIM (FTYPE (FUNCTION (DIR) INTEGER) SUSV3-XSI:TELLDIR))
   (DEFUN SUSV3-XSI:TELLDIR (DIR-STREAM)
     ;; implementation dependent
     )

cl-posix-dirent-susv3-lisp cl-posix-generalities