Changeset 13129 in project
- Timestamp:
- 01/28/09 03:53:06 (11 years ago)
- Location:
- release/3/posix-extensions/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
release/3/posix-extensions/trunk/4unix.scm
r13118 r13129 11 11 ;; - Should have OS specific extension module for stuff like MacOS X 'prio/darwin-thread'. 12 12 ;; 13 ;; - Assumes id_t, pid_t, gid_t, & uid_t all are representable by aFIXNUM!13 ;; - Assumes id_t, pid_t, gid_t, & uid_t representable by FIXNUM! 14 14 ;; 15 15 ;; - The EINTR condition (system call interrupted) is not handled. … … 25 25 (no-bound-checks) 26 26 (bound-to-procedure 27 ##sys#null-pointer 28 ##sys#null-pointer? 27 29 ##sys#make-string 28 30 ##sys#make-c-string 29 31 ##sys#expand-home-path 32 ##sys#check-exact 33 ##sys#check-number 34 ##sys#check-string 35 ##sys#check-closure 30 36 ##sys#update-errno 31 37 ##sys#error … … 69 75 winsize-ypixel-set! 70 76 ; 77 termios/ignbrk 78 termios/brkint 79 termios/ignpar 80 termios/parmrk 81 termios/inpck 82 termios/istrip 83 termios/inlcr 84 termios/igncr 85 termios/icrnl 86 termios/iuclc 87 termios/ixon 88 termios/ixoff 89 termios/ixany 90 termios/iutf8 91 termios/imaxbel 92 termios/opost 93 termios/olcuc 94 termios/onlcr 95 termios/ocrnl 96 termios/onocr 97 termios/onlret 98 termios/ofill 99 termios/nldly 100 termios/nl0 101 termios/nl1 102 termios/nl2 103 termios/nl3 104 termios/tabdly 105 termios/tab0 106 termios/tab1 107 termios/tab2 108 termios/tab3 109 termios/crdly 110 termios/cr0 111 termios/cr1 112 termios/cr2 113 termios/cr3 114 termios/ffdly 115 termios/ff0 116 termios/ff1 117 termios/bsdly 118 termios/bs0 119 termios/bs1 120 termios/vtdly 121 termios/vt0 122 termios/vt1 123 termios/ofdel 124 termios/oxtabs 125 termios/onoeot 126 termios/cbaud 127 termios/cbaudx 128 termios/cibaud 129 termios/loblk 130 termios/csize 131 termios/cs5 132 termios/cs6 133 termios/cs7 134 termios/cs8 135 termios/cstopb 136 termios/cread 137 termios/parenb 138 termios/parodd 139 termios/hupcl 140 termios/clocal 141 termios/cignore 142 termios/mdmbuf 143 termios/crtscts 144 termios/ccts_oflow 145 termios/crts-oflow 146 termios/cdtr-oflow 147 termios/cdsr-oflow 148 termios/ccar-oflow 149 termios/isig 150 termios/isig 151 termios/icanon 152 termios/echoe 153 termios/echok 154 termios/echo 155 termios/echonl 156 termios/iexten 157 termios/tostop 158 termios/noflsh 159 termios/echoctl 160 termios/echoke 161 termios/echoprt 162 termios/pendin 163 termios/flusho 164 termios/altwerase 165 termios/nokerninfo 166 termios/extproc 167 termios/vswitch 168 termios/veof 169 termios/veol 170 termios/verase 171 termios/vkill 172 termios/vintr 173 termios/vquit 174 termios/vsusp 175 termios/vstart 176 termios/vstop 177 termios/vmin 178 termios/vtime 179 termios/veol2 180 termios/vwerase 181 termios/vreprint 182 termios/vdsusp 183 termios/vlnext 184 termios/vdiscard 185 termios/vstatus 186 termios/nccs 71 187 make-termios 72 188 alloc-termios … … 82 198 termios-cc 83 199 termios-cc-set! 84 termios/nccs85 200 ; 201 termctl-baud/0 202 termctl-baud/50 203 termctl-baud/75 204 termctl-baud/110 205 termctl-baud/134 206 termctl-baud/150 207 termctl-baud/200 208 termctl-baud/300 209 termctl-baud/600 210 termctl-baud/1200 211 termctl-baud/1800 212 termctl-baud/2400 213 termctl-baud/4800 214 termctl-baud/7200 215 termctl-baud/9600 216 termctl-baud/14400 217 termctl-baud/19200 218 termctl-baud/28800 219 termctl-baud/38400 220 termctl-baud/57600 221 termctl-baud/76800 222 termctl-baud/115200 223 termctl-baud/230400 224 termctl-baud/460800 86 225 terminal-control-input-speed 87 226 terminal-control-output-speed … … 90 229 set-terminal-control-speed! 91 230 ; 231 termctl-action/now 232 termctl-action/drain 233 termctl-action/flush 234 termctl-action/soft 92 235 terminal-control-attributes 93 236 set-terminal-control-attributes! 94 237 ; 238 termctl-flush/input 239 termctl-flush/output 240 termctl-flush/input-output 241 terminal-control-flush 242 ; 243 termctl-flow/output-off 244 termctl-flow/output-on 245 termctl-flow/input-off 246 termctl-flow/input-on 247 terminal-control-flow 248 ; 95 249 terminal-control-drain 96 terminal-control-flow97 terminal-control-flush98 250 terminal-control-send-break 99 251 terminal-control-make-raw … … 103 255 fork-pseudo-tty 104 256 ; 105 terminal- type-device?257 terminal-device?? 106 258 terminal-device-name 107 259 current-process-tty-number … … 111 263 (require-extension posix) 112 264 (require-extension miscmacros) 265 113 266 114 267 ;;; … … 134 287 ] ) 135 288 289 136 290 ;;; 291 292 (include "standard-errors") 293 294 295 ;;; Pointer stuff 137 296 138 297 #< … … 144 303 ># 145 304 305 ;; From Unit lolevel 306 307 (define (##sys#tag-pointer ptr tag) 308 (let ([tp (##sys#make-tagged-pointer tag)]) 309 (##core#inline "C_copy_pointer" ptr tp) 310 tp ) ) 311 146 312 (define _null (##sys#null-pointer)) 147 313 148 (define (##sys#check-pointer obj #!optional loc)149 (unless (##sys#pointer? obj)150 (##sys#signal-hook #:type-error loc "bad argument type - not a pointer" obj) ) )151 152 (define (##sys#check-pointer-argument obj #!optional loc)153 (unless (or (##sys#pointer? obj) (not obj))154 (##sys#signal-hook #:type-error loc "bad argument type - not a pointer or #f" obj) ) )155 314 156 315 ;;; Errno … … 163 322 164 323 (define posix-errno _errno) 324 165 325 166 326 ;;; File metadata … … 170 330 #include <utime.h> 171 331 172 static double C_utime_atime;173 static double C_utime_mtime;174 332 static struct utimbuf C_utime_buf; 175 333 176 #define C_lchmod(fn, m) C_fix(lchmod(C_data_pointer(fn), C_unfix(m))) 177 #define C_lchown(fn, u, g) C_fix(lchown(C_data_pointer(fn), C_unfix(u), C_unfix(g))) 178 #define C_mknod(fn, m, d) C_fix(mknod(C_data_pointer(fn), C_unfix(m), C_unfix(d))) 179 #define C_utime(fn) C_fix((C_utime_buf.actime = C_utime_atime, C_utime_buf.modtime = C_utime_mtime, utime(C_data_pointer(fn), &C_utime_buf))) 180 <# 181 182 (define-foreign-variable _utime_atime double "C_utime_atime") 183 (define-foreign-variable _utime_mtime double "C_utime_mtime") 184 185 (define-foreign-variable _s_ifmt int "S_IFMT") 186 (define-foreign-variable _s_ififo int "S_IFIFO") 187 (define-foreign-variable _s_ifchr int "S_IFCHR") 188 (define-foreign-variable _s_ifdir int "S_IFDIR") 189 (define-foreign-variable _s_ifblk int "S_IFBLK") 190 (define-foreign-variable _s_ifreg int "S_IFREG") 191 (define-foreign-variable _s_iflnk int "S_IFLNK") 192 (define-foreign-variable _s_ifsock int "S_IFSOCK") 193 194 (define stat/ifmt _s_ifmt) 195 (define stat/ififo _s_ififo) 196 (define stat/ifchr _s_ifchr) 197 (define stat/ifdir _s_ifdir) 198 (define stat/ifblk _s_ifblk) 199 (define stat/ifreg _s_ifreg) 200 (define stat/iflnk _s_iflnk) 201 (define stat/ifsock _s_ifsock) 334 #define C_lchmod( fn, m ) C_fix( lchmod( C_data_pointer( fn ), C_unfix( m ) ) ) 335 #define C_lchown( fn, u, g ) C_fix( lchown( C_data_pointer( fn ), C_unfix( u ), C_unfix( g ) ) ) 336 #define C_mknod( fn, m, d ) C_fix( mknod( C_data_pointer( fn ), C_unfix( m ), C_unfix( d ) ) ) 337 #define C_utime( fn ) C_fix( utime( C_data_pointer( fn ), &C_utime_buf ) ) 338 <# 339 340 (define-foreign-type time_t "time_t") 341 342 (define-foreign-variable _utime_atime time_t "C_utime_buf.actime") 343 (define-foreign-variable _utime_mtime time_t "C_utime_buf.modtime") 344 345 (define stat/ifmt (foreign-value "S_IFMT" int)) 346 (define stat/ififo (foreign-value "S_IFIFO" int)) 347 (define stat/ifchr (foreign-value "S_IFCHR" int)) 348 (define stat/ifdir (foreign-value "S_IFDIR" int)) 349 (define stat/ifblk (foreign-value "S_IFBLK" int)) 350 (define stat/ifreg (foreign-value "S_IFREG" int)) 351 (define stat/iflnk (foreign-value "S_IFLNK" int)) 352 (define stat/ifsock (foreign-value "S_IFSOCK" int)) 202 353 203 354 (define (change-link-mode fname mode) … … 229 380 (when (fx= -1 (##core#inline "C_utime" (##sys#make-c-string (##sys#expand-home-path fname)))) 230 381 (##sys#posix-error #:file-error 'change-file-times "cannot change file times" fname atime mtime) ) ) 382 231 383 232 384 ;;; Process Priority … … 264 416 (##sys#posix-error #:process-error 'set-scheduling-priority! "cannot set process priority" which who prio) ) ) ) 265 417 266 ;;; Termios & Winsize Records 418 419 ;;; Terminal Operations 267 420 268 421 #> … … 298 451 (winsize-ypixel-set! ws ypixels) 299 452 (set-finalizer! ws free-winsize) 300 ws) )453 (##sys#tag-pointer ws 'winsize) ) ) 301 454 302 455 ;; Termios 303 456 304 (define-foreign-type tcflag_t unsigned-long) 305 (define-foreign-type cc_t unsigned-char) 306 (define-foreign-type speed_t unsigned-long) 307 308 (define-foreign-variable IGNBRK tcflag_t "IGNBRK") 309 (define-foreign-variable BRKINT tcflag_t "BRKINT") 310 (define-foreign-variable IGNPAR tcflag_t "IGNPAR") 311 (define-foreign-variable PARMRK tcflag_t "PARMRK") 312 (define-foreign-variable INPCK tcflag_t "INPCK") 313 (define-foreign-variable ISTRIP tcflag_t "ISTRIP") 314 (define-foreign-variable INLCR tcflag_t "INLCR") 315 (define-foreign-variable IGNCR tcflag_t "IGNCR") 316 (define-foreign-variable ICRNL tcflag_t "ICRNL") 317 (define-foreign-variable IXON tcflag_t "IXON") 318 (define-foreign-variable IXOFF tcflag_t "IXOFF") 319 (define-foreign-variable IXANY tcflag_t "IXANY") 320 (cond-expand 321 [macosx 322 (define-foreign-variable IMAXBEL tcflag_t "IMAXBEL") 323 (define-foreign-variable IUTF8 tcflag_t "IUTF8") 324 ] [else] ) 325 326 (define-foreign-variable OPOST tcflag_t "OPOST") 327 (define-foreign-variable ONLCR tcflag_t "ONLCR") 328 (define-foreign-variable OCRNL tcflag_t "OCRNL") 329 (define-foreign-variable ONOCR tcflag_t "ONOCR") 330 (define-foreign-variable ONLRET tcflag_t "ONLRET") 331 (define-foreign-variable OFILL tcflag_t "OFILL") 332 (define-foreign-variable NLDLY tcflag_t "NLDLY") 333 (define-foreign-variable NL0 tcflag_t "NL0") 334 (define-foreign-variable NL1 tcflag_t "NL1") 335 (cond-expand 336 [macosx 337 (define-foreign-variable NL2 tcflag_t "NL2") 338 (define-foreign-variable NL3 tcflag_t "NL3") 339 ] [else] ) 340 (define-foreign-variable TABDLY tcflag_t "TABDLY") 341 (define-foreign-variable TAB0 tcflag_t "TAB0") 342 (define-foreign-variable TAB1 tcflag_t "TAB1") 343 (define-foreign-variable TAB2 tcflag_t "TAB2") 344 (define-foreign-variable TAB3 tcflag_t "TAB3") 345 (define-foreign-variable CRDLY tcflag_t "CRDLY") 346 (define-foreign-variable CR0 tcflag_t "CR0") 347 (define-foreign-variable CR1 tcflag_t "CR1") 348 (define-foreign-variable CR2 tcflag_t "CR2") 349 (define-foreign-variable CR3 tcflag_t "CR3") 350 (define-foreign-variable FFDLY tcflag_t "FFDLY") 351 (define-foreign-variable FF0 tcflag_t "FF0") 352 (define-foreign-variable FF1 tcflag_t "FF1") 353 (define-foreign-variable BSDLY tcflag_t "BSDLY") 354 (define-foreign-variable BS0 tcflag_t "BS0") 355 (define-foreign-variable BS1 tcflag_t "BS1") 356 (define-foreign-variable VTDLY tcflag_t "VTDLY") 357 (define-foreign-variable VT0 tcflag_t "VT0") 358 (define-foreign-variable VT1 tcflag_t "VT1") 359 (define-foreign-variable OFDEL tcflag_t "OFDEL") 360 (cond-expand 361 [macosx 362 (define-foreign-variable OXTABS tcflag_t "OXTABS") 363 (define-foreign-variable ONOEOT tcflag_t "ONOEOT") 364 ] [else] ) 365 366 (define-foreign-variable CSIZE tcflag_t "CSIZE") 367 (define-foreign-variable CS5 tcflag_t "CS5") 368 (define-foreign-variable CS6 tcflag_t "CS6") 369 (define-foreign-variable CS7 tcflag_t "CS7") 370 (define-foreign-variable CS8 tcflag_t "CS8") 371 (define-foreign-variable CSTOPB tcflag_t "CSTOPB") 372 (define-foreign-variable CREAD tcflag_t "CREAD") 373 (define-foreign-variable PARENB tcflag_t "PARENB") 374 (define-foreign-variable PARODD tcflag_t "PARODD") 375 (define-foreign-variable HUPCL tcflag_t "HUPCL") 376 (define-foreign-variable CLOCAL tcflag_t "CLOCAL") 377 (cond-expand 378 [macosx 379 (define-foreign-variable CIGNORE tcflag_t "CIGNORE") 380 (define-foreign-variable CCTS_OFLOW tcflag_t "CCTS_OFLOW") 381 (define-foreign-variable CRTSCTS tcflag_t "CRTSCTS") 382 (define-foreign-variable CRTS_OFLOW tcflag_t "CRTS_OFLOW") 383 (define-foreign-variable CDTR_OFLOW tcflag_t "CDTR_OFLOW") 384 (define-foreign-variable CDSR_OFLOW tcflag_t "CDSR_OFLOW") 385 (define-foreign-variable CCAR_OFLOW tcflag_t "CCAR_OFLOW") 386 (define-foreign-variable MDMBUF tcflag_t "MDMBUF") 387 ] [else] ) 388 389 (define-foreign-variable ECHOE tcflag_t "ECHOE") 390 (define-foreign-variable ECHOK tcflag_t "ECHOK") 391 (define-foreign-variable ECHO tcflag_t "ECHO") 392 (define-foreign-variable ECHONL tcflag_t "ECHONL") 393 (define-foreign-variable ISIG tcflag_t "ISIG") 394 (define-foreign-variable ICANON tcflag_t "ICANON") 395 (define-foreign-variable IEXTEN tcflag_t "IEXTEN") 396 (define-foreign-variable TOSTOP tcflag_t "TOSTOP") 397 (define-foreign-variable NOFLSH tcflag_t "NOFLSH") 398 (cond-expand 399 [macosx 400 (define-foreign-variable ECHOKE tcflag_t "ECHOKE") 401 (define-foreign-variable ECHOPRT tcflag_t "ECHOPRT") 402 (define-foreign-variable ECHOCTL tcflag_t "ECHOCTL") 403 (define-foreign-variable ALTWERASE tcflag_t "ALTWERASE") 404 (define-foreign-variable EXTPROC tcflag_t "EXTPROC") 405 (define-foreign-variable FLUSHO tcflag_t "FLUSHO") 406 (define-foreign-variable NOKERNINFO tcflag_t "NOKERNINFO") 407 (define-foreign-variable PENDIN tcflag_t "PENDIN") 408 ] [else] ) 409 410 (define-foreign-variable VEOF unsigned-short "VEOF") 411 (define-foreign-variable VEOL unsigned-short "VEOL") 412 (define-foreign-variable VERASE unsigned-short "VERASE") 413 (define-foreign-variable VKILL unsigned-short "VKILL") 414 (define-foreign-variable VINTR unsigned-short "VINTR") 415 (define-foreign-variable VQUIT unsigned-short "VQUIT") 416 (define-foreign-variable VSUSP unsigned-short "VSUSP") 417 (define-foreign-variable VSTART unsigned-short "VSTART") 418 (define-foreign-variable VSTOP unsigned-short "VSTOP") 419 (define-foreign-variable VMIN unsigned-short "VMIN") 420 (define-foreign-variable VTIME unsigned-short "VTIME") 421 (cond-expand 422 [macosx 423 (define-foreign-variable VEOL2 unsigned-short "VEOL2") 424 (define-foreign-variable VWERASE unsigned-short "VWERASE") 425 (define-foreign-variable VREPRINT unsigned-short "VREPRINT") 426 (define-foreign-variable VDSUSP unsigned-short "VDSUSP") 427 (define-foreign-variable VLNEXT unsigned-short "VLNEXT") 428 (define-foreign-variable VDISCARD unsigned-short "VDISCARD") 429 (define-foreign-variable VSTATUS unsigned-short "VSTATUS") 430 ] [else] ) 431 (define-foreign-variable _nccs unsigned-short "NCCS") 457 (define-foreign-type tcflag_t "tcflag_t") 458 (define-foreign-type cc_t "cc_t") 459 (define-foreign-type speed_t "speed_t") 460 461 ; Input Flags 462 463 #> 464 #ifndef IUCLC 465 # define IUCLC 0 466 #endif 467 468 #ifndef IXANY 469 # define IXANY 0 470 #endif 471 472 #ifndef IUTF8 473 # define IUTF8 0 474 #endif 475 476 #ifndef IMAXBEL 477 # define IMAXBEL 0 478 #endif 479 <# 480 481 (define termios/ignbrk (foreign-value "IGNBRK" tcflag_t)) 482 (define termios/brkint (foreign-value "BRKINT" tcflag_t)) 483 (define termios/ignpar (foreign-value "IGNPAR" tcflag_t)) 484 (define termios/parmrk (foreign-value "PARMRK" tcflag_t)) 485 (define termios/inpck (foreign-value "INPCK" tcflag_t)) 486 (define termios/istrip (foreign-value "ISTRIP" tcflag_t)) 487 (define termios/inlcr (foreign-value "INLCR" tcflag_t)) 488 (define termios/igncr (foreign-value "IGNCR" tcflag_t)) 489 (define termios/icrnl (foreign-value "ICRNL" tcflag_t)) 490 (define termios/iuclc (foreign-value "IUCLC" tcflag_t)) 491 (define termios/ixon (foreign-value "IXON" tcflag_t)) 492 (define termios/ixoff (foreign-value "IXOFF" tcflag_t)) 493 (define termios/ixany (foreign-value "IXANY" tcflag_t)) 494 (define termios/iutf8 (foreign-value "IUTF8" tcflag_t)) 495 (define termios/imaxbel (foreign-value "IMAXBEL" tcflag_t)) 496 497 ; Output Flags 498 499 #> 500 #ifndef OLCUC 501 # define OLCUC 0 502 #endif 503 504 #ifndef NLDLY 505 # define NLDLY 0 506 #endif 507 508 #ifndef NL0 509 # define NL0 0 510 #endif 511 512 #ifndef NL1 513 # define NL1 0 514 #endif 515 516 #ifndef NL3 517 # define NL3 0 518 #endif 519 520 #ifndef TABDLY 521 # define TABDLY 0 522 #endif 523 524 #ifndef TAB0 525 # define TAB0 0 526 #endif 527 528 #ifndef TAB1 529 # define TAB1 0 530 #endif 531 532 #ifndef TAB2 533 # define TAB2 0 534 #endif 535 536 #ifndef TAB3 537 # define TAB3 0 538 #endif 539 540 #ifndef CRDLY 541 # define CRDLY 0 542 #endif 543 544 #ifndef CR0 545 # define CR0 0 546 #endif 547 548 #ifndef CR1 549 # define CR1 0 550 #endif 551 552 #ifndef CR2 553 # define CR2 0 554 #endif 555 556 #ifndef CR3 557 # define CR3 0 558 #endif 559 560 #ifndef FFDLY 561 # define FFDLY 0 562 #endif 563 564 #ifndef FF0 565 # define FF0 0 566 #endif 567 568 #ifndef FF1 569 # define FF1 0 570 #endif 571 572 #ifndef BSDLY 573 # define BSDLY 0 574 #endif 575 576 #ifndef BS0 577 # define BS0 0 578 #endif 579 580 #ifndef BS1 581 # define BS1 0 582 #endif 583 584 #ifndef VTDLY 585 # define VTDLY 0 586 #endif 587 588 #ifndef VT0 589 # define VT0 0 590 #endif 591 592 #ifndef VT1 593 # define VT1 0 594 #endif 595 596 #ifndef OFDEL 597 # define OFDEL 0 598 #endif 599 600 #ifndef OXTABS 601 # define OXTABS 0 602 #endif 603 604 #ifndef ONOEOT 605 # define ONOEOT 0 606 #endif 607 <# 608 609 (define termios/opost (foreign-value "OPOST" tcflag_t)) 610 (define termios/olcuc (foreign-value "OLCUC" tcflag_t)) 611 (define termios/onlcr (foreign-value "ONLCR" tcflag_t)) 612 (define termios/ocrnl (foreign-value "OCRNL" tcflag_t)) 613 (define termios/onocr (foreign-value "ONOCR" tcflag_t)) 614 (define termios/onlret (foreign-value "ONLRET" tcflag_t)) 615 (define termios/ofill (foreign-value "OFILL" tcflag_t)) 616 (define termios/nldly (foreign-value "NLDLY" tcflag_t)) 617 (define termios/nl0 (foreign-value "NL0" tcflag_t)) 618 (define termios/nl1 (foreign-value "NL1" tcflag_t)) 619 (define termios/nl2 (foreign-value "NL2" tcflag_t)) 620 (define termios/nl3 (foreign-value "NL3" tcflag_t)) 621 (define termios/tabdly (foreign-value "TABDLY" tcflag_t)) 622 (define termios/tab0 (foreign-value "TAB0" tcflag_t)) 623 (define termios/tab1 (foreign-value "TAB1" tcflag_t)) 624 (define termios/tab2 (foreign-value "TAB2" tcflag_t)) 625 (define termios/tab3 (foreign-value "TAB3" tcflag_t)) 626 (define termios/crdly (foreign-value "CRDLY" tcflag_t)) 627 (define termios/cr0 (foreign-value "CR0" tcflag_t)) 628 (define termios/cr1 (foreign-value "CR1" tcflag_t)) 629 (define termios/cr2 (foreign-value "CR2" tcflag_t)) 630 (define termios/cr3 (foreign-value "CR3" tcflag_t)) 631 (define termios/ffdly (foreign-value "FFDLY" tcflag_t)) 632 (define termios/ff0 (foreign-value "FF0" tcflag_t)) 633 (define termios/ff1 (foreign-value "FF1" tcflag_t)) 634 (define termios/bsdly (foreign-value "BSDLY" tcflag_t)) 635 (define termios/bs0 (foreign-value "BS0" tcflag_t)) 636 (define termios/bs1 (foreign-value "BS1" tcflag_t)) 637 (define termios/vtdly (foreign-value "VTDLY" tcflag_t)) 638 (define termios/vt0 (foreign-value "VT0" tcflag_t)) 639 (define termios/vt1 (foreign-value "VT1" tcflag_t)) 640 (define termios/ofdel (foreign-value "OFDEL" tcflag_t)) 641 (define termios/oxtabs (foreign-value "OXTABS" tcflag_t)) 642 (define termios/onoeot (foreign-value "ONOEOT" tcflag_t)) 643 644 ; Control Flags 645 646 #> 647 #ifndef CBAUD 648 # define CBAUD 0 649 #endif 650 651 #ifndef CBAUDX 652 # define CBAUDX 0 653 #endif 654 655 #ifndef CIBAUD 656 # define CIBAUD 0 657 #endif 658 659 #ifndef LOBLK 660 # define LOBLK 0 661 #endif 662 663 #ifndef CIGNORE 664 # define CIGNORE 0 665 #endif 666 667 #ifndef MDMBUF 668 # define MDMBUF 0 669 #endif 670 671 #ifndef CRTSCTS 672 # define CRTSCTS 0 673 #endif 674 675 #ifndef CCTS_OFLOW 676 # define CCTS_OFLOW 0 677 #endif 678 679 #ifndef CRTS_OFLOW 680 # define CRTS_OFLOW 0 681 #endif 682 683 #ifndef CDTR_OFLOW 684 # define CDTR_OFLOW 0 685 #endif 686 687 #ifndef CDSR_OFLOW 688 # define CDSR_OFLOW 0 689 #endif 690 691 #ifndef CCAR_OFLOW 692 # define CCAR_OFLOW 0 693 #endif 694 <# 695 696 (define termios/cbaud (foreign-value "CBAUD" tcflag_t)) 697 (define termios/cbaudx (foreign-value "CBAUDX" tcflag_t)) 698 (define termios/cibaud (foreign-value "CIBAUD" tcflag_t)) 699 (define termios/loblk (foreign-value "LOBLK" tcflag_t)) 700 (define termios/csize (foreign-value "CSIZE" tcflag_t)) 701 (define termios/cs5 (foreign-value "CS5" tcflag_t)) 702 (define termios/cs6 (foreign-value "CS6" tcflag_t)) 703 (define termios/cs7 (foreign-value "CS7" tcflag_t)) 704 (define termios/cs8 (foreign-value "CS8" tcflag_t)) 705 (define termios/cstopb (foreign-value "CSTOPB" tcflag_t)) 706 (define termios/cread (foreign-value "CREAD" tcflag_t)) 707 (define termios/parenb (foreign-value "PARENB" tcflag_t)) 708 (define termios/parodd (foreign-value "PARODD" tcflag_t)) 709 (define termios/hupcl (foreign-value "HUPCL" tcflag_t)) 710 (define termios/clocal (foreign-value "CLOCAL" tcflag_t)) 711 (define termios/cignore (foreign-value "CIGNORE" tcflag_t)) 712 (define termios/mdmbuf (foreign-value "MDMBUF" tcflag_t)) 713 (define termios/crtscts (foreign-value "CRTSCTS" tcflag_t)) 714 (define termios/ccts_oflow (foreign-value "CCTS_OFLOW" tcflag_t)) 715 (define termios/crts-oflow (foreign-value "CRTS_OFLOW" tcflag_t)) 716 (define termios/cdtr-oflow (foreign-value "CDTR_OFLOW" tcflag_t)) 717 (define termios/cdsr-oflow (foreign-value "CDSR_OFLOW" tcflag_t)) 718 (define termios/ccar-oflow (foreign-value "CCAR_OFLOW" tcflag_t)) 719 720 ; Local Flags 721 722 #> 723 #ifndef XCASE 724 # define XCASE 0 725 #endif 726 727 #ifndef ECHOCTL 728 # define ECHOCTL 0 729 #endif 730 731 #ifndef ECHOKE 732 # define ECHOKE 0 733 #endif 734 735 #ifndef ECHOPRT 736 # define ECHOPRT 0 737 #endif 738 739 #ifndef PENDIN 740 # define PENDIN 0 741 #endif 742 743 #ifndef FLUSHO 744 # define FLUSHO 0 745 #endif 746 747 #ifndef ALTWERASE 748 # define ALTWERASE 0 749 #endif 750 751 #ifndef NOKERNINFO 752 # define NOKERNINFO 0 753 #endif 754 755 #ifndef EXTPROC 756 # define EXTPROC 0 757 #endif 758 <# 759 760 (define termios/xcase (foreign-value "XCASE" tcflag_t)) 761 (define termios/isig (foreign-value "ISIG" tcflag_t)) 762 (define termios/icanon (foreign-value "ICANON" tcflag_t)) 763 (define termios/echoe (foreign-value "ECHOE" tcflag_t)) 764 (define termios/echok (foreign-value "ECHOK" tcflag_t)) 765 (define termios/echo (foreign-value "ECHO" tcflag_t)) 766 (define termios/echonl (foreign-value "ECHONL" tcflag_t)) 767 (define termios/iexten (foreign-value "IEXTEN" tcflag_t)) 768 (define termios/tostop (foreign-value "TOSTOP" tcflag_t)) 769 (define termios/noflsh (foreign-value "NOFLSH" tcflag_t)) 770 (define termios/echoctl (foreign-value "ECHOCTL" tcflag_t)) 771 (define termios/echoke (foreign-value "ECHOKE" tcflag_t)) 772 (define termios/echoprt (foreign-value "ECHOPRT" tcflag_t)) 773 (define termios/pendin (foreign-value "PENDIN" tcflag_t)) 774 (define termios/flusho (foreign-value "FLUSHO" tcflag_t)) 775 (define termios/altwerase (foreign-value "ALTWERASE" tcflag_t)) 776 (define termios/nokerninfo (foreign-value "NOKERNINFO" tcflag_t)) 777 (define termios/extproc (foreign-value "EXTPROC" tcflag_t)) 778 779 ; Special Control Character Indicies 780 781 #> 782 #ifndef VSWTCH 783 # define VSWTCH NCCS 784 #endif 785 786 #ifndef VEOL2 787 # define VEOL2 NCCS 788 #endif 789 790 #ifndef VWERASE 791 # define VWERASE NCCS 792 #endif 793 794 #ifndef VREPRINT 795 # define VREPRINT NCCS 796 #endif 797 798 #ifndef VDSUSP 799 # define VDSUSP NCCS 800 #endif 801 802 #ifndef VLNEXT 803 # define VLNEXT NCCS 804 #endif 805 806 #ifndef VDISCARD 807 # define VDISCARD NCCS 808 #endif 809 810 #ifndef VSTATUS 811 # define VSTATUS NCCS 812 #endif 813 <# 814 815 (define termios/vswitch (foreign-value "VSWTCH" int)) 816 (define termios/veof (foreign-value "VEOF" int)) 817 (define termios/veol (foreign-value "VEOL" int)) 818 (define termios/verase (foreign-value "VERASE" int)) 819 (define termios/vkill (foreign-value "VKILL" int)) 820 (define termios/vintr (foreign-value "VINTR" int)) 821 (define termios/vquit (foreign-value "VQUIT" int)) 822 (define termios/vsusp (foreign-value "VSUSP" int)) 823 (define termios/vstart (foreign-value "VSTART" int)) 824 (define termios/vstop (foreign-value "VSTOP" int)) 825 (define termios/vmin (foreign-value "VMIN" int)) 826 (define termios/vtime (foreign-value "VTIME" int)) 827 (define termios/veol2 (foreign-value "VEOL2" int)) 828 (define termios/vwerase (foreign-value "VWERASE" int)) 829 (define termios/vreprint (foreign-value "VREPRINT" int)) 830 (define termios/vdsusp (foreign-value "VDSUSP" int)) 831 (define termios/vlnext (foreign-value "VLNEXT" int)) 832 (define termios/vdiscard (foreign-value "VDISCARD" int)) 833 (define termios/vstatus (foreign-value "VSTATUS" int)) 834 835 (define-foreign-variable _nccs cc_t "NCCS") 432 836 (define termios/nccs _nccs) 837 838 (define termios/posix-vdisable (foreign-value "_POSIX_VDISABLE" cc_t)) 839 840 ; Special Control Characters 841 842 #> 843 #define CTRLCHAR( c ) ((c) & 31) 844 845 #ifndef CEOF 846 # ifdef EOF 847 # define CEOF EOF 848 # else 849 # define CEOF CTRLCHAR( 'd' ) 850 #endif 851 852 CERASE CTRLCHAR( 'd' ) 853 CINTR CTRLCHAR( 'c' ) 854 CSTATUS CTRLCHAR( 't' ) 855 CKILL CTRLCHAR( 'u' ) 856 857 CMIN CTRLCHAR( 'd' ) 858 859 CQUIT CTRLCHAR( '\\' ) 860 CSUSP CTRLCHAR( 'z' ) 861 862 CTIME CTRLCHAR( '' ) 863 864 CDSUSP CTRLCHAR( 'y' ) 865 CSTART CTRLCHAR( 'q' ) 866 CSTOP CTRLCHAR( 's' ) 867 CLNEXT CTRLCHAR( 'v' ) 868 CDISCARD CTRLCHAR( 'o' ) 869 CWERASE CTRLCHAR( 'w' ) 870 CREPRINT CTRLCHAR( 'r' ) 871 872 CEOT CTRLCHAR( 'd' ) 873 874 <# 875 876 (define termios-cc/eof (foreign-value "CEOF" cc_t)) 877 (define termios-cc/eol (foreign-value "CEOL" cc_t)) 878 (define termios-cc/erase (foreign-value "CERASE" cc_t)) 879 (define termios-cc/intr (foreign-value "CINTR" cc_t)) 880 (define termios-cc/status (foreign-value "CSTATUS" cc_t)) 881 (define termios-cc/kill (foreign-value "CKILL" cc_t)) 882 (define termios-cc/min (foreign-value "CMIN" cc_t)) 883 (define termios-cc/quit (foreign-value "CQUIT" cc_t)) 884 (define termios-cc/susp (foreign-value "CSUSP" cc_t)) 885 (define termios-cc/time (foreign-value "CTIME" cc_t)) 886 (define termios-cc/dsusp (foreign-value "CDSUSP" cc_t)) 887 (define termios-cc/start (foreign-value "CSTART" cc_t)) 888 (define termios-cc/stop (foreign-value "CSTOP" cc_t)) 889 (define termios-cc/lnext (foreign-value "CLNEXT" cc_t)) 890 (define termios-cc/discard (foreign-value "CDISCARD" cc_t)) 891 (define termios-cc/werase (foreign-value "CWERASE" cc_t)) 892 (define termios-cc/reprint (foreign-value "CREPRINT" cc_t)) 893 (define termios-cc/eot (foreign-value "CEOT" cc_t)) 894 (define termios-cc/brk (foreign-value "CBRK" cc_t)) 895 (define termios-cc/crprnt (foreign-value "CRPRINT" cc_t)) 896 (define termios-cc/flush (foreign-value "CFLUSH" cc_t)) 897 898 #| 899 (define termios-default/iflag (foreign-value "TTYDEF_IFLAG" tcflag_t)) 900 (define termios-default/oflag (foreign-value "TTYDEF_OFLAG" tcflag_t)) 901 (define termios-default/lflag (foreign-value "TTYDEF_LFLAG" tcflag_t)) 902 (define termios-default/cflag (foreign-value "TTYDEF_CFLAG" tcflag_t)) 903 (define termios-default/speed (foreign-value "TTYDEF_SPEED" tcflag_t)) 904 |# 433 905 434 906 ; c_iflag input flags … … 449 921 450 922 (define (make-termios #!key (iflags 0) (oflags 0) (cflags 0) (lflags 0) cc) 451 (##sys#check-exact iflags 'make-termios)452 (##sys#check-exact oflags 'make-termios)453 (##sys#check-exact cflags 'make-termios)454 (##sys#check-exact lflags 'make-termios)455 923 (let ([tr (alloc-termios)]) 456 924 925 (define (flags obj) 926 (cond 927 [(list? obj) (apply bitwise-ior obj)] 928 [(fixnum? obj) obj] 929 [else 930 (##sys#signal-hook #:type-error 'make-termios "bad argument type - not a fixnum" obj) ] ) ) 931 457 932 (define (setcc! len getter) 458 (dotimes (idx (fxmin _nccs len)) (termios-cc-set! tr idx val)) )459 460 (termios-iflag-set! tr iflags)461 (termios-oflag-set! tr oflags)462 (termios-cflag-set! tr cflags)463 (termios-lflag-set! tr lflags)933 (dotimes (idx (fxmin _nccs len)) (termios-cc-set! tr idx (getter cc idx))) ) 934 935 (termios-iflag-set! tr (flags iflags)) 936 (termios-oflag-set! tr (flags oflags)) 937 (termios-cflag-set! tr (flags cflags)) 938 (termios-lflag-set! tr (flags lflags)) 464 939 (set-finalizer! tr free-termios) 465 940 (cond … … 469 944 [(string? cc) (setcc! (string-length cc) (lambda (x i) (char->integer (string-ref x i))))] 470 945 [else 471 (##sys#signal-hook #:type-error 'make-termios "bad argument type - not a list, vector, or string" cc) ] ) 472 tr ) ) 473 474 ;; Termios access 475 476 (define-foreign-variable B0 speed_t "B0") 477 (define-foreign-variable B50 speed_t "B50") 478 (define-foreign-variable B75 speed_t "B75") 479 (define-foreign-variable B110 speed_t "B110") 480 (define-foreign-variable B134 speed_t "B134") 481 (define-foreign-variable B150 speed_t "B150") 482 (define-foreign-variable B200 speed_t "B200") 483 (define-foreign-variable B300 speed_t "B300") 484 (define-foreign-variable B600 speed_t "B600") 485 (define-foreign-variable B1200 speed_t "B1200") 486 (define-foreign-variable B1800 speed_t "B1800") 487 (define-foreign-variable B2400 speed_t "B2400") 488 (define-foreign-variable B4800 speed_t "B4800") 489 (define-foreign-variable B9600 speed_t "B9600") 490 (define-foreign-variable B19200 speed_t "B19200") 491 (define-foreign-variable B38400 speed_t "B38400") 492 (cond-expand 493 [macosx 494 (define-foreign-variable B7200 speed_t "B7200") 495 (define-foreign-variable B14400 speed_t "B14400") 496 (define-foreign-variable B28800 speed_t "B28800") 497 (define-foreign-variable B57600 speed_t "B57600") 498 (define-foreign-variable B76800 speed_t "B76800") 499 (define-foreign-variable B115200 speed_t "B115200") 500 (define-foreign-variable B230400 speed_t "B230400") 501 (define-foreign-variable EXTA speed_t "EXTA") 502 (define-foreign-variable EXTB speed_t "EXTB") 503 ] [else] ) 946 (##sys#signal-hook #:type-error 'make-termios "bad argument type - not a sequence" cc) ] ) 947 (##sys#tag-pointer tr 'termios) ) ) 948 949 ;; Terminal Speed 950 951 #< 952 #ifndef B7200 953 # define B7200 B4800 954 #endif 955 956 #ifndef B14400 957 # define B14400 B9600 958 #endif 959 960 #ifndef B28800 961 # define B28800 B14400 962 #endif 963 964 #ifndef B57600 965 # define B57600 B28800 966 #endif 967 968 #ifndef B76800 969 # define B76800 B57600 970 #endif 971 972 #ifndef B115200 973 # define B115200 B76800 974 #endif 975 976 #ifndef B230400 977 # define B230400 B115200 978 #endif 979 980 #ifndef B460800 981 # define B460800 B230400 982 #endif 983 ># 984 985 (define termctl-baud/0 (foreign-value "B0" speed_t)) 986 (define termctl-baud/50 (foreign-value "B50" speed_t)) 987 (define termctl-baud/75 (foreign-value "B75" speed_t)) 988 (define termctl-baud/110 (foreign-value "B110" speed_t)) 989 (define termctl-baud/134 (foreign-value "B134" speed_t)) 990 (define termctl-baud/150 (foreign-value "B150" speed_t)) 991 (define termctl-baud/200 (foreign-value "B200" speed_t)) 992 (define termctl-baud/300 (foreign-value "B300" speed_t)) 993 (define termctl-baud/600 (foreign-value "B600" speed_t)) 994 (define termctl-baud/1200 (foreign-value "B1200" speed_t)) 995 (define termctl-baud/1800 (foreign-value "B1800" speed_t)) 996 (define termctl-baud/2400 (foreign-value "B2400" speed_t)) 997 (define termctl-baud/4800 (foreign-value "B4800" speed_t)) 998 (define termctl-baud/7200 (foreign-value "B7200" speed_t)) 999 (define termctl-baud/9600 (foreign-value "B9600" speed_t)) 1000 (define termctl-baud/14400 (foreign-value "B14400" speed_t)) 1001 (define termctl-baud/19200 (foreign-value "B19200" speed_t)) 1002 (define termctl-baud/28800 (foreign-value "B28800" speed_t)) 1003 (define termctl-baud/38400 (foreign-value "B38400" speed_t)) 1004 (define termctl-baud/57600 (foreign-value "B57600" speed_t)) 1005 (define termctl-baud/76800 (foreign-value "B76800" speed_t)) 1006 (define termctl-baud/115200 (foreign-value "B115200" speed_t)) 1007 (define termctl-baud/230400 (foreign-value "B230400" speed_t)) 1008 (define termctl-baud/460800 (foreign-value "B460800" speed_t)) 504 1009 505 1010 #> … … 516 1021 517 1022 (define (terminal-control-input-speed ptermios) 518 (##sys#check- pointer ptermios 'terminal-control-input-speed)1023 (##sys#check-non-null-pointer ptermios 'terminal-control-input-speed) 519 1024 520 1025 (define (terminal-control-output-speed ptermios) 521 (##sys#check- pointer ptermios 'terminal-control-output-speed)1026 (##sys#check-non-null-pointer ptermios 'terminal-control-output-speed) 522 1027 523 1028 (define (set-terminal-control-input-speed! ptermios speed) 524 (##sys#check- pointer ptermios 'set-terminal-control-output-speed!)1029 (##sys#check-non-null-pointer ptermios 'set-terminal-control-output-speed!) 525 1030 (##sys#check-exact speed 'set-terminal-control-input-speed!) 526 1031 (when (fx= -1 (##core#inline "C_cfsetispeed" ptermios speed)) … … 528 1033 529 1034 (define (set-terminal-control-output-speed! ptermios speed) 530 (##sys#check- pointer ptermios 'set-terminal-control-output-speed!)1035 (##sys#check-non-null-pointer ptermios 'set-terminal-control-output-speed!) 531 1036 (##sys#check-exact speed 'set-terminal-control-output-speed!) 532 1037 (when (fx= -1 (##core#inline "C_cfsetospeed" ptermios speed)) … … 553 1058 554 1059 (define (set-terminal-control-speed! ptermios speed) 555 (##sys#check- pointer ptermios 'set-terminal-control-speed!)1060 (##sys#check-non-null-pointer ptermios 'set-terminal-control-speed!) 556 1061 (##sys#check-exact speed 'set-terminal-control-speed!) 557 1062 (when (fx= -1 (##core#inline "C_cfsetspeed" ptermios speed)) 558 1063 (##sys#posix-error #:file-error 'set-terminal-control-speed! "cannot change termios speed" ptermios speed) ) ) 559 1064 560 ;; Terminal Control Get & Set 561 562 bsd now drain flush soft 563 solaris linux now drain flush 564 565 (define-foreign-variable TCSANOW int "TCSANOW") 566 (define-foreign-variable TCSADRAIN int "TCSADRAIN") 567 (define-foreign-variable TCSAFLUSH int "TCSAFLUSH") 568 569 (cond-expand 570 [(or macosx freebsd netbsd openbsd) 571 (define-foreign-variable TCSASOFT int "TCSASOFT") 572 ] [else] ) 1065 ;; Terminal Attributes Get & Set 1066 1067 #> 1068 #ifndef TCSASOFT 1069 # define TCSASOFT 0 1070 #endif 1071 <# 1072 1073 (define termctl-action/now (foreign-value "TCSANOW" int)) 1074 (define termctl-action/drain (foreign-value "TCSADRAIN" int)) 1075 (define termctl-action/flush (foreign-value "TCSAFLUSH" int)) 1076 (define termctl-action/soft (foreign-value "TCSASOFT" int)) 573 1077 574 1078 #> … … 583 1087 (unless ptermios 584 1088 (set! ptermios (alloc-termios)) ) 585 (##sys#check- pointer ptermios 'terminal-control-attributes)1089 (##sys#check-non-null-pointer ptermios 'terminal-control-attributes) 586 1090 (if (fx= -1 (##core#inline "C_tcgetattr" fd ptermios)) 587 (##sys#posix-error #:file-error 'terminal-control-attributes "cannot copy terminal parameters" fd)1091 (##sys#posix-error #:file-error 'terminal-control-attributes "cannot aquire terminal attributes" fd) 588 1092 ptermios ) ) 589 1093 … … 591 1095 (##sys#check-exact fd 'set-terminal-control-attributes!) 592 1096 (##sys#check-exact act 'set-terminal-control-attributes!) 593 (##sys#check- pointer ptermios 'set-terminal-control-attributes!)1097 (##sys#check-non-null-pointer ptermios 'set-terminal-control-attributes!) 594 1098 (when (fx= -1 (##core#inline "C_tcsetattr" fd act ptermios)) 595 (##sys#posix-error #:file-error 'set-terminal-control-attributes! "cannot change terminal parameters" fd act) ) )1099 (##sys#posix-error #:file-error 'set-terminal-control-attributes! "cannot change terminal attributes" fd act) ) ) 596 1100 597 1101 ;; Terminal Control Drain … … 606 1110 (##sys#posix-error #:file-error 'terminal-control-drain "cannot drain terminal input" fd) ) ) 607 1111 608 ;; Terminal ControlFlow609 610 (define -foreign-variable TCOOFF int "TCOOFF")611 (define -foreign-variable TCOON int "TCOON")612 (define -foreign-variable TCIOFF int "TCIOFF")613 (define -foreign-variable TCION int "TCION")1112 ;; Terminal Flow 1113 1114 (define termctl-flow/output-off (foreign-value "TCOOFF" int)) 1115 (define termctl-flow/output-on (foreign-value "TCOON" int)) 1116 (define termctl-flow/input-off (foreign-value "TCIOFF" int)) 1117 (define termctl-flow/input-on (foreign-value "TCION" int)) 614 1118 615 1119 #> … … 623 1127 (##sys#posix-error #:file-error 'terminal-control-flow "cannot control terminal flow" fd act) ) ) 624 1128 625 ;; Terminal ControlFlush626 627 (define -foreign-variable TCIFLUSH int "TCIFLUSH")628 (define -foreign-variable TCOFLUSH int "TCOFLUSH")629 (define -foreign-variable TCIOFLUSH int "TCIOFLUSH")1129 ;; Terminal Flush 1130 1131 (define termctl-flush/input (foreign-value "TCIFLUSH" int)) 1132 (define termctl-flush/output (foreign-value "TCOFLUSH" int)) 1133 (define termctl-flush/input-output (foreign-value "TCIOFLUSH" int)) 630 1134 631 1135 #> … … 639 1143 (##sys#posix-error #:file-error 'terminal-control-flush "cannot perform terminal flush" fd act) ) ) 640 1144 641 ;; Terminal ControlSend Break1145 ;; Terminal Send Break 642 1146 643 1147 #> … … 650 1154 (when (fx= -1 (##core#inline "C_tcsendbreak" fd dur)) 651 1155 (##sys#posix-error #:file-error 'terminal-control-send-break "cannot transmit terminal break" fd dur) ) ) 1156 1157 ;; Terminal Raw Mode 652 1158 653 1159 (cond-expand … … 673 1179 674 1180 (define (terminal-control-make-raw ptermios) 675 (##sys#check- pointer ptermios 'terminal-control-make-raw)676 ( if(fx= -1 (##core#inline "C_cfmakeraw" ptermios))1181 (##sys#check-non-null-pointer ptermios 'terminal-control-make-raw) 1182 (when (fx= -1 (##core#inline "C_cfmakeraw" ptermios)) 677 1183 (##sys#posix-error #:file-error 'terminal-control-make-raw "cannot set terminal raw I/O path" ptermios) ) ) 1184 678 1185 679 1186 ;;; Pseudo-tty … … 747 1254 (##sys#check-pointer-argument pwinsize 'fork-pseudo-tty) 748 1255 (let-location ([master int]) 749 (let ([ ret(##core#inline "C_forkpty" #$master _null (or ptermios _null) (or pwinsize _null))])1256 (let ([pid (##core#inline "C_forkpty" #$master _null (or ptermios _null) (or pwinsize _null))]) 750 1257 (cond 751 [(fx= -1 ret)1258 [(fx= -1 pid) 752 1259 (##sys#posix-error #:file-error 'fork-pseudo-tty "cannot create child process in pseudo-tty") ] 753 [(fx= 0 ret)1260 [(fx= 0 pid) 754 1261 (thunk) 755 1262 ((foreign-lambda void "_exit" int) 0) ] 756 1263 [else 757 (values retmaster) ] ) ) ) )1264 (values pid master) ] ) ) ) ) 758 1265 759 1266 ] ) 1267 760 1268 761 1269 ;;; Terminal Information … … 775 1283 <# 776 1284 777 (define (terminal- type-device? fd)778 (##sys#check-exact fd 'terminal- type-device?)1285 (define (terminal-device?? fd) 1286 (##sys#check-exact fd 'terminal-device??) 779 1287 (##core#inline "C_isatty" fd) ) 780 1288 … … 791 1299 (cond 792 1300 [(not len) 793 (##sys#signal-hook #: limit-error 'terminal-device-name "buffer overflow" fd) ]1301 (##sys#signal-hook #:bounds-error 'terminal-device-name "buffer overflow" fd) ] 794 1302 [(fx= 0 len) 795 1303 ; Cannot find device or not a tty. … … 805 1313 (cond 806 1314 [(not len) 807 (##sys#signal-hook #: limit-error 'terminal-device-name "buffer overflow" fd) ]1315 (##sys#signal-hook #:bounds-error 'terminal-device-name "buffer overflow" fd) ] 808 1316 [(fx= 0 len) 809 1317 ; Cannot find device or not a tty. … … 818 1326 fd ) ) ) 819 1327 1328 820 1329 ;;; Fileno 821 1330 … … 824 1333 (duplicate-fileno fd sfd) 825 1334 (file-close fd) ) ) 1335 826 1336 827 1337 ;;; Spawn Stuff -
release/3/posix-extensions/trunk/posix-extensions.meta
r13039 r13129 9 9 ;(needs posix) 10 10 (files 11 "4windows.scm" 12 "4unix.scm" 13 "posix-extensions.setup" 14 "tests" 15 "setup-header.scm") ) 11 "standard-errors" 12 "4windows.scm" 13 "4unix.scm" 14 "posix-extensions.setup" 15 "tests" 16 "setup-header.scm") ) -
release/3/posix-extensions/trunk/posix-extensions.wiki
r13118 r13129 80 80 result in buffer overflow. 81 81 82 <procedure>(fork-pseudo-tty THUNK [WINSIZE [TERMIOS]]) => (values PID_T MASTER-FILENO)</procedure> 83 84 As per the C function {{forkpty(3)}}, creates a new pty, and returns the master 85 fd {{MASTER-FILENO}} and process-id of the created process. 82 <procedure>(fork-pseudo-tty THUNK [WINSIZE [TERMIOS]]) => (values CHILD-PID MASTER-FILENO)</procedure> 83 84 As per the C function {{forkpty(3)}}, creates a new pty, and returns the 85 process-id {{CHILD-PID}} and master fd {{MASTER-FILENO}} of the child process 86 to the parent process. 87 88 {{THUNK}} is executed in the child process. 86 89 87 90 The pseudo-tty name, {{WINSIZE}}, and {{TERMIOS}} as in {{open_pty}}. … … 103 106 Returns the pointer to a new C {{struct winsize}}, initialized per supplied arguments. 104 107 108 {{COUNT}} is an unsigned exact integer {{unsigned short}}. 109 105 110 Sets a finalizer. 106 111 107 112 Winsize has the following accessors: 108 113 109 <procedure>(winsize-col WINSIZE) => INTEGER</procedure> 110 <procedure>(winsize-col-set! WINSIZE INTEGER)</procedure> 111 112 <procedure>(winsize-row WINSIZE) => INTEGER</procedure> 113 <procedure>(winsize-row-set! WINSIZE INTEGER)</procedure> 114 115 <procedure>(winsize-xpixel WINSIZE) => INTEGER</procedure> 116 <procedure>(winsize-xpixel-set! WINSIZE INTEGER)</procedure> 117 118 <procedure>(winsize-ypixel WINSIZE) => INTEGER</procedure> 119 <procedure>(winsize-ypixel-set! WINSIZE INTEGER)</procedure> 120 121 The domain of all {{INTEGER}} is {{unsigned short}}. 114 <procedure>(winsize-col WINSIZE) => COUNT</procedure> 115 <procedure>(winsize-col-set! WINSIZE COUNT)</procedure> 116 117 <procedure>(winsize-row WINSIZE) => COUNT</procedure> 118 <procedure>(winsize-row-set! WINSIZE COUNT)</procedure> 119 120 <procedure>(winsize-xpixel WINSIZE) => COUNT</procedure> 121 <procedure>(winsize-xpixel-set! WINSIZE COUNT)</procedure> 122 123 <procedure>(winsize-ypixel WINSIZE) => COUNT</procedure> 124 <procedure>(winsize-ypixel-set! WINSIZE COUNT)</procedure> 122 125 123 126 Unavailable with Windows. … … 125 128 ==== Termios 126 129 130 The follow constants are as per the Unix General Terminal Interface. 131 132 Input Flags (TCFLAG): 133 134 <constant>termios/ignbrk</constant> 135 <constant>termios/brkint</constant> 136 <constant>termios/ignpar</constant> 137 <constant>termios/parmrk</constant> 138 <constant>termios/inpck</constant> 139 <constant>termios/istrip</constant> 140 <constant>termios/inlcr</constant> 141 <constant>termios/igncr</constant> 142 <constant>termios/icrnl</constant> 143 <constant>termios/iuclc</constant> 144 <constant>termios/ixon</constant> 145 <constant>termios/ixoff</constant> 146 <constant>termios/ixany</constant> 147 <constant>termios/iutf8</constant> 148 <constant>termios/imaxbel</constant> 149 150 Output Flags (TCFLAG): 151 152 <constant>termios/opost</constant> 153 <constant>termios/olcuc</constant> 154 <constant>termios/onlcr</constant> 155 <constant>termios/ocrnl</constant> 156 <constant>termios/onocr</constant> 157 <constant>termios/onlret</constant> 158 <constant>termios/ofill</constant> 159 <constant>termios/nldly</constant> 160 <constant>termios/nl0</constant> 161 <constant>termios/nl1</constant> 162 <constant>termios/nl2</constant> 163 <constant>termios/nl3</constant> 164 <constant>termios/tabdly</constant> 165 <constant>termios/tab0</constant> 166 <constant>termios/tab1</constant> 167 <constant>termios/tab2</constant> 168 <constant>termios/tab3</constant> 169 <constant>termios/crdly</constant> 170 <constant>termios/cr0</constant> 171 <constant>termios/cr1</constant> 172 <constant>termios/cr2</constant> 173 <constant>termios/cr3</constant> 174 <constant>termios/ffdly</constant> 175 <constant>termios/ff0</constant> 176 <constant>termios/ff1</constant> 177 <constant>termios/bsdly</constant> 178 <constant>termios/bs0</constant> 179 <constant>termios/bs1</constant> 180 <constant>termios/vtdly</constant> 181 <constant>termios/vt0</constant> 182 <constant>termios/vt1</constant> 183 <constant>termios/ofdel</constant> 184 <constant>termios/oxtabs</constant> 185 <constant>termios/onoeot</constant> 186 187 Control Flags (TCFLAG): 188 189 <constant>termios/cbaud</constant> 190 <constant>termios/cbaudx</constant> 191 <constant>termios/cibaud</constant> 192 <constant>termios/loblk</constant> 193 <constant>termios/csize</constant> 194 <constant>termios/cs5</constant> 195 <constant>termios/cs6</constant> 196 <constant>termios/cs7</constant> 197 <constant>termios/cs8</constant> 198 <constant>termios/cstopb</constant> 199 <constant>termios/cread</constant> 200 <constant>termios/parenb</constant> 201 <constant>termios/parodd</constant> 202 <constant>termios/hupcl</constant> 203 <constant>termios/clocal</constant> 204 <constant>termios/cignore</constant> 205 <constant>termios/mdmbuf</constant> 206 <constant>termios/crtscts</constant> 207 <constant>termios/ccts_oflow</constant> 208 <constant>termios/crts-oflow</constant> 209 <constant>termios/cdtr-oflow</constant> 210 <constant>termios/cdsr-oflow</constant> 211 <constant>termios/ccar-oflow</constant> 212 213 Local Flags (TCFLAG): 214 215 <constant>termios/xcase</constant> 216 <constant>termios/isig</constant> 217 <constant>termios/icanon</constant> 218 <constant>termios/echoe</constant> 219 <constant>termios/echok</constant> 220 <constant>termios/echo</constant> 221 <constant>termios/echonl</constant> 222 <constant>termios/iexten</constant> 223 <constant>termios/tostop</constant> 224 <constant>termios/noflsh</constant> 225 <constant>termios/echoctl</constant> 226 <constant>termios/echoke</constant> 227 <constant>termios/echoprt</constant> 228 <constant>termios/pendin</constant> 229 <constant>termios/flusho</constant> 230 <constant>termios/altwerase</constant> 231 <constant>termios/nokerninfo</constant> 232 <constant>termios/extproc</constant> 233 234 Special Control Character Indicies: 235 236 <constant>termios/vswitch</constant> 237 <constant>termios/veof</constant> 238 <constant>termios/veol</constant> 239 <constant>termios/verase</constant> 240 <constant>termios/vkill</constant> 241 <constant>termios/vintr</constant> 242 <constant>termios/vquit</constant> 243 <constant>termios/vsusp</constant> 244 <constant>termios/vstart</constant> 245 <constant>termios/vstop</constant> 246 <constant>termios/vmin</constant> 247 <constant>termios/vtime</constant> 248 <constant>termios/veol2</constant> 249 <constant>termios/vwerase</constant> 250 <constant>termios/vreprint</constant> 251 <constant>termios/vdsusp</constant> 252 <constant>termios/vlnext</constant> 253 <constant>termios/vdiscard</constant> 254 <constant>termios/vstatus</constant> 255 <constant>termios/nccs</constant> 256 257 Special Control Characters (CC): 258 259 260 127 261 <procedure>(alloc-termios) => TERMIOS</procedure> 128 262 … … 133 267 Releases a C {{struct termios}}. 134 268 135 <procedure>(make-termios [#:iflags TCFLAG _T] [#:oflags TCFLAG_T] [#:cflags TCFLAG_T] [#:lflags TCFLAG_T] [#:cc LIST | VECTOR |STRING]) => TERMIOS</procedure>269 <procedure>(make-termios [#:iflags TCFLAG|LIST] [#:oflags TCFLAG|LIST] [#:cflags TCFLAG|LIST] [#:lflags TCFLAG|LIST] [#:cc LIST|VECTOR|STRING]) => TERMIOS</procedure> 136 270 137 271 Returns the pointer to a new C {{struct termios}}, initialized per supplied arguments. 272 273 A flag argument of type {{LIST}} is element-by-element or'ed to produce a {{TCFLAG}}. 274 275 A control-character argument of type {{SEQUENCE}} must have {{CC}} elements. 276 Any sequence elements beyond {{termios/nccs}} are ignored. 138 277 139 278 Sets a finalizer. … … 144 283 <procedure>(termios-cc-set! TERMIOS IDX CC_T)</procedure> 145 284 146 <procedure>(termios-cflag TERMIOS) => TCFLAG_T</procedure> 147 <procedure>(termios-cflag-set! TERMIOS TCFLAG_T)</procedure> 148 149 <procedure>(termios-iflag TERMIOS) => TCFLAG_T</procedure> 150 <procedure>(termios-iflag-set! TERMIOS TCFLAG_T)</procedure> 151 152 <procedure>(termios-lflag TERMIOS) => TCFLAG_T</procedure> 153 <procedure>(termios-lflag-set! TERMIOS TCFLAG_T)</procedure> 154 155 <procedure>(termios-oflag TERMIOS) => TCFLAG_T</procedure> 156 <procedure>(termios-oflag-set! TERMIOS TCFLAG_T)</procedure> 157 158 Unavailable with Windows. 159 160 === 161 162 {{SPEED}} 163 164 {{TERMIOS}} is a {{(c-pointer struct termios)}}. 165 166 {{FILENO}} 285 <procedure>(termios-cflag TERMIOS) => TCFLAG</procedure> 286 <procedure>(termios-cflag-set! TERMIOS TCFLAG)</procedure> 287 288 <procedure>(termios-iflag TERMIOS) => TCFLAG</procedure> 289 <procedure>(termios-iflag-set! TERMIOS TCFLAG)</procedure> 290 291 <procedure>(termios-lflag TERMIOS) => TCFLAG</procedure> 292 <procedure>(termios-lflag-set! TERMIOS TCFLAG)</procedure> 293 294 <procedure>(termios-oflag TERMIOS) => TCFLAG</procedure> 295 <procedure>(termios-oflag-set! TERMIOS TCFLAG)</procedure> 296 297 Unavailable with Windows. 298 299 === Terminal Speed 300 301 <constant>termctl-baud/0</constant> 302 <constant>termctl-baud/50</constant> 303 <constant>termctl-baud/75</constant> 304 <constant>termctl-baud/110</constant> 305 <constant>termctl-baud/134</constant> 306 <constant>termctl-baud/150</constant> 307 <constant>termctl-baud/200</constant> 308 <constant>termctl-baud/300</constant> 309 <constant>termctl-baud/600</constant> 310 <constant>termctl-baud/1200</constant> 311 <constant>termctl-baud/1800</constant> 312 <constant>termctl-baud/2400</constant> 313 <constant>termctl-baud/4800</constant> 314 <constant>termctl-baud/7200</constant> 315 <constant>termctl-baud/9600</constant> 316 <constant>termctl-baud/14400</constant> 317 <constant>termctl-baud/19200</constant> 318 <constant>termctl-baud/28800</constant> 319 <constant>termctl-baud/38400</constant> 320 <constant>termctl-baud/57600</constant> 321 <constant>termctl-baud/76800</constant> 322 <constant>termctl-baud/115200</constant> 323 <constant>termctl-baud/230400</constant> 324 <constant>termctl-baud/460800</constant> 167 325 168 326 <procedure>(terminal-control-input-speed TERMIOS) => SPEED</procedure> … … 177 335 Set both input & output speed elements of the {{TERMIOS}}. 178 336 337 === Terminal Attributes 338 339 <constant>termctl-action/now</constant> 340 <constant>termctl-action/drain</constant> 341 <constant>termctl-action/flush</constant> 342 <constant>termctl-action/soft</constant> 343 179 344 <procedure>(terminal-control-attributes FILENO [TERMIOS]) => TERMIOS</procedure> 180 345 <procedure>(set-terminal-control-attributes! FILENO ACTION TERMIOS)</procedure> … … 182 347 Get & set the {{TERMIOS}} elements. 183 348 349 === Terminal Flow 350 351 <constant>termctl-flow/output-off</constant> 352 <constant>termctl-flow/output-on</constant> 353 <constant>termctl-flow/input-off</constant> 354 <constant>termctl-flow/input-on</constant> 355 356 <procedure>(terminal-control-flow FILENO ACTION)</procedure> 357 358 === Terminal Flush 359 360 <constant>termctl-flush/input</constant> 361 <constant>termctl-flush/output</constant> 362 <constant>termctl-flush/input-output</constant> 363 364 <procedure>(terminal-control-flush FILENO ACTION)</procedure> 365 366 === Terminal Miscellaneous 367 184 368 <procedure>(terminal-control-drain FILENO)</procedure> 185 369 186 <procedure>(terminal-control-flow FILENO ACTION)</procedure>187 188 <procedure>(terminal-control-flush FILENO ACTION)</procedure>189 190 370 <procedure>(terminal-control-send-break FILENO DURATION)</procedure> 191 371 … … 194 374 ==== Terminal Information 195 375 196 <procedure>(terminal- type-device? FILENO) => BOOLEAN</procedure>376 <procedure>(terminal-device?? FILENO) => BOOLEAN</procedure> 197 377 198 378 Does the file descriptor {{FILENO}} refer to a valid terminal type device?
Note: See TracChangeset
for help on using the changeset viewer.