2022-03-06 18:46:04 +01:00
|
|
|
"#iota.isbpl" include
|
2022-03-06 18:13:25 +01:00
|
|
|
|
2022-03-06 18:46:04 +01:00
|
|
|
native stream
|
2022-03-06 18:13:25 +01:00
|
|
|
|
2022-03-12 20:05:04 +01:00
|
|
|
def STREAM.create.file.in riota =STREAM.create.file.in
|
|
|
|
def STREAM.create.file.out iota =STREAM.create.file.out
|
|
|
|
def STREAM.create.socket iota =STREAM.create.socket
|
|
|
|
def STREAM.close iota =STREAM.close
|
|
|
|
def STREAM.read iota =STREAM.read
|
|
|
|
def STREAM.write iota =STREAM.write
|
2022-03-06 18:13:25 +01:00
|
|
|
|
|
|
|
"not implemented:" #
|
2022-03-12 20:05:04 +01:00
|
|
|
def STREAM.aread iota =STREAM.aread
|
|
|
|
def STREAM.awrite iota =STREAM.awrite
|
|
|
|
|
|
|
|
def STREAM.create.server iota =STREAM.create.server
|
2022-03-06 21:06:44 +01:00
|
|
|
|
2022-05-04 19:48:09 +02:00
|
|
|
func STREAM.stdin {
|
2022-05-05 17:27:21 +02:00
|
|
|
getos strlowercase "win" astartswith dup if { "conIN$" 2 stop } not if { "/dev/stdin" 2 stop }
|
2022-05-04 19:48:09 +02:00
|
|
|
}
|
|
|
|
|
2022-03-06 21:06:44 +01:00
|
|
|
func stream.readline {
|
|
|
|
def id =id
|
|
|
|
def byte 0 =byte
|
|
|
|
def array 0 anew =array
|
|
|
|
def tmparray 0 anew =tmparray
|
|
|
|
def i 1 neg =i
|
2022-04-16 18:44:07 +02:00
|
|
|
id STREAM.read stream =byte
|
|
|
|
byte -1 eq if {
|
|
|
|
-1
|
|
|
|
2 stop
|
|
|
|
}
|
2022-03-06 21:06:44 +01:00
|
|
|
while { ( i 1 + =i ) ( byte 10 eq not ) } {
|
|
|
|
array ( ( array alen 1 + anew ) dup =tmparray ) 0 0 ( array alen ) acopy =array
|
|
|
|
array dup alen 1 - byte _char aput
|
2022-04-16 18:44:07 +02:00
|
|
|
id STREAM.read stream =byte
|
|
|
|
}
|
|
|
|
array alen 0 eq if {
|
|
|
|
array _string
|
|
|
|
2 stop
|
2022-03-06 21:06:44 +01:00
|
|
|
}
|
2022-05-05 17:38:40 +02:00
|
|
|
array array alen 1 - aget _int 13 eq if {
|
2022-05-05 17:34:11 +02:00
|
|
|
def arr array alen 1 - anew =arr
|
|
|
|
array arr 0 0 arr alen acopy =array
|
|
|
|
}
|
2022-04-18 21:36:53 +02:00
|
|
|
array _string
|
2022-03-06 21:06:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func stream.write {
|
|
|
|
def id =id
|
|
|
|
def str _array =str
|
|
|
|
def i 1 neg =i
|
|
|
|
while { ( i 1 + =i ) ( i str alen lt ) } {
|
2022-03-12 20:05:04 +01:00
|
|
|
str i aget id STREAM.write stream
|
2022-03-06 21:06:44 +01:00
|
|
|
}
|
|
|
|
}
|