1 1.1 christos # $NetBSD: dmesg,v 1.1 2020/04/14 13:58:11 christos Exp $ 2 1.1 christos 3 1.1 christos define dmesg 4 1.1 christos set $mbp = msgbufp 5 1.1 christos set $bufdata = &$mbp->msg_bufc[0] 6 1.1 christos set $print = $mbp->msg_bufs 7 1.1 christos set $newl = 0 8 1.1 christos set $skip = 0 9 1.1 christos set $i = -1 10 1.1 christos set $p = $bufdata + $mbp->msg_bufx - 1 11 1.1 christos 12 1.1 christos while ($i < $mbp->msg_bufs) 13 1.1 christos set $i = $i + 1 14 1.1 christos set $p = $p + 1 15 1.1 christos if ($p == $bufdata + $mbp->msg_bufs) 16 1.1 christos set $p = $bufdata 17 1.1 christos end 18 1.1 christos if ($i < $mbp->msg_bufs - $print) 19 1.1 christos loop_continue 20 1.1 christos end 21 1.1 christos set $c = $p[0] 22 1.1 christos # Skip syslog sequences 23 1.1 christos if ($skip) 24 1.1 christos if ($c == '>') 25 1.1 christos set $newl = 0 26 1.1 christos set $skip = 0 27 1.1 christos end 28 1.1 christos loop_continue 29 1.1 christos end 30 1.1 christos if ($newl && $c == '<') 31 1.1 christos set $skip = 1 32 1.1 christos loop_continue 33 1.1 christos end 34 1.1 christos if ($c == '\0') 35 1.1 christos loop_continue 36 1.1 christos end 37 1.1 christos set $newl = $c == '\n' 38 1.1 christos printf "%c", $c 39 1.1 christos end 40 1.1 christos if (!$newl) 41 1.1 christos printf "\n" 42 1.1 christos end 43 1.1 christos end 44 1.1 christos 45 1.1 christos document dmesg 46 1.1 christos print the message buffer 47 1.1 christos end 48