;;;; vim:ft=lisp ;;;; Touched: <10-Oct-03 05:34:56 IST, madhu> ;;;; ;;;; (CLISP and WIN32) (in-package pdf) #+pdf-compress (ffi:def-call-out zlib-compress-string (:name "compress") (:library "c:/windows/system/zlib.dll") (:arguments (dest ffi:c-pointer :in) (destlen (ffi:c-ptr ffi:ulong) :in-out) (source ffi:c-string) (sourcelen ffi:ulong)) (:return-type ffi:int) (:language :stdc)) ;; whats the idea in making this a symbol-macro place? #+pdf-compress (setf custom:*foreign-encoding* +external-format+) ;; if it were a global special I can shadow it when calling compress-string ;; instead of setting it globally #+pdf-compress (defun compress-string (source) "Compress the string SOURCE. Returns an array of bytes representing the compressed data." (let* ((sourcelen (length source)) (destlen (+ 12 (ceiling (* sourcelen 1.05))))) ;; Using CLISP's symbol-macro based interface (ffi:with-c-var (dest `(ffi:c-array ffi:uint8 ,destlen)) ; no init (multiple-value-bind (status actual) (zlib-compress-string (ffi:c-var-address dest) destlen source sourcelen) (if (zerop status) ;;(subseq dest 0 actual) ;;ffi:cast not usable because of different size... (ffi:offset dest 0 `(ffi:c-array ffi:uint8 ,actual)) (error "zlib error, code ~d" status))))))