#!/usr/bin/env ruby require 'optparse' require "rubygems" require "ffi" libname = FFI.map_library_name('magic') module FFIFileMagic module Checker def self.check_lib(path) begin dylib = FFI::DynamicLibrary.open(path, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL) rescue LoadError return end puts "checking for needed methods in #{dylib.name}" result = true [:magic_open, :magic_close, :magic_file, :magic_buffer, :magic_error, :magic_setflags, :magic_load, :magic_compile, :magic_check, :magic_errno].each do |method| result &= begin print "\tmethod exists? #{method} ... " if dylib.find_symbol(method.to_s) puts "yes"; true else puts "no"; false end end end if result puts "\t#{dylib.name} suitable? ... #{result ? 'yes' : 'no'}"; return dylib end end end end #sorry, no windows if RUBY_PLATFORM =~ /mswin/ raise < port install file | | | | Others - build file from source - ftp://ftp.astron.com/pub/file/ | | | | Or: | | you can run this tool with an option to force the location of the library: | | | | > ffi_file_magic_setup --with-magic-lib=/opt/local/lib | | | +----------------------------------------------------------------------------+ END_FAIL end template =<