;
: DIE" ( n " quoted" -- ; If v then print message and exit )
- " ROT IF TELL NL EMIT EXIT THEN 2DROP
+ " ROT IF TELL NL EMIT 1 EXIT THEN 2DROP
;
HEX 100 DECIMAL CONSTANT MSG_WAITALL
VARIABLE RECV-BUFFER NL_MAX_PAYLOAD ALLOT
-: PRINTMSG ( n -- ; print RECV-BUFFER message )
- ( n is message length when >0 but we only use text up to first NUL )
- DUP 0 >
- IF DROP RECV-BUFFER DUP STRLEN TELL NL EMIT
- ELSE S" ** Error: " TELL . NL EMIT
- THEN
-;
-
VARIABLE NL-SOCKADDR
( 0-1 .family ) AF_NETLINK W,
( 2-3 ??? ) 0 W,
: NL-LOOP
BEGIN
NL-SOCKET @ RECV-BUFFER NL_MAX_PAYLOAD MSG_WAITALL 0 0
- SYS_RECVFROM PRINTMSG
+ SYS_RECVFROM DUP 0 >
+ IF DROP RECV-BUFFER DUP STRLEN TELL NL EMIT
+ ELSE S" ** Error: " TELL . NL EMIT
+ THEN
AGAIN
;