*** empty log message ***
This commit is contained in:
parent
ddf13b9e3d
commit
846439590d
|
@ -68,3 +68,16 @@ int fbufcount(FILE* fs)
|
||||||
{
|
{
|
||||||
return(fs->_cnt);
|
return(fs->_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns true if there is no buffered data in stream FS
|
||||||
|
** (or there is no buffering, period.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns true if the buffer in stream FS is full
|
||||||
|
** (or there is no buffering, period).
|
||||||
|
*/
|
||||||
|
|
||||||
|
int obuf_full(FILE *fs) {return fs->_cnt <= 0;}
|
||||||
|
|
101
scsh/network.scm
101
scsh/network.scm
|
@ -1,5 +1,5 @@
|
||||||
;;; Networking for the Scheme Shell
|
;;; Networking for the Scheme Shell
|
||||||
;;; Copyright (c) 1994 by Brian D. Carlstrom.
|
;;; Copyright (c) 1994-1995 by Brian D. Carlstrom.
|
||||||
;;; Copyright (c) 1994 by Olin Shivers.
|
;;; Copyright (c) 1994 by Olin Shivers.
|
||||||
|
|
||||||
;;; Scheme48 implementation.
|
;;; Scheme48 implementation.
|
||||||
|
@ -364,7 +364,7 @@
|
||||||
(else
|
(else
|
||||||
(let ((s (make-string len)))
|
(let ((s (make-string len)))
|
||||||
(receive (nread from)
|
(receive (nread from)
|
||||||
(receive-message! socket flags s 0 len)
|
(receive-message! socket s 0 len flags)
|
||||||
(values
|
(values
|
||||||
(cond ((not nread) #f) ; EOF
|
(cond ((not nread) #f) ; EOF
|
||||||
((= nread len) s)
|
((= nread len) s)
|
||||||
|
@ -372,21 +372,21 @@
|
||||||
from)))))))
|
from)))))))
|
||||||
|
|
||||||
(define (receive-message! socket s . maybe-args)
|
(define (receive-message! socket s . maybe-args)
|
||||||
(receive (start end flags)
|
(if (not (string? s))
|
||||||
(parse-optionals maybe-args 0 (string-length s) 0)
|
(error "receive-message!: string expected")
|
||||||
(cond ((not (socket? socket))
|
(receive (start end flags)
|
||||||
(error "receive-message!: socket expected"))
|
(parse-optionals maybe-args 0 (string-length s) 0)
|
||||||
((not (or (integer? flags)
|
(cond ((not (socket? socket))
|
||||||
(integer? start)
|
(error "receive-message!: socket expected"))
|
||||||
(integer? end)))
|
((not (or (integer? flags)
|
||||||
(error "receive-message!: integer expected"))
|
(integer? start)
|
||||||
((not (string? s))
|
(integer? end)))
|
||||||
(error "receive-message!: string expected"))
|
(error "receive-message!: integer expected"))
|
||||||
(else
|
(else
|
||||||
(generic-receive-message! (socket->fdes socket) flags
|
(generic-receive-message! (socket->fdes socket) flags
|
||||||
s start end
|
s start end
|
||||||
recv-substring!/errno
|
recv-substring!/errno
|
||||||
(socket:family socket))))))
|
(socket:family socket)))))))
|
||||||
|
|
||||||
(define (generic-receive-message! sockfd flags s start end reader from)
|
(define (generic-receive-message! sockfd flags s start end reader from)
|
||||||
(if (bogus-substring-spec? s start end)
|
(if (bogus-substring-spec? s start end)
|
||||||
|
@ -419,26 +419,30 @@
|
||||||
(not (integer? len)))
|
(not (integer? len)))
|
||||||
(error "receive-message/partial: integer expected"))
|
(error "receive-message/partial: integer expected"))
|
||||||
(else
|
(else
|
||||||
(let* ((s (make-string len))
|
(let ((s (make-string len)))
|
||||||
(nread (receive-message!/partial socket flags s 0 len )))
|
(receive (nread addr)
|
||||||
(cond ((not nread) #f) ; EOF
|
(receive-message!/partial socket s 0 len flags)
|
||||||
((= nread len) s)
|
(values
|
||||||
(else (substring s 0 nread))))))))
|
(cond ((not nread) #f) ; EOF
|
||||||
|
((= nread len) s)
|
||||||
|
(else (substring s 0 nread)))
|
||||||
|
addr)))))))
|
||||||
|
|
||||||
(define (receive-message!/partial socket s . maybe-args)
|
(define (receive-message!/partial socket s . maybe-args)
|
||||||
(receive (start end flags)
|
(if (not (string? s))
|
||||||
(parse-optionals maybe-args 0 (string-length s) 0)
|
(error "receive-message!/partial: string expected")
|
||||||
(cond ((not (socket? socket))
|
(receive (start end flags)
|
||||||
(error "receive-message!/partial: socket expected"))
|
(parse-optionals maybe-args 0 (string-length s) 0)
|
||||||
((not (integer? flags))
|
(cond ((not (socket? socket))
|
||||||
(error "receive-message!/partial: integer expected"))
|
(error "receive-message!/partial: socket expected"))
|
||||||
((not (string? s))
|
((not (integer? flags))
|
||||||
(error "receive-message!/partial: string expected"))
|
(error "receive-message!/partial: integer expected"))
|
||||||
(else
|
(else
|
||||||
(generic-receive-message!/partial (socket->fdes socket) flags
|
(generic-receive-message!/partial (socket->fdes socket)
|
||||||
s start end
|
flags
|
||||||
recv-substring!/errno
|
s start end
|
||||||
(socket:family socket))))))
|
recv-substring!/errno
|
||||||
|
(socket:family socket)))))))
|
||||||
|
|
||||||
(define (generic-receive-message!/partial sockfd flags s start end reader from)
|
(define (generic-receive-message!/partial sockfd flags s start end reader from)
|
||||||
(if (bogus-substring-spec? s start end)
|
(if (bogus-substring-spec? s start end)
|
||||||
|
@ -458,7 +462,7 @@
|
||||||
s start start end addr)))
|
s start start end addr)))
|
||||||
(values
|
(values
|
||||||
(and (not (zero? nread)) nread)
|
(and (not (zero? nread)) nread)
|
||||||
from)))))))
|
(make-socket-address from addr))))))))
|
||||||
|
|
||||||
(define-foreign recv-substring!/errno
|
(define-foreign recv-substring!/errno
|
||||||
(recv_substring (integer sockfd)
|
(recv_substring (integer sockfd)
|
||||||
|
@ -523,9 +527,7 @@
|
||||||
s start end
|
s start end
|
||||||
send-substring/errno
|
send-substring/errno
|
||||||
(if addr (socket-address:family addr) 0)
|
(if addr (socket-address:family addr) 0)
|
||||||
(and addr
|
(if addr (socket-address:address addr)))))))
|
||||||
(socket-address:family
|
|
||||||
addr)))))))
|
|
||||||
|
|
||||||
(define (generic-send-message/partial sockfd flags s start end writer family addr)
|
(define (generic-send-message/partial sockfd flags s start end writer family addr)
|
||||||
(if (bogus-substring-spec? s start end)
|
(if (bogus-substring-spec? s start end)
|
||||||
|
@ -534,17 +536,16 @@
|
||||||
s start end writer))
|
s start end writer))
|
||||||
|
|
||||||
(if (= start end) 0 ; Vacuous request.
|
(if (= start end) 0 ; Vacuous request.
|
||||||
(let ((addr (if addr (make-addr family) "")))
|
(let loop ()
|
||||||
(let loop ()
|
(receive (err nwritten)
|
||||||
(receive (err nwritten)
|
(writer sockfd flags s start end family addr)
|
||||||
(writer sockfd flags s start end family addr)
|
(if err
|
||||||
(if err
|
(case err
|
||||||
(case err
|
((errno/intr) (loop))
|
||||||
((errno/intr) (loop))
|
((errno/again errno/wouldblock) 0)
|
||||||
((errno/again errno/wouldblock) 0)
|
(else (errno-error err sockfd flags family addr
|
||||||
(else (errno-error err sockfd flags family addr
|
s start start end writer)))
|
||||||
s start start end writer)))
|
nwritten)))))
|
||||||
nwritten))))))
|
|
||||||
|
|
||||||
(define-foreign send-substring/errno
|
(define-foreign send-substring/errno
|
||||||
(send_substring (integer sockfd)
|
(send_substring (integer sockfd)
|
||||||
|
|
Loading…
Reference in New Issue