Loading classes.fs +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading connected.fs +4 −1 Original line number Diff line number Diff line Loading @@ -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! ; Loading file.fs +14 −3 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 ) ; Loading Loading @@ -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) Loading linux/notify.fs +36 −41 Original line number Diff line number Diff line Loading @@ -22,22 +22,6 @@ '&' of ." &" endof '"' of ." "" endof emit 0 endcase LOOP ; : escape-<&>-shell ( addr u -- ) bounds ?DO case i c@ '<' of ." <" endof '>' of ." >" endof '&' of ." &" endof '"' of ." "" 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 ) Loading Loading @@ -78,6 +62,9 @@ $Variable net2o-logo : !net2o-logo ( -- ) s" ../doc/net2o-logo.png" fpath file>abspath net2o-logo $! ; !upath !net2o-logo [IFDEF] use-execve : ?free0 ( addr -- ) dup 0= IF drop EXIT THEN @ free throw ; : !notify-args ( -- ) Loading @@ -98,22 +85,30 @@ $Variable net2o-logo 0 , \ must be terminated by null pointer r> dp ! ; !upath !net2o-logo !notify-args !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] ; tools.fs +23 −0 Original line number Diff line number Diff line Loading @@ -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 ) Loading Loading
classes.fs +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
connected.fs +4 −1 Original line number Diff line number Diff line Loading @@ -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! ; Loading
file.fs +14 −3 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 ) ; Loading Loading @@ -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) Loading
linux/notify.fs +36 −41 Original line number Diff line number Diff line Loading @@ -22,22 +22,6 @@ '&' of ." &" endof '"' of ." "" endof emit 0 endcase LOOP ; : escape-<&>-shell ( addr u -- ) bounds ?DO case i c@ '<' of ." <" endof '>' of ." >" endof '&' of ." &" endof '"' of ." "" 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 ) Loading Loading @@ -78,6 +62,9 @@ $Variable net2o-logo : !net2o-logo ( -- ) s" ../doc/net2o-logo.png" fpath file>abspath net2o-logo $! ; !upath !net2o-logo [IFDEF] use-execve : ?free0 ( addr -- ) dup 0= IF drop EXIT THEN @ free throw ; : !notify-args ( -- ) Loading @@ -98,22 +85,30 @@ $Variable net2o-logo 0 , \ must be terminated by null pointer r> dp ! ; !upath !net2o-logo !notify-args !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] ;
tools.fs +23 −0 Original line number Diff line number Diff line Loading @@ -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 ) Loading