upscheme/scheme-core/dump.scm

17 lines
722 B
Scheme
Raw Normal View History

(define (dump-buffers-as-c-literal . bufs)
(xdisplay "char boot_image[] = \"")
(let loop-bufs ((bufs bufs))
(if (not (null? bufs))
(begin (let ((buf (car bufs)))
(let loop-buf-bytes ((i 0))
(let ((char (read-u8 buf)))
(if (not (io.eof? buf))
(let ((code (+ char 0)))
(if (= 0 (mod i 16)) (xdisplay "\"\n\""))
(xdisplay "\\x")
(if (< code #x10) (xdisplay "0"))
(xdisplay (number->string code 16))
(loop-buf-bytes (+ i 1)))))))
(loop-bufs (cdr bufs)))))
(xdisplay "\";\n"))