ffi-cups2 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/.gitignore +14 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +110 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ffi-cups.gemspec +26 -0
- data/lib/ffi-cups/connection.rb +39 -0
- data/lib/ffi-cups/constants.rb +98 -0
- data/lib/ffi-cups/enum/http/ppd.rb +22 -0
- data/lib/ffi-cups/enum/http/status.rb +50 -0
- data/lib/ffi-cups/enum/ipp/job_state.rb +15 -0
- data/lib/ffi-cups/enum/ipp/res.rb +10 -0
- data/lib/ffi-cups/enum/ipp/status.rb +53 -0
- data/lib/ffi-cups/enum/ipp/tag.rb +51 -0
- data/lib/ffi-cups/ffi/array.rb +17 -0
- data/lib/ffi-cups/ffi/cups.rb +216 -0
- data/lib/ffi-cups/ffi/http.rb +40 -0
- data/lib/ffi-cups/ffi/ipp_attribute.rb +74 -0
- data/lib/ffi-cups/ffi/ppd.rb +65 -0
- data/lib/ffi-cups/job.rb +89 -0
- data/lib/ffi-cups/printer.rb +342 -0
- data/lib/ffi-cups/struct/destination.rb +9 -0
- data/lib/ffi-cups/struct/ipp_attribute.rb +6 -0
- data/lib/ffi-cups/struct/job.rb +15 -0
- data/lib/ffi-cups/struct/option.rb +5 -0
- data/lib/ffi-cups/struct/ppd_choice.rb +9 -0
- data/lib/ffi-cups/struct/ppd_file.rb +6 -0
- data/lib/ffi-cups/struct/ppd_option.rb +14 -0
- data/lib/ffi-cups/version.rb +3 -0
- data/lib/ffi-cups.rb +48 -0
- data/lib/ffi-cups2.rb +1 -0
- data.tar.gz.sig +4 -0
- metadata +117 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c6209044ae5c1ea2448cab3e8d044f33adf328b4fad06cd61869c68dbbf54855
|
|
4
|
+
data.tar.gz: e4cdd08e543a84abf899938f47a175910476cb5abbb0ff21005c29d951c3c217
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3afe3c436e6f6f42f70f716289e27d88890e2460302a1bc2dbad2df1e69157228373a2fc37e2419e4dbb5fd32229d32d3681e5f847260e3b87adada433d8735e
|
|
7
|
+
data.tar.gz: 5f189e1fc6dc75c059bece9e7109a1f3e4254cbf8daff8eef768378230cd632f23df1a58611387befea69a16a9ce2e98d094658caec061efa1a3532fc668e12b
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Hugo Marquez & Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# FFI-Cups
|
|
2
|
+
[](https://badge.fury.io/rb/ffi-cups2)
|
|
3
|
+
|
|
4
|
+
ffi-cups2 is a FFI bindings for libcups providing access to the Cups API through Ruby.
|
|
5
|
+
It is compatible to ffi-cups, but the maintainer of ffi-cups is not reachable.
|
|
6
|
+
|
|
7
|
+
CUPS is the standards-based, open source printing system developed by Apple Inc. for macOS® and other UNIX®-like operating systems. CUPS uses the Internet Printing Protocol (IPP) to support printing to local and network printers. - from http://www.cups.org/
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
```bash
|
|
11
|
+
gem install ffi-cups2
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Setup & Requirements
|
|
15
|
+
ffi-cups2 requires libcups2 to be installed
|
|
16
|
+
|
|
17
|
+
## Example usage
|
|
18
|
+
```ruby
|
|
19
|
+
require 'ffi-cups'
|
|
20
|
+
|
|
21
|
+
printers = Cups::Printer.get_destinations
|
|
22
|
+
# [#<Cups::Printer:0x000055fe50b15798 @name="Virtual_PDF_Printer",
|
|
23
|
+
# @options={"copies"=>"1", "device-uri"=>"cups-pdf:/", "finishings"=>"3"
|
|
24
|
+
# "job-cancel-after"=>"10800", "job-hold-until"=>"no-hold", ...
|
|
25
|
+
|
|
26
|
+
printer = Cups::Printer.get_destination("Virtual_PDF_Printer")
|
|
27
|
+
# <Cups::Printer:0x0000560f1d4e0958 @name="Virtual_PDF_Printer", @options={"copies"=>"1"
|
|
28
|
+
# "device-uri"=>"cups-pdf:/", ...
|
|
29
|
+
|
|
30
|
+
printer.state
|
|
31
|
+
# :idle
|
|
32
|
+
|
|
33
|
+
printer.state_reasons
|
|
34
|
+
# ["none"]
|
|
35
|
+
|
|
36
|
+
printer.find_dest_supported
|
|
37
|
+
# {type: :ipp_tag_keyword,
|
|
38
|
+
# values:
|
|
39
|
+
# ["copies",
|
|
40
|
+
# ...
|
|
41
|
+
# "print-scaling",
|
|
42
|
+
# "printer-resolution",
|
|
43
|
+
# "sides"]}
|
|
44
|
+
|
|
45
|
+
printer.find_dest_supported("copies")
|
|
46
|
+
# {type: :ipp_tag_range, values: [{lowervalue: 1, uppervalue: 9999}]}
|
|
47
|
+
|
|
48
|
+
printer.find_dest_supported("sides")
|
|
49
|
+
# {type: :ipp_tag_keyword, values: ["one-sided", "two-sided-long-edge", "two-sided-short-edge"]}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Print a file (PDF, JPG, etc) you can pass a hash of printing options if you
|
|
53
|
+
# want to override the printer's default. See Cups::Constants for more options
|
|
54
|
+
options = {
|
|
55
|
+
Cups::MEDIA => Cups::MEDIA_A4,
|
|
56
|
+
Cups::ORIENTATION => Cups::ORIENTATION_LANDSCAPE
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
job = printer.print_file('/tmp/example.jpg', 'Title', options)
|
|
60
|
+
# <Cups::Job:0x000055c87104d1e0 @id=10, @title="README", @printer="Virtual_PDF_Printer", @format="text/plain", @state=:processing, @size=4, @completed_time=1969-12-31 18:00:00 -0600, @creation_time=2021-04-18 17:35:04 -0500, @processing_time=2021-04-18 17:35:04 -0500>
|
|
61
|
+
|
|
62
|
+
# Get all jobs from a printer
|
|
63
|
+
jobs = Cups::Job.get_jobs('Virtual_PDF_Printer')
|
|
64
|
+
# [#<Cups::Job:0x0000563aa6359008 @id=1, @title="Test Print", @printer="Virtual_PDF_Printer", @format="text/plain", @state=:completed, @size=1, @completed_time=2021-04-08 07:06:23 -0500, @creation_time=2021-04-08 07:06:18 -0500, @processing_time=2021-04-08 07:06:18 -0500>, ...]
|
|
65
|
+
|
|
66
|
+
# filtering job's query, see Constants file for more options
|
|
67
|
+
jobs = Cups::Job.get_jobs('Virtual_PDF_Printer', Cups::WHICHJOBS_ACTIVE)
|
|
68
|
+
|
|
69
|
+
# Query job with id and printer's name
|
|
70
|
+
job = Cups::Job.get_job(10, 'Virtual_PDF_Printer')
|
|
71
|
+
# <Cups::Job:0x000055c870fc8490 @id=10, @title="README", @printer="Virtual_PDF_Printer", @format="text/plain", @state=:completed, @size=4, @completed_time=2021-04-18 17:35:04 -0500, @creation_time=2021-04-18 17:35:04 -0500, @processing_time=2021-04-18 17:35:04 -0500>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Remote CUPS Server
|
|
75
|
+
You may create a connection object passing a :hostname and/or :port arguments.
|
|
76
|
+
|
|
77
|
+
```ruby
|
|
78
|
+
# Create a Connection object with hostname and/or port
|
|
79
|
+
connection = Cups::Connection.new('print.example.com')
|
|
80
|
+
|
|
81
|
+
# Get all printers from the remote connection
|
|
82
|
+
remote_printers = Cups::Printer.get_destinations(connection)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Documentation
|
|
86
|
+
Check out the documentation - [docs](https://www.rubydoc.info/gems/ffi-cups2)
|
|
87
|
+
|
|
88
|
+
## Authors
|
|
89
|
+
- Contributors @ https://github.com/larskanis/ffi-cups/graphs/contributors
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
The MIT License
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
95
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
96
|
+
in the Software without restriction, including without limitation the rights
|
|
97
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
98
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
99
|
+
furnished to do so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in
|
|
102
|
+
all copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
110
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "ffi-cups"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/ffi-cups.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'lib/ffi-cups/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = "ffi-cups2"
|
|
5
|
+
s.version = Cups::VERSION
|
|
6
|
+
s.platform = Gem::Platform::RUBY
|
|
7
|
+
s.authors = ["Hugo Marquez", "Nathan Ehresman", "Lars Kanis"]
|
|
8
|
+
s.email = ["hugomarquez.dev@gmail.com", "n_github@ehresman.org", "lars@greiz-reinsdorf.de"]
|
|
9
|
+
s.homepage = "https://github.com/larskanis/ffi-cups"
|
|
10
|
+
s.summary = "FFI wrapper around libcups2"
|
|
11
|
+
s.description = "Simple wrapper around libcups to give CUPS printing capabilities to Ruby apps."
|
|
12
|
+
s.license = "MIT"
|
|
13
|
+
s.required_ruby_version = Gem::Requirement.new(">= 3.2")
|
|
14
|
+
|
|
15
|
+
s.add_runtime_dependency "ffi", "~> 1.16"
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
s.bindir = "exe"
|
|
23
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
|
|
25
|
+
s.require_paths = ["lib"]
|
|
26
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Cups
|
|
2
|
+
class Connection
|
|
3
|
+
extend Gem::Deprecate
|
|
4
|
+
|
|
5
|
+
attr_accessor :hostname, :port
|
|
6
|
+
|
|
7
|
+
def initialize(hostname, port=nil)
|
|
8
|
+
@hostname = hostname
|
|
9
|
+
@port = port.nil? ? 631 : port
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Wrapper around {::Cups::Http#httpConnectEncrypt}
|
|
13
|
+
# @deprecated Use {#httpConnect2} instead
|
|
14
|
+
# @return [Pointer] a http pointer
|
|
15
|
+
def httpConnectEncrypt
|
|
16
|
+
http = Cups::Http.httpConnectEncrypt(hostname, port, Cups.cupsEncryption())
|
|
17
|
+
raise "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
18
|
+
return http
|
|
19
|
+
end
|
|
20
|
+
deprecate :httpConnectEncrypt, "This function is deprecated by CUPS, please use httpConnect2 instead", 2025, 12
|
|
21
|
+
|
|
22
|
+
# Wrapper around {::Cups::Http#httpConnect2}
|
|
23
|
+
# Creates a http connection to a print server
|
|
24
|
+
# @return [Pointer] a http pointer
|
|
25
|
+
def httpConnect2
|
|
26
|
+
http = Cups::Http.httpConnect2(hostname, port, nil, 0, Cups.cupsEncryption(), 1, 30000, nil)
|
|
27
|
+
raise "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
28
|
+
return http
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Closes the http connection and autoreleases the pointer
|
|
32
|
+
# Wrapper around {::Cups::Http#httpClose}
|
|
33
|
+
# @param http (Pointer)
|
|
34
|
+
def self.close(http)
|
|
35
|
+
Cups::Http.httpClose(http)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module Cups
|
|
2
|
+
# cups.h
|
|
3
|
+
FORMAT_JPEG = "image/jpeg"
|
|
4
|
+
FORMAT_PDF = "application/pdf"
|
|
5
|
+
FORMAT_TEXT = "text/plain"
|
|
6
|
+
JOBID_ALL = -1
|
|
7
|
+
WHICHJOBS_ALL = -1
|
|
8
|
+
WHICHJOBS_ACTIVE = 0
|
|
9
|
+
WHICHJOBS_COMPLETED = 1
|
|
10
|
+
HTTP_DEFAULT = nil
|
|
11
|
+
|
|
12
|
+
# Options and Values
|
|
13
|
+
COPIES = "copies"
|
|
14
|
+
COPIES_SUPPORTED = "copies-supported"
|
|
15
|
+
|
|
16
|
+
FINISHINGS = "CUPS_FINISHINGS"
|
|
17
|
+
FINISHINGS_SUPPORTED = "finishings-supported"
|
|
18
|
+
FINISHINGS_BIND = "7"
|
|
19
|
+
FINISHINGS_COVER = "6"
|
|
20
|
+
FINISHINGS_FOLD = "10"
|
|
21
|
+
FINISHINGS_NONE = "3"
|
|
22
|
+
FINISHINGS_PUNCH = "5"
|
|
23
|
+
FINISHINGS_STAPLE = "4"
|
|
24
|
+
FINISHINGS_TRIM = "11"
|
|
25
|
+
|
|
26
|
+
# MEDIA
|
|
27
|
+
MEDIA = "media"
|
|
28
|
+
MEDIA_READY = "media-ready"
|
|
29
|
+
MEDIA_SUPPORTED = "media-supported"
|
|
30
|
+
|
|
31
|
+
MEDIA_3X5 = "na_index-3x5_3x5in"
|
|
32
|
+
MEDIA_4X6 = "na_index-4x6_4x6in"
|
|
33
|
+
MEDIA_5X7 = "na_5x7_5x7in"
|
|
34
|
+
MEDIA_8X10 = "na_govt-letter_8x10in"
|
|
35
|
+
MEDIA_A3 = "iso_a3_297x420mm"
|
|
36
|
+
MEDIA_A4 = "iso_a4_210x297mm"
|
|
37
|
+
MEDIA_A5 = "iso_a5_148x210mm"
|
|
38
|
+
MEDIA_A6 = "iso_a6_105x148mm"
|
|
39
|
+
MEDIA_ENV10 = "na_number-10_4.125x9.5in"
|
|
40
|
+
MEDIA_ENVDL = "iso_dl_110x220mm"
|
|
41
|
+
MEDIA_LEGAL = "na_legal_8.5x14in"
|
|
42
|
+
MEDIA_LETTER = "na_letter_8.5x11in"
|
|
43
|
+
MEDIA_PHOTO_L = "oe_photo-l_3.5x5in"
|
|
44
|
+
MEDIA_SUPERBA3 = "na_super-b_13x19in"
|
|
45
|
+
MEDIA_TABLOID = "na_ledger_11x17in"
|
|
46
|
+
|
|
47
|
+
MEDIA_SOURCE = "media-source"
|
|
48
|
+
MEDIA_SOURCE_SUPPORTED = "media-source-supported"
|
|
49
|
+
|
|
50
|
+
MEDIA_SOURCE_AUTO = "auto"
|
|
51
|
+
MEDIA_SOURCE_MANUAL = "manual"
|
|
52
|
+
|
|
53
|
+
MEDIA_TYPE = "media-type"
|
|
54
|
+
MEDIA_TYPE_SUPPORTED = "media-type-supported"
|
|
55
|
+
|
|
56
|
+
MEDIA_TYPE_AUTO = "auto"
|
|
57
|
+
MEDIA_TYPE_ENVELOPE = "envelope"
|
|
58
|
+
MEDIA_TYPE_LABELS = "labels"
|
|
59
|
+
MEDIA_TYPE_LETTERHEAD = "stationery-letterhead"
|
|
60
|
+
MEDIA_TYPE_PHOTO = "photographic"
|
|
61
|
+
MEDIA_TYPE_PHOTO_GLOSSY = "photographic-glossy"
|
|
62
|
+
MEDIA_TYPE_PHOTO_MATTE = "photographic-matte"
|
|
63
|
+
MEDIA_TYPE_PLAIN = "stationery"
|
|
64
|
+
MEDIA_TYPE_TRANSPARENCY = "transparency"
|
|
65
|
+
|
|
66
|
+
NUMBER_UP = "number-up"
|
|
67
|
+
NUMBER_UP_SUPPORTED = "number-up-supported"
|
|
68
|
+
|
|
69
|
+
ORIENTATION = "orientation-requested"
|
|
70
|
+
ORIENTATION_SUPPORTED = "orientation-requested-supported"
|
|
71
|
+
|
|
72
|
+
ORIENTATION_PORTRAIT = "3"
|
|
73
|
+
ORIENTATION_LANDSCAPE = "4"
|
|
74
|
+
|
|
75
|
+
PRINT_COLOR_MODE = "print-color-mode"
|
|
76
|
+
PRINT_COLOR_MODE_SUPPORTED = "print-color-mode-supported"
|
|
77
|
+
|
|
78
|
+
PRINT_COLOR_MODE_AUTO = "auto"
|
|
79
|
+
PRINT_COLOR_MODE_MONOCHROME = "monochrome"
|
|
80
|
+
PRINT_COLOR_MODE_COLOR = "color"
|
|
81
|
+
|
|
82
|
+
PRINT_QUALITY = "print-quality"
|
|
83
|
+
PRINT_QUALITY_SUPPORTED = "print-quality-supported"
|
|
84
|
+
|
|
85
|
+
PRINT_QUALITY_DRAFT = "3"
|
|
86
|
+
PRINT_QUALITY_NORMAL = "4"
|
|
87
|
+
PRINT_QUALITY_HIGH = "5"
|
|
88
|
+
|
|
89
|
+
SIDES = "sides"
|
|
90
|
+
SIDES_SUPPORTED = "sides-supported"
|
|
91
|
+
|
|
92
|
+
SIDES_ONE_SIDED = "one-sided"
|
|
93
|
+
SIDES_TWO_SIDED_PORTRAIT = "two-sided-long-edge"
|
|
94
|
+
SIDES_TWO_SIDED_LANDSCAPE = "two-sided-short-edge"
|
|
95
|
+
|
|
96
|
+
PPD_MAX_NAME = 41
|
|
97
|
+
PPD_MAX_TEXT = 81
|
|
98
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Cups::Enum
|
|
2
|
+
module Ppd
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
# Maps the native ppd_ui_t enum from cups/ppd.h
|
|
6
|
+
Ui = enum(
|
|
7
|
+
:ppd_ui_boolean, # 0 - True or False option
|
|
8
|
+
:ppd_ui_pickone, # 1 - Pick exactly one choice
|
|
9
|
+
:ppd_ui_pickmany # 2 - Pick one or more choices
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Maps the native ppd_section_t enum from cups/ppd.h
|
|
13
|
+
Section = enum(
|
|
14
|
+
:ppd_order_any, # 0 - Code can be anywhere in the document
|
|
15
|
+
:ppd_order_jcl, # 1 - Job Control Language code
|
|
16
|
+
:ppd_order_prolog, # 2 - PostScript prolog section
|
|
17
|
+
:ppd_order_setup, # 3 - PostScript document setup section
|
|
18
|
+
:ppd_order_page_setup, # 4 - PostScript page setup section
|
|
19
|
+
:ppd_order_exit # 5 - PostScript exit server section
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Cups::Enum
|
|
2
|
+
module HTTP
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
Status = enum [
|
|
6
|
+
:http_error, -1,
|
|
7
|
+
:http_continue, 100,
|
|
8
|
+
:http_switching_protocols,
|
|
9
|
+
:http_ok, 200,
|
|
10
|
+
:http_created,
|
|
11
|
+
:http_accepted,
|
|
12
|
+
:http_not_authoritative,
|
|
13
|
+
:http_no_content,
|
|
14
|
+
:http_reset_content,
|
|
15
|
+
:http_partial_content,
|
|
16
|
+
:http_multiple_choices, 300,
|
|
17
|
+
:http_moved_permanently,
|
|
18
|
+
:http_moved_temporarily,
|
|
19
|
+
:http_see_other,
|
|
20
|
+
:http_not_modified,
|
|
21
|
+
:http_use_proxy,
|
|
22
|
+
:http_bad_request, 400,
|
|
23
|
+
:http_unauthorized,
|
|
24
|
+
:http_payment_required,
|
|
25
|
+
:http_forbidden,
|
|
26
|
+
:http_not_found,
|
|
27
|
+
:http_method_not_allowed,
|
|
28
|
+
:http_not_acceptable,
|
|
29
|
+
:http_proxy_authentication,
|
|
30
|
+
:http_request_timeout,
|
|
31
|
+
:http_conflict,
|
|
32
|
+
:http_gone,
|
|
33
|
+
:http_length_required,
|
|
34
|
+
:http_precondition,
|
|
35
|
+
:http_request_too_large,
|
|
36
|
+
:http_uri_too_long,
|
|
37
|
+
:http_unsupported_mediatype,
|
|
38
|
+
:http_requested_range,
|
|
39
|
+
:http_expectation_failed,
|
|
40
|
+
:http_upgrade_required, 426,
|
|
41
|
+
:http_server_error, 500,
|
|
42
|
+
:http_not_implemented,
|
|
43
|
+
:http_bad_gateway,
|
|
44
|
+
:http_service_unavailable,
|
|
45
|
+
:http_gateway_timeout,
|
|
46
|
+
:http_not_supported,
|
|
47
|
+
:http_authorization_canceled, 1000
|
|
48
|
+
]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Cups::Enum
|
|
2
|
+
module IPP
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
Status = enum [
|
|
6
|
+
:ipp_ok, 0,
|
|
7
|
+
:ipp_ok_subst,
|
|
8
|
+
:ipp_ok_conflict,
|
|
9
|
+
:ipp_ok_ignored_subscriptions,
|
|
10
|
+
:ipp_ok_ignored_notifications,
|
|
11
|
+
:ipp_ok_too_many_events,
|
|
12
|
+
:ipp_ok_but_cancel_subscription,
|
|
13
|
+
:ipp_ok_events_complete,
|
|
14
|
+
:ipp_redirection_other_site, 512,
|
|
15
|
+
:cups_see_other, 640,
|
|
16
|
+
:ipp_bad_request, 1024,
|
|
17
|
+
:ipp_forbidden,
|
|
18
|
+
:ipp_not_authenticated,
|
|
19
|
+
:ipp_not_authorized,
|
|
20
|
+
:ipp_not_possible,
|
|
21
|
+
:ipp_timeout,
|
|
22
|
+
:ipp_not_found,
|
|
23
|
+
:ipp_gone,
|
|
24
|
+
:ipp_request_entity,
|
|
25
|
+
:ipp_request_value,
|
|
26
|
+
:ipp_document_format,
|
|
27
|
+
:ipp_attributes,
|
|
28
|
+
:ipp_uri_scheme,
|
|
29
|
+
:ipp_charset,
|
|
30
|
+
:ipp_conflict,
|
|
31
|
+
:ipp_compression_not_supported,
|
|
32
|
+
:ipp_compression_error,
|
|
33
|
+
:ipp_document_format_error,
|
|
34
|
+
:ipp_document_access_error,
|
|
35
|
+
:ipp_attributes_not_settable,
|
|
36
|
+
:ipp_ignored_all_subscriptions,
|
|
37
|
+
:ipp_too_many_subscriptions,
|
|
38
|
+
:ipp_ignored_all_notifications,
|
|
39
|
+
:ipp_print_support_file_not_found,
|
|
40
|
+
:ipp_internal_error, 1280,
|
|
41
|
+
:ipp_operation_not_supported,
|
|
42
|
+
:ipp_service_unavailable,
|
|
43
|
+
:ipp_version_not_supported,
|
|
44
|
+
:ipp_device_error,
|
|
45
|
+
:ipp_temporary_error,
|
|
46
|
+
:ipp_not_accepting,
|
|
47
|
+
:ipp_printer_busy,
|
|
48
|
+
:ipp_error_job_canceled,
|
|
49
|
+
:ipp_multiple_jobs_not_supported,
|
|
50
|
+
:ipp_printer_is_deactivated
|
|
51
|
+
]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Cups::Enum
|
|
2
|
+
module IPP
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
Tag = enum [ # ipp_tag_e **** Format tags for attributes ****
|
|
6
|
+
:ipp_tag_cups_invalid, -1, # Invalid tag name for @link ippTagValue@
|
|
7
|
+
:ipp_tag_zero, 0x00, # Zero tag - used for separators
|
|
8
|
+
:ipp_tag_operation, # operation group
|
|
9
|
+
:ipp_tag_job, # job group
|
|
10
|
+
:ipp_tag_end, # end-of-attributes
|
|
11
|
+
:ipp_tag_printer, # printer group
|
|
12
|
+
:ipp_tag_unsupported_group, # Unsupported attributes group
|
|
13
|
+
:ipp_tag_subscription, # Subscription group
|
|
14
|
+
:ipp_tag_event_notification, # Event group
|
|
15
|
+
:ipp_tag_resource, # resource group @private@
|
|
16
|
+
:ipp_tag_document, # document group
|
|
17
|
+
:ipp_tag_unsupported_value, 0x10, # Unsupported value
|
|
18
|
+
:ipp_tag_default, # default value
|
|
19
|
+
:ipp_tag_unknown, # unknown value
|
|
20
|
+
:ipp_tag_novalue, # no-value value
|
|
21
|
+
:ipp_tag_notsettable, 0x15, # Not-settable value
|
|
22
|
+
:ipp_tag_deleteattr, # delete-attribute value
|
|
23
|
+
:ipp_tag_admindefine, # Admin-defined value
|
|
24
|
+
:ipp_tag_integer, 0x21, # Integer value
|
|
25
|
+
:ipp_tag_boolean, # boolean value
|
|
26
|
+
:ipp_tag_enum, # enumeration value
|
|
27
|
+
:ipp_tag_string, 0x30, # Octet string value
|
|
28
|
+
:ipp_tag_date, # date/time value
|
|
29
|
+
:ipp_tag_resolution, # resolution value
|
|
30
|
+
:ipp_tag_range, # range value
|
|
31
|
+
:ipp_tag_begin_collection, # Beginning of collection value
|
|
32
|
+
:ipp_tag_textlang, # text-with-language value
|
|
33
|
+
:ipp_tag_namelang, # name-with-language value
|
|
34
|
+
:ipp_tag_end_collection, # End of collection value
|
|
35
|
+
:ipp_tag_text, 0x41, # Text value
|
|
36
|
+
:ipp_tag_name, # name value
|
|
37
|
+
:ipp_tag_reserved_string, # Reserved for future string value @private@
|
|
38
|
+
:ipp_tag_keyword, # keyword value
|
|
39
|
+
:ipp_tag_uri, # uri value
|
|
40
|
+
:ipp_tag_urischeme, # urI scheme value
|
|
41
|
+
:ipp_tag_charset, # character set value
|
|
42
|
+
:ipp_tag_language, # language value
|
|
43
|
+
:ipp_tag_mimetype, # mimE media type value
|
|
44
|
+
:ipp_tag_membername, # collection member name value
|
|
45
|
+
:ipp_tag_extension, 0x7f, # Extension point for 32-bit tags
|
|
46
|
+
:ipp_tag_cups_mask, 0x7fffffff, # Mask for copied attribute values @private@
|
|
47
|
+
# the following expression is used to avoid compiler warnings with +/-0x80000000
|
|
48
|
+
:ipp_tag_cups_const, -0x7fffffff-1 # Bitflag for copied/const attribute values @private@
|
|
49
|
+
]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Cups
|
|
2
|
+
module Array
|
|
3
|
+
extend FFI::Library
|
|
4
|
+
|
|
5
|
+
ffi_lib(Cups.libcups)
|
|
6
|
+
|
|
7
|
+
# @overload cupsArrayFirst(pointer)
|
|
8
|
+
# @param pointer [Pointer] to _cups_array_s struct
|
|
9
|
+
# @return [Pointer] void pointer to first element
|
|
10
|
+
attach_function 'cupsArrayFirst', [:pointer], :pointer, blocking: true
|
|
11
|
+
|
|
12
|
+
# @overload cupsArrayNext(pointer)
|
|
13
|
+
# @param pointer [Pointer] to _cups_array_s struct
|
|
14
|
+
# @return [Pointer] void pointer to first element
|
|
15
|
+
attach_function 'cupsArrayNext', [:pointer], :pointer, blocking: true
|
|
16
|
+
end
|
|
17
|
+
end
|