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



                  
                            















                                                
;;; Use (a subset of) CL and the xpc part of the "frpc" package from QuickLisp instead?

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