class Cups::Connection

Attributes

hostname[RW]
port[RW]

Public Class Methods

close(http) click to toggle source

Closes the http connection and autoreleases the pointer Wrapper around {::FFI::Cups::Http#httpClose} @param http (Pointer)

# File lib/ffi-cups/connection.rb, line 34
def self.close(http)
  FFI::Cups::Http.httpClose(http)
end
new(hostname, port=nil) click to toggle source
# File lib/ffi-cups/connection.rb, line 7
def initialize(hostname, port=nil)
  @hostname = hostname
  @port = port.nil? ? 631 : port
end

Public Instance Methods

httpConnect2() click to toggle source

Wrapper around {::FFI::Cups::Http#httpConnect2} Creates a http connection to a print server @return [Pointer] a http pointer

# File lib/ffi-cups/connection.rb, line 25
def httpConnect2
  http = FFI::Cups::Http.httpConnect2(hostname, port, nil, 0, FFI::Cups.cupsEncryption(), 1, 30000, nil)
  raise "Print server at #{hostname}:#{port} is not available" if http.null? 
  return http
end
httpConnectEncrypt() click to toggle source

Wrapper around {::FFI::Cups::Http#httpConnectEncrypt} @deprecated Use {#httpConnect2} instead @return [Pointer] a http pointer

# File lib/ffi-cups/connection.rb, line 15
def httpConnectEncrypt
  http = FFI::Cups::Http.httpConnectEncrypt(hostname, port, FFI::Cups.cupsEncryption())
  raise "Print server at #{hostname}:#{port} is not available" if http.null?
  return http
end