original commit: 222d56df55f3c2dc40c1ee33eca5d934d100d609
This commit is contained in:
Matthew Flatt 2005-04-19 02:40:15 +00:00
parent 45f3cb7ede
commit d4ea1c265e

View File

@ -1,12 +1,6 @@
(module os mzscheme
(require (lib "foreign.ss")) (unsafe!)
(define BUFFER-SIZE 1024)
(define (extract-terminated-string proc)
(let ([s (make-bytes BUFFER-SIZE)])
(and (proc s BUFFER-SIZE)
(bytes->string/utf-8 (car (regexp-match #rx#"^[^\0]*" s))))))
(define kernel32
(delay (and (eq? 'windows (system-type))
(ffi-lib "kernel32"))))
@ -17,6 +11,14 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gethostbyname
(define BUFFER-SIZE 1024)
(define (extract-terminated-string proc)
(let ([s (make-bytes BUFFER-SIZE)])
(if (proc s BUFFER-SIZE)
(bytes->string/utf-8 (car (regexp-match #rx#"^[^\0]*" s)))
(error 'gethostname
"could not get hostname"))))
(define unix-gethostname
(delay-ffi-obj "gethostname" #f
(_fun _bytes _int -> _int)))