blob: ffbb86864568b2dcf62c417ca0d0e69d6405b530 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
(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))
|