cl-ipp

Internet Printing Protocol (IPP) for Common Lisp
git clone https://logand.com/git/cl-ipp.git/
Log | Files | Refs

commit c2fd6ea11c5faadfd8e567b46bd4cceebfc5ea03
parent 028e82efab7ca13a3f67278016b6338e12736805
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 18 Aug 2013 01:03:44 +0200

curl-client and wget-client low level stuff moved to cl-rw

Diffstat:
Mipp.lisp | 99++++++++++++++++++-------------------------------------------------------------
1 file changed, 22 insertions(+), 77 deletions(-)

diff --git a/ipp.lisp b/ipp.lisp @@ -24,6 +24,7 @@ (:use :cl) (:export :cancel-job :create-job + :curl-client :disable-printer :enable-printer :get-job-attributes @@ -39,7 +40,8 @@ :release-job :restart-job :resume-printer - :validate-job)) + :validate-job + :wget-client)) (in-package :ipp) @@ -773,101 +775,44 @@ (with-open-file (s response-file) (rw:till (printer-search-reader (rw:char-reader s))))) -(defpackage :ipp.wget - (:use :cl) - (:export :ipp-client)) - -(in-package :ipp.wget) - -(defun run-command (cmd args &optional error-plist) - (let ((code - #+ccl(ccl::external-process-%exit-code (ccl:run-program cmd args)) - #-ccl(error "TODO port IPP.WGET::RUN-COMMAND"))) - (unless (zerop code) - (let ((reason (or (cdr (assoc code error-plist)) ""))) - (error (format nil "~a error ~d: ~a ~s" cmd code reason args)))))) - -(defun wget (url &key request-file response-file content-type) - (run-command - "wget" - `("-q" - ,@ (when request-file - `("--post-file" ,request-file)) - ,@ (when response-file - `("-O" ,response-file)) - ,@ (when content-type - `("--header" ,(format nil "Content-Type:~a" content-type))) - ,url) - '((1 . "Generic panic code") - (2 . "Parse panic") - (3 . "File I/O panic") - (4 . "Network failure") - (5 . "SSL verification failure") - (6 . "Username/password authentication failure") - (7 . "Protocol panics") - (8 . "Server issued an panic response")))) - -;;(wget "http://localhost:631/printers/" :response-file "/tmp/a.html") - -(defun ipp-client (content-type printer-uri request-file response-file) - (wget printer-uri - :request-file request-file - :response-file response-file - :content-type content-type)) +(defun wget-client (content-type printer-uri request-file response-file) + (rw.net:wget printer-uri + :request-file request-file + :response-file response-file + :content-type content-type)) ;;(ipp:list-printers 'ipp-client "http://localhost:631/printers/" "printers.html") -(defpackage :ipp.curl - (:use :cl) - (:export :ipp-client)) - -(in-package :ipp.curl) - -(defun curl (url &key request-file response-file content-type) - (ipp.wget::run-command - "curl" - `("-s" - ,@ (when request-file - `("--data-binary" ,(format nil "@~a" request-file))) - ,@ (when response-file - `("-o" ,response-file)) - ,@ (when content-type - `("-H" ,(format nil "Content-Type:~a" content-type))) - ,url))) - -;;(curl "http://localhost:631/printers/" :response-file "printers.html") -;;(curl "http://localhost:631/jobs/82" :response-file "job-status.html") - -(defun ipp-client (content-type printer-uri request-file response-file) - (curl printer-uri - :request-file request-file - :response-file response-file - :content-type content-type)) - -(defpackage :ipp.wget.test +(defun curl-client (content-type printer-uri request-file response-file) + (rw.net:curl printer-uri + :request-file request-file + :response-file response-file + :content-type content-type)) + +(defpackage :ipp.test (:use :cl)) -(in-package :ipp.wget.test) +(in-package :ipp.test) #+nil -(ipp::cups-get-default 'ipp.wget:ipp-client +(ipp::cups-get-default 'ipp:wget-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat" "response2.dat" 314) #+nil -(ipp::cups-get-printers 'ipp.wget:ipp-client +(ipp::cups-get-printers 'ipp:wget-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat" "response2.dat" 314) -;;(ipp:list-printers 'ipp.wget:ipp-client "http://localhost:631/printers/" "printers.html") +;;(ipp:list-printers 'ipp:wget-client "http://localhost:631/printers/" "printers.html") #+nil (let ((p (ipp:make-printer - 'ipp.wget:ipp-client + 'ipp:wget-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat" "response2.dat" @@ -896,7 +841,7 @@ #+nil (let ((x (ipp:make-job - 'ipp.wget:ipp-client + 'ipp:wget-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat" "response2.dat" @@ -911,7 +856,7 @@ #+nil ;; TODO (let* ((p (ipp:make-printer - 'ipp.wget:ipp-client + 'ipp:wget-client "http://localhost:631/printers/Virtual_PDF_Printer" "request2.dat" "response2.dat"