blob: ffae67f9edfbe3034dbeeaba06b4014da46f9262 (
plain) (
tree)
|
|
;;; Use (a subset of) CL and the xpc part of the "frpc" package from QuickLisp instead?
;;; No, use eisl and ../build/xdr-tests-1.0.
(require "olunit")
(defpackage #:xdr
(:use #:openlisp #:olunit)
(:export
#:h-to-xdr
#:xdr-to-h))
(in-package #:xdr)
(defglobal *encode-buf* nil)
(defun buffer-init (buf op)
(case op
((encode) (setq *encode-buf* buf))
((decode) (setq *decode-buf* buf))
(t (error "bad op"))))
(defun set-be-x (buf n)
(setf (elt buf 0) (logand (ash -56 n) #xFF))
(setf (elt buf 1) (logand (ash -48 n) #xFF)))
(defun h-to-xdr (n)
(set-be-x xdr-encode-buf n))
(provide "xdr")
(deftest wrt-test ()
(buffer-init buffer 'encode)
(i-to-xdr 1234)
(write-file buffer +bytes-per-unit+ fh))
|