cupsffi 0.1.6 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cupsffi/lib.rb +30 -30
- data/lib/cupsffi/printer.rb +10 -1
- data/lib/cupsffi/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 47a841acf2892908e3fc82f1c57dbb8ce88de8702eb23c97a008ae16f09cb9d3
|
4
|
+
data.tar.gz: 26ed717b2d62f9691f3e73eed0328536e1f2f51290a88cfc124c7678485527af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7be6fae7c463d30bb708f0bf21f23b46b25f628a3318831acb0d7e9c9ee7de956986cb4621a046ae12b102e2130c831fc96d1107eabd6494bbe2174fec0c723
|
7
|
+
data.tar.gz: '0628de98a1925214e6a3519b7af0c807373e9612b21ae6181efe2cfd39adc1769637d77588481b90b68dc5bb1446692493c15bf7cdfb06b36456de3a06ea93ec'
|
data/lib/cupsffi/lib.rb
CHANGED
@@ -170,18 +170,18 @@ module CupsFFI
|
|
170
170
|
|
171
171
|
|
172
172
|
|
173
|
-
attach_function 'cupsEncryption', [], :int
|
174
|
-
attach_function 'httpConnectEncrypt', [ :string, :int, :int], :pointer
|
175
|
-
attach_function 'httpClose', [ :pointer ], :void
|
173
|
+
attach_function 'cupsEncryption', [], :int, blocking: true
|
174
|
+
attach_function 'httpConnectEncrypt', [ :string, :int, :int], :pointer, blocking: true
|
175
|
+
attach_function 'httpClose', [ :pointer ], :void, blocking: true
|
176
176
|
|
177
177
|
|
178
|
-
attach_function 'cupsGetDests', [ :pointer ], :int
|
178
|
+
attach_function 'cupsGetDests', [ :pointer ], :int, blocking: true
|
179
179
|
|
180
|
-
attach_function 'cupsGetDests2', [ :pointer, :pointer ], :int
|
180
|
+
attach_function 'cupsGetDests2', [ :pointer, :pointer ], :int, blocking: true
|
181
181
|
|
182
182
|
# :int is the number of CupsDestS structs to free
|
183
183
|
# :pointer is the first one
|
184
|
-
attach_function 'cupsFreeDests', [ :int, :pointer ], :void
|
184
|
+
attach_function 'cupsFreeDests', [ :int, :pointer ], :void, blocking: true
|
185
185
|
|
186
186
|
# Parameters:
|
187
187
|
# - printer name
|
@@ -191,18 +191,18 @@ module CupsFFI
|
|
191
191
|
# - a pointer to a CupsOptionS struct
|
192
192
|
# Returns
|
193
193
|
# - job number or 0 on error
|
194
|
-
attach_function 'cupsPrintFile', [ :string, :string, :string, :int, :pointer ], :int
|
194
|
+
attach_function 'cupsPrintFile', [ :string, :string, :string, :int, :pointer ], :int, blocking: true
|
195
195
|
|
196
|
-
attach_function 'cupsPrintFile2', [ :pointer, :string, :string, :string, :int, :pointer ], :int
|
196
|
+
attach_function 'cupsPrintFile2', [ :pointer, :string, :string, :string, :int, :pointer ], :int, blocking: true
|
197
197
|
|
198
|
-
attach_function 'cupsLastErrorString', [], :string
|
198
|
+
attach_function 'cupsLastErrorString', [], :string, blocking: true
|
199
199
|
|
200
200
|
# Parameters
|
201
201
|
# - printer name
|
202
202
|
# - job id
|
203
|
-
attach_function 'cupsCancelJob', [:string, :int], :void
|
203
|
+
attach_function 'cupsCancelJob', [:string, :int], :void, blocking: true
|
204
204
|
|
205
|
-
attach_function 'cupsCancelJob2', [:pointer, :string, :int], :void
|
205
|
+
attach_function 'cupsCancelJob2', [:pointer, :string, :int], :void, blocking: true
|
206
206
|
|
207
207
|
# Parameters
|
208
208
|
# - pointer to struct CupsJobS to populate
|
@@ -211,12 +211,12 @@ module CupsFFI
|
|
211
211
|
# - whichjobs (CUPS_WHICHJOBS_ALL, CUPS_WHICHJOBS_ACTIVE, or CUPS_WHICHJOBS_COMPLETED)
|
212
212
|
# Returns:
|
213
213
|
# - number of jobs
|
214
|
-
attach_function 'cupsGetJobs', [:pointer, :string, :int, :int], :int
|
214
|
+
attach_function 'cupsGetJobs', [:pointer, :string, :int, :int], :int, blocking: true
|
215
215
|
|
216
216
|
# Parameters
|
217
217
|
# - number of jobs
|
218
218
|
# - pointer to the first CupsJobS to free
|
219
|
-
attach_function 'cupsFreeJobs', [:int, :pointer ], :void
|
219
|
+
attach_function 'cupsFreeJobs', [:int, :pointer ], :void, blocking: true
|
220
220
|
|
221
221
|
# Parameters
|
222
222
|
# - pointer to http connection to server or CUPS_HTTP_DEFAULT
|
@@ -226,7 +226,7 @@ module CupsFFI
|
|
226
226
|
# - pointer to a CupsOptionS struct
|
227
227
|
# Returns
|
228
228
|
# - job number or 0 on error
|
229
|
-
attach_function 'cupsCreateJob', [:pointer, :string, :string, :int, :pointer], :int
|
229
|
+
attach_function 'cupsCreateJob', [:pointer, :string, :string, :int, :pointer], :int, blocking: true
|
230
230
|
|
231
231
|
# Parameters
|
232
232
|
# - pointer to http connection to server or CUPS_HTTP_DEFAULT
|
@@ -237,7 +237,7 @@ module CupsFFI
|
|
237
237
|
# - last document (1 for last document in job, 0 otherwise)
|
238
238
|
# Returns
|
239
239
|
# - HttpStatus
|
240
|
-
attach_function 'cupsStartDocument', [:pointer, :string, :int, :string, :string, :int], HttpStatus
|
240
|
+
attach_function 'cupsStartDocument', [:pointer, :string, :int, :string, :string, :int], HttpStatus, blocking: true
|
241
241
|
|
242
242
|
# Parameters
|
243
243
|
# - pointer to http connection to server or CUPS_HTTP_DEFAULT
|
@@ -245,21 +245,21 @@ module CupsFFI
|
|
245
245
|
# - length of data
|
246
246
|
# Returns
|
247
247
|
# - HttpStatus
|
248
|
-
attach_function 'cupsWriteRequestData', [:pointer, :pointer, :size_t], HttpStatus
|
248
|
+
attach_function 'cupsWriteRequestData', [:pointer, :pointer, :size_t], HttpStatus, blocking: true
|
249
249
|
|
250
250
|
# Parameters
|
251
251
|
# - pointer to http connection to server or CUPS_HTTP_DEFAULT
|
252
252
|
# - printer name
|
253
253
|
# Returns
|
254
254
|
# - IppStatus
|
255
|
-
attach_function 'cupsFinishDocument', [:pointer, :string], IppStatus
|
255
|
+
attach_function 'cupsFinishDocument', [:pointer, :string], IppStatus, blocking: true
|
256
256
|
|
257
257
|
# Parameters
|
258
258
|
# - printer name
|
259
259
|
# Returns
|
260
260
|
# - filename for PPD file
|
261
|
-
attach_function 'cupsGetPPD', [:string], :string
|
262
|
-
attach_function 'cupsGetPPD2', [:pointer, :string], :string
|
261
|
+
attach_function 'cupsGetPPD', [:string], :string, blocking: true
|
262
|
+
attach_function 'cupsGetPPD2', [:pointer, :string], :string, blocking: true
|
263
263
|
|
264
264
|
# Parameters
|
265
265
|
# - option name
|
@@ -268,12 +268,12 @@ module CupsFFI
|
|
268
268
|
# - pointer to options
|
269
269
|
# Returns
|
270
270
|
# - number of options
|
271
|
-
attach_function 'cupsAddOption', [:string, :string, :int, :pointer], :int
|
271
|
+
attach_function 'cupsAddOption', [:string, :string, :int, :pointer], :int, blocking: true
|
272
272
|
|
273
273
|
# Parameters
|
274
274
|
# - number of options
|
275
275
|
# - pointer to options
|
276
|
-
attach_function 'cupsFreeOptions', [:int, :pointer], :void
|
276
|
+
attach_function 'cupsFreeOptions', [:int, :pointer], :void, blocking: true
|
277
277
|
|
278
278
|
|
279
279
|
|
@@ -389,23 +389,23 @@ module CupsFFI
|
|
389
389
|
# - filename for PPD file
|
390
390
|
# Returns
|
391
391
|
# - pointer to PPDFileS struct
|
392
|
-
attach_function 'ppdOpenFile', [:string], :pointer
|
392
|
+
attach_function 'ppdOpenFile', [:string], :pointer, blocking: true
|
393
393
|
|
394
394
|
# Parameters
|
395
395
|
# - pointer to PPDFileS struct
|
396
|
-
attach_function 'ppdClose', [:pointer], :void
|
396
|
+
attach_function 'ppdClose', [:pointer], :void, blocking: true
|
397
397
|
|
398
398
|
# Parameters
|
399
399
|
# - pointer to PPDFileS struct
|
400
400
|
# Returns
|
401
401
|
# - pointer to PPDOptionS struct
|
402
|
-
attach_function 'ppdFirstOption', [:pointer], :pointer
|
402
|
+
attach_function 'ppdFirstOption', [:pointer], :pointer, blocking: true
|
403
403
|
|
404
404
|
# Parameters
|
405
405
|
# - pointer to PPDFileS struct
|
406
406
|
# Returns
|
407
407
|
# - pointer to PPDOptionS struct
|
408
|
-
attach_function 'ppdNextOption', [:pointer], :pointer
|
408
|
+
attach_function 'ppdNextOption', [:pointer], :pointer, blocking: true
|
409
409
|
|
410
410
|
# Parameters
|
411
411
|
# - pointer to PPDFileS struct
|
@@ -413,7 +413,7 @@ module CupsFFI
|
|
413
413
|
# - spec name
|
414
414
|
# Returns
|
415
415
|
# - pointer to PPDAttrS struct
|
416
|
-
attach_function 'ppdFindAttr', [:pointer, :string, :string], :pointer
|
416
|
+
attach_function 'ppdFindAttr', [:pointer, :string, :string], :pointer, blocking: true
|
417
417
|
|
418
418
|
# Parameters
|
419
419
|
# - pointer to PPDFileS struct
|
@@ -421,14 +421,14 @@ module CupsFFI
|
|
421
421
|
# - spec name
|
422
422
|
# Returns
|
423
423
|
# - pointer to PPDAttrS struct
|
424
|
-
attach_function 'ppdFindNextAttr', [:pointer, :string, :string], :pointer
|
424
|
+
attach_function 'ppdFindNextAttr', [:pointer, :string, :string], :pointer, blocking: true
|
425
425
|
|
426
426
|
# Parameters
|
427
427
|
# - pointer to PPDFileS struct
|
428
428
|
# - page name
|
429
429
|
# Returns
|
430
430
|
# - pointer to PPDSizeS struct
|
431
|
-
attach_function 'ppdPageSize', [:pointer, :string], :pointer
|
431
|
+
attach_function 'ppdPageSize', [:pointer, :string], :pointer, blocking: true
|
432
432
|
|
433
433
|
|
434
434
|
|
@@ -439,11 +439,11 @@ module CupsFFI
|
|
439
439
|
# - pointer to _cups_array_s struct
|
440
440
|
# Returns
|
441
441
|
# - void pointer to first element
|
442
|
-
attach_function 'cupsArrayFirst', [:pointer], :pointer
|
442
|
+
attach_function 'cupsArrayFirst', [:pointer], :pointer, blocking: true
|
443
443
|
|
444
444
|
# Parameters
|
445
445
|
# - pointer to _cups_array_s struct
|
446
446
|
# Returns
|
447
447
|
# - void pointer to first element
|
448
|
-
attach_function 'cupsArrayNext', [:pointer], :pointer
|
448
|
+
attach_function 'cupsArrayNext', [:pointer], :pointer, blocking: true
|
449
449
|
end
|
data/lib/cupsffi/printer.rb
CHANGED
@@ -93,6 +93,15 @@ class CupsPrinter
|
|
93
93
|
release_connection(connection)
|
94
94
|
hash
|
95
95
|
end
|
96
|
+
|
97
|
+
def self.default_printer
|
98
|
+
connection = get_connection
|
99
|
+
walk_attributes(connection) do |dest|
|
100
|
+
return dest[:name].dup if dest[:is_default] == 1
|
101
|
+
end
|
102
|
+
release_connection(connection)
|
103
|
+
nil
|
104
|
+
end
|
96
105
|
|
97
106
|
def attributes
|
98
107
|
hash = {}
|
@@ -235,7 +244,7 @@ class CupsPrinter
|
|
235
244
|
options.each do |key,value|
|
236
245
|
key_string = key.to_s
|
237
246
|
# Accept common CUPS options
|
238
|
-
next if [
|
247
|
+
next if %w[collate copies landscape].include?(key_string)
|
239
248
|
|
240
249
|
raise "Invalid option #{key} for printer #{@name}" if ppd_options[key_string].nil?
|
241
250
|
choices = ppd_options[key_string][:choices].map{|c| c[:choice]}
|
data/lib/cupsffi/version.rb
CHANGED
metadata
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cupsffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ehresman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '0'
|
19
|
-
name: ffi
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Simple wrapper around libcups to give CUPS printing capabilities to Ruby
|
27
|
+
description: Simple wrapper around libcups to give CUPS printing capabilities to Ruby
|
28
|
+
apps.
|
28
29
|
email:
|
29
30
|
- nehresma@gmail.com
|
30
31
|
executables: []
|
@@ -46,7 +47,7 @@ files:
|
|
46
47
|
homepage: https://github.com/nehresma/cupsffi
|
47
48
|
licenses: []
|
48
49
|
metadata: {}
|
49
|
-
post_install_message:
|
50
|
+
post_install_message:
|
50
51
|
rdoc_options: []
|
51
52
|
require_paths:
|
52
53
|
- lib
|
@@ -61,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
62
|
- !ruby/object:Gem::Version
|
62
63
|
version: '0'
|
63
64
|
requirements: []
|
64
|
-
|
65
|
-
|
66
|
-
signing_key:
|
65
|
+
rubygems_version: 3.0.6
|
66
|
+
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: FFI wrapper around libcups
|
69
69
|
test_files: []
|