Commit 009ee979 authored by Bernd Paysan's avatar Bernd Paysan

List-based spitting started

parent 36eb637b
......@@ -263,6 +263,8 @@ cmd-class class
field: rqd-xts \ callbacks for request done (array)
field: my-error-id
field: beacon-hash
field: slurp#$ \ slurp id+num string
field: spit#$ \ spit id+num string
0 +field end-strings
field: dest-addrs \ list of destinations
field: punch-addrs \ list of punch destinations
......
......@@ -45,9 +45,12 @@ connect-table $@ inherit-table context-table
over dest-top <> and false dest-end ?!@ drop \ atomic, replaces or!
dest-top!
endwith ;
+net2o: slurp ( -- ) \g slurp in tracked files
$2E net2o: slurped ( $slurped -- ) \g respond to slurped stuff
$> spit#$ $+! ;
$2C net2o: slurp ( -- ) \g slurp in tracked files
\ !!FIXME!! this should probably be asynchronous
net2o:slurp swap ulit, flag, set-top
slurp#$ $@ $, slurped slurp#$ $free
['] do-track-seek net2o:track-all-seeks net2o:send-chunks ;
+net2o: ack-reset ( -- ) \g reset ack state
0 ack-state c! ;
......
......@@ -364,12 +364,16 @@ in net2o : save-block ( back tail id -- delta ) { id -- delta }
id id>addr? .fs-write
file1( id f-wid @ = IF dup f-wamount +!
ELSE f-wid @ 0>= f-wamount @ 0> and IF
." split: " f-wid @ . f-wamount @ hex. cr THEN
." spit: " f-wid @ . f-wamount @ hex. cr THEN
id f-wid ! dup f-wamount ! THEN )
>blockalign dup negate residualwrite +! ;
\ careful: must follow exactly the same logic as slurp (see below)
: .spit ( -- )
spit#$ $@ 2dup dump
bounds ?DO I c@ hex. I 1+ p2@+ >r x64. cr r> I - +LOOP ;
in net2o : spit { back tail -- newback }
back tail back u<= ?EXIT fstates 0= ?EXIT drop
slurp( ." spit: " tail rdata-back@ drop data-rmap with mapc dest-raddr - endwith hex.
......@@ -385,6 +389,7 @@ in net2o : spit { back tail -- newback }
msg( ." Write end" cr ) +file
back fails states u>= IF >maxalign THEN \ if all files are done, align
;] file-sema c-section
slurp( .spit ) spit#$ $free
slurp( ." left: " tail rdata-back@ drop data-rmap with mapc dest-raddr - endwith hex.
write-file# ? residualwrite @ hex. forth:cr ) ;
......@@ -435,10 +440,16 @@ scope{ net2o
\ read in from files
: slurp-block { id -- delta }
data-head@ id id>addr? .fs-read dup /head
data-head@ id id>addr? .fs-read
dup IF id slurp#$ c$+! dup u>64 slurp#$ p2$+!
dup >blockalign over - ?dup-IF
$FF slurp#$ c$+! u>64 slurp#$ p2$+!
THEN
THEN
dup /head
file1( id f-rid @ = IF dup f-ramount +!
ELSE f-rid @ 0>= f-ramount @ 0> and IF
." split: " f-rid @ . f-ramount @ hex. cr THEN
." slurp: " f-rid @ . f-ramount @ hex. cr THEN
id f-rid ! dup f-ramount ! THEN ) ;
\ careful: must follow exactpy the same logic as net2o:spit (see above)
......
......@@ -22,22 +22,6 @@
'&' of ." &amp;" endof
'"' of ." &quot;" endof
emit 0 endcase LOOP ;
: escape-<&>-shell ( addr u -- )
bounds ?DO case i c@
'<' of ." &lt;" endof
'>' of ." &gt;" endof
'&' of ." &amp;" endof
'"' of ." &quot;" endof
'\' of ." \\" endof
'$' of ." \$" endof
'!' of ." \!" endof
emit 0 endcase LOOP ;
: escape-shell ( addr u -- )
bounds ?DO case i c@
'\' of ." \\" endof
'$' of ." \$" endof
'!' of ." \!" endof
emit 0 endcase LOOP ;
: build-notification ( -- ) ;
: notify@ ( -- addr u )
......@@ -78,42 +62,53 @@ $Variable net2o-logo
: !net2o-logo ( -- )
s" ../doc/net2o-logo.png" fpath file>abspath net2o-logo $! ;
: ?free0 ( addr -- )
dup 0= IF drop EXIT THEN @ free throw ;
: !notify-args ( -- )
title-string ?free0
content-string ?free0
here >r notify-args dp !
"notify-send\0" drop ,
"-a\0" drop ,
"net2o\0" drop ,
"-c\0" drop ,
"im.received\0" drop ,
net2o-logo $@len IF
"-i\0" drop ,
net2o-logo $@ drop ,
THEN
here to title-string 0 ,
here to content-string 0 ,
0 , \ must be terminated by null pointer
r> dp ! ;
!upath !net2o-logo !notify-args
!upath !net2o-logo
[IFDEF] use-execve
: ?free0 ( addr -- )
dup 0= IF drop EXIT THEN @ free throw ;
: !notify-args ( -- )
title-string ?free0
content-string ?free0
here >r notify-args dp !
"notify-send\0" drop ,
"-a\0" drop ,
"net2o\0" drop ,
"-c\0" drop ,
"im.received\0" drop ,
net2o-logo $@len IF
"-i\0" drop ,
net2o-logo $@ drop ,
THEN
here to title-string 0 ,
here to content-string 0 ,
0 , \ must be terminated by null pointer
r> dp ! ;
!notify-args
[THEN]
:noname defers 'cold
!upath !net2o-logo !notify-args ; is 'cold
!upath !net2o-logo [IFDEF] !notify-args !notify-args [THEN] ; is 'cold
: linux-notification ( -- ) notify-send $@len 0= ?EXIT
[IFDEF] use-execve
\ for now unknown reasons, notify-send doesn't like this way of
\ being called
notify@ content-string 0$!
['] notify-title $tmp dup 0= IF 2drop EXIT THEN title-string 0$!
notify-send $@ notify-args fork+exec
[ELSE]
\ Use variables to avoid needing to quote stuff
\ Unfortunately, HTML quoting still needed
"TITLE" ['] notify-title $tmp ['] escape-<&> $tmp 1 setenv ?ior
"MESSAGE" notify@ 1 setenv ?ior
[: notify-send $. space
." -a net2o -c im.received "
net2o-logo $@len IF
." -i " net2o-logo $. space THEN
['] notify-title $tmp dup 0= IF 2drop EXIT THEN
'"' emit escape-<&>-shell '"' emit space
'"' emit notify@ escape-shell '"' emit ;] $tmp system
.\" \"$TITLE\" \"$MESSAGE\""
;] $tmp system
"TITLE" unsetenv ?ior
"MESSAGE" unsetenv ?ior
[THEN] ;
......@@ -236,6 +236,29 @@ require bits.fs
: ps@+ ( addr -- 64n addr' )
p@+ >r zz>n r> ;
\ compact representation of mostly power-of-two numbers
: p2@+ ( addr -- 64bit addr' )
count >r r@ $C0 u>= IF
64#1 r> $3F and 64lshift n64-swap EXIT THEN
r@ $0F and u>64 r> 4 rshift 8 umin 0 ?DO
8 64lshift 64>r count u>64 64r> 64+
LOOP n64-swap ;
: p2$+! ( 64bit addr -- )
>r
64dup $F u>64 64u> IF
64dup 64dup 64#1 64- 64and 64-0= IF
64>f fdup f* { | w^ ff1 }
ff1 sf! ff1 [ 3 pad ! pad c@ ]L + c@ $3F - $C0 or
r> c$+! EXIT THEN
THEN
0 >r <#
BEGIN 64dup $F u>64 64u> WHILE
64dup 64>n $FF and hold 8 64rshift
r> $10 + >r
REPEAT
64>n r> or hold #0. #> r> $+! ;
\ bit reversing
: bitreverse8 ( u1 -- u2 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment