File: file-options.scm

package info (click to toggle)
scheme48 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 18,232 kB
  • sloc: lisp: 88,907; ansic: 87,519; sh: 3,224; makefile: 771
file content (52 lines) | stat: -rw-r--r-- 1,364 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
; Part of Scheme 48 1.9.  See file COPYING for notices and license.

; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber

; Options for open() and fcntl()
 
(define-enumerated-type file-option :file-option
  file-option?				; predicate
  the-file-options		      ; vector containing all elements
  file-option-name			; name accessor
  file-option-index			; index accessor
  ;; the order of these is known to the C code
  ( ;; Options for open()
   create
   exclusive
   no-controlling-tty
   truncate

   ;; Options for open(), read and written by fcntl()
   append
   synchronized-data	      ; New in POSIX 2nd edition, not in Linux
   nonblocking
   synchronized-read	      ; New in POSIX 2nd edition, not in Linux
   synchronized

   ;; Modes for open(), read by fcntl()
   read-only
   read-write
   write-only))

(define open-options-mask  #o0777)
(define fcntl-options-mask #o0760)
(define mode-mask          #o7000)

(define-enum-set-type file-options :file-options
  file-options?
  make-file-options

  file-option file-option?
  the-file-options
  file-option-index)

(define-exported-binding "posix-file-options-enum-set-type" :file-options)

(define (file-options-on? options0 options1)
  (enum-set=? (enum-set-intersection options0 options1)
	      options1))

(define (file-options-union options0 options1)
  (enum-set-union options0 options1))