cl-ipp

Project home: http://logand.com/sw/cl-ipp.html

Contact: http://logand.com/contact.html

Up: http://logand.com/sw/

Table of Contents

1 Introduction

cl-ipp is a library which implements the Internet Printing Protocol (IPP) in Common Lisp. It is licensed under the MIT style licence.

It is implemented in portable Common Lisp, except two functions STRING-TO-OCTETS and OCTETS-TO-STRING that require Clozure CL at the moment. Other Lisp implementations have similar functions or a portable library (e.g. babel) could be used in the future. HTTP functionality is provided by cl-rw wrapping wget or curl program calls. A HTTP backend using drakma could be added if a compile-time dependency is preferable to the install-time dependency on wget or curl.

2 Download and install

cl-ipp depends on cl-rw.

Download the source code:

$ git clone http://logand.com/git/cl-ipp.git

Then set up the Common Lisp environment to find the cl-ipp.asd and cl-rw.asd files and load the system into the Lisp image.

3 Usage

The core (low level) function which implements the Internet Printing Protocol is the function IPP::IPP. This function is pretty much working (minus string encodings and a minor issue with parsing sign of binary integers).

A few wrapper (high level) funtions are exported and are meant to be used by applications to talk to the print server. The high level functions are more or less experimental code waiting to crystalize into useable API.

3.1 List Printers Example

CL-USER> (ipp:list-printers 'ipp::wget-client "http://localhost:631/printers/" "printers.html")
("Virtual_PDF_Printer")

3.2 Print Job Example

(let ((p (ipp:make-printer
          'ipp:wget-client
          "http://localhost:631/printers/Virtual_PDF_Printer"
          "request2.dat"
          "response2.dat"
          314)))
  (ipp:print-job p "/home/tomas/git/cl-ipp/test.txt" :ipp-attribute-fidelity nil :copies 2 :sides "two-sided-long-edge"))
(:IPP-RESPONSE
 :MAJOR 1
 :MINOR 0
 :CODE 0
 :REQUEST-ID 314
 :GROUPS ((:OPERATION-ATTRIBUTES-TAG
           (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
           (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
          (:JOB-ATTRIBUTES-TAG
           (:URI :JOB-URI "ipp://localhost:631/jobs/126")
           (:INTEGER :JOB-ID 126)
           (:ENUM :JOB-STATE 3)
           (:KEYWORD :JOB-STATE-REASONS "none"))))

3.3 Printer Attributes Example

(let ((p (ipp:make-printer
          'ipp:wget-client
          "http://localhost:631/printers/Virtual_PDF_Printer"
          "request2.dat"
          "response2.dat"
          314)))
  (ipp:get-printer-attributes p))
(:IPP-RESPONSE
 :MAJOR 1
 :MINOR 0
 :CODE 0
 :REQUEST-ID 314
 :GROUPS ((:OPERATION-ATTRIBUTES-TAG
           (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
           (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
          (:PRINTER-ATTRIBUTES-TAG
           (:INTEGER :MARKER-CHANGE-TIME 0)
           (:DATETIME :PRINTER-CURRENT-TIME (:DATETIME 2013 8 26 18 53 50 0 43 0 0))
           (:NO-VALUE :PRINTER-DNS-SD-NAME NIL)
           (:NAMEWITHOUTLANGUAGE :PRINTER-ERROR-POLICY "stop-printer")
           (:NAMEWITHOUTLANGUAGE :PRINTER-ERROR-POLICY-SUPPORTED "abort-job" "retry-current-job" "retry-job" "stop-printer")
           (:URI :PRINTER-ICONS "http://localhost:631/icons/Virtual_PDF_Printer.png")
           (:BOOLEAN :PRINTER-IS-ACCEPTING-JOBS T)
           (:BOOLEAN :PRINTER-IS-SHARED NIL)
           (:URI :PRINTER-MORE-INFO "http://localhost:631/printers/Virtual_PDF_Printer")
           (:NAMEWITHOUTLANGUAGE :PRINTER-OP-POLICY "default")
           (:ENUM :PRINTER-STATE 3)
           (:INTEGER :PRINTER-STATE-CHANGE-TIME 1377542930)
           (:TEXTWITHOUTLANGUAGE :PRINTER-STATE-MESSAGE "loadFile failed: temp file: unable to find trailer dictionary while recovering damaged file")
           (:KEYWORD :PRINTER-STATE-REASONS "none")
           (:ENUM :PRINTER-TYPE 10678348)
           (:INTEGER :PRINTER-UP-TIME 1377543230)
           (:URI :PRINTER-URI-SUPPORTED "ipp://localhost:631/printers/Virtual_PDF_Printer")
           (:INTEGER :QUEUED-JOB-COUNT 113)
           (:KEYWORD :URI-AUTHENTICATION-SUPPORTED "requesting-user-name")
           (:KEYWORD :URI-SECURITY-SUPPORTED "none")
           (:NAMEWITHOUTLANGUAGE :PRINTER-NAME "Virtual_PDF_Printer")
           (:TEXTWITHOUTLANGUAGE :PRINTER-LOCATION NIL)
           (:TEXTWITHOUTLANGUAGE :PRINTER-INFO "Virtual PDF Printer")
           (:URI :PRINTER-UUID "urn:uuid:49115578-eded-337a-6a33-4121b0a19a43")
           (:INTEGER :JOB-QUOTA-PERIOD 0)
           (:INTEGER :JOB-K-LIMIT 0)
           (:INTEGER :JOB-PAGE-LIMIT 0)
           (:NAMEWITHOUTLANGUAGE :JOB-SHEETS-DEFAULT "none" "none")
           (:URI :DEVICE-URI "cups-pdf:/")
           (:MIMEMEDIATYPE "document-format-supported" "application/octet-stream" "application/pdf" "application/postscript" "application/vnd.adobe-reader-postscript" "application/vnd.cups-command" "application/vnd.cups-pdf" "application/vnd.cups-pdf-banner" "application/vnd.cups-postscript" "application/vnd.cups-raw" "application/x-cshell" "application/x-csource" "application/x-perl" "application/x-shell" "image/gif" "image/jpeg" "image/png" "image/tiff" "image/urf" "image/x-bitmap" "image/x-photocd" "image/x-portable-anymap" "image/x-portable-bitmap" "image/x-portable-graymap" "image/x-portable-pixmap" "image/x-sgi-rgb" "image/x-sun-raster" "image/x-xbitmap" "image/x-xpixmap" "image/x-xwindowdump" "text/css" "text/html" "text/plain")
           (:INTEGER "copies-default" 1)
           (:MIMEMEDIATYPE "document-format-default" "application/octet-stream")
           (:KEYWORD "job-hold-until-default" "no-hold")
           (:INTEGER "job-priority-default" 50)
           (:INTEGER "number-up-default" 1)
           (:INTEGER "notify-lease-duration-default" 86400)
           (:KEYWORD "notify-events-default" "job-completed")
           (:NO-VALUE "orientation-requested-default" NIL)
           (:ENUM "print-quality-default" 4)
           (:BOOLEAN "color-supported" T)
           (:INTEGER "pages-per-minute" 8)
           (:INTEGER "pages-per-minute-color" 8)
           (:ENUM "print-quality-supported" 4)
           (:TEXTWITHOUTLANGUAGE "printer-make-and-model" "Generic CUPS-PDF Printer")
           (:KEYWORD "media-default" "iso_a4_210x297mm")
           (:KEYWORD "media-supported" "na_edp_11x14in" "na_ledger_11x17in" "na_b-plus_12x19.17in" "custom_16x20in_16x20in" "custom_16x24in_16x24in" "om_2-a_1188.86x1682.04mm" "om_4-a_1682.04x2380.9mm" "na_govt-letter_8x10in" "custom_8x12in_8x12in" "iso_a0_841x1189mm" "iso_a1_594x841mm" "iso_a2_420x594mm" "iso_a3_297x420mm" "iso_a4_210x297mm" "iso_a5_148x210mm" "na_letter_8.5x11in" "na_c_17x22in" "na_d_22x34in" "na_e_34x44in" "oe_arch-a_9x12in" "oe_arch-b_12x18in" "oe_arch-c_18x24in" "oe_arch-d_24x36in" "oe_arch-e_36x48in" "om_c0_916.87x1296.81mm" "om_c1_647.7x916.87mm" "om_c2_457.91x647.7mm" "om_c3_323.85x457.91mm" "om_c4_228.95x323.85mm" "iso_c5_162x229mm" "na_number-10_4.125x9.5in" "iso_dl_110x220mm" "na_monarch_3.875x7.5in" "na_executive_7.25x10.5in" "iso_b0_1000x1414mm" "iso_b1_707x1000mm" "iso_b2_500x707mm" "iso_b3_353x500mm" "iso_b4_250x353mm" "iso_b5_176x250mm" "om_jisb0_1029.76x1455.91mm" "om_jisb1_727.78x1029.76mm" "om_jisb2_514.7x727.78mm" "om_jisb3_363.01x514.7mm" "om_jisb4_256.47x363.01mm" "om_jisb5_182.74x256.47mm" "oe_ledger_17x11in" "na_legal_8.5x14in" "om_ra0_859.72x1219.91mm" "om_ra1_609.95x859.72mm" "om_ra2_429.68x609.95mm" "om_ra3_304.8x429.68mm" "om_ra4_214.84x304.8mm" "om_sra0_899.94x1279.88mm" "om_sra1_639.94x899.94mm" "om_sra2_449.79x639.94mm" "om_sra3_319.97x449.79mm" "om_sra4_224.72x319.97mm" "na_super-a_8.94x14in" "custom_min_0.5x0.5in" "custom_max_35277.78x35277.78mm")
           (:INTEGER "media-bottom-margin-supported" 0)
           (:INTEGER "media-left-margin-supported" 0)
           (:INTEGER "media-right-margin-supported" 0)
           (:INTEGER "media-top-margin-supported" 0)
           (:KEYWORD "output-bin-supported" "face-down")
           (:KEYWORD "output-bin-default" "face-down")
           (:KEYWORD "output-mode-supported" "monochrome" "color")
           (:KEYWORD "output-mode-default" "color")
           (:KEYWORD "print-color-mode-supported" "monochrome" "color")
           (:KEYWORD "print-color-mode-default" "color")
           (:RESOLUTION "printer-resolution-supported" (:RESOLUTION 150 150 3) (:RESOLUTION 300 300 3) (:RESOLUTION 600 600 3) (:RESOLUTION 1200 1200 3) (:RESOLUTION 2400 2400 3))
           (:RESOLUTION "printer-resolution-default" (:RESOLUTION 300 300 3))
           (:KEYWORD "sides-supported" "one-sided")
           (:KEYWORD "sides-default" "one-sided")
           (:KEYWORD "printer-commands" "AutoConfigure" "Clean" "PrintSelfTestPage")
           (:NAMEWITHOUTLANGUAGE "port-monitor" "none")
           (:NAMEWITHOUTLANGUAGE "port-monitor-supported" "none")
           (:ENUM "finishings-supported" 3)
           (:ENUM "finishings-default" 3)
           (:CHARSET "charset-configured" "utf-8")
           (:CHARSET "charset-supported" "us-ascii" "utf-8")
           (:KEYWORD "compression-supported" "none" "gzip")
           (:RANGEOFINTEGER "copies-supported" (:RANGEOFINTEGER 1 9999))
           (:TEXTWITHOUTLANGUAGE "cups-version" "1.6.3")
           (:NATURALLANGUAGE "generated-natural-language-supported" "en-gb")
           (:KEYWORD "ipp-versions-supported" "1.0" "1.1" "2.0" "2.1")
           (:INTEGER "ippget-event-life" 15)
           (:KEYWORD "job-creation-attributes-supported" "copies" "finishings" "ipp-attribute-fidelity" "job-hold-until" "job-name" "job-priority" "job-sheets" "media" "media-col" "multiple-document-handling" "number-up" "output-bin" "output-mode" "orientation-requested" "page-ranges" "print-quality" "printer-resolution" "sides")
           (:KEYWORD "job-hold-until-supported" "no-hold" "indefinite" "day-time" "evening" "night" "second-shift" "third-shift" "weekend")
           (:BOOLEAN "job-ids-supported" T)
           (:RANGEOFINTEGER "job-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
           (:INTEGER "job-priority-supported" 100)
           (:KEYWORD "job-settable-attributes-supported" "copies" "finishings" "job-hold-until" "job-name" "job-priority" "media" "media-col" "multiple-document-handling" "number-up" "output-bin" "output-mode" "orientation-requested" "page-ranges" "print-quality" "printer-resolution" "sides")
           (:NAMEWITHOUTLANGUAGE "job-sheets-supported" "none" "classified" "confidential" "secret" "standard" "topsecret" "unclassified")
           (:RANGEOFINTEGER "jpeg-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
           (:RANGEOFINTEGER "jpeg-x-dimension-supported" (:RANGEOFINTEGER 0 65535))
           (:RANGEOFINTEGER "jpeg-y-dimension-supported" (:RANGEOFINTEGER 1 65535))
           (:KEYWORD "media-col-supported" "media-bottom-margin" "media-left-margin" "media-right-margin" "media-size" "media-source" "media-top-margin" "media-type")
           (:KEYWORD "multiple-document-handling-supported" "separate-documents-uncollated-copies" "separate-documents-collated-copies")
           (:BOOLEAN "multiple-document-jobs-supported" T)
           (:INTEGER "multiple-operation-time-out" 300)
           (:NATURALLANGUAGE "natural-language-configured" "en-gb")
           (:KEYWORD "notify-attributes-supported" "printer-state-change-time" "notify-lease-expiration-time" "notify-subscriber-user-name")
           (:RANGEOFINTEGER "notify-lease-duration-supported" (:RANGEOFINTEGER 0 2147483647))
           (:INTEGER "notify-max-events-supported" 100)
           (:KEYWORD "notify-events-supported" "job-completed" "job-config-changed" "job-created" "job-progress" "job-state-changed" "job-stopped" "printer-added" "printer-changed" "printer-config-changed" "printer-deleted" "printer-finishings-changed" "printer-media-changed" "printer-modified" "printer-restarted" "printer-shutdown" "printer-state-changed" "printer-stopped" "server-audit" "server-restarted" "server-started" "server-stopped")
           (:KEYWORD "notify-pull-method-supported" "ippget")
           (:KEYWORD "notify-schemes-supported" "dbus" "mailto" "rss")
           (:INTEGER "number-up-supported" 1 2 4 6 9 16)
           (:ENUM "operations-supported" 2 4 5 6 8 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 34 35 37 38 56 57 59 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16423 14)
           (:ENUM "orientation-requested-supported" 3 4 5 6)
           (:BOOLEAN "page-ranges-supported" T)
           (:RANGEOFINTEGER "pdf-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
           (:KEYWORD "pdf-versions-supported" "adobe-1.2" "adobe-1.3" "adobe-1.4" "adobe-1.5" "adobe-1.6" "adobe-1.7" "iso-19005-1_2005" "iso-32000-1_2008" "pwg-5102.3")
           (:KEYWORD "pdl-override-supported" "attempted")
           (:NAMEWITHOUTLANGUAGE "printer-op-policy-supported" "authenticated" "default")
           (:KEYWORD "printer-settable-attributes-supported" "printer-info" "printer-location")
           (:BOOLEAN "server-is-sharing-printers" NIL)
           (:KEYWORD "which-jobs-supported" "completed" "not-completed" "aborted" "all" "canceled" "pending" "pending-held" "processing" "processing-stopped"))))

3.4 Get Jobs Example

(let ((p (ipp:make-printer
          'ipp:wget-client
          "http://localhost:631/printers/Virtual_PDF_Printer"
          "request2.dat"
          "response2.dat"
          314)))
  (ipp:get-jobs p :limit 2))
(:IPP-RESPONSE
 :MAJOR 1
 :MINOR 0
 :CODE 0
 :REQUEST-ID 314
 :GROUPS ((:OPERATION-ATTRIBUTES-TAG
           (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
           (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
          (:JOB-ATTRIBUTES-TAG
           (:URI :JOB-URI "ipp://localhost:631/jobs/2")
           (:INTEGER :JOB-ID 2))
          (:JOB-ATTRIBUTES-TAG
           (:URI :JOB-URI "ipp://localhost:631/jobs/5")
           (:INTEGER :JOB-ID 5))))

4 Links

Author: Tomas Hlavaty

Date: 2013-08-26 22:57:13 CEST