mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
They can be close()d explicitly with close-file-descriptor, and will close() on gc, but only explicitly closing the last port on them will close the fileno. Notably needed for network sockets where we open separate input and output ports on the same socket.
53 lines
2.1 KiB
Text
53 lines
2.1 KiB
Text
|
|
(cond-expand
|
|
(string-streams
|
|
(define-c non-null-string (%read-line "fgets")
|
|
((result (array char arg1)) int (default (current-input-port) input-port)))
|
|
|
|
(define-c size_t (%read-string "fread")
|
|
((result (array char (result arg2))) (value 1 size_t) size_t (default (current-input-port) input-port)))
|
|
|
|
(define-c size_t (%read-string! "fread")
|
|
(string (value 1 size_t) size_t (default (current-input-port) input-port)))
|
|
))
|
|
|
|
(define-c-const int (seek/set "SEEK_SET"))
|
|
(define-c-const int (seek/cur "SEEK_CUR"))
|
|
(define-c-const int (seek/end "SEEK_END"))
|
|
|
|
(define-c long (file-position "ftell") (port))
|
|
(define-c long (set-file-position! "fseek") (port long int))
|
|
|
|
(c-include "port.c")
|
|
|
|
(define-c boolean (is-a-socket? "sexp_is_a_socket_p") (fileno))
|
|
|
|
(define-c errno (%send-file "sexp_send_file")
|
|
(fileno fileno off_t (default 0 off_t) (result off_t)))
|
|
|
|
(define-c sexp (%make-custom-input-port "sexp_make_custom_input_port")
|
|
((value ctx sexp) (value self sexp) sexp sexp sexp))
|
|
|
|
(define-c sexp (%make-custom-output-port "sexp_make_custom_output_port")
|
|
((value ctx sexp) (value self sexp) sexp sexp sexp))
|
|
|
|
(define-c sexp (open-input-bytevector "sexp_open_input_bytevector")
|
|
((value ctx sexp) (value self sexp) sexp))
|
|
(define-c sexp (open-output-bytevector "sexp_open_output_bytevector")
|
|
((value ctx sexp) (value self sexp)))
|
|
(define-c sexp (get-output-bytevector "sexp_get_output_bytevector")
|
|
((value ctx sexp) (value self sexp) sexp))
|
|
|
|
(define-c sexp (string-count-chars "sexp_string_count")
|
|
((value ctx sexp) (value self sexp) sexp sexp sexp (default NULL sexp)))
|
|
(define-c sexp (%string->utf8 "sexp_string_to_utf8")
|
|
((value ctx sexp) (value self sexp) sexp))
|
|
(define-c sexp (utf8->string! "sexp_utf8_to_string_x")
|
|
((value ctx sexp) (value self sexp) sexp))
|
|
|
|
(define-c sexp (write-u8 "sexp_write_u8")
|
|
((value ctx sexp) (value self sexp) sexp (default (current-output-port) sexp)))
|
|
(define-c sexp (read-u8 "sexp_read_u8")
|
|
((value ctx sexp) (value self sexp) (default (current-input-port) sexp)))
|
|
(define-c sexp (peek-u8 "sexp_peek_u8")
|
|
((value ctx sexp) (value self sexp) (default (current-input-port) sexp)))
|