cl-ipp

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

cl-ipp.org (14337B)


      1 #+title: cl-ipp
      2 #+author: Tomas Hlavaty
      3 #+options: creator:nil 
      4 
      5 cl-ipp
      6 
      7 Project home: http://logand.com/sw/cl-ipp.html
      8 
      9 Contact: http://logand.com/contact.html
     10 
     11 Up: http://logand.com/sw/
     12 
     13 * Introduction
     14 
     15 cl-ipp is a library which implements the Internet Printing Protocol
     16 (IPP) in Common Lisp.  It is licensed under the MIT style licence.
     17 
     18 It is implemented in portable Common Lisp, except two functions
     19 STRING-TO-OCTETS and OCTETS-TO-STRING that require Clozure CL at the
     20 moment.  Other Lisp implementations have similar functions or a
     21 portable library (e.g. [[http://www.cliki.net/babel][babel]]) could be used in the future.  HTTP
     22 functionality is provided by [[http://logand.com/sw/cl-rw.html][cl-rw]] wrapping wget or curl program
     23 calls.  A HTTP backend using [[http://www.cliki.net/drakma][drakma]] could be added if a compile-time
     24 dependency is preferable to the install-time dependency on wget or
     25 curl.
     26 
     27 * Download and install
     28 
     29 cl-ipp depends on [[http://logand.com/sw/cl-rw.html][cl-rw]].
     30 
     31 Download the source code:
     32 
     33 : $ git clone http://logand.com/git/cl-ipp.git
     34 
     35 Then set up the Common Lisp environment to find the cl-ipp.asd and
     36 cl-rw.asd files and load the system into the Lisp image.
     37 
     38 * Usage
     39 
     40 The core (low level) function which implements the Internet Printing
     41 Protocol is the function IPP::IPP.  This function is pretty much
     42 working (minus string encodings and a minor issue with parsing sign of
     43 binary integers).
     44 
     45 A few wrapper (high level) funtions are exported and are meant to be
     46 used by applications to talk to the print server.  The high level
     47 functions are more or less experimental code waiting to crystalize
     48 into useable API.
     49 
     50 ** List Printers Example
     51 
     52 #+begin_src text
     53 CL-USER> (ipp:list-printers 'ipp::wget-client "http://localhost:631/printers/" "printers.html")
     54 ("Virtual_PDF_Printer")
     55 #+end_src
     56 
     57 ** Print Job Example
     58 
     59 #+begin_src text
     60 (let ((p (ipp:make-printer
     61           'ipp:wget-client
     62           "http://localhost:631/printers/Virtual_PDF_Printer"
     63           "request2.dat"
     64           "response2.dat"
     65           314)))
     66   (ipp:print-job p "/home/tomas/git/cl-ipp/test.txt" :ipp-attribute-fidelity nil :copies 2 :sides "two-sided-long-edge"))
     67 (:IPP-RESPONSE
     68  :MAJOR 1
     69  :MINOR 0
     70  :CODE 0
     71  :REQUEST-ID 314
     72  :GROUPS ((:OPERATION-ATTRIBUTES-TAG
     73            (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
     74            (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
     75           (:JOB-ATTRIBUTES-TAG
     76            (:URI :JOB-URI "ipp://localhost:631/jobs/126")
     77            (:INTEGER :JOB-ID 126)
     78            (:ENUM :JOB-STATE 3)
     79            (:KEYWORD :JOB-STATE-REASONS "none"))))
     80 #+end_src
     81 
     82 ** Printer Attributes Example
     83 
     84 #+begin_src text
     85 (let ((p (ipp:make-printer
     86           'ipp:wget-client
     87           "http://localhost:631/printers/Virtual_PDF_Printer"
     88           "request2.dat"
     89           "response2.dat"
     90           314)))
     91   (ipp:get-printer-attributes p))
     92 (:IPP-RESPONSE
     93  :MAJOR 1
     94  :MINOR 0
     95  :CODE 0
     96  :REQUEST-ID 314
     97  :GROUPS ((:OPERATION-ATTRIBUTES-TAG
     98            (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
     99            (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
    100           (:PRINTER-ATTRIBUTES-TAG
    101            (:INTEGER :MARKER-CHANGE-TIME 0)
    102            (:DATETIME :PRINTER-CURRENT-TIME (:DATETIME 2013 8 26 18 53 50 0 43 0 0))
    103            (:NO-VALUE :PRINTER-DNS-SD-NAME NIL)
    104            (:NAMEWITHOUTLANGUAGE :PRINTER-ERROR-POLICY "stop-printer")
    105            (:NAMEWITHOUTLANGUAGE :PRINTER-ERROR-POLICY-SUPPORTED "abort-job" "retry-current-job" "retry-job" "stop-printer")
    106            (:URI :PRINTER-ICONS "http://localhost:631/icons/Virtual_PDF_Printer.png")
    107            (:BOOLEAN :PRINTER-IS-ACCEPTING-JOBS T)
    108            (:BOOLEAN :PRINTER-IS-SHARED NIL)
    109            (:URI :PRINTER-MORE-INFO "http://localhost:631/printers/Virtual_PDF_Printer")
    110            (:NAMEWITHOUTLANGUAGE :PRINTER-OP-POLICY "default")
    111            (:ENUM :PRINTER-STATE 3)
    112            (:INTEGER :PRINTER-STATE-CHANGE-TIME 1377542930)
    113            (:TEXTWITHOUTLANGUAGE :PRINTER-STATE-MESSAGE "loadFile failed: temp file: unable to find trailer dictionary while recovering damaged file")
    114            (:KEYWORD :PRINTER-STATE-REASONS "none")
    115            (:ENUM :PRINTER-TYPE 10678348)
    116            (:INTEGER :PRINTER-UP-TIME 1377543230)
    117            (:URI :PRINTER-URI-SUPPORTED "ipp://localhost:631/printers/Virtual_PDF_Printer")
    118            (:INTEGER :QUEUED-JOB-COUNT 113)
    119            (:KEYWORD :URI-AUTHENTICATION-SUPPORTED "requesting-user-name")
    120            (:KEYWORD :URI-SECURITY-SUPPORTED "none")
    121            (:NAMEWITHOUTLANGUAGE :PRINTER-NAME "Virtual_PDF_Printer")
    122            (:TEXTWITHOUTLANGUAGE :PRINTER-LOCATION NIL)
    123            (:TEXTWITHOUTLANGUAGE :PRINTER-INFO "Virtual PDF Printer")
    124            (:URI :PRINTER-UUID "urn:uuid:49115578-eded-337a-6a33-4121b0a19a43")
    125            (:INTEGER :JOB-QUOTA-PERIOD 0)
    126            (:INTEGER :JOB-K-LIMIT 0)
    127            (:INTEGER :JOB-PAGE-LIMIT 0)
    128            (:NAMEWITHOUTLANGUAGE :JOB-SHEETS-DEFAULT "none" "none")
    129            (:URI :DEVICE-URI "cups-pdf:/")
    130            (: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")
    131            (:INTEGER "copies-default" 1)
    132            (:MIMEMEDIATYPE "document-format-default" "application/octet-stream")
    133            (:KEYWORD "job-hold-until-default" "no-hold")
    134            (:INTEGER "job-priority-default" 50)
    135            (:INTEGER "number-up-default" 1)
    136            (:INTEGER "notify-lease-duration-default" 86400)
    137            (:KEYWORD "notify-events-default" "job-completed")
    138            (:NO-VALUE "orientation-requested-default" NIL)
    139            (:ENUM "print-quality-default" 4)
    140            (:BOOLEAN "color-supported" T)
    141            (:INTEGER "pages-per-minute" 8)
    142            (:INTEGER "pages-per-minute-color" 8)
    143            (:ENUM "print-quality-supported" 4)
    144            (:TEXTWITHOUTLANGUAGE "printer-make-and-model" "Generic CUPS-PDF Printer")
    145            (:KEYWORD "media-default" "iso_a4_210x297mm")
    146            (: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")
    147            (:INTEGER "media-bottom-margin-supported" 0)
    148            (:INTEGER "media-left-margin-supported" 0)
    149            (:INTEGER "media-right-margin-supported" 0)
    150            (:INTEGER "media-top-margin-supported" 0)
    151            (:KEYWORD "output-bin-supported" "face-down")
    152            (:KEYWORD "output-bin-default" "face-down")
    153            (:KEYWORD "output-mode-supported" "monochrome" "color")
    154            (:KEYWORD "output-mode-default" "color")
    155            (:KEYWORD "print-color-mode-supported" "monochrome" "color")
    156            (:KEYWORD "print-color-mode-default" "color")
    157            (:RESOLUTION "printer-resolution-supported" (:RESOLUTION 150 150 3) (:RESOLUTION 300 300 3) (:RESOLUTION 600 600 3) (:RESOLUTION 1200 1200 3) (:RESOLUTION 2400 2400 3))
    158            (:RESOLUTION "printer-resolution-default" (:RESOLUTION 300 300 3))
    159            (:KEYWORD "sides-supported" "one-sided")
    160            (:KEYWORD "sides-default" "one-sided")
    161            (:KEYWORD "printer-commands" "AutoConfigure" "Clean" "PrintSelfTestPage")
    162            (:NAMEWITHOUTLANGUAGE "port-monitor" "none")
    163            (:NAMEWITHOUTLANGUAGE "port-monitor-supported" "none")
    164            (:ENUM "finishings-supported" 3)
    165            (:ENUM "finishings-default" 3)
    166            (:CHARSET "charset-configured" "utf-8")
    167            (:CHARSET "charset-supported" "us-ascii" "utf-8")
    168            (:KEYWORD "compression-supported" "none" "gzip")
    169            (:RANGEOFINTEGER "copies-supported" (:RANGEOFINTEGER 1 9999))
    170            (:TEXTWITHOUTLANGUAGE "cups-version" "1.6.3")
    171            (:NATURALLANGUAGE "generated-natural-language-supported" "en-gb")
    172            (:KEYWORD "ipp-versions-supported" "1.0" "1.1" "2.0" "2.1")
    173            (:INTEGER "ippget-event-life" 15)
    174            (: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")
    175            (:KEYWORD "job-hold-until-supported" "no-hold" "indefinite" "day-time" "evening" "night" "second-shift" "third-shift" "weekend")
    176            (:BOOLEAN "job-ids-supported" T)
    177            (:RANGEOFINTEGER "job-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
    178            (:INTEGER "job-priority-supported" 100)
    179            (: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")
    180            (:NAMEWITHOUTLANGUAGE "job-sheets-supported" "none" "classified" "confidential" "secret" "standard" "topsecret" "unclassified")
    181            (:RANGEOFINTEGER "jpeg-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
    182            (:RANGEOFINTEGER "jpeg-x-dimension-supported" (:RANGEOFINTEGER 0 65535))
    183            (:RANGEOFINTEGER "jpeg-y-dimension-supported" (:RANGEOFINTEGER 1 65535))
    184            (:KEYWORD "media-col-supported" "media-bottom-margin" "media-left-margin" "media-right-margin" "media-size" "media-source" "media-top-margin" "media-type")
    185            (:KEYWORD "multiple-document-handling-supported" "separate-documents-uncollated-copies" "separate-documents-collated-copies")
    186            (:BOOLEAN "multiple-document-jobs-supported" T)
    187            (:INTEGER "multiple-operation-time-out" 300)
    188            (:NATURALLANGUAGE "natural-language-configured" "en-gb")
    189            (:KEYWORD "notify-attributes-supported" "printer-state-change-time" "notify-lease-expiration-time" "notify-subscriber-user-name")
    190            (:RANGEOFINTEGER "notify-lease-duration-supported" (:RANGEOFINTEGER 0 2147483647))
    191            (:INTEGER "notify-max-events-supported" 100)
    192            (: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")
    193            (:KEYWORD "notify-pull-method-supported" "ippget")
    194            (:KEYWORD "notify-schemes-supported" "dbus" "mailto" "rss")
    195            (:INTEGER "number-up-supported" 1 2 4 6 9 16)
    196            (: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)
    197            (:ENUM "orientation-requested-supported" 3 4 5 6)
    198            (:BOOLEAN "page-ranges-supported" T)
    199            (:RANGEOFINTEGER "pdf-k-octets-supported" (:RANGEOFINTEGER 0 7683952))
    200            (: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")
    201            (:KEYWORD "pdl-override-supported" "attempted")
    202            (:NAMEWITHOUTLANGUAGE "printer-op-policy-supported" "authenticated" "default")
    203            (:KEYWORD "printer-settable-attributes-supported" "printer-info" "printer-location")
    204            (:BOOLEAN "server-is-sharing-printers" NIL)
    205            (:KEYWORD "which-jobs-supported" "completed" "not-completed" "aborted" "all" "canceled" "pending" "pending-held" "processing" "processing-stopped"))))
    206 #+end_src
    207 
    208 ** Get Jobs Example
    209 
    210 #+begin_src text
    211 (let ((p (ipp:make-printer
    212           'ipp:wget-client
    213           "http://localhost:631/printers/Virtual_PDF_Printer"
    214           "request2.dat"
    215           "response2.dat"
    216           314)))
    217   (ipp:get-jobs p :limit 2))
    218 (:IPP-RESPONSE
    219  :MAJOR 1
    220  :MINOR 0
    221  :CODE 0
    222  :REQUEST-ID 314
    223  :GROUPS ((:OPERATION-ATTRIBUTES-TAG
    224            (:CHARSET :ATTRIBUTES-CHARSET "utf-8")
    225            (:NATURALLANGUAGE :ATTRIBUTES-NATURAL-LANGUAGE "en"))
    226           (:JOB-ATTRIBUTES-TAG
    227            (:URI :JOB-URI "ipp://localhost:631/jobs/2")
    228            (:INTEGER :JOB-ID 2))
    229           (:JOB-ATTRIBUTES-TAG
    230            (:URI :JOB-URI "ipp://localhost:631/jobs/5")
    231            (:INTEGER :JOB-ID 5))))
    232 #+end_src
    233 
    234 * Links
    235 
    236 Comments:
    237 http://www.reddit.com/r/lisp/comments/1l53xs/clipp_internet_printing_protocol_ipp_for_common/