From: John L. <wu...@us...> - 2005-04-15 05:23:23
|
Update of /cvsroot/swig/SWIG/Examples/chicken/zlib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4387/Examples/chicken/zlib Modified Files: Makefile test-zlib.scm Log Message: Add a whole bunch of chicken runme scripts, and fix the bugs exposed by those scripts Index: test-zlib.scm =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/chicken/zlib/test-zlib.scm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test-zlib.scm 30 May 2004 07:11:25 -0000 1.3 --- test-zlib.scm 15 Apr 2005 05:23:13 -0000 1.4 *************** *** 1,36 **** ! ;; run with './zlib test-zlib.scm' ! ! (declare (uses example)) ! (declare (uses format)) ;; Init zstream ! (define s (zlib:new-z-stream)) ! (zlib:z-stream-zalloc-set s #f) ! (zlib:z-stream-zfree-set s #f) ! (zlib:z-stream-opaque-set s #f) ! (zlib:deflate-init s (zlib:z-default-compression)) ;; Deflate something small so we don't need to loop/stream data (define in "some pony et jumping et jack et flash et had a jack pony") (define out (make-string 1000)) ! (format #t "to be compressed: ~A~%to be compressed bytes: ~D~%~%" in (string-length in)) ! (zlib:z-stream-next-in-set s in) ! (zlib:z-stream-avail-in-set s (string-length in)) ! (zlib:z-stream-next-out-set s out) ! (zlib:z-stream-avail-out-set s (string-length out)) (let* ! ((saved-out (zlib:z-stream-save-next-out s)) ! (ret (zlib:deflate s (zlib:z-finish)))) (cond ! ((= ret (zlib:z-stream-end)) ! (format #t "deflated properly!~%compressed bytes: ~D~%compressed stream: ~S~%" ! (zlib:z-stream-total-out-get s) (zlib:z-stream-get-next-chunk s saved-out))) ! ((= ret (zlib:z-ok)) (display "only partial deflation ... not enough output space\n")) (else ! (format #t "deflate error(~D): ~A ~%" ret (zlib:z-stream-msg-get s))))) ;; Use simple compress routine, and set max output size to 100 ! (define c (zlib:compress 100 in)) (newline) (let --- 1,33 ---- ! (load-library 'example "./zlib.so") ;; Init zstream ! (define s (new-z-stream)) ! (z-stream-zalloc-set s #f) ! (z-stream-zfree-set s #f) ! (z-stream-opaque-set s #f) ! (deflate-init s (Z-DEFAULT-COMPRESSION)) ;; Deflate something small so we don't need to loop/stream data (define in "some pony et jumping et jack et flash et had a jack pony") (define out (make-string 1000)) ! (printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in)) ! (z-stream-next-in-set s in) ! (z-stream-avail-in-set s (string-length in)) ! (z-stream-next-out-set s out) ! (z-stream-avail-out-set s (string-length out)) (let* ! ((saved-out (z-stream-save-next-out s)) ! (ret (deflate s (Z-FINISH)))) (cond ! ((= ret (Z-STREAM-END)) ! (printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%" ! (z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out))) ! ((= ret (Z-OK)) (display "only partial deflation ... not enough output space\n")) (else ! (printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s))))) ;; Use simple compress routine, and set max output size to 100 ! (define c (compress 100 in)) (newline) (let *************** *** 38,45 **** (compressed (cadr c))) (cond ! ((= ret (zlib:z-ok)) ! (format #t "compressed properly!~%compressed bytes: ~D~%compressed stream: ~S~%" (string-length compressed) compressed)) (else ! (format #t "compress error(~D): ~A ~%" ret (zlib:z-error ret))))) --- 35,43 ---- (compressed (cadr c))) (cond ! ((= ret (Z-OK)) ! (printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%" (string-length compressed) compressed)) (else ! (printf "compress error(~D): ~A ~%" ret (z-error ret))))) + (exit 0) Index: Makefile =================================================================== RCS file: /cvsroot/swig/SWIG/Examples/chicken/zlib/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 30 May 2004 07:11:25 -0000 1.6 --- Makefile 15 Apr 2005 05:23:13 -0000 1.7 *************** *** 6,17 **** TARGET = zlib INCLUDE = ! SWIGOPT = -I/usr/include -mixed -prefix zlib CFLAGS = VARIANT = LIBS = -lz ! ! # comment out the following two lines to build a dynamic exe ! CHICKEN_MAIN = test-zlib.scm ! VARIANT = _static all:: $(TARGET) --- 6,14 ---- TARGET = zlib INCLUDE = ! SWIGOPT = -I/usr/include CFLAGS = VARIANT = LIBS = -lz ! VARIANT = _direct all:: $(TARGET) *************** *** 19,23 **** $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ ! SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) --- 16,20 ---- $(TARGET): $(INTERFACE) $(SRCS) $(MAKE) -f $(TOP)/Makefile \ ! SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \ INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) *************** *** 25,31 **** clean:: $(MAKE) -f $(TOP)/Makefile chicken_clean ! rm -f example.scm example-generic.scm example-clos.scm rm -f $(TARGET) check:: ! csi -batch simple.so test-zlib.scm --- 22,28 ---- clean:: $(MAKE) -f $(TOP)/Makefile chicken_clean ! rm -f example.scm rm -f $(TARGET) check:: ! csi test-zlib.scm |