Commits

Taylor Venable committed 7d173a3

Move the XZ library

Comments (0)

Files changed (4)

+                       **********************************
+                         XZ Archive File Format Support
+                       **********************************
+
+                     Copyright (c) 2010, Taylor C. Venable.
+                              All rights reserved.
+
+================================================================================
+ INTRODUCTION
+================================================================================
+
+The xz method is an algorithm for compressing files.  It's specifically designed
+for a small file size, and fast decompression.  This makes it ideal for files
+that are compressed once, transferred many times, and decompressed many times: a
+use case which matches perfectly the distribution of files over the Internet.
+This is the reason that CTAN uses it to archive TeX libraries.
+
+The latest official specification for the format can be found online at:
+  http://tukaani.org/xz/xz-file-format.txt
+
+================================================================================
+ IMPLEMENTATION
+================================================================================
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;                                                                ;;;
+;;;  XZ Archive File Format Support                                ;;;
+;;;  Copyright (c) 2010, Taylor Venable.  All rights reserved.     ;;;
+;;;                                                                ;;;
+;;;  Released under the simplified (2-clause) BSD license.         ;;;
+;;;                                                                ;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(use-modules (ice-9 format))
+(use-modules (srfi srfi-1) (srfi srfi-26))
+
+(define (encode-number n output)
+  (let loop ((n n))
+    (if (> n #x80)
+      (begin
+        (write-char output (integer->char #xFF))
+        (loop (- n 127)))
+      (write-char output (integer->char n)))))
+
+(define (decode-number input)
+  (let loop ((b (char->integer (read-char input)))
+             (n 0))
+    (if (zero? (logand b #x80))
+      (+ n b)
+      (loop (char->integer (read-char input))
+            (+ n (logand b #x7F))))))
+
+(define header-magic (list (integer->char #xFD) #\7 #\z #\X #\Z #\nul))
+
+(define (write-magic output)
+  (for-each (cut write-char <> output) header-magic))
+
+(define (check-magic input)
+  (let ((alleged-magic (let loop ((i 0) (c (list (read-char input))))
+                         (if (< i 5)
+                           (loop (1+ i) (cons (read-char input) c))
+                           (reverse c)))))
+    ;(for-each (cut format #t "~X " <>) (map char->integer alleged-magic))
+    (fold (lambda (a b) (and a b)) #t
+          (map (lambda (x) (char=? (car x) (cadr x))) (zip header-magic alleged-magic)))))

xz/README

-                       **********************************
-                         XZ Archive File Format Support
-                       **********************************
-
-                     Copyright (c) 2010, Taylor C. Venable.
-                              All rights reserved.
-
-================================================================================
- INTRODUCTION
-================================================================================
-
-The xz method is an algorithm for compressing files.  It's specifically designed
-for a small file size, and fast decompression.  This makes it ideal for files
-that are compressed once, transferred many times, and decompressed many times: a
-use case which matches perfectly the distribution of files over the Internet.
-This is the reason that CTAN uses it to archive TeX libraries.
-
-The latest official specification for the format can be found online at:
-  http://tukaani.org/xz/xz-file-format.txt
-
-================================================================================
- IMPLEMENTATION
-================================================================================
-

xz/xz.scm

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;                                                                ;;;
-;;;  XZ Archive File Format Support                                ;;;
-;;;  Copyright (c) 2010, Taylor Venable.  All rights reserved.     ;;;
-;;;                                                                ;;;
-;;;  Released under the simplified (2-clause) BSD license.         ;;;
-;;;                                                                ;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (ice-9 format))
-(use-modules (srfi srfi-1) (srfi srfi-26))
-
-(define (encode-number n output)
-  (let loop ((n n))
-    (if (> n #x80)
-      (begin
-        (write-char output (integer->char #xFF))
-        (loop (- n 127)))
-      (write-char output (integer->char n)))))
-
-(define (decode-number input)
-  (let loop ((b (char->integer (read-char input)))
-             (n 0))
-    (if (zero? (logand b #x80))
-      (+ n b)
-      (loop (char->integer (read-char input))
-            (+ n (logand b #x7F))))))
-
-(define header-magic (list (integer->char #xFD) #\7 #\z #\X #\Z #\nul))
-
-(define (write-magic output)
-  (for-each (cut write-char <> output) header-magic))
-
-(define (check-magic input)
-  (let ((alleged-magic (let loop ((i 0) (c (list (read-char input))))
-                         (if (< i 5)
-                           (loop (1+ i) (cons (read-char input) c))
-                           (reverse c)))))
-    ;(for-each (cut format #t "~X " <>) (map char->integer alleged-magic))
-    (fold (lambda (a b) (and a b)) #t
-          (map (lambda (x) (char=? (car x) (cadr x))) (zip header-magic alleged-magic)))))