Sha256: 0726cb01abe0cfcacc9e8edd53f0f5ad06223e46fb9e974094231a14b138234e

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

# This is only used to be able to read get the last ZMQ error.
module CZMQ::FFI::Errors
  extend ::FFI::Library

  lib_name = 'libzmq'
  lib_paths = ['/usr/local/lib', '/opt/local/lib', '/usr/lib64']
    .map { |path| "#{path}/#{lib_name}.#{::FFI::Platform::LIBSUFFIX}" }
  ffi_lib lib_paths + [lib_name]

  opts = {
    blocking: true  # only necessary on MRI to deal with the GIL.
  }

  attach_function :zmq_strerror, [:int], :string, **opts
  attach_function :zmq_errno, [], :int, **opts

  # @return [String] error code of the last (ZMQ) error
  def self.errno
    zmq_errno
  end

  # @return [String] the string representation of the last (ZMQ) error
  def self.strerror
    zmq_strerror(zmq_errno)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
czmq-ffi-gen-0.8.0 lib/czmq-ffi-gen/errors.rb
czmq-ffi-gen-0.7.0 lib/czmq-ffi-gen/errors.rb
czmq-ffi-gen-0.6.0 lib/czmq-ffi-gen/errors.rb
czmq-ffi-gen-0.5.0 lib/czmq-ffi-gen/errors.rb