1; Part of Scheme 48 1.9. See file COPYING for notices and license. 2 3; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Roderic Morris, 4; Eric Knauel, Martin Gasbichler, Will Noble 5 6(define-interface posix-files-interface 7 (export directory-stream? 8 open-directory-stream ; name -> directory 9 read-directory-stream ; directory -> name or #f 10 close-directory-stream ; directory -> () 11 list-directory ; name -> list of names 12 13 working-directory 14 set-working-directory! 15 16 open-file 17 18 (file-options :syntax) 19 file-options-on? 20 file-options-union 21 22 make-directory 23 make-fifo 24 25 link 26 unlink 27 remove-directory 28 rename 29 30 get-file-info get-file/link-info get-port-info 31 32 file-info? 33 file-info-name 34 file-info-type 35 file-info-device 36 file-info-inode 37 file-info-mode 38 file-info-link-count 39 file-info-owner 40 file-info-group 41 file-info-size 42 file-info-last-access 43 file-info-last-modification 44 file-info-last-status-change 45 46 file-type? file-type-name 47 (file-type :syntax) 48 49 set-file-creation-mask! 50 51 file-mode? 52 (file-mode :syntax) 53 file-mode+ file-mode- 54 file-mode=? file-mode<=? file-mode>=? 55 file-mode->integer integer->file-mode 56 57 accessible? 58 (access-mode :syntax) 59 60 create-symbolic-link 61 read-symbolic-link 62 )) 63 64(define-interface posix-time-interface 65 (export make-time time? time-seconds 66 time=? time<? time<=? time>? time>=? 67 time->string 68 current-time 69 make-date date? 70 date-second date-minute date-hour 71 date-month-day date-month 72 date-year 73 date-week-day 74 date-year-day 75 date-dst 76 77 date->string 78 time->utc-date 79 time->local-date 80 date->time 81 format-date 82 )) 83 84(define-interface posix-users-interface 85 (export user-id? 86 user-id->integer integer->user-id 87 user-id=? 88 89 user-info? 90 user-info-name user-info-id user-info-group 91 user-info-home-directory user-info-shell 92 user-id->user-info 93 name->user-info 94 95 group-id? 96 group-id->integer integer->group-id 97 group-id=? 98 99 group-info? 100 group-info-name group-info-id group-info-members 101 group-id->group-info 102 name->group-info 103 )) 104 105(define-interface posix-errnos-interface 106 (export (errno :syntax) 107 errno-name 108 errno-os-number 109 integer->errno 110 name->errno 111 errno=? 112 errno?)) 113 114(define-interface posix-syslog-interface 115 (export (syslog-option :syntax) 116 syslog-option? 117 118 make-syslog-options 119 syslog-options? 120 (syslog-options :syntax) 121 122 (syslog-facility :syntax) 123 syslog-facility? 124 125 (syslog-level :syntax) 126 syslog-level? 127 128 make-syslog-mask 129 syslog-mask? 130 (syslog-mask :syntax) 131 syslog-mask-all 132 syslog-mask-upto 133 134 with-syslog-destination 135 136 syslog 137 138 open-syslog-channel 139 close-syslog-channel 140 with-syslog-channel)) 141 142(define-structures ((posix-files posix-files-interface) 143 (posix-users posix-users-interface)) 144 (open scheme define-record-types finite-types 145 external-calls load-dynamic-externals 146 bitwise ;for manipulating protection masks 147 exceptions 148 posix-file-options 149 posix-time ; external binding for `posix-time-type' 150 channels 151 channel-i/o 152 channel-ports 153 os-strings) 154 (for-syntax (open scheme bitwise)) 155 (files dir)) 156 157(define-structure posix-time posix-time-interface 158 (open scheme 159 define-record-types 160 external-calls load-dynamic-externals 161 os-strings) 162 (files time)) 163 164(define-structure posix-file-options (export ((file-option file-options) 165 :syntax) 166 file-options? 167 file-options-on? 168 file-options-union) 169 (open scheme define-record-types finite-types enum-sets 170 external-calls load-dynamic-externals 171 bitwise) 172 (files file-options)) 173 174(define-interface posix-process-data-interface 175 (export get-process-id get-parent-process-id 176 177 ; I am not happy with these names. They don't mention the process. 178 get-user-id get-effective-user-id 179 set-user-id! set-effective-user-id! 180 get-group-id get-effective-group-id 181 set-group-id! set-effective-group-id! 182 183 get-groups 184 get-login-name 185 186 lookup-environment-variable 187 lookup-environment-variable->string 188 set-environment-variable! 189 environment-alist 190 environment-alist-as-strings 191 )) 192 193(define-interface posix-platform-names-interface 194 (export os-name os-node-name os-release-name os-version-name 195 machine-name)) 196 197(define-structures ((posix-process-data posix-process-data-interface) 198 (posix-platform-names posix-platform-names-interface)) 199 (open scheme define-record-types 200 external-calls load-dynamic-externals 201 os-strings 202 interrupts 203 posix-processes posix-users posix-time) ; we need these to be loaded 204 (files proc-env)) 205 206(define-interface posix-processes-interface 207 (export process-id? 208 process-id=? 209 210 process-id->integer 211 integer->process-id 212 213 process-id-exit-status 214 process-id-terminating-signal 215 216 fork 217 fork-and-forget 218 219 exec 220 exec-with-environment 221 exec-file 222 exec-file-with-environment 223 exec-with-alias 224 225 exit 226 227 wait-for-child-process 228 229 signal-process 230 231 (signal :syntax) 232 signal-name 233 signal-os-number 234 integer->signal 235 name->signal 236 signal=? 237 signal? 238 239 make-signal-queue 240 signal-queue? 241 signal-queue-monitored-signals 242 dequeue-signal! 243 maybe-dequeue-signal! 244 signal-queue-signals 245 add-signal-queue-signal! 246 remove-signal-queue-signal! 247 )) 248 249(define-structure posix-processes posix-processes-interface 250 (open scheme 251 define-record-types finite-types 252 reinitializers 253 external-calls load-dynamic-externals 254 interrupts 255 placeholders 256 weak 257 value-pipes 258 debug-messages 259 session-data 260 exceptions 261 root-scheduler ;scheme-exit-now 262 channel-ports ;force-channel-output-ports! 263 interrupts ;set-interrupt-handler! 264 architecture ;interrupts enum 265 os-strings) 266 (files proc 267 signal)) 268 269(define-interface posix-i/o-interface 270 (export open-pipe 271 272 dup 273 dup-switching-mode 274 dup2 275 remap-file-descriptors! 276 close-all-but 277 278 close-on-exec? 279 set-close-on-exec?! 280 281 i/o-flags 282 set-i/o-flags! 283 284 fd-port? 285 port->fd 286 287 port-is-a-terminal? 288 port-terminal-name 289 )) 290 291(define-structure posix-i/o posix-i/o-interface 292 (open scheme 293 external-calls load-dynamic-externals 294 i/o ;read-block 295 channels 296 channel-i/o 297 channel-ports 298 exceptions 299 util 300 posix-file-options 301 ports ;port? 302 os-strings 303 architecture 304 enum-case) 305 (files io)) 306 307(define-interface posix-regexps-interface 308 (export make-regexp 309 (regexp-option :syntax) 310 regexp? 311 regexp-match 312 313 match? 314 match-start 315 match-end 316 match-submatches 317 )) 318 319(define-structures ((posix-regexps posix-regexps-interface) 320 (posix-regexps-internal (export make-match))) 321 (open scheme define-record-types finite-types 322 external-calls load-dynamic-externals 323 (subset big-util (string->immutable-string)) 324 exceptions 325 os-strings text-codecs) 326 (files regexp)) 327 328(define-interface regexps-interface 329 (export set 330 range ranges 331 ascii-range ascii-ranges 332 333 negate intersection union subtract 334 335 regexp? 336 337 lower-case upper-case alphabetic 338 numeric hexdigit 339 alphanumeric 340 punctuation whitespace blank 341 graphic printing 342 control 343 344 sequence one-of text repeat 345 346 string-start string-end 347 348 ignore-case use-case 349 350 submatch no-submatches 351 352 any-match? exact-match? 353 match 354 355 match? 356 match-start match-end match-submatches)) 357 358(define-interface regexps-internal-interface 359 (export set? char-in-set? set-string 360 the-empty-set empty-set? 361 string-start? string-end? 362 submatch? submatch-exp submatch-id 363 sequence? sequence-exps 364 epsilon epsilon? 365 one-of? one-of-exps 366 repeat? repeat-low repeat-high repeat-exp)) 367 368(define-structures ((regexps regexps-interface) 369 (regexps-internal regexps-internal-interface)) 370 (open scheme define-record-types mvlet ascii unicode exceptions 371 bitwise bigbit 372 reduce 373 (modify posix-regexps (hide regexp?) (rename (make-regexp make-posix-regexp))) 374 posix-regexps-internal 375 (subset util (every))) 376 (optimize auto-integrate) 377 (files func-regexp)) 378 379 380(define-structure posix-errnos posix-errnos-interface 381 (open scheme 382 exceptions 383 define-record-types 384 finite-types 385 external-calls load-dynamic-externals 386 (subset unicode-char-maps (string-upcase string-foldcase)) 387 session-data 388 interrupts 389 reinitializers 390 weak) 391 (files errno)) 392 393(define-structure posix-syslog posix-syslog-interface 394 (open scheme 395 exceptions 396 fluids 397 locks 398 define-record-types 399 finite-types enum-sets enum-sets-internal 400 external-calls 401 load-dynamic-externals 402 reinitializers 403 os-strings) 404 (files syslog)) 405 406; All in one chunk. 407 408(define-structure posix (compound-interface 409 (interface-of posix-processes) 410 (interface-of posix-process-data) 411 (interface-of posix-platform-names) 412 (interface-of posix-files) 413 (interface-of posix-i/o) 414 (interface-of posix-time) 415 (interface-of posix-users) 416 (interface-of posix-regexps) 417 (interface-of posix-errnos) 418 (interface-of posix-syslog)) 419 (open posix-processes 420 posix-process-data 421 posix-platform-names 422 posix-files 423 posix-i/o 424 posix-time 425 posix-users 426 posix-regexps 427 posix-errnos 428 posix-syslog)) 429 430