diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1369984 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/makefile.csm +/rain diff --git a/Makefile b/Makefile deleted file mode 100644 index 11f1fc7..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CSM := csm -PREFIX := /usr/local -INSTALL := install - -.PHONY: all -all: Makefile.csm - $(MAKE) -f Makefile.csm - -Makefile.csm: - $(CSM) -makefile Makefile.csm - -.PHONY: clean -clean: Makefile.csm - $(MAKE) -f Makefile.csm clean - rm -f Makefile.csm rain - -.PHONY: install -install: - $(INSTALL) -sDm755 rain $(DESTDIR)$(PREFIX)/bin/rain diff --git a/README.md b/README.md index d7538b6..6b504a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Dependencies - [CHICKEN Scheme](https://call-cc.org) 5 or 6; -- A few CHICKEN extensions, installable using `chicken-install -s html-parser openssl http-client matchable srfi-18`. +- A few CHICKEN extensions, installable using `chicken-install -s format html-parser openssl http-client matchable`. # Building diff --git a/makefile b/makefile new file mode 100644 index 0000000..738144f --- /dev/null +++ b/makefile @@ -0,0 +1,18 @@ +CSM := csm +PREFIX := /usr/local +INSTALL := install + +.PHONY: all +all: makefile.csm + $(MAKE) -f makefile.csm + +makefile.csm: + $(CSM) -makefile makefile.csm + +.PHONY: clean +clean: + git clean -fdx + +.PHONY: install +install: + $(INSTALL) -sDm755 rain $(DESTDIR)$(PREFIX)/bin/rain diff --git a/rain.scm b/rain.scm index b3e8b7e..7440640 100644 --- a/rain.scm +++ b/rain.scm @@ -1,5 +1,3 @@ -(define parallel 1) - (define (find-comic-image index) (call-with-current-continuation (lambda (k) @@ -11,7 +9,7 @@ (define (download-comic-image index) (format (current-error-port) "* downloading comic image ~a~%" index) - (call-with-output-file (format #f "rain-~a.png" index) + (call-with-output-file (format #f "rain-~4,48,d.png" (string->number index)) (lambda (out) (call-with-input-request (find-comic-image index) #f @@ -20,38 +18,20 @@ (format (current-error-port) "* downloaded comic image ~a~%" index)) (define (download-all indices) - (format (current-error-port) "* using ~a threads~%" parallel) - (for-each download-batch (chop indices parallel))) - -(define (download-batch batch) - (let ((threads (map (lambda (index) - (make-thread - (lambda () - (download-comic-image index)))) - batch))) - (for-each thread-start! threads) - (for-each thread-join! threads))) + (for-each download-comic-image indices)) (define (usage) (format (current-error-port) "usage: ~a [OPTION ...] INDEX ...~%" (program-name)) (format (current-error-port) "options:~%") (format (current-error-port) " -h|-help display this help message~%") - (format (current-error-port) " -v|-version display version information~%") - (format (current-error-port) " -j|-parallel N download N images in parallel~%")) + (format (current-error-port) " -v|-version display version information~%")) (define parse-command-line (match-lambda (((or "-h" "-help") . _) (usage)) (((or "-v" "-version") . _) - (format (current-error-port) "rain.scm 1.0.0~%" (program-name))) - (((or "-j" "-parallel") n . rest) - (let ((nn (string->number n))) - (unless nn - (usage) - (exit 1)) - (set! parallel nn) - (parse-command-line rest))) + (format (current-error-port) "rain.scm 1.0.1~%" (program-name))) (() (usage)) (indices diff --git a/rain.sld b/rain.sld index 0c2c22e..12d74bb 100755 --- a/rain.sld +++ b/rain.sld @@ -8,13 +8,12 @@ exec csi -s "$0" "$@" (scheme file) (chicken base) (chicken io) - (chicken format) (chicken port) (chicken process-context) + (format) (html-parser) (openssl) ; has to be before http-client (http-client) - (matchable) - (srfi-18)) + (matchable)) (include "rain.scm") (begin (main (command-line-arguments))))