about summary refs log blame commit diff stats
path: root/xdr.lsp
blob: ffbb86864568b2dcf62c417ca0d0e69d6405b530 (plain) (tree)
1
2
3
4
5
6
7
8
                  
                 
                            



                  
                            















                                                
(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))