Module: Cups

Extended by:
FFI::Library
Defined in:
lib/ffi-cups/ffi/cups.rb,
lib/ffi-cups.rb,
lib/ffi-cups/job.rb,
lib/ffi-cups/printer.rb,
lib/ffi-cups/version.rb,
lib/ffi-cups/ffi/http.rb,
lib/ffi-cups/constants.rb,
lib/ffi-cups/ffi/array.rb,
lib/ffi-cups/connection.rb

Overview

Defined Under Namespace

Modules: Array, Enum, Http, Struct Classes: Connection, Job, Printer

Constant Summary collapse

VERSION =
"0.3.2"
FORMAT_JPEG =

cups.h

"image/jpeg"
FORMAT_PDF =
"application/pdf"
FORMAT_TEXT =
"text/plain"
JOBID_ALL =
-1
WHICHJOBS_ALL =
-1
WHICHJOBS_ACTIVE =
0
WHICHJOBS_COMPLETED =
1
HTTP_DEFAULT =
nil
COPIES =

Options and Values

"copies"
COPIES_SUPPORTED =
"copies-supported"
FINISHINGS =
"CUPS_FINISHINGS"
FINISHINGS_SUPPORTED =
"finishings-supported"
FINISHINGS_BIND =
"7"
FINISHINGS_COVER =
"6"
FINISHINGS_FOLD =
"10"
FINISHINGS_NONE =
"3"
FINISHINGS_PUNCH =
"5"
FINISHINGS_STAPLE =
"4"
FINISHINGS_TRIM =
"11"
MEDIA =

MEDIA

"media"
MEDIA_READY =
"media-ready"
MEDIA_SUPPORTED =
"media-supported"
MEDIA_3X5 =
"na_index-3x5_3x5in"
MEDIA_4X6 =
"na_index-4x6_4x6in"
MEDIA_5X7 =
"na_5x7_5x7in"
MEDIA_8X10 =
"na_govt-letter_8x10in"
MEDIA_A3 =
"iso_a3_297x420mm"
MEDIA_A4 =
"iso_a4_210x297mm"
MEDIA_A5 =
"iso_a5_148x210mm"
MEDIA_A6 =
"iso_a6_105x148mm"
MEDIA_ENV10 =
"na_number-10_4.125x9.5in"
MEDIA_ENVDL =
"iso_dl_110x220mm"
"na_legal_8.5x14in"
MEDIA_LETTER =
"na_letter_8.5x11in"
MEDIA_PHOTO_L =
"oe_photo-l_3.5x5in"
MEDIA_SUPERBA3 =
"na_super-b_13x19in"
MEDIA_TABLOID =
"na_ledger_11x17in"
MEDIA_SOURCE =
"media-source"
MEDIA_SOURCE_SUPPORTED =
"media-source-supported"
MEDIA_SOURCE_AUTO =
"auto"
MEDIA_SOURCE_MANUAL =
"manual"
MEDIA_TYPE =
"media-type"
MEDIA_TYPE_SUPPORTED =
"media-type-supported"
MEDIA_TYPE_AUTO =
"auto"
MEDIA_TYPE_ENVELOPE =
"envelope"
MEDIA_TYPE_LABELS =
"labels"
MEDIA_TYPE_LETTERHEAD =
"stationery-letterhead"
MEDIA_TYPE_PHOTO =
"photographic"
MEDIA_TYPE_PHOTO_GLOSSY =
"photographic-glossy"
MEDIA_TYPE_PHOTO_MATTE =
"photographic-matte"
MEDIA_TYPE_PLAIN =
"stationery"
MEDIA_TYPE_TRANSPARENCY =
"transparency"
NUMBER_UP =
"number-up"
NUMBER_UP_SUPPORTED =
"number-up-supported"
ORIENTATION =
"orientation-requested"
ORIENTATION_SUPPORTED =
"orientation-requested-supported"
ORIENTATION_PORTRAIT =
"3"
ORIENTATION_LANDSCAPE =
"4"
"print-color-mode"
"print-color-mode-supported"
"auto"
"monochrome"
"color"
"print-quality"
"print-quality-supported"
"3"
"4"
"5"
SIDES =
"sides"
SIDES_SUPPORTED =
"sides-supported"
SIDES_ONE_SIDED =
"one-sided"
SIDES_TWO_SIDED_PORTRAIT =
"two-sided-long-edge"
SIDES_TWO_SIDED_LANDSCAPE =
"two-sided-short-edge"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.libcupsObject

Custom or default path for libcups.so



6
7
8
9
10
11
12
# File 'lib/ffi-cups.rb', line 6

def self.libcups
  if ENV['CUPS_LIB']
    ENV['CUPS_LIB']
  else
    'cups'
  end
end

Instance Method Details

#cupsAddOption(string, string, int, pointer) ⇒ Integer

Add an option to an option array. https://www.cups.org/doc/cupspm.html#cupsAddOption

Returns number of options.

Parameters:

  • name (String)

    of option

  • value (String)

    of option

  • number (Integer)

    of options

  • pointer (Pointer)

    to options

Returns:

  • (Integer)

    number of options



179
# File 'lib/ffi-cups/ffi/cups.rb', line 179

attach_function 'cupsAddOption', [:string, :string, :int, :pointer], :int, blocking: true

#cupsCancelDestJob(string, int) ⇒ Integer

Returns IPP status.

Parameters:

  • connection (Pointer)

    to a http server

  • pointer (Pointer)

    to a destination

  • id (Integer)

    of the job

Returns:

  • (Integer)

    IPP status



91
# File 'lib/ffi-cups/ffi/cups.rb', line 91

attach_function 'cupsCancelDestJob', [:string, :int], :void, blocking: true

#cupsCancelJob(string, int) ⇒ Integer

Cancel a job on a destination name

Returns 1 if canceled, 0 otherwise.

Parameters:

  • name (String)

    of the destination

  • id (Ingeger)

    of the job

Returns:

  • (Integer)

    1 if canceled, 0 otherwise



98
# File 'lib/ffi-cups/ffi/cups.rb', line 98

attach_function 'cupsCancelJob', [:string, :int], :int, blocking: true

#cupsCancelJob2(pointer, string, int) ⇒ Enum

Cancel a job on a destination

Returns Cups::Enun::IPP::Status.

Parameters:

  • pointer (Pointer)

    of the http connection

  • name (String)

    of the destination

  • id (Ingeger)

    of the job

  • purge (Integer)

    1 to purge, 0 to cancel

Returns:

  • (Enum)

    Cups::Enun::IPP::Status



107
# File 'lib/ffi-cups/ffi/cups.rb', line 107

attach_function 'cupsCancelJob2', [:pointer, :string, :int, :int], Cups::Enum::IPP::Status, blocking: true

#cupsCheckDestSupported(pointer, pointer, pointer, string, string) ⇒ Integer

Check that the option and value are supported by the destination. https://www.cups.org/doc/cupspm.html#cupsCheckDestSupported

Returns 1 if supported, 0 otherwise.

Parameters:

  • http (Pointer)
  • destination (Pointer)
  • dinfo (Pointer)
  • option (String)
  • value (String)

Returns:

  • (Integer)

    1 if supported, 0 otherwise



24
# File 'lib/ffi-cups/ffi/cups.rb', line 24

attach_function 'cupsCheckDestSupported', [:pointer, :pointer, :pointer, :string, :string], :int, blocking: true

#cupsCopyDestInfo(pointer, pointer) ⇒ Pointer

Get the supported values/capabilities for the destination. https://www.cups.org/doc/cupspm.html#cupsCopyDestInfo

Returns Destination information.

Parameters:

  • http (Pointer)
  • dest (Pointer)

Returns:

  • (Pointer)

    Destination information



32
# File 'lib/ffi-cups/ffi/cups.rb', line 32

attach_function 'cupsCopyDestInfo', [:pointer, :pointer], :pointer, blocking: true

#cupsCreateJob(pointer, string, string, int, pointer) ⇒ Integer

Create a job on a destination.

Returns job number or 0 on error.

Parameters:

  • pointer (Pointer)

    to http connection to server or CUPS_HTTP_DEFAULT

  • name (String)

    of the printer

  • title (String)

    of the job

  • number (Integer)

    of options

  • pointer (Pointer)

    to a Cups::Struct::Option object

Returns:

  • (Integer)

    job number or 0 on error



144
# File 'lib/ffi-cups/ffi/cups.rb', line 144

attach_function 'cupsCreateJob', [:pointer, :string, :string, :int, :pointer], :int, blocking: true

#cupsEncryptionInteger

Get the current encryption settings. https://www.cups.org/doc/cupspm.html#cupsEncryption

Returns:

  • (Integer)

    encryption settings



13
# File 'lib/ffi-cups/ffi/cups.rb', line 13

attach_function 'cupsEncryption', [], :int, blocking: true

#cupsFinishDocument(pointer, string) ⇒ Cups::Enum::IPP::Status

Returns IppStatus.

Parameters:

  • pointer (Pointer)

    to http connection to server or CUPS_HTTP_DEFAULT

  • name (String)

    of the printer

Returns:



169
# File 'lib/ffi-cups/ffi/cups.rb', line 169

attach_function 'cupsFinishDocument', [:pointer, :string], Cups::Enum::IPP::Status, blocking: true

#cupsFreeDests(int, pointer) ⇒ Object

Free the memory used by the list of destinations. https://www.cups.org/doc/cupspm.html#cupsFreeDests

Parameters:

  • number (Integer)

    of destinations

  • pointer (Pointer)

    to destinations



57
# File 'lib/ffi-cups/ffi/cups.rb', line 57

attach_function 'cupsFreeDests', [:int, :pointer], :void, blocking: true

#cupsFreeJobs(int, pointer) ⇒ Object

Parameters:

  • number (Integer)

    of jobs

  • pointer (Pointer)

    to the first Cups::Struct::Job to free



134
# File 'lib/ffi-cups/ffi/cups.rb', line 134

attach_function 'cupsFreeJobs', [:int, :pointer ], :void, blocking: true

#cupsFreeOptions(int, pointer) ⇒ Object

Free all memory used by options. https://www.cups.org/doc/cupspm.html#cupsFreeOptions

Parameters:

  • number (Integer)

    of options

  • pointer (Pointer)

    to options



186
# File 'lib/ffi-cups/ffi/cups.rb', line 186

attach_function 'cupsFreeOptions', [:int, :pointer], :void, blocking: true

#cupsGetDest(string, string, int, pointer) ⇒ Pointer, NULL

Get the named destination from the list. https://www.cups.org/doc/cupspm.html#cupsGetDest

Returns destination or NULL.

Parameters:

  • name (String)
  • instance (String)

    instance name or NULL

  • num_dests (Integer)

    number of destinations

  • destinations (Pointer)

Returns:

  • (Pointer, NULL)

    destination or NULL



42
# File 'lib/ffi-cups/ffi/cups.rb', line 42

attach_function 'cupsGetDest', [:string, :string, :int, :pointer], :pointer, blocking: true

#cupsGetDests2(pointer, pointer) ⇒ Integer

Get the list of destinations from the specified server. https://www.cups.org/doc/cupspm.html#cupsGetDests2

Returns number of destinations.

Parameters:

  • pointer (Pointer)

    to http connection for server or CUPS_HTTP_DEFAULT

  • pointer (Pointer)

    to destinations

Returns:

  • (Integer)

    number of destinations



50
# File 'lib/ffi-cups/ffi/cups.rb', line 50

attach_function 'cupsGetDests2', [:pointer, :pointer], :int, blocking: true

#cupsGetJobs(pointer, string, int, int) ⇒ Integer

Get the jobs

Returns number of jobs.

Parameters:

  • pointer (Pointer)

    to Cups::Struct::Job to populate

  • name (String)

    of the printer

  • number (Integer)

    of type of job (0 == all users, 1 == mine)

  • which (Integer)

    jobs (CUPS_WHICHJOBS_ALL, CUPS_WHICHJOBS_ACTIVE, or CUPS_WHICHJOBS_COMPLETED)

Returns:

  • (Integer)

    number of jobs



127
# File 'lib/ffi-cups/ffi/cups.rb', line 127

attach_function 'cupsGetJobs', [:pointer, :string, :int, :int], :int, blocking: true

#cupsGetJobs2(pointer, pointer, string, int, int) ⇒ Integer

Get the jobs from a connection https://www.cups.org/doc/cupspm.html#cupsGetJobs2

Returns number of jobs.

Parameters:

  • pointer (Pointer)

    to a http connection object

  • pointer (Pointer)

    to Cups::Struct::Job

  • name (String)

    of the printer

  • number (Integer)

    of type of job (0 == all users, 1 == mine)

  • which (Integer)

    jobs (CUPS_WHICHJOBS_ALL, CUPS_WHICHJOBS_ACTIVE, or CUPS_WHICHJOBS_COMPLETED)

Returns:

  • (Integer)

    number of jobs



118
# File 'lib/ffi-cups/ffi/cups.rb', line 118

attach_function 'cupsGetJobs2', [:pointer, :pointer, :string, :int, :int], :int, blocking: true

#cupsLastErrorStringString

Returns the last error in string format

Returns:

  • (String)

    error



82
# File 'lib/ffi-cups/ffi/cups.rb', line 82

attach_function 'cupsLastErrorString', [], :string, blocking: true

#cupsPrintFile(string, string, string, int, pointer) ⇒ Integer

Prints a File

Returns job number or 0 on error.

Parameters:

  • name (String)

    of the printer

  • name (String)

    of the file

  • title (String)

    of the job

  • number (Integer)

    of options

  • pointer (Pointer)

    to a CupsOptionS struct

Returns:

  • (Integer)

    job number or 0 on error



67
# File 'lib/ffi-cups/ffi/cups.rb', line 67

attach_function 'cupsPrintFile', [ :string, :string, :string, :int, :pointer ], :int, blocking: true

#cupsPrintFile2(pointer, string, string, string, int, pointer) ⇒ Integer

Prints a file from a specific connection

Returns number of the job or 0 on error.

Parameters:

  • pointer (Pointer)

    to an http connection

  • name (String)

    of the printer

  • name (String)

    of the file

  • title (String)

    of the title

  • number (Integer)

    of options

  • pointer (Pointer)

    to a CupsOptionS struct

Returns:

  • (Integer)

    number of the job or 0 on error



78
# File 'lib/ffi-cups/ffi/cups.rb', line 78

attach_function 'cupsPrintFile2', [ :pointer, :string, :string, :string, :int, :pointer ], :int, blocking: true

#cupsStartDocument(pointer, string, int, string, string, int) ⇒ Cups::Enum::HTTP::Status

Returns HttpStatus.

Parameters:

  • pointer (Pointer)

    to http connection to server or CUPS_HTTP_DEFAULT

  • name (String)

    of the printer

  • id (Integer)

    of the job

  • name (String)

    of the document

  • mime_type (String)

    format of the document

  • number (Integer)

    of the last document (1 for last document in job, 0 otherwise)

Returns:



156
# File 'lib/ffi-cups/ffi/cups.rb', line 156

attach_function 'cupsStartDocument', [:pointer, :string, :int, :string, :string, :int], Cups::Enum::HTTP::Status, blocking: true

#cupsWriteRequestData(pointer, pointer, bytesize) ⇒ Cups::Enum::HTTP::Status

Returns HttpStatus.

Parameters:

  • pointer (Pointer)

    to http connection to server or CUPS_HTTP_DEFAULT

  • data (Pointer)

    in a character string pointer

  • length (Byte)

    of data

Returns:



163
# File 'lib/ffi-cups/ffi/cups.rb', line 163

attach_function 'cupsWriteRequestData', [:pointer, :pointer, :size_t], Cups::Enum::HTTP::Status, blocking: true